diff options
Diffstat (limited to 'extensions/test')
66 files changed, 16131 insertions, 0 deletions
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.cpp b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp new file mode 100644 index 000000000..58d088a01 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp @@ -0,0 +1,131 @@ +/************************************************************************* + * + * $RCSfile: AxTestComponents.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +// 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 <initguid.h> +#include "AxTestComponents.h" + +#include "AxTestComponents_i.c" +#include "Basic.h" + + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_Basic, CBasic) +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); +} + + diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.def b/extensions/test/ole/AxTestComponents/AxTestComponents.def new file mode 100644 index 000000000..6c19f0c53 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.def @@ -0,0 +1,9 @@ +; AxTestComponents.def : Declares the module parameters. + +LIBRARY "AxTestComponents.DLL" + +EXPORTS + DllCanUnloadNow @1 PRIVATE + DllGetClassObject @2 PRIVATE + DllRegisterServer @3 PRIVATE + DllUnregisterServer @4 PRIVATE diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.dsp b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp new file mode 100644 index 000000000..77c14a7dd --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp @@ -0,0 +1,323 @@ +# 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..3885bc19f --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.idl @@ -0,0 +1,158 @@ +/************************************************************************* + * + * $RCSfile: AxTestComponents.idl,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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. + +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(BFE10EBD-8584-11D4-8335-005004526AB4), + dual, + helpstring("IBasic Interface"), + pointer_default(unique) + ] + interface IBasic : IDispatch + { + [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(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(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(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] unsigned char aChar, + [out] unsigned char *outChar, + [in, out] unsigned char* inoutChar, + [in] VARIANT var, + [out] VARIANT* outVar, + [in,out] VARIANT* inoutVar, + [in] SAFEARRAY(VARIANT) ar, + [out] SAFEARRAY(VARIANT)* outAr, + [in,out] SAFEARRAY(VARIANT)* inoutAr, + [in] IDispatch *disp, + [out] IDispatch** outDisp, + [in,out] IDispatch** inoutDisp); + [id(44), helpstring("method inSequenceLong")] HRESULT inSequenceLong([in] SAFEARRAY(long) ar); + + }; + +[ + 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; + }; +}; diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.rc b/extensions/test/ole/AxTestComponents/AxTestComponents.rc new file mode 100644 index 000000000..4224fae2f --- /dev/null +++ b/extensions/test/ole/AxTestComponents/AxTestComponents.rc @@ -0,0 +1,198 @@ +/************************************************************************* +* +* $RCSfile: AxTestComponents.rc,v $ +* +* $Revision: 1.1.1.1 $ +* +* last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ +* +* The Contents of this file are made available subject to the terms of +* either of the following licenses +* +* - GNU Lesser General Public License Version 2.1 +* - Sun Industry Standards Source License Version 1.1 +* +* Sun Microsystems Inc., October, 2000 +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2000 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +* +* Sun Industry Standards Source License Version 1.1 +* ================================================= +* The contents of this file are subject to the Sun Industry Standards +* Source License Version 1.1 (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.openoffice.org/license.html. +* +* Software provided under this License is provided on an "AS IS" basis, +* WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +* WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +* See the License for the specific provisions governing your rights and +* obligations concerning the Software. +* +* The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +* +* Copyright: 2000 by Sun Microsystems, Inc. +* +* All Rights Reserved. +* +* Contributor(s): _______________________________________ +* +* +* +**************************************************************************/ + +//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" +#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/Basic.cpp b/extensions/test/ole/AxTestComponents/Basic.cpp new file mode 100644 index 000000000..737f8a459 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.cpp @@ -0,0 +1,523 @@ +/************************************************************************* + * + * $RCSfile: Basic.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "stdafx.h" +#include "AxTestComponents.h" +#include "Basic.h" + +///////////////////////////////////////////////////////////////////////////// +// CBasic + + +STDMETHODIMP CBasic::inByte(unsigned char val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inByte: value= %d", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inShort(short val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inByte: value= %d", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + + return S_OK; +} + +STDMETHODIMP CBasic::inLong(long val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inLong: value= %d", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inString(BSTR val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inString: value= %S", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + + return S_OK; +} + +STDMETHODIMP CBasic::inFloat(float val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inFloat: value= %f", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inDouble(double val) +{ + USES_CONVERSION; + char buf[256]; + sprintf( buf, "inDouble: value= %g", val); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inVariant(VARIANT val) +{ + USES_CONVERSION; + CComVariant var; + VariantCopyInd( &var, &val); + if( var.vt == VT_BSTR) + { + char buf[256]; + sprintf( buf, "inVariant: value= %S", var.bstrVal); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + } + + return S_OK; +} + +STDMETHODIMP CBasic::inArray(LPSAFEARRAY val) +{ + HRESULT hr= S_OK; + 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[4096]; + ZeroMemory( buf, 10); + for( long i= 0; i < length ; i++) + { + varElement.Clear(); + hr= SafeArrayGetElement( val, &i, &varElement); + + if( varElement.vt == VT_BSTR) + { char bufTmp[256]; + sprintf( bufTmp, " %d string: = %S \n", i, varElement.bstrVal); + strcat( buf, bufTmp); + } + } + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inObject(IDispatch *val) +{ + // We expect the object to be an AxTestComponent.Basic object + // with the property prpString set. + HRESULT hr= S_OK; + USES_CONVERSION; + char buf[256]; + CComDispatchDriver disp( val); + CComBSTR bstr; + if( disp) + { + CComVariant var; + hr= disp.GetPropertyByName(L"prpString", &var); + if( var.vt== VT_BSTR) + bstr= var.bstrVal; + } + sprintf( buf, "inObject: value= %S", bstr.m_str); + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + + return S_OK; +} + + + +STDMETHODIMP CBasic::inoutByte(unsigned char* val) +{ + *val+= 1; + return S_OK; +} + +STDMETHODIMP CBasic::inoutShort(short *val) +{ + *val+= 1; + + return S_OK; +} + +STDMETHODIMP CBasic::inoutLong(long *val) +{ + *val+= 1; + + return S_OK; +} + +STDMETHODIMP CBasic::inoutString(BSTR *val) +{ + MessageBoxW( NULL, *val, L"AxTestComponents.Basic", MB_OK); + return S_OK; +} + +STDMETHODIMP CBasic::inoutFloat(float *val) +{ + *val+= 1; + + return S_OK; +} + +STDMETHODIMP CBasic::inoutDouble(double *val) +{ + *val+= 1; + + return S_OK; +} + +STDMETHODIMP CBasic::inoutVariant(VARIANT *val) +{ + if( val->vt & VT_BSTR) + { + MessageBoxW( NULL, val->bstrVal, L"AxTestComponents.Basic", MB_OK); + SysFreeString( val->bstrVal); + val->bstrVal= SysAllocString(L" a string from AxTestComponents.Basic"); + } + return S_OK; +} + +STDMETHODIMP CBasic::inoutArray(LPSAFEARRAY *val) +{ + inArray(*val); + SafeArrayDestroy(*val); + outArray( val); + return S_OK; +} + +STDMETHODIMP CBasic::inoutObject(IDispatch **val) +{ + inObject( *val); + outObject( val); + return S_OK; +} + + + +STDMETHODIMP CBasic::outByte(unsigned char *val) +{ + *val= 111; + return S_OK; +} + +STDMETHODIMP CBasic::outShort(short *val) +{ + *val= 1111; + return S_OK; +} + +STDMETHODIMP CBasic::outLong(long *val) +{ + *val= 111111; + return S_OK; +} + +STDMETHODIMP CBasic::outString(BSTR *val) +{ + *val= SysAllocString(L" a string as out value"); + return S_OK; +} + +STDMETHODIMP CBasic::outFloat(float *val) +{ + *val= 3.14; + return S_OK; +} + +STDMETHODIMP CBasic::outDouble(double *val) +{ + *val= 3.145; + return S_OK; +} + +STDMETHODIMP CBasic::outVariant(VARIANT *val) +{ + val->vt = VT_BSTR; + val->bstrVal= SysAllocString(L"This is a string in a VARIANT"); + return S_OK; +} + +STDMETHODIMP CBasic::outArray(LPSAFEARRAY *val) +{ + HRESULT hr= S_OK; + SAFEARRAY* ar= SafeArrayCreateVector( VT_VARIANT, 0, 3); + CComVariant arStrings[3]; //BSTR arStrings[3]; + arStrings[0].bstrVal= SysAllocString(L" out string 0"); + arStrings[0].vt= VT_BSTR; + arStrings[1].bstrVal= SysAllocString( L"out string 1"); + arStrings[1].vt= VT_BSTR; + arStrings[2].bstrVal= SysAllocString( L" outstring 2"); + arStrings[2].vt= VT_BSTR; + for( long i= 0; i < 3; i++) + { + SafeArrayPutElement( ar, &i, (void*) &arStrings[i]); + } + *val= ar; + return S_OK; +} + +STDMETHODIMP CBasic::outObject(IDispatch* *val) +{ + HRESULT hr= S_OK; + CComPtr< IUnknown > spUnk; + hr= spUnk.CoCreateInstance(L"AxTestComponents.Basic"); + CComDispatchDriver disp( spUnk); + CComVariant varVal( L"This is the property prp String"); + hr= disp.PutPropertyByName( L"prpString", &varVal); + *val= disp; + (*val)->AddRef(); + return S_OK; +} + + + + +STDMETHODIMP CBasic::get_prpByte(unsigned char *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpByte(unsigned char newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpShort(short *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpShort(short newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpLong(long *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpLong(long newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpString(BSTR *pVal) +{ + 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) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpFloat(float newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpDouble(double *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpDouble(double newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpVariant(VARIANT *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpVariant(VARIANT newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpArray(LPSAFEARRAY *pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpArray(LPSAFEARRAY newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::get_prpObject(IDispatch **pVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::put_prpObject(IDispatch *newVal) +{ + // TODO: Add your implementation code here + + return S_OK; +} + +STDMETHODIMP CBasic::mixed1( + /* [in] */ unsigned char aChar, + /* [out] */ unsigned char __RPC_FAR *outChar, + /* [out][in] */ unsigned char __RPC_FAR *inoutChar, + /* [in] */ VARIANT var, + /* [out] */ VARIANT __RPC_FAR *outVar, + /* [out][in] */ VARIANT __RPC_FAR *inoutVar, + /* [in] */ SAFEARRAY __RPC_FAR * ar, + /* [out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *outAr, + /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *inoutAr, + /* [in] */ IDispatch __RPC_FAR *disp, + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *outDisp, + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *inoutDisp) +{ + HRESULT hr= S_OK; + inByte( aChar); + outByte( outChar); + inoutByte( inoutChar); + inVariant( var); + outVariant( outVar); + inoutVariant( inoutVar); + inArray( ar); + outArray( outAr); + inoutArray( inoutAr); + inObject( disp); + outObject( outDisp); + inoutObject( inoutDisp); + return hr; +} + + + + +// VT_UI1 + +STDMETHODIMP CBasic::inSequenceLong(LPSAFEARRAY val) +{ + HRESULT hr= S_OK; + 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[4096]; + ZeroMemory( buf, 10); + for( long i= 0; i < length ; i++) + { + varElement.Clear(); + hr= SafeArrayGetElement( val, &i, &varElement); + + if( varElement.vt == VT_BSTR) + { char bufTmp[256]; + sprintf( bufTmp, " %d string: = %d \n", i, varElement.lVal); + strcat( buf, bufTmp); + } + } + MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK); + + return S_OK; +} diff --git a/extensions/test/ole/AxTestComponents/Basic.h b/extensions/test/ole/AxTestComponents/Basic.h new file mode 100644 index 000000000..babb2d8b3 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.h @@ -0,0 +1,160 @@ +/************************************************************************* + * + * $RCSfile: Basic.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// Basic.h : Declaration of the CBasic + +#ifndef __BASIC_H_ +#define __BASIC_H_ + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CBasic +class ATL_NO_VTABLE CBasic : + public CComObjectRootEx<CComSingleThreadModel>, + public CComCoClass<CBasic, &CLSID_Basic>, + public IDispatchImpl<IBasic, &IID_IBasic, &LIBID_AXTESTCOMPONENTSLib> +{ +public: + 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(inSequenceLong)(LPSAFEARRAY ar); + STDMETHOD(mixed1)( + /* [in] */ unsigned char aChar, + /* [out] */ unsigned char __RPC_FAR *outChar, + /* [out][in] */ unsigned char __RPC_FAR *inoutChar, + /* [in] */ VARIANT var, + /* [out] */ VARIANT __RPC_FAR *outVar, + /* [out][in] */ VARIANT __RPC_FAR *inoutVar, + /* [in] */ SAFEARRAY __RPC_FAR * ar, + /* [out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *outAr, + /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *inoutAr, + /* [in] */ IDispatch __RPC_FAR *disp, + /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *outDisp, + /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *inoutDisp) ; + + 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(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(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(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); + + + CComBSTR m_bstrPrpString; +}; + +#endif //__BASIC_H_ + diff --git a/extensions/test/ole/AxTestComponents/Basic.rgs b/extensions/test/ole/AxTestComponents/Basic.rgs new file mode 100644 index 000000000..97dee4860 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/Basic.rgs @@ -0,0 +1,26 @@ +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}' + } + } +} diff --git a/extensions/test/ole/AxTestComponents/StdAfx.cpp b/extensions/test/ole/AxTestComponents/StdAfx.cpp new file mode 100644 index 000000000..537d9fdc9 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/StdAfx.cpp @@ -0,0 +1,69 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include <statreg.h> +#include <statreg.cpp> +#endif + +#include <atlimpl.cpp> diff --git a/extensions/test/ole/AxTestComponents/StdAfx.h b/extensions/test/ole/AxTestComponents/StdAfx.h new file mode 100644 index 000000000..3bfa08622 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/StdAfx.h @@ -0,0 +1,87 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +#include <atlbase.h> +//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 <atlcom.h> + +//{{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) diff --git a/extensions/test/ole/AxTestComponents/resource.h b/extensions/test/ole/AxTestComponents/resource.h new file mode 100644 index 000000000..b124b37d9 --- /dev/null +++ b/extensions/test/ole/AxTestComponents/resource.h @@ -0,0 +1,77 @@ +/************************************************************************* + * + * $RCSfile: resource.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by AxTestComponents.rc +// +#define IDS_PROJNAME 100 +#define IDR_BASIC 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 diff --git a/extensions/test/ole/JScriptNewStyle.htm b/extensions/test/ole/JScriptNewStyle.htm new file mode 100644 index 000000000..d2b061d75 --- /dev/null +++ b/extensions/test/ole/JScriptNewStyle.htm @@ -0,0 +1,1039 @@ +<HTML> +<HEAD> +<META NAME="GENERATOR" Content="Microsoft Developer Studio"> +<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> +<TITLE>Document Title</TITLE> +</HEAD> +<BODY id=theBody> + +<script language="JScript"> +function callOleTest( id) +{ + var factory= new ActiveXObject("com.sun.star.ServiceManager"); + var oletest= factory.createInstance("oletest.OleTest"); +// alert(oletest); + + var arr= new Array( 1, 2, 3, 4, 0); + var arrDouble= new Array( 1.2345, 12.345, 123,45, 1234.5, 12345); + var arrBool= new Array( 1, 0, 2, 0, 3); + var arrChar= new Array( '1', 'A', "1", "A", ' ', 55, 56); + var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza"); + var arrAny= new Array( 100, 100.1235,"hallo"); + var arrSeq= new Array( arr, arr, arr); + var arrSeq2= new Array( arrSeq, arrSeq, arrSeq) + +// var ob= new Object(); +// ob.value= "A JScript object"; +// var arrObject= new Array( ob, ob, ob); + + + var arrout1= new Array(); + var arrout2= new Array(); + var arrout3= new Array(); + + var ret, i; + var sfarray, sfarray1, sfarray2, sfarray3; + var value= oletest._GetValueObject(); + var outValue= oletest._GetValueObject(); + outValue.InitOutParam(); + var outValue2= oletest._GetValueObject(); + outValue2.InitOutParam(); + var outValue3= oletest._GetValueObject(); + outValue3.InitOutParam(); + + var inoutValue= oletest._GetValueObject(); +// inoutValue.InitInOutParam(); + + switch( id) + { + // Array in-params + case 1: + value.Set("[]byte", arr) + ret= oletest.methodByte( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() + "<br>"); + document.writeln( "Returns a Sequence< BYTE > <br>" + sfarray.toArray()) ; break; + + case 2: + value.Set("[]double", arrDouble) + ret= oletest.methodDouble( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrDouble.toString() +"<br>"); + document.writeln( "Returns a Sequence< double > <br>" + sfarray.toArray()) ; break; + + case 3: + value.Set("[]boolean", arrBool) + ret= oletest.methodBool( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrBool.toString() +"<br>"); + document.writeln( "Returns a Sequence< BOOL > <br>" + sfarray.toArray()) ; break; + + case 4: + value.Set("[]short", arr) + ret= oletest.methodShort( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< SHORT > <br>" + sfarray.toArray()) ; break; + + case 5: + value.Set("[]unsigned short", arr) + ret= oletest.methodUShort( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< unsigned SHORT > <br>" + sfarray.toArray()) ; break; + + case 6: + value.Set("[]long", arr) + ret= oletest.methodLong( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< LONG > <br>" + sfarray.toArray()) ; break; + + case 7: + value.Set("[]unsigned long", arr) + ret= oletest.methodULong( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< unsigned LONG > <br>" + sfarray.toArray()) ; break; + + case 8: + value.Set("[]char", arrChar) + ret= oletest.methodChar( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrChar.toString() +"<br>"); + document.writeln( "Returns a Sequence< wchar_t > <br>" + sfarray.toArray()) ; break; + + case 9: + value.Set("[]string", arrString) + ret= oletest.methodString( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrString.toString() +"<br>"); + document.writeln( "Returns a Sequence< UString > <br>" + sfarray.toArray()) ; break; + + case 10: + value.Set("[]any", arrAny) + ret= oletest.methodAny( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrAny.toString() +"<br>"); + document.writeln( "Returns a Sequence< UsrAny > <br>" + sfarray.toArray() ) ; break; + + case 11: + var allArray= new Array(); + for(var i= 0; i <3; i++) + { + var value1= oletest._GetValueObject(); + value1.Set("[]long", arr); + allArray[i]= value1; + } + + value.Set("[][]long", allArray); + + ret= oletest.methodSequence( value); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrSeq.toString() +"<br>"); + document.writeln("Returns a Sequence< Sequence < long >> <br>") ; + var arr1= new Array(); + arr1= sfarray.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + var arr2= new Array(); + arr2= sfarray2.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + + case 12: + var array1= new Array(); + for(var i= 0; i <3; i++) + { + var array2 = new Array(); + for( var j= 0; j < 3; j++) + { + var value2= oletest._GetValueObject(); + value2.Set("[]long", arr); + array2[j]= value2; + } + + var value1= oletest._GetValueObject(); + value1.Set("[][]long", array2) + array1[i]= value1; + } + var valueAll= oletest._GetValueObject(); + valueAll.Set("[][][]long",array1); + + ret= oletest.methodSequence2( valueAll); + document.writeln( "Param: " + arrSeq2.toString() +"<br>"); + sfarray1= new VBArray( ret); + arr1= sfarray1.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + arr2= sfarray2.toArray(); + + for ( j=0; j < arr2.length; j++) + { + sfarray3= new VBArray( arr2[j]); + arr3= sfarray3.toArray(); + document.write( i+ " "); + document.writeln(j + ": "+ arr3.toString() + "<br>" ); + } + + } + break; + + case 13: + + var ar= new Array(); + for( i=0; i< 3; i++) + { + var ob= new Object(); + var valueObject= oletest._GetValueObject(); + ob.value= "A JScript object!"; + valueObject.Set("com.sun.star.uno.XInterface", ob); +// valueObject.Set("long", 5); + ar[i]= valueObject; + } + value.Set("[]com.sun.star.uno.XInterface", ar); +// value.Set("[]long", ar); + + ret = oletest.methodXInterface( value); + sfarray= new VBArray( ret); + var arRet= sfarray.toArray(); + + document.writeln( "Params : Array containing objects ") + for( index in ar) + { + document.writeln( "object " + index + ": " + ar[index].Get().value +" "); + } + document.writeln( "<br>" ) ; + document.writeln("Return: <br>"); + for( index in arRet) + { + document.writeln( "object " + index + ": " + arRet[index].value + " "); + } + break; + + + + + // Properties: setting and getting values + case 200: + value.Set("[]byte", arr) + oletest.AttrByte = value; + ret= oletest.AttrByte; + sfarray= new VBArray( ret); + document.writeln("Setting AttrByte: " + arr.toString() + "<p>"); + document.writeln("Getting AttrByte: " + sfarray.toArray()); break; + + case 201: + value.Set("[]double", arrDouble) + oletest.AttrDouble= value; + ret= oletest.AttrDouble; + sfarray= new VBArray( ret); + document.writeln("Setting AttrDouble: " + arrDouble.toString() + "<p>"); + document.writeln("Getting AttrDouble: " + sfarray.toArray()); break; + + case 202: + value.Set("[]boolean", arrBool) + oletest.AttrBool= value; + ret= oletest.AttrBool; + sfarray= new VBArray( ret); + document.writeln("Setting AttrBool: " + arrBool.toString() + "<p>"); + document.writeln("Getting AttrBool: " + sfarray.toArray()); break; + + case 203: + value.Set("[]short", arr) + oletest.AttrShort= value; + ret= oletest.AttrShort; + sfarray= new VBArray( ret); + document.writeln("Setting AttrShort: " + arr.toString() + "<p>"); + document.writeln("Getting AttrShort: " + sfarray.toArray()); break; + + case 204: + value.Set("[]unsigned short", arr) + oletest.AttrUShort= value; + ret= oletest.AttrUShort; + sfarray= new VBArray( ret); + document.writeln("Setting AttrUShort: " + arr.toString() + "<p>"); + document.writeln("Getting AttrUShort: " + sfarray.toArray()); break; + + case 205: + value.Set("[]long", arr) + oletest.AttrLong= value; + ret= oletest.AttrLong; + sfarray= new VBArray( ret); + document.writeln("Setting AttrLong: " + arr.toString() + "<p>"); + document.writeln("Getting AttrLong: " + sfarray.toArray()); break; + + case 206: + value.Set("[]unsigned long", arr) + oletest.AttrULong= value; + ret= oletest.AttrULong; + sfarray= new VBArray( ret); + document.writeln("Setting AttrULong: " + arr.toString() + "<p>"); + document.writeln("Getting AttrULong: " + sfarray.toArray()); break; + + case 207: + value.Set("[]char", arrChar) + oletest.AttrChar= value; + ret= oletest.AttrChar; + sfarray= new VBArray( ret); + document.writeln("Setting AttrChar: " + arrChar.toString() + "<p>"); + document.writeln("Getting AttrChar: " + sfarray.toArray()); break; + + case 208: + value.Set("[]string", arrString) + oletest.AttrString= value; + ret= oletest.AttrString; + sfarray= new VBArray( ret); + document.writeln("Setting AttrString: " + arrString.toString() + "<p>"); + document.writeln("Getting AttrString: " + sfarray.toArray()); break; + + case 209: + value.Set("[]any", arrAny) + oletest.AttrAny= value; + ret= oletest.AttrAny; + sfarray= new VBArray( ret); + document.writeln("Setting AttrAny: " + arrAny.toString() + "<p>"); + document.writeln("Getting AttrAny: " + sfarray.toArray()); break; + + case 210: + var allArray= new Array(); + for(var i= 0; i <3; i++) + { + var value1= oletest._GetValueObject(); + value1.Set("[]long", arr); + allArray[i]= value1; + } + + value.Set("[][]long", allArray); + + oletest.AttrSequence= value; + ret= oletest.AttrSequence; + sfarray= new VBArray( ret); + + document.writeln( "Param: " + arrSeq.toString() +"<br>"); + document.writeln("Returns a Sequence< Sequence < long >> <br>") ; + var arr1= new Array(); + arr1= sfarray.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + var arr2= new Array(); + arr2= sfarray2.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + + case 211: + var array1= new Array(); + for(var i= 0; i <3; i++) + { + var array2 = new Array(); + for( var j= 0; j < 3; j++) + { + var value2= oletest._GetValueObject(); + value2.Set("[]long", arr); + array2[j]= value2; + } + + var value1= oletest._GetValueObject(); + value1.Set("[][]long", array2) + array1[i]= value1; + } + var valueAll= oletest._GetValueObject(); + valueAll.Set("[][][]long",array1); + + oletest.AttrSequence2= valueAll; + ret= oletest.AttrSequence2; + sfarray1= new VBArray( ret); + arr1= sfarray1.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + arr2= sfarray2.toArray(); + + for ( j=0; j < arr2.length; j++) + { + sfarray3= new VBArray( arr2[j]); + arr3= sfarray3.toArray(); + document.write( i+ " "); + document.writeln(j + ": "+ arr3.toString() + "<br>" ); + } + + } + break; + + case 212: + var ar= new Array(); + for( i=0; i< 3; i++) + { + var ob= new Object(); + var valueObject= oletest._GetValueObject(); + ob.value= "A JScript object!"; + valueObject.Set("com.sun.star.uno.XInterface", ob); + ar[i]= valueObject; + } + value.Set("[]com.sun.star.uno.XInterface", ar); + + oletest.AttrXInterface= value; + ret= oletest.AttrXInterface; + sfarray= new VBArray( ret); + var arRet= sfarray.toArray(); + + document.writeln( "Params : Array containing objects ") + for( index in ar) + { + document.writeln( "object " + index + ": " + ar[index].Get().value +" "); + } + document.writeln( "<br>" ) ; + document.writeln("Return: <br>"); + for( index in arRet) + { + document.writeln( "object " + index + ": " + arRet[index].value + " "); + } + + break; + + // Out-parameter ------------------------------------------------------------ + case (2000): + + oletest.testout_methodByte( outValue ); + alert("byte: " + outValue.Get() ); break; + case (2001): + oletest.testout_methodDouble( outValue ); + alert( "double: " + outValue.Get() ); break; + case (2002): + oletest.testout_methodBool( outValue ); + alert( "boolean: " + outValue.Get() ); break; + case (2003): + oletest.testout_methodShort( outValue ); + alert( "short: " + outValue.Get() ); break; + case (2004): + oletest.testout_methodUShort( outValue ); + alert( "unsigned short: " + outValue.Get() ); break; + case (2005): + oletest.testout_methodLong( outValue ); + alert( "long: " + outValue.Get() ); break; + case (2006): + oletest.testout_methodULong( outValue ); + alert( "unsigned long: " + outValue.Get() ); break; + case (2007): + oletest.testout_methodChar( outValue ); + alert( "char: " + outValue.Get() ); break; + case (2008): + oletest.testout_methodString( outValue ); + alert( "string: " + outValue.Get()); break; + case (2009): + oletest.testout_methodAny( outValue ); + alert( "any: " + outValue.Get() ); break; + case (2010): + oletest.testout_methodSequence( outValue ); + var sfarray= new VBArray( outValue.Get()); + arr= sfarray.toArray(); + document.writeln("use the browser's back arrow to go to the previous page <p>"); + document.writeln( arr.toString()); + break; + case (2011): + oletest.testout_methodSequence2( outValue ); + var sfarray= new VBArray( outValue.Get()); + arr= sfarray.toArray(); + var i; + for( i=0; i < arr.length; i++) + { + var sfarray= new VBArray( arr[i]); + var arr2= new Array(); + arr2= sfarray.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + case (2012): + oletest.testout_methodMulParams1( outValue, outValue2 ); + document.writeln( "int : " + outValue.Get() + " int :" + outValue2.Get()); break; + case (2013): + oletest.testout_methodMulParams2( outValue, outValue2, outValue3 ); + document.writeln( "int: " + outValue.Get() + " int: " + outValue2.Get() + " string: " + outValue3.Get() ); break; + case (2014): + oletest.testout_methodMulParams3( "hallo", outValue ); + document.writeln( "string: " + outValue.Get() ); break; + case (2015): + oletest.testout_methodXInterface( outValue ); + var out= outValue.Get(); + document.writeln( "string: " + out.AttrAny2); break; + + // INOUT - Parameter ------------------------------------------------------------------------------- + // The in value has to be placed on index 0 of the passed in array + case (500): + inoutValue.InitInOutParam("byte", 100); + oletest.testinout_methodByte( inoutValue ); + alert("byte: " + inoutValue.Get() ); break; + case (501): + inoutValue.InitInOutParam("double", 3.14); + oletest.testinout_methodDouble( inoutValue ); + alert( "double: " + inoutValue.Get() ); break; + case (502): + inoutValue.InitInOutParam("boolean", false); + oletest.testinout_methodBool( inoutValue ); + alert( "boolean: " + inoutValue.Get() ); break; + case (503): + inoutValue.InitInOutParam( "short", 200); + oletest.testinout_methodShort( inoutValue ); + alert( "short: " + inoutValue.Get() ); break; + case (504): + inoutValue.InitInOutParam("unsigned short", 300); + oletest.testinout_methodUShort( inoutValue ); + alert( "unsigned short: " + inoutValue.Get() ); break; + case (505): + inoutValue.InitInOutParam("long", 400); + oletest.testinout_methodLong( inoutValue ); + alert( "long: " + inoutValue.Get() ); break; + case (506): + inoutValue.InitInOutParam( "unsigned long", 500); + oletest.testinout_methodULong( inoutValue ); + alert( "unsigned long: " + inoutValue.Get() ); break; + case (507): + inoutValue.InitInOutParam( "char", "A"); + oletest.testinout_methodChar( inoutValue ); + alert( "char: " + inoutValue.Get() ); break; + case (508): + inoutValue.InitInOutParam("string", "I am a string"); + oletest.testinout_methodString( inoutValue ); + alert( "string: " + inoutValue.Get() ); break; + case (509): + inoutValue.InitInOutParam("[]long", arr); + oletest.testinout_methodAny( inoutValue ); // the method simply returns the argument + sfarray= new VBArray( inoutValue.Get()); + arr= sfarray.toArray(); + alert( "any: " + arr.toString() ); break; + case (510): + inoutValue.InitInOutParam("[]long", arr); + oletest.testinout_methodSequence( inoutValue ); + var sfarray= new VBArray( inoutValue.Get()); + arr= sfarray.toArray(); + document.writeln("use the browser's back arrow to go to the previous page <p>"); + document.writeln( arr.toString()); + break; + case (511): + inoutValue.InitInOutParam( "[][]long", arrSeq); + oletest.testinout_methodSequence2( inoutValue ); + var sfarray= new VBArray( inoutValue.Get()); + arr= sfarray.toArray(); + var i; + for( i=0; i < arr.length; i++) + { + var sfarray= new VBArray( arr[i]); + var arr2= new Array(); + arr2= sfarray.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + case 512: + var ob= new Object(); + ob.value= "this is a string"; + inoutValue.InitInOutParam( "com.sun.star.script.XInvocation", ob); + oletest.testinout_methodXInterface( inoutValue); + document.write("Out value: " + inoutValue.Get().value ); + break; + + + + + + // Test ANY + // Methods + case 1000: + i= 100; + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1001: + i= 3.14; + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1002: + i= "Hallo" + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1003: + i= arr; + ret= oletest.methodAnyTest1( i); + sfarray= new VBArray( ret); + document.writeln( "in: " + i + " ret: " + sfarray.toArray()); + break; + case 1004: + var obj= new Object(); + obj[1]= "This is index 0"; + ret= oletest.methodAnyTest1( obj); + document.writeln( "in: " + obj + " ret: " + ret); + break; + + + // Test ANY property + case 1010: + i= 100; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1011: + i= 3.14; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1012: + i= "Hallo" + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1013: + i= arr; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + sfarray= new VBArray( ret); + document.writeln( "set: " + i + " get: " + sfarray.toArray()); + break; + case 1014: + var obj= new Object(); + obj[1]= "This is index 0"; + oletest.AttrAny2= obj; + ret= oletest.AttrAny2; + document.writeln( "set: " + obj + " get: " + ret); + break; + + + case 2100: + alert("2100"); + var ret= oletest.retMethodByte(); + var sfarray= VBArray( ret); + document.writeln( sfarray.toArray() ); + break; + + +// case 5000: +// oletest.other_methodAnyIn("hallo"); + + + + } + +} + +function funcOut( out) +{ + out["du"]= 0xffff; +} + +</script> + +<script language="VBScript"> + +sub callBasic(id) + + Dim factory + Set factory= GetObject("", "com.sun.star.ServiceManager") + + Set oletest= factory.createInstance("oletest.OleTest") + + + arrInt= Array(1,2,3,4,5) + arrInt2= Array( -1, -2, 127, 128, 0) + arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5) + arrBool= Array(0,1,0,2,0) + arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff) + arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger") + arrChar= Array("a",65, "M") + arrAny= Array("Mickey", 3.14, 100, "A") + + Dim arrDim2Int(1,1) + For i= 0 To 1 + For j= 0 To 1 + arrDim2Int(i,j) = i*2 + j + Next + Next + + Dim arrDim3Int(1,1,1) + For i= 0 To 1 + For j= 0 To 1 + For k=0 To 1 + arrDim3Int(i,j,k) = i*2 + j*2 + k + Next + Next + Next + + + select case id + case 0 + document.writeln "param: " + printArray arrInt + ret= oletest.methodByte(arrInt) + document.writeln "<br> return value: " + printArray ret + case 1 + document.writeln "param: " + printArray arrDouble + ret= oletest.methodDouble(arrDouble) + document.writeln "<br> return value: " + printArray ret + case 2 + document.writeln "param: " + printArray arrBool + ret= oletest.methodBool(arrBool) + document.writeln "<br> return value: " + printArray ret + case 3 + document.writeln "param: " + printArray arrInt2 + ret= oletest.methodShort(arrInt2) + document.writeln "<br> return value: " + printArray ret + case 4 + document.writeln "param: " + printArray arrInt + ret= oletest.methodUShort(arrInt) + document.writeln "<br> return value: " + printArray ret + case 5 + document.writeln "param: " + printArray arrLong + ret= oletest.methodLong(arrLong) + document.writeln "<br> return value: " + printArray ret + case 6 + document.writeln "param: " + printArray arrInt + ret= oletest.methodULong(arrInt) + document.writeln "<br> return value: " + printArray ret + case 7 + document.writeln "param: " + printArray arrString + ret= oletest.methodString(arrString) + document.writeln "<br> return value: " + printArray ret + case 8 + document.writeln "param: " + printArray arrChar + ret= oletest.methodChar(arrChar) + document.writeln "<br> return value: " + printArray ret + case 9 + document.writeln "param: " + printArray arrAny + ret= oletest.methodAny(arrAny) + document.writeln "<br> return value: " + printArray ret + case 10 + document.writeln "param: " + printArray2 arrDim2Int + ret= oletest.methodSequence(arrDim2Int) + document.writeln "<br> return value: " + for each val in ret + document.write "<br> array: " + for each val2 in val + document.write val2 + next + next + + // In Out Parameter -------------------------------------------------- + case 100 + a= 100 + document.write "param: " & CStr( a) & "<br>" + oletest.testinout_methodByte a + document.write a + case 101 + a= 1.11 + document.write "param: " & CStr( a) & "<br>" + oletest.testinout_methodDouble a + document.write a + case 102 + a= 5 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodBool a + document.write a + case 103 + a= -10 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodShort a + document.write a + case 104 + a= 128 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodUShort a + document.write a + case 105 + a= 65556 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodLong a + document.write a + case 106 + a= 65556 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodULong a + document.write a + case 107 + a= "ein test string" + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodString a + document.write a + case 108 + a= "W" + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodChar a + document.write a + case 109 + a= "Ein String im Any" + document.write "param: "& CStr( a) & "<br>" + oletest.other_methodAnyIn a + document.write a +// Attributes ----------------------------------------------------------------- + case 200 + document.write "set: " + printArray arrInt + oletest.AttrByte= arrInt + b= oletest.AttrByte + call printArrayEx( "<br> get: ", "<br>", b) + case 201 + document.write "set: " + printArray arrDouble + oletest.AttrDouble= arrDouble + b= oletest.AttrDouble + call printArrayEx( "<br> get: ", "<br>", b) + case 202 + document.write "set: " + printArray arrBool : + oletest.AttrBool= arrBool + b= oletest.AttrBool + call printArrayEx( "<br> get: ", "<br>", b) + case 203 + document.write "set: " + printArray arrInt2 : + oletest.AttrShort= arrInt2 + b= oletest.AttrShort + call printArrayEx( "<br> get: ", "<br>", b) + case 204 + document.write "set: " + printArray arrInt + oletest.AttrUShort= arrInt + b= oletest.AttrUShort + call printArrayEx( "<br> get: ", "<br>", b) + case 205 + document.write "set: " + printArray arrInt2 + oletest.AttrLong= arrInt2 + b= oletest.AttrLong + call printArrayEx( "<br> get: ", "<br>", b) + case 206 + document.write "set: " + printArray arrInt + oletest.AttrULong= arrInt + b= oletest.AttrULong + call printArrayEx( "<br> get: ", "<br>", b) + case 207 + document.write "set: " + printArray arrString + oletest.AttrString= arrString + b= oletest.AttrString + call printArrayEx( "<br> get: ", "<br>", b) + case 208 + document.write "set: " + printArray arrChar + oletest.AttrChar= arrChar + b= oletest.AttrChar + call printArrayEx( "<br> get: ", "<br>", b) + case 209 + document.write "set: " + printArray arrAny + oletest.AttrAny= arrAny + b= oletest.AttrAny + call printArrayEx( "<br> get: ", "<br>", b) + + case 210 + document.write "set: <br>" + printArray2 arrDim2Int : + oletest.AttrSequence= arrDim2Int + ret= oletest.AttrSequence + document.write "get: " + for each val in ret + document.write "<br> array: " + for each val2 in val + document.write val2 + next + next + + end select +end sub +sub printArray( arr) + document.write "array: " + For Each val In arr + document.write CStr(val) & " " + Next +end sub + +// print a 2 dimensional Array + +sub printArray2( arr) + elements1= UBound( arr, 1) - LBound( arr, 1) +1 + elements2= UBound( arr, 2) - LBound( arr, 2) +1 + + For i=0 To elements1 -1 + document.write( "array " & CStr( i) & ": " ) + For j=0 To elements2 -1 + document.write CStr( arr(i,j)) + Next + document.write( "<br>") + Next +end sub + +sub printArrayEx( pre, post, array) + document.write pre + printArray array + document.write post +end sub +</script> + +<div id=out> </div> + +<!-- Insert HTML here --> + +<h2> JScript with _GetValueObject </h2> +Tests Array/Sequence conversion.<br> +All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons. +<br> +<button onclick='callOleTest( 1)'>byte</Button> +<button onclick='callOleTest( 2)'>double</Button> +<button onclick='callOleTest( 3)'>boolean</Button> +<button onclick='callOleTest( 4)'>short</Button> +<button onclick='callOleTest( 5)'>unsigned short</Button> +<button onclick='callOleTest( 6)'>long</Button> +<button onclick='callOleTest( 7)'>unsigned long</Button> +<button onclick='callOleTest( 8)'>char</Button> +<button onclick='callOleTest( 10)'>any</Button> +<button onclick='callOleTest( 11)'>sequence<long> </Button> +<button onclick='callOleTest( 12)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 13)'>XInterface</Button> +<p> + +<p> +Out Parameter <br> +<button onclick='callOleTest( 2000)'>byte </Button> +<button onclick='callOleTest( 2001)'>double</Button> +<button onclick='callOleTest( 2002)'>boolean</Button> +<button onclick='callOleTest( 2003)'>short</Button> +<button onclick='callOleTest( 2004)'>unsigned short</Button> +<button onclick='callOleTest( 2005)'>long</Button> +<button onclick='callOleTest( 2006)'>unsigned long</Button> +<button onclick='callOleTest( 2007)'>char</Button> +<button onclick='callOleTest( 2008)'>string</Button> +<button onclick='callOleTest( 2009)'>any</Button> +<button onclick='callOleTest( 2010)'>sequence<long> </Button> +<button onclick='callOleTest( 2011)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 2012)'>2 out </Button> +<button onclick='callOleTest( 2013)'>3 out </Button> +<button onclick='callOleTest( 2014)'>1 in & 1 out </Button> +<button onclick='callOleTest( 2015)'>XInterface </Button> + +<p> +In Out Parameter <br> +<button onclick='callOleTest( 500)'>byte </Button> +<button onclick='callOleTest( 501)'>double</Button> +<button onclick='callOleTest( 502)'>boolean</Button> +<button onclick='callOleTest( 503)'>short</Button> +<button onclick='callOleTest( 504)'>unsigned short</Button> +<button onclick='callOleTest( 505)'>long</Button> +<button onclick='callOleTest( 506)'>unsigned long</Button> +<button onclick='callOleTest( 507)'>char</Button> +<button onclick='callOleTest( 508)'>string</Button> +<button onclick='callOleTest( 509)'>any</Button> +<button onclick='callOleTest( 510)'>sequence<long> </Button> +<button onclick='callOleTest( 511)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 512)'>XInterface </Button> +<p> + +Tests Array/Sequence conversion with Attributes. All params are of type Sequence and + the element type of the Sequence is written on the buttons. <br> +<button onclick='callOleTest( 200)'>byte </Button> +<button onclick='callOleTest( 201)'>double</Button> +<button onclick='callOleTest( 202)'>boolean</Button> +<button onclick='callOleTest( 203)'>short</Button> +<button onclick='callOleTest( 204)'>unsigned short</Button> +<button onclick='callOleTest( 205)'>long</Button> +<button onclick='callOleTest( 206)'>unsigned long</Button> +<button onclick='callOleTest( 207)'>char</Button> +<button onclick='callOleTest( 208)'>string</Button> +<button onclick='callOleTest( 209)'>any</Button> +<button onclick='callOleTest( 210)'>sequence<long> </Button> +<button onclick='callOleTest( 211)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 212)'>XInterface </Button> +<p> + +<!-- +Test of Any parameter in a method. Any contains:<br> +<button onclick='callOleTest( 1000)'>integer </Button> +<button onclick='callOleTest( 1001)'>double </Button> +<button onclick='callOleTest( 1002)'>string</Button> +<button onclick='callOleTest( 1003)'>array</Button> +<button onclick='callOleTest( 1004)'>object</Button> +<p> +Test of Any parameter in a property. Any contains:<br> +<button onclick='callOleTest( 1010)'>integer </Button> +<button onclick='callOleTest( 1011)'>double </Button> +<button onclick='callOleTest( 1012)'>string</Button> +<button onclick='callOleTest( 1013)'>array</Button> +<button onclick='callOleTest( 1014)'>object</Button> +<p> +<p> + + +<h2> Visual Basic Tests </h2> +Test array /Sequence conversion and return value<br> +Template: <b> Sequence < type > method( Sequence< type > ) </b> <br> +<!--<font color= red>Multi dimensional arrays are not processed by VBSript</font> <br> --> +<!-- +<button onclick='callBasic(0)'>byte</button> +<button onclick='callBasic(1)'>double</button> +<button onclick='callBasic(2)'>boolean</button> +<button onclick='callBasic(3)'>short</button> +<button onclick='callBasic(4)'>u short</button> +<button onclick='callBasic(5)'>long</button> +<button onclick='callBasic(6)'>u long</button> +<button onclick='callBasic(7)'>string</button> +<button onclick='callBasic(8)'>char</button> +<button onclick='callBasic(9)'>any</button> <br> +<button onclick='callBasic(10)'>Seq < int ></button> <br> + + +Out parameter <br> +Template: <b> void method( Sequence < type > ) </b> <br> +<button onclick='callBasic(100)'>byte</button> +<button onclick='callBasic(101)'>double</button> +<button onclick='callBasic(102)'>boolean</button> +<button onclick='callBasic(103)'>short</button> +<button onclick='callBasic(104)'>u short</button> +<button onclick='callBasic(105)'>long</button> +<button onclick='callBasic(106)'>u long</button> +<button onclick='callBasic(107)'>string</button> +<button onclick='callBasic(108)'>char</button> +<button onclick='callBasic(109)'>any</button> <br> + +Tests Array/Sequence conversion with <b>Attributes</b>. All params are of type Sequence and + the element type of the Sequence is written on the buttons. <br> +<button onclick='callBasic( 200)'>byte </Button> +<button onclick='callBasic( 201)'>double</Button> +<button onclick='callBasic( 202)'>boolean</Button> +<button onclick='callBasic( 203)'>short</Button> +<button onclick='callBasic( 204)'>unsigned short</Button> +<button onclick='callBasic( 205)'>long</Button> +<button onclick='callBasic( 206)'>unsigned long</Button> +<button onclick='callBasic( 207)'>string</Button> +<button onclick='callBasic( 208)'>char</Button> +<button onclick='callBasic( 209)'>any</Button> +<button onclick='callBasic( 210)'>sequence<long> </Button> + +--> + + diff --git a/extensions/test/ole/OleClient/clientTest.cxx b/extensions/test/ole/OleClient/clientTest.cxx new file mode 100644 index 000000000..dc6e04fb9 --- /dev/null +++ b/extensions/test/ole/OleClient/clientTest.cxx @@ -0,0 +1,536 @@ +/************************************************************************* + * + * $RCSfile: clientTest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <windows.h> +#include <comdef.h> +#include <tchar.h> +#include <atlbase.h> +extern CComModule _Module; +#include<atlcom.h> +#include<atlimpl.cpp> + +#include <com/sun/star/bridge/ModelDependent.hpp> +#include <com/sun/star/bridge/XBridgeSupplier2.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <oletest/XCallback.hpp> +#include <rtl/process.h> +#include <com/sun/star/uno/Reference.h> +#include <cppuhelper/servicefactory.hxx> +#include <rtl/string.h> +#pragma hdrstop + + +CComModule _Module; +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 cppu; +using namespace rtl; +HRESULT doTest(); +HRESULT doTest2( Reference<XInvocation> &); +Reference<XInvocation> getComObject(OUString& ); + +HRESULT InitializeParameter(); +void printResultVariantArray( VARIANT & var); +void printVariant( VARIANT & var); + + +Reference< XMultiServiceFactory > objectFactory; + + +int __cdecl _tmain( int argc, _TCHAR * argv[] ) +{ + HRESULT hr; + if( FAILED( hr=CoInitialize(NULL))) + { + _tprintf(_T("CoInitialize 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; +} + + +Reference<XInvocation> getComObject( OUString progId) +{ + HRESULT hr= S_OK; + Reference< XInvocation > ret; +// Reference<XMultiServiceFactory> fac; + if( ! objectFactory.is()) + { + Reference< XMultiServiceFactory > mgr= createRegistryServiceFactory( OUString(L"applicat.rdb")); + Reference< XInterface > xInt= mgr->createInstance( OUString(L"com.sun.star.bridge.OleObjectFactory")); + objectFactory= Reference<XMultiServiceFactory>::query( xInt); + } + + if( objectFactory.is()) + { + Reference<XInterface> xIntAx= objectFactory->createInstance( progId.getStr()); + if( xIntAx.is() ) + { + Reference< XInvocation > xInv( xIntAx, UNO_QUERY); + ret= xInv; + } + } +// CComPtr<IUnknown> spUnkMgr; +// Reference< XInvocation > ret; +// Reference< XMultiServiceFactory > mgr= createRegistryServiceFactory( OUString(L"applicat.rdb")); +// Reference< XInterface > xInt= mgr->createInstance(OUString(L"com.sun.star.bridge.OleObjectFactory")); +// Reference< XMultiServiceFactory > fac( xInt, UNO_QUERY); + return ret; +} + +HRESULT doTest() +{ + HRESULT hr= S_OK; + USES_CONVERSION; + Reference<XInvocation> inv= getComObject( L"AxTestComponents.Basic"); + Sequence< sal_Int16> seqIndices; + Sequence<Any> seqOut; + + Any aAny; + Any anyOut; + char buff[256]; + + //################################################################################### + // in parameter + //################################################################################### +// aAny <<= ( sal_Int8) 127; +// inv->invoke( OUString(L"inByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// aAny <<= ( sal_Int16) 0xffff; +// inv->invoke( OUString(L"inShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); + +// aAny <<= ( sal_Int32) 1234567; +// inv->invoke( OUString(L"inLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// aAny <<= OUString(L" this is clientTest.exe"); +// inv->invoke( OUString(L"inString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// aAny <<= ( float) 3.14; +// inv->invoke( OUString(L"inFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// aAny <<= ( double) 3.145; +// inv->invoke( OUString(L"inDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// aAny <<= OUString( L" A string in an any"); +// inv->invoke( OUString(L"inVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// +// OUString arStr[]= {L"string0", L"string1", L"string2"}; +// Sequence<OUString> seq( arStr, 3); +// Any arAny[1]; +// arAny[0] <<= seq; +// inv->invoke( OUString(L"inArray"), Sequence< Any > ( arAny, 1), seqIndices, seqOut); + +// Reference < XInvocation > inv2= getComObject(L"AxTestComponents.Basic"); +// Any anyVal; +// anyVal <<= OUString(L"this is the value of prpString"); +// inv2->setValue( OUString(L"prpString"), anyVal); +// aAny <<= inv2; +// inv->invoke( OUString(L"inObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// //################################################################################### +// // out parameter +// //################################################################################### + // outByte +// aAny= Any(); +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outByte"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out Byte: %d", *( char*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // outShort +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outShort"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out Short: %d", *( sal_Int16*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // outLong +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outLong"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out Long: %d", *( sal_Int32*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // outString +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outString"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out String: %S", (*( OUString*)anyOut.getValue()).getStr()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // outFloat +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outFloat"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out float: %f", *( float*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // outDouble +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outDouble"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " out double: %g", *( double*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); + + // outVariant +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outVariant"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// if( anyOut.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// anyOut >>= s; +// sprintf( buff, " out string ( variant): %S", s.getStr()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// } +// +// // outArray +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outArray"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// Sequence<Any> seqOutValue; +// anyOut >>= seqOutValue; +// +// // we assume that the Sequence contains Anys of strings +// OUString usMessage; +// for( int i=0; i < seqOutValue.getLength(); i++) +// { +// OUString stemp; +// if( seqOutValue[i] >>= stemp) +// { +// usMessage += OUString(L"\n"); +// usMessage += stemp; +// } +// } +// MessageBox( NULL, W2T( usMessage.getStr()), _T("Test Program"), MB_OK); +// +// // outObject +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// inv->invoke( OUString(L"outObject"), Sequence< Any > ( &aAny, 1 ), seqIndices, seqOut); +// Reference<XInvocation> invOut; +// if( seqOut[0]>>=invOut) +// { +// Any val= invOut->getValue( L"prpString"); +// +// if( val.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// val>>=s; +// MessageBox( NULL,W2T( s.getStr()), _T("Test Program"), MB_OK); +// } +// } + +// //################################################################################### +// // in/out parameter +// //################################################################################### +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= ( sal_Int8) 127; +// inv->invoke( OUString(L"inoutByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " in out Byte: %d", *( char*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); + + // in out short +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= ( sal_Int16) 1111; +// inv->invoke( OUString(L"inoutShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " in out Short: %d", *( sal_Int16*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// //in out long +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= ( sal_Int32) 111111; +// inv->invoke( OUString(L"inoutLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, "inout Long: %d", *( sal_Int32*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// //in out string +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= OUString(L" this is clientTest.exe"); +// inv->invoke( OUString(L"inoutString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " inout String: %S", (*( OUString*)anyOut.getValue()).getStr()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// //in out float +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= ( float) 3.14; +// inv->invoke( OUString(L"inoutFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " inout float: %f", *( float*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // in out double +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= ( double) 3.145; +// inv->invoke( OUString(L"inoutDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// sprintf( buff, " inout double: %g", *( double*)anyOut.getValue()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// // in out VARIANT +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// aAny <<= OUString( L" A string in an any"); +// inv->invoke( OUString(L"inoutVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// anyOut <<= seqOut[0]; +// if( anyOut.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// anyOut >>= s; +// sprintf( buff, " in out string ( variant): %S", s.getStr()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// } + +// // in out Array +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// OUString arStr2[]= {L"string0", L"string1", L"string2"}; +// Sequence<OUString> seq2( arStr2, 3); +// Any arAny2[1]; +// arAny2[0] <<= seq2; +// inv->invoke( OUString(L"inoutArray"), Sequence< Any > ( arAny2, 1), seqIndices, seqOut); +// Sequence<Any> seqOutValue2; +// seqOut[0]>>= seqOutValue2; +// +// // we assume that the Sequence contains Anys of strings +// OUString usMessage2; +// for(int i2=0; i2 < seqOutValue2.getLength(); i2++) +// { +// OUString stemp; +// if( seqOutValue2[i2] >>= stemp) +// { +// usMessage2 += OUString(L"\n"); +// usMessage2 += stemp; +// } +// } +// MessageBox( NULL, W2T( usMessage2.getStr()), _T("Test Program"), MB_OK); + +// +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// Reference < XInvocation > inv3= getComObject(L"AxTestComponents.Basic"); +// Any anyVal2; +// anyVal2 <<= OUString(L"this is the value of prpString"); +// inv3->setValue( OUString(L"prpString"), anyVal2); +// aAny <<= inv3; +// inv->invoke( OUString(L"inoutObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut); +// Reference<XInvocation> invOut2; +// if( seqOut[0]>>=invOut2) +// { +// Any val= invOut2->getValue( L"prpString"); +// +// if( val.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// val>>=s; +// MessageBox( NULL,W2T( s.getStr()), _T("Test Program"), MB_OK); +// } +// } + + //################################################################################### + // mixed parameter + //################################################################################### +// // mixed1 +// seqIndices.realloc( 0); +// seqOut.realloc(0); +// Sequence< Any > params(12); +// sal_Int8 aByte=111; +// OUString aString(L" a string in a VARIANT"); +// Any param[12]; +// param[0] <<= aByte; +// param[2] <<= aByte; //in out +// param[3] <<= aString; // in String +// param[5] <<= aString; // in out string +// +// OUString arStr3[]= {L"string0", L"string1", L"string2"}; +// Sequence<OUString> seq3( arStr3,3); +// param[6] <<= seq3; // in Array +// param[8] <<= seq3; // in ou Array +// +// Reference < XInvocation > inv4= getComObject(L"AxTestComponents.Basic"); +// Any anyVal3; +// anyVal3 <<= OUString(L"this is the value of prpString"); +// inv4->setValue( OUString(L"prpString"), anyVal3); +// param[9] <<= inv4; // in dispatch +// param[11] <<= inv4; +// inv->invoke( OUString(L"mixed1"), Sequence< Any > ( param, 12),seqIndices, seqOut); +// +// for( int i3=0; i3<seqOut.getLength();i3++) +// { +// Any any; +// any <<= seqOut[i3]; +// +// } +// sal_Int8 outChar= *( char*)seqOut[0].getValue(); +// sal_Int8 inoutChar= *( char*)seqOut[1].getValue(); +// sprintf( buff, " out Byte: %d \n in out Byte %d", outChar, inoutChar ); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// OUString outString( *(OUString*)seqOut[2].getValue()); +// OUString inoutString( *(OUString*)seqOut[3].getValue()); +// sprintf( buff, "out string: %S \n in out string: %S", outString.getStr(), inoutString.getStr()); +// MessageBox( NULL, A2T( buff), _T("Test Program"), MB_OK); +// +// Sequence< Any > outSeq; +// seqOut[4] >>= outSeq; +// OUString usMessage3; +// for(int i4=0; i4 < outSeq.getLength(); i4++) +// { +// OUString stemp; +// if( outSeq[i4] >>= stemp) +// { +// usMessage3 += OUString(L"\n"); +// usMessage3 += stemp; +// } +// } +// MessageBox( NULL, W2T( usMessage3.getStr()), _T("Test Program. out Sequence"), MB_OK); +// +// seqOut[5] >>= outSeq; +// OUString usMessage4; +// for(int i5=0; i5 < outSeq.getLength(); i5++) +// { +// OUString stemp; +// if( outSeq[i5] >>= stemp) +// { +// usMessage4 += OUString(L"\n"); +// usMessage4 += stemp; +// } +// } +// MessageBox( NULL, W2T( usMessage3.getStr()), _T("Test Program. in out Sequence"), MB_OK); +// +// Reference<XInvocation> invOut3; +// seqOut[6] >>= invOut3; +// if( seqOut[0]>>=invOut3) +// { +// Any val= invOut3->getValue( L"prpString"); +// +// if( val.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// val>>=s; +// MessageBox( NULL,W2T( s.getStr()), _T("Test Program, out object"), MB_OK); +// } +// } +// +// Reference<XInvocation> invOut4; +// seqOut[6] >>= invOut4; +// if( seqOut[0]>>=invOut4) +// { +// Any val= invOut4->getValue( L"prpString"); +// +// if( val.getValueTypeClass() == TypeClass_STRING) +// { +// OUString s; +// val>>=s; +// MessageBox( NULL,W2T( s.getStr()), _T("Test Program, in out object"), MB_OK); +// } +// } + + //################################################################################### + // Sequences + //################################################################################### + + seqIndices.realloc( 0); + seqOut.realloc(0); + sal_Int32 arLong[]={ 1,2,3}; + Any seqLongAny; + seqLongAny<<= Sequence<sal_Int32>( arLong, 3); + inv->invoke( OUString(L"inSequenceLong"),Sequence< Any > ( &seqLongAny, 1), seqIndices, seqOut); + + return hr; +} diff --git a/extensions/test/ole/OleClient/makefile.mk b/extensions/test/ole/OleClient/makefile.mk new file mode 100644 index 000000000..a6b74362e --- /dev/null +++ b/extensions/test/ole/OleClient/makefile.mk @@ -0,0 +1,128 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/..$/ + +PRJNAME=extensions +TARGET=clientTest +TARGETTYPE=CUI +LIBTARGET=NO + +#USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +BOOTSTRAP_SERVICE=FALSE + +# --- Settings --- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files --- + +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb + + +UNOUCROUT= $(OUT)$/inc +INCPRE+= $(OUT)$/inc -I$(SOLARINCDIR)$/external$/atl + + +UNOTYPES= com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.script.XInvocation \ + oletest.XCallback + + + +.IF "$(depend)" != "" + +.ENDIF # depend + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/clientTest.obj +LIBCMT=msvcrtd.lib + + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + user32.lib \ + kernel32.lib \ + ole32.lib \ + oleaut32.lib \ + uuid.lib \ + comdlg32.lib + + + +.IF "$(GUI)"=="WNT" +APP1STDLIBS += $(LIBCIMT) +.ENDIF + +APP1DEF= $(MISC)\$(APP1TARGET).def + +# --- Targets --- + +.INCLUDE : target.mk + diff --git a/extensions/test/ole/OleClient/readme.txt b/extensions/test/ole/OleClient/readme.txt new file mode 100644 index 000000000..aff1ce948 --- /dev/null +++ b/extensions/test/ole/OleClient/readme.txt @@ -0,0 +1,7 @@ +The program tests the OleClient service which enables to use COM components +through XInvocation. + +Requirements: + +applicat.rdb has to be next to the executable. +COM component: XCallback_Impl.Simple ( extensions/test/ole/unotocomcalls/XCallback_Impl )
\ No newline at end of file diff --git a/extensions/test/ole/OleConverterVar1/convTest.cxx b/extensions/test/ole/OleConverterVar1/convTest.cxx new file mode 100644 index 000000000..4f61b3eaf --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/convTest.cxx @@ -0,0 +1,678 @@ +/************************************************************************* + * + * $RCSfile: convTest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <windows.h> +#include <comdef.h> +#include <tchar.h> +#include <atlbase.h> +extern CComModule _Module; +#include<atlcom.h> +#include<atlimpl.cpp> + +#include <com/sun/star/bridge/ModelDependent.hpp> +#include <com/sun/star/bridge/XBridgeSupplier2.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <oletest/XTestSequence.hpp> +#include <rtl/process.h> +#include <com/sun/star/uno/Reference.h> +#include <cppuhelper/servicefactory.hxx> +#include <rtl/string.h> +#pragma hdrstop + + +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; +using namespace rtl; +HRESULT doTest(); +HRESULT InitializeParameter(); +void printResultVariantArray( VARIANT & var); +void printVariant( VARIANT & var); + + + + +int __cdecl _tmain( int argc, _TCHAR * argv[] ) +{ + HRESULT hr; + if( FAILED( hr=CoInitialize(NULL))) + { + _tprintf(_T("CoInitialize 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; +} +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., 1234.5, 123.45, 12.345, 1.2345}; +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<char> 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<IUnknown> spUnkMgr; + + Reference< XMultiServiceFactory > mgr= createRegistryServiceFactory( OUString(L"applicat.rdb")); + Reference< XInterface > xIntSupplier= mgr->createInstance(OUString(L"com.sun.star.bridge.OleBridgeSupplierVar1")); + Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY); + Reference <XInterface> xOletest= mgr->createInstance( OUString(L"oletest.OleTest")); + Any any; + any <<= xOletest; + sal_uInt8 arId[16]; + rtl_getGlobalProcessId( arId); + Any target= xSuppl->createBridge( any, Sequence<sal_Int8>( (sal_Int8*)arId, 16), UNO, OLE); + CComDispatchDriver oletest; + if (target.getValueTypeClass() == getCppuType((sal_uInt32*) 0).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 aquiring member information + // on demand in IDispatch::Invoke + // Step through the corresponding IDispatch implementation of the ole bridge + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet); + // Name ok but different case + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet); + // not existing member + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet); + + // Property + varParam1.vt= VT_ARRAY | VT_I1; + varParam1.parray= (SAFEARRAY*)arByte; + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1); + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1); + // Name ok but different case + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1); + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1); + // not existing member + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1); + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1); + + // PropertyGet + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet); + + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet); + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet); + //not existing member + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrBy"), &varRet); + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(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<IUnknown*> 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<IDispatch> dispOut; + CComVariant varOutXInterface; //### + varOutXInterface.vt= VT_BYREF |VT_DISPATCH; + V_DISPATCHREF(&varOutXInterface)= &dispOut.p; + + // In Parameter ( all of type Sequence ########################################################### + OutputDebugString( _T("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<LPCOLESTR>(L"methodByte"), &varByteArray, &varRet); + OutputDebugStringA("methodByte | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodShort | Params: \n"); + printVariant( varShortArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodShort"), &varShortArray, &varRet); + OutputDebugStringA("methodShort | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodLong | Params: \n"); + printVariant( varLongArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodLong"), &varLongArray, &varRet); + OutputDebugStringA("methodLong | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodDouble | Params: \n"); + printVariant( varDoubleArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodDouble"), &varDoubleArray, &varRet); + OutputDebugStringA("methodDouble | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodString | Params: \n"); + printVariant( varStringArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodString"), &varStringArray, &varRet); + OutputDebugStringA("methodString | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodAny | Params: \n"); + printVariant( varArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodAny"), &varArray, &varRet); + OutputDebugStringA("methodAny | return value \n"); + printVariant( varRet); + + OutputDebugStringA("methodXInterface | Params: \n"); + printVariant( varUnkArray); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodXInterface"), &varUnkArray, &varRet); + OutputDebugStringA("methodAny | return value \n"); + printVariant( varRet); + + // Out Parameter ########################################################################### + OutputDebugString( _T("Out parameter ###########################################\n\n")); + + OutputDebugString(_T("testout_methodByte \n")); + hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testout_methodByte"), &varOutByte, 1, &varRet); + OutputDebugString(_T("testout_methodByte | out value: \n")); + printVariant( varOutByte); + + OutputDebugString(_T("testout_methodShort \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodShort"), &varOutShort, &varRet); + OutputDebugString(_T("testout_methodShort | out value: \n")); + printVariant( varOutShort); + + OutputDebugString(_T("testout_methodLong \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodLong"), &varOutLong, &varRet); + OutputDebugString(_T("testout_methodLong | out value: \n")); + printVariant( varOutLong); + + OutputDebugString(_T("testout_methodDouble \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodDouble"), &varOutDouble, &varRet); + OutputDebugString(_T("testout_methodDouble | out value: \n")); + printVariant( varOutDouble); + + OutputDebugString(_T("testout_methodString \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodString"), &varOutString, &varRet); + OutputDebugString(_T("testout_methodString | out value: \n")); + printVariant( varOutString); + + OutputDebugString(_T("testout_methodAny \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodAny"), &varOutAny, &varRet); + OutputDebugString(_T("methodAny | out value: \n")); + printVariant( varOutAny); + + OutputDebugString(_T("testout_methodXInterface \n")); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodXInterface"), &varOutXInterface, &varRet); + OutputDebugString(_T("methodAny | out value: \n")); + printVariant( varOutXInterface); + CComDispatchDriver outDisp( *varOutXInterface.ppdispVal); + CComVariant varAttr3; + outDisp.GetPropertyByName(L"AttrAny2", &varAttr3); + ATLTRACE("property OleTest.AttrAny2: %s", W2T(varAttr3.bstrVal)); + + OutputDebugString(_T("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<LPCOLESTR>(L"testout_methodMulParams1"), (VARIANT*)&_params, 2); + OutputDebugString(_T("testout_methodMulParams1 | out values: \n")); + printVariant( _params[1]); + printVariant( _params[0]); + + OutputDebugString(_T("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<LPCOLESTR>( L"testout_methodMulParams2"), (VARIANT*)&_params2, 3); + OutputDebugString(_T("testout_methodMulParams2 | out values: \n")); + printVariant( _params2[2]); + printVariant( _params2[1]); + printVariant( _params2[0]); + + OutputDebugString(_T("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<LPCOLESTR>( L"testout_methodMulParams3"), (VARIANT*)&_params3, 2); + OutputDebugString(_T("testout_methodMulParams3 | out values: \n")); + printVariant( _params3[1]); + printVariant( _params3[0]); + + //In Out Parameter ########################################################################### + OutputDebugString( _T("In Out parameter ###########################################\n\n")); + + *V_I1REF(&varOutByte)= 5; + ATLTRACE(_T("testinout_methodByte | in value: %d \n"), *V_I1REF(&varOutByte)); + hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varOutByte, 1, &varRet); + OutputDebugString(_T("testinout_methodByte | out value: \n")); + printVariant( varOutByte); + + OutputDebugString(_T("testinout_methodShort | in value= 1000 \n")); + *V_UI2REF(&varOutShort)= 1000; + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodShort"), &varOutShort, &varRet); + OutputDebugString(_T("testinout_methodShort | out value: \n")); + printVariant( varOutShort); + + OutputDebugString(_T("testinout_methodLong | in value= 10000 \n")); + *V_UI4REF(&varOutLong)= 10000; + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodLong"), &varOutLong, &varRet); + OutputDebugString(_T("testinout_methodLong | out value: \n")); + printVariant( varOutLong); + + *V_R8REF(&varOutDouble)= 3.14; + ATLTRACE(_T("testinou_methodDouble in value: %f \n"),*V_R8REF(&varOutDouble)); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodDouble"), &varOutDouble, &varRet); + OutputDebugString(_T("testinout_methodDouble | out value: \n")); + printVariant( varOutDouble); + + SysFreeString( *V_BSTRREF(&varOutString)); + *V_BSTRREF(&varOutString)= SysAllocString( L"this is a in string"); + ATLTRACE(_T("testinout_methodString | value: %s \n"), W2T(*V_BSTRREF(&varOutString))); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodString"), &varOutString, &varRet); + OutputDebugString(_T("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(_T("testinout_methodAny | parameter: %s\n"), W2T(var1.bstrVal)); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodAny"), &varOutAny, &varRet); + OutputDebugString(_T("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(); + OutputDebugString(_T("testinout_methodXInterface | in value: \n")); + printVariant(varOutIFace); + hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodXInterface"), &varOutIFace, &varRet); + OutputDebugString(_T("testinout_methodXInterface | out value: \n")); + printVariant( varOutIFace); + + // Properties ###################################################################### + OutputDebugString( _T(" Properties ###########################################\n\n")); + + OutputDebugString(_T("set property \"AttrByte\" | value")); + CComVariant propArByte; + propArByte.vt= VT_ARRAY | VT_I1; + varParam1.parray= (SAFEARRAY*)arByte; + printVariant( varParam1); + hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1); + OutputDebugString(_T("get property \"AttrByte\" | value:")); + varRet.Clear(); + hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(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; + OutputDebugString( _T("# Array \n")); + for( long i= 0; i < count; i++) + { +// CComVariant variantValue; + TCHAR *buf[256]; + wsprintf( (TCHAR*)buf, _T("%d : "), i); + OutputDebugString( (TCHAR*)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 + { + TCHAR buf[256]; + switch (var.vt) + { + case VT_I1: wsprintf( (TCHAR*)buf, _T(" VT_I1: %d \n"), V_I1( &var) ); + break; + case VT_UI1: wsprintf( (TCHAR*)buf, _T(" VT_UI1: %d \n"), V_I1( &var) ); + break; + + case VT_I2: wsprintf( (TCHAR*)buf, _T(" VT_I2: %d \n"), V_I2( &var) ); + break; + case VT_I4: wsprintf( (TCHAR*)buf, _T(" 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( (TCHAR*)buf, _T(" 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<LPCOLESTR>(L"Name"), &ret); + wsprintf( (TCHAR*)buf, _T(" VT_UNKNOWN: property \"Name\": %s \n"), W2T(ret.bstrVal)); + break; + } + case VT_DISPATCH: + // The object implement IFont + { + CComDispatchDriver disp( var.punkVal); + CComVariant ret; + if( SUCCEEDED( hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret))) + wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH: property \"Name\": %s \n"), W2T(ret.bstrVal)); + else + wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH \n")); + + break; + } + + + case VT_BSTR: + { + TCHAR* str= W2T( var.bstrVal); + wsprintf( (TCHAR*)buf, _T(" VT_BSTR: %s \n"), str); + } + break; + default: + wsprintf( (TCHAR*)buf, _T("\n")); + + } + + OutputDebugString( (TCHAR*) buf); + } + + return; + +} + diff --git a/extensions/test/ole/OleConverterVar1/makefile.mk b/extensions/test/ole/OleConverterVar1/makefile.mk new file mode 100644 index 000000000..e7d8fbd9c --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/makefile.mk @@ -0,0 +1,136 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/..$/..$/ + +PRJNAME=extensions +TARGET=convTest +TARGETTYPE=CUI +LIBTARGET=NO + +#USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +BOOTSTRAP_SERVICE=FALSE + +# --- Settings --- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files --- + +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb + +.IF "$(BOOTSTRAP_SERVICE)" == "TRUE" +UNOUCROUT= $(OUT)$/inc$/comprehensive +INCPRE+= $(OUT)$/inc$/comprehensive +CPPUMAKERFLAGS += -C +.ELSE +UNOUCROUT= $(OUT)$/inc +INCPRE+= $(OUT)$/inc -I$(SOLARINCDIR)$/3rdparty$/atl +.ENDIF + +UNOTYPES= com.sun.star.bridge.ModelDependent \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.bridge.XBridgeSupplier2 + + + +.IF "$(depend)" != "" + +.ENDIF # depend + +APP1TARGET= $(TARGET) +APP1OBJS= $(OBJ)$/convTest.obj +LIBCMT=msvcrtd.lib + + +APP1STDLIBS= \ + $(SALLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + user32.lib \ + kernel32.lib \ + ole32.lib \ + oleaut32.lib \ + uuid.lib \ + comdlg32.lib + + + +#gdi32.lib winspool.lib advapi32.lib shell32.lib odbc32.lib odbccp32.lib + + +.IF "$(GUI)"=="WNT" +APP1STDLIBS += $(LIBCIMT) +APP2STDLIBS += $(LIBCIMT) +.ENDIF + +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..104fb1808 --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/readme.txt @@ -0,0 +1,2 @@ +The program test the Service com.sun.star.bridge.OleBridgeSupplierVar1. +While running in debug mode it writes infos to the debug - output.
\ No newline at end of file diff --git a/extensions/test/ole/OleConverterVar1/smartarray.h b/extensions/test/ole/OleConverterVar1/smartarray.h new file mode 100644 index 000000000..f32e9c31a --- /dev/null +++ b/extensions/test/ole/OleConverterVar1/smartarray.h @@ -0,0 +1,267 @@ +/************************************************************************* + * + * $RCSfile: smartarray.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef _SMARTARRAY_H +#define _SMARTARRAY_H + + +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<long>(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<IUnknown*> +{ + SAFEARRAY *m_array; +public: + + SmartArray( sourceType * parParams, int count, VARTYPE destVartype); +// { +// ATLTRACE("SmartArray<IUnknown>"); +// 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 <IUnknown*>::SmartArray(sourceType * parParams, int count, VARTYPE destVartype):m_array(NULL) +{ + ATLTRACE("SmartArray<IUnknown>"); + 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++) + { + pData[i]= parParams[i]; + pData[i]->AddRef(); + } + } + SafeArrayUnaccessData( m_array); +}; +#endif diff --git a/extensions/test/ole/OleTest.htm b/extensions/test/ole/OleTest.htm new file mode 100644 index 000000000..d59392eb9 --- /dev/null +++ b/extensions/test/ole/OleTest.htm @@ -0,0 +1,943 @@ +<HTML> +<HEAD> +<META NAME="GENERATOR" Content="Microsoft Developer Studio"> +<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> +<TITLE>Document Title</TITLE> +</HEAD> +<BODY id=theBody> + +<script language="JScript"> +function callOleTest( id) +{ + var factory= new ActiveXObject("com.sun.star.ServiceManager"); + var oletest= factory.createInstance("oletest.OleTest"); +// alert(oletest); + + var arr= new Array( 1, 2, 3, 4, 0); + var arrDouble= new Array( 1.2345, 12.345, 123,45, 1234.5, 12345); + var arrBool= new Array( 1, 0, 2, 0, 3); + var arrChar= new Array( '1', 'A', "1", "A", ' ', 55, 56); + var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza"); + var arrAny= new Array( 100, 100.1235,"hallo"); + var arrSeq= new Array( arr, arr, arr); + var arrSeq2= new Array( arrSeq, arrSeq, arrSeq) + + + var arrout1= new Array(); + var arrout2= new Array(); + var arrout3= new Array(); + + var ret, i; + var sfarray, sfarray1, sfarray2, sfarray3; + switch( id) + { + // Array in-params + case 1: ret= oletest.methodByte( arr); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() + "<br>"); + document.writeln( "Returns a Sequence< BYTE > <br>" + sfarray.toArray()) ; break; + + case 2: ret= oletest.methodDouble( arrDouble); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrDouble.toString() +"<br>"); + document.writeln( "Returns a Sequence< double > <br>" + sfarray.toArray()) ; break; + + case 3: ret= oletest.methodBool( arrBool); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrBool.toString() +"<br>"); + document.writeln( "Returns a Sequence< BOOL > <br>" + sfarray.toArray()) ; break; + + case 4: ret= oletest.methodShort( arr); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< SHORT > <br>" + sfarray.toArray()) ; break; + + case 5: ret= oletest.methodUShort( arr); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< unsigned SHORT > <br>" + sfarray.toArray()) ; break; + + case 6: ret= oletest.methodLong( arr); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< LONG > <br>" + sfarray.toArray()) ; break; + + case 7: ret= oletest.methodULong( arr); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arr.toString() +"<br>"); + document.writeln( "Returns a Sequence< unsigned LONG > <br>" + sfarray.toArray()) ; break; + + case 8: ret= oletest.methodChar( arrChar); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrChar.toString() +"<br>"); + document.writeln( "Returns a Sequence< wchar_t > <br>" + sfarray.toArray()) ; break; + + case 9: ret= oletest.methodString( arrString); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrString.toString() +"<br>"); + document.writeln( "Returns a Sequence< UString > <br>" + sfarray.toArray()) ; break; + + case 10: ret= oletest.methodAny( arrAny); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrAny.toString() +"<br>"); + document.writeln( "Returns a Sequence< UsrAny > <br>" + sfarray.toArray() ) ; break; + + case 11: ret= oletest.methodSequence( arrSeq); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrSeq.toString() +"<br>"); + document.writeln("Returns a Sequence< Sequence < long >> <br>") ; + var arr1= new Array(); + arr1= sfarray.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + var arr2= new Array(); + arr2= sfarray2.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + + case 12: ret= oletest.methodSequence2( arrSeq2); + document.writeln( "Param: " + arrSeq2.toString() +"<br>"); + sfarray1= new VBArray( ret); + arr1= sfarray1.toArray(); + for( i=0; i < arr1.length; i++) + { + sfarray2= new VBArray( arr1[i]); + arr2= sfarray2.toArray(); + + for ( j=0; j < arr2.length; j++) + { + sfarray3= new VBArray( arr2[j]); + arr3= sfarray3.toArray(); + document.write( i+ " "); + document.writeln(j + ": "+ arr3.toString() + "<br>" ); + } + + } + break; + + case 13: + var ar= new Array(); + for( i=0; i< 3; i++) + { + var ob= new Object(); + ob.value= "A JScript object!"; + ar[i]= ob; + } + + ret = oletest.methodXInterface( ar); + sfarray= new VBArray( ret); + var arRet= sfarray.toArray(); + + document.writeln( "Params : Array containing objects ") + for( index in ar) + { + document.writeln( "object " + index + ": " + ar[index].value +" "); + } + document.writeln( "<br>" ) ; + document.writeln("Return: <br>"); + for( index in arRet) + { + document.writeln( "object " + index + ": " + arRet[index].value + " "); + } + break; + + case 14: ret= oletest.methodFloat( arrDouble); + sfarray= new VBArray( ret); + document.writeln( "Param: " + arrDouble.toString() +"<br>"); + document.writeln( "Returns a Sequence< float> <br>" + sfarray.toArray()) ; break; + + + + + + + // Properties: setting and getting values + case 200: oletest.AttrByte = arr; + ret= oletest.AttrByte; + document.writeln("Setting AttrByte: " + arr.toString() + "<p>"); + document.writeln("Getting AttrByte: " + arr.toString()); break; + + case 201: oletest.AttrDouble= arrDouble; + ret= oletest.AttrDouble; + document.writeln("Setting AttrDouble: " + arrDouble.toString() + "<p>"); + document.writeln("Getting AttrDouble: " + arrDouble.toString()); break; + + case 202: oletest.AttrBool= arrBool; + ret= oletest.AttrBool; + document.writeln("Setting AttrBool: " + arrBool.toString() + "<p>"); + document.writeln("Getting AttrBool: " + arrBool.toString()); break; + + case 203: oletest.AttrShort= arr; + ret= oletest.AttrShort; + document.writeln("Setting AttrShort: " + arr.toString() + "<p>"); + document.writeln("Getting AttrShort: " + arr.toString()); break; + + case 204: oletest.AttrUShort= arr; + ret= oletest.AttrUShort; + document.writeln("Setting AttrUShort: " + arr.toString() + "<p>"); + document.writeln("Getting AttrUShort: " + arr.toString()); break; + + case 205: oletest.AttrLong= arr; + ret= oletest.AttrLong; + document.writeln("Setting AttrLong: " + arr.toString() + "<p>"); + document.writeln("Getting AttrLong: " + arr.toString()); break; + + case 206: oletest.AttrULong= arr; + ret= oletest.AttrULong; + document.writeln("Setting AttrULong: " + arr.toString() + "<p>"); + document.writeln("Getting AttrULong: " + arr.toString()); break; + + case 207: oletest.AttrChar= arrChar; + ret= oletest.AttrChar; + document.writeln("Setting AttrChar: " + arrChar.toString() + "<p>"); + document.writeln("Getting AttrChar: " + arrChar.toString()); break; + + case 208: oletest.AttrString= arrString; + ret= oletest.AttrString; + document.writeln("Setting AttrString: " + arrString.toString() + "<p>"); + document.writeln("Getting AttrString: " + arrString.toString()); break; + + case 209: oletest.AttrAny= arrAny; + ret= oletest.AttrAny; + document.writeln("Setting AttrAny: " + arrAny.toString() + "<p>"); + document.writeln("Getting AttrAny: " + arrAny.toString()); break; + + case 210: oletest.AttrSequence= arrSeq; + ret= oletest.AttrSequence; + document.writeln("Setting AttrSequence: " + arrSeq.toString() + "<p>"); + document.writeln("Getting AttrSequence: " + arrSeq.toString()); break; + + case 211: oletest.AttrSequence2= arrSeq2; + ret= oletest.AttrSequence2; + document.writeln("Setting AttrSequence2: " + arrSeq2.toString() + "<p>"); + document.writeln("Getting AttrSequence2: " + arrSeq2.toString()); break; + + case 212: oletest.AttrFloat= arrDouble; + ret= oletest.AttrFloat; + document.writeln("Setting AttrFloat: " + arrDouble.toString() + "<p>"); + document.writeln("Getting AttrFloat: " + arrDouble.toString()); break; + + + + // Out-parameter ------------------------------------------------------------ + case (2000): + oletest.testout_methodByte( arrout1 ); + alert("byte: " + arrout1[0] ); break; + case (2001): + oletest.testout_methodDouble( arrout1 ); + alert( "double: " + arrout1[0] ); break; + case (2002): + oletest.testout_methodBool( arrout1 ); + alert( "boolean: " + arrout1[0] ); break; + case (2003): + oletest.testout_methodShort( arrout1 ); + alert( "short: " + arrout1[0] ); break; + case (2004): + oletest.testout_methodUShort( arrout1 ); + alert( "unsigned short: " + arrout1[0] ); break; + case (2005): + oletest.testout_methodLong( arrout1 ); + alert( "long: " + arrout1[0] ); break; + case (2006): + oletest.testout_methodULong( arrout1 ); + alert( "unsigned long: " + arrout1[0] ); break; + case (2007): + oletest.testout_methodChar( arrout1 ); + alert( "char: " + arrout1[0] ); break; + case (2008): + oletest.testout_methodString( arrout1 ); + alert( "string: " + arrout1[0] ); break; + case (2009): + oletest.testout_methodAny( arrout1 ); + alert( "any: " + arrout1[0] ); break; + case (2010): + oletest.testout_methodSequence( arrout1 ); + var sfarray= new VBArray( arrout1[0]); + arr= sfarray.toArray(); + document.writeln("use the browser's back arrow to go to the previous page <p>"); + document.writeln( arr.toString()); + break; + case (2011): + oletest.testout_methodSequence2( arrout1 ); + var sfarray= new VBArray( arrout1[0]); + arr= sfarray.toArray(); + var i; + for( i=0; i < arr.length; i++) + { + var sfarray= new VBArray( arr[i]); + var arr2= new Array(); + arr2= sfarray.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + case (2012): + oletest.testout_methodMulParams1( arrout1, arrout2 ); + document.writeln( "int : " + arrout1[0] + " int :" + arrout2[0] ); break; + case (2013): + oletest.testout_methodMulParams2( arrout1, arrout2, arrout3 ); + document.writeln( "int: " + arrout1[0] + " int: " + arrout2[0] + " string: " + arrout3[0] ); break; + case (2014): + oletest.testout_methodMulParams3( "hallo", arrout1 ); + document.writeln( "string: " + arrout1[0] ); break; + case (2015): + oletest.testout_methodXInterface( arrout1 ); + document.writeln( "string: " + arrout1[0].AttrAny2); break; + case (2016): + oletest.testout_methodFloat( arrout1 ); + alert( "float: " + arrout1[0] ); break; + case (2017): + var in1= 3.14; + var in2= 1111; + var in3= -2222; + oletest.testout_methodMulParams4( in1, arrout1, in2, arrout2, in3 ); + document.write("param1 [in] float: " + in1 + " param2 [out] float: " + arrout1[0] + + " param3 [in] long: " + in2 + " param4 [out] long: " + arrout2[0] + + " param5 [in] long: " + in3); + break; + + + // INOUT - Parameter ------------------------------------------------------------------------------- + // The in value has to be placed on index 0 of the passed in array + case (500): + arrout1[0]= 100; + oletest.testinout_methodByte( arrout1 ); + alert("byte: " + arrout1[0] ); break; + case (501): + arrout1[0]= 3.14; + oletest.testinout_methodDouble( arrout1 ); + alert( "double: " + arrout1[0] ); break; + case (502): + arrout1[0]= false; + oletest.testinout_methodBool( arrout1 ); + alert( "boolean: " + arrout1[0] ); break; + case (503): + arrout1[0]= 200; + oletest.testinout_methodShort( arrout1 ); + alert( "short: " + arrout1[0] ); break; + case (504): + arrout1[0]= 300; + oletest.testinout_methodUShort( arrout1 ); + alert( "unsigned short: " + arrout1[0] ); break; + case (505): + arrout1[0]= 400; + oletest.testinout_methodLong( arrout1 ); + alert( "long: " + arrout1[0] ); break; + case (506): + arrout1[0]= 500; + oletest.testinout_methodULong( arrout1 ); + alert( "unsigned long: " + arrout1[0] ); break; + case (507): + arrout1[0]= "A"; + oletest.testinout_methodChar( arrout1 ); + alert( "char: " + arrout1[0] ); break; + case (508): + arrout1[0]= "I am a string"; + oletest.testinout_methodString( arrout1 ); + alert( "string: " + arrout1[0] ); break; + case (509): + arrout1[0]= arr; + oletest.testinout_methodAny( arrout1 ); // the method simply returns the argument + sfarray= new VBArray( arrout1[0]); + arr= sfarray.toArray(); + alert( "any: " + arr.toString() ); break; + case (510): + arrout1[0]= arr; + oletest.testinout_methodSequence( arrout1 ); + var sfarray= new VBArray( arrout1[0]); + arr= sfarray.toArray(); + document.writeln("use the browser's back arrow to go to the previous page <p>"); + document.writeln( arr.toString()); + break; + case (511): + arrout1[0]= arrSeq; + oletest.testinout_methodSequence2( arrout1 ); + var sfarray= new VBArray( arrout1[0]); + arr= sfarray.toArray(); + var i; + for( i=0; i < arr.length; i++) + { + var sfarray= new VBArray( arr[i]); + var arr2= new Array(); + arr2= sfarray.toArray(); + document.writeln( arr2.toString() + "<br>" ); + } + break; + case 512: + var ob= new Object(); + ob.value= "this is a string"; + + arrout1[0]= ob; + alert (arrout1[0].value); + oletest.testinout_methodXInterface( arrout1); + var outValue= arrout1[0]; + for ( key in outValue) + { + document.write( outValue[key] ); + } + document.write("Out value: " + outValue ); + document.write("Out 1 value: " + arrout1[1]); + break; + +// var ob= new Object(); +// ob.value= "this is a string"; +// inoutValue.Set( "object", ob); +// oletest.testinout_methodXInterface( inoutValue); +// document.write("Out value: " + inoutValue.Get().value ); +// break; + + case (513): + arrout1[0]= 3.14; + oletest.testinout_methodFloat( arrout1 ); + alert( "float: " + arrout1[0] ); break; + + + + // Test ANY + // Methods + case 1000: + i= 100; + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1001: + i= 3.14; + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1002: + i= "Hallo" + ret= oletest.methodAnyTest1( i); + document.writeln( "in: " + i + " ret: " + ret); + break; + case 1003: + i= arr; + ret= oletest.methodAnyTest1( i); + sfarray= new VBArray( ret); + document.writeln( "in: " + i + " ret: " + sfarray.toArray()); + break; + case 1004: + var obj= new Object(); + obj[1]= "This is index 0"; + ret= oletest.methodAnyTest1( obj); + document.writeln( "in: " + obj + " ret: " + ret); + break; + + + // Test ANY property + case 1010: + i= 100; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1011: + i= 3.14; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1012: + i= "Hallo" + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + document.writeln( "set: " + i + " get: " + ret); + break; + case 1013: + i= arr; + oletest.AttrAny2= i; + ret= oletest.AttrAny2; + sfarray= new VBArray( ret); + document.writeln( "set: " + i + " get: " + sfarray.toArray()); + break; + case 1014: + var obj= new Object(); + obj[1]= "This is index 0"; + oletest.AttrAny2= obj; + ret= oletest.AttrAny2; + document.writeln( "set: " + obj + " get: " + ret); + break; + + case 1020: + var val= 3.14; + oletest.in_float( val); + break; + + case 2100: + alert("2100"); + var ret= oletest.retMethodByte(); + var sfarray= VBArray( ret); + document.writeln( sfarray.toArray() ); + break; + + + + } + +} + +function funcOut( out) +{ + out["du"]= 0xffff; +} + +</script> + +<script language="VBScript"> + +sub callBasic(id) + + Dim factory + Set factory= GetObject("", "com.sun.star.ServiceManager") + + Set oletest= factory.createInstance("oletest.OleTest") + + + arrInt= Array(1,2,3,4,5) + arrInt2= Array( -1, -2, 127, 128, 0) + arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5) + arrBool= Array(0,1,0,2,0) + arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff) + arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger") + arrChar= Array("a",65, "M") + arrAny= Array("Mickey", 3.14, 100, "A") + + Dim arrDim2Int(1,1) + For i= 0 To 1 + For j= 0 To 1 + arrDim2Int(i,j) = i*2 + j + Next + Next + + Dim arrDim3Int(1,1,1) + For i= 0 To 1 + For j= 0 To 1 + For k=0 To 1 + arrDim3Int(i,j,k) = i*2 + j*2 + k + Next + Next + Next + + + select case id + case 0 + document.writeln "param: " + printArray arrInt + ret= oletest.methodByte(arrInt) + document.writeln "<br> return value: " + printArray ret + case 1 + document.writeln "param: " + printArray arrDouble + ret= oletest.methodDouble(arrDouble) + document.writeln "<br> return value: " + printArray ret + case 2 + document.writeln "param: " + printArray arrBool + ret= oletest.methodBool(arrBool) + document.writeln "<br> return value: " + printArray ret + case 3 + document.writeln "param: " + printArray arrInt2 + ret= oletest.methodShort(arrInt2) + document.writeln "<br> return value: " + printArray ret + case 4 + document.writeln "param: " + printArray arrInt + ret= oletest.methodUShort(arrInt) + document.writeln "<br> return value: " + printArray ret + case 5 + document.writeln "param: " + printArray arrLong + ret= oletest.methodLong(arrLong) + document.writeln "<br> return value: " + printArray ret + case 6 + document.writeln "param: " + printArray arrInt + ret= oletest.methodULong(arrInt) + document.writeln "<br> return value: " + printArray ret + case 7 + document.writeln "param: " + printArray arrString + ret= oletest.methodString(arrString) + document.writeln "<br> return value: " + printArray ret + case 8 + document.writeln "param: " + printArray arrChar + ret= oletest.methodChar(arrChar) + document.writeln "<br> return value: " + printArray ret + case 9 + document.writeln "param: " + printArray arrAny + ret= oletest.methodAny(arrAny) + document.writeln "<br> return value: " + printArray ret + case 10 + document.writeln "param: " + printArray2 arrDim2Int + ret= oletest.methodSequence(arrDim2Int) + document.writeln "<br> return value: " + for each val in ret + document.write "<br> array: " + for each val2 in val + document.write val2 + next + next + + // Out Parameter + case 150 + dim rOut + oletest.testout_methodByte rOut + MsgBox 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); + + + // In Out Parameter -------------------------------------------------- + case 100 + a= 100 + document.write "param: " & CStr( a) & "<br>" + oletest.testinout_methodByte a + document.write a + case 101 + a= 1.11 + document.write "param: " & CStr( a) & "<br>" + oletest.testinout_methodDouble a + document.write a + case 102 + a= 5 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodBool a + document.write a + case 103 + a= -10 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodShort a + document.write a + case 104 + a= 128 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodUShort a + document.write a + case 105 + a= 65556 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodLong a + document.write a + case 106 + a= 65556 + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodULong a + document.write a + case 107 + a= "ein test string" + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodString a + document.write a + case 108 + a= "W" + document.write "param: "& CStr( a) & "<br>" + oletest.testinout_methodChar a + document.write a + case 109 + a= "Ein String im Any" + document.write "param: "& CStr( a) & "<br>" + oletest.other_methodAnyIn a + document.write a + + case 150 + dim a + document.write "param: "& CStr( a) & "<br>" + oletest.testout_methodByte( a) + document.write a +// Attributes ----------------------------------------------------------------- + case 200 + document.write "set: " + printArray arrInt + oletest.AttrByte= arrInt + b= oletest.AttrByte + call printArrayEx( "<br> get: ", "<br>", b) + case 201 + document.write "set: " + printArray arrDouble + oletest.AttrDouble= arrDouble + b= oletest.AttrDouble + call printArrayEx( "<br> get: ", "<br>", b) + case 202 + document.write "set: " + printArray arrBool : + oletest.AttrBool= arrBool + b= oletest.AttrBool + call printArrayEx( "<br> get: ", "<br>", b) + case 203 + document.write "set: " + printArray arrInt2 : + oletest.AttrShort= arrInt2 + b= oletest.AttrShort + call printArrayEx( "<br> get: ", "<br>", b) + case 204 + document.write "set: " + printArray arrInt + oletest.AttrUShort= arrInt + b= oletest.AttrUShort + call printArrayEx( "<br> get: ", "<br>", b) + case 205 + document.write "set: " + printArray arrInt2 + oletest.AttrLong= arrInt2 + b= oletest.AttrLong + call printArrayEx( "<br> get: ", "<br>", b) + case 206 + document.write "set: " + printArray arrInt + oletest.AttrULong= arrInt + b= oletest.AttrULong + call printArrayEx( "<br> get: ", "<br>", b) + case 207 + document.write "set: " + printArray arrString + oletest.AttrString= arrString + b= oletest.AttrString + call printArrayEx( "<br> get: ", "<br>", b) + case 208 + document.write "set: " + printArray arrChar + oletest.AttrChar= arrChar + b= oletest.AttrChar + call printArrayEx( "<br> get: ", "<br>", b) + case 209 + document.write "set: " + printArray arrAny + oletest.AttrAny= arrAny + b= oletest.AttrAny + call printArrayEx( "<br> get: ", "<br>", b) + + case 210 + document.write "set: <br>" + printArray2 arrDim2Int : + oletest.AttrSequence= arrDim2Int + ret= oletest.AttrSequence + document.write "get: " + for each val in ret + document.write "<br> array: " + for each val2 in val + document.write val2 + next + next + + case 300 + dim aByte + aByte= 100 + call oletest.testinout_methodByte( aByte) + MsgBox aByte + + end select +end sub +sub printArray( arr) + document.write "array: " + For Each val In arr + document.write CStr(val) & " " + Next +end sub + +// print a 2 dimensional Array + +sub printArray2( arr) + elements1= UBound( arr, 1) - LBound( arr, 1) +1 + elements2= UBound( arr, 2) - LBound( arr, 2) +1 + + For i=0 To elements1 -1 + document.write( "array " & CStr( i) & ": " ) + For j=0 To elements2 -1 + document.write CStr( arr(i,j)) + Next + document.write( "<br>") + Next +end sub + +sub printArrayEx( pre, post, array) + document.write pre + printArray array + document.write post +end sub +</script> + +<div id=out> </div> + +<!-- Insert HTML here --> + +<h2> JScript </h2> +Tests Array/Sequence conversion.<br> +All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons. +<br> +<button onclick='callOleTest( 1)'>byte</Button> +<button onclick='callOleTest( 14)'>float</Button> +<button onclick='callOleTest( 2)'>double</Button> +<button onclick='callOleTest( 3)'>boolean</Button> +<button onclick='callOleTest( 4)'>short</Button> +<button onclick='callOleTest( 5)'>unsigned short</Button> +<button onclick='callOleTest( 6)'>long</Button> +<button onclick='callOleTest( 7)'>unsigned long</Button> +<button onclick='callOleTest( 8)'>char</Button> +<button onclick='callOleTest( 9)'>string</Button> +<button onclick='callOleTest( 10)'>any</Button> +<button onclick='callOleTest( 11)'>sequence<long> </Button> +<button onclick='callOleTest( 12)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 13)'>XInterface</Button> + +<p> + +<p> +Out Parameter <br> +<button onclick='callOleTest( 2000)'>byte </Button> +<button onclick='callOleTest( 2016)'>float</Button> +<button onclick='callOleTest( 2001)'>double</Button> +<button onclick='callOleTest( 2002)'>boolean</Button> +<button onclick='callOleTest( 2003)'>short</Button> +<button onclick='callOleTest( 2004)'>unsigned short</Button> +<button onclick='callOleTest( 2005)'>long</Button> +<button onclick='callOleTest( 2006)'>unsigned long</Button> +<button onclick='callOleTest( 2007)'>char</Button> +<button onclick='callOleTest( 2008)'>string</Button> +<button onclick='callOleTest( 2009)'>any</Button> +<button onclick='callOleTest( 2010)'>sequence<long> </Button> +<button onclick='callOleTest( 2011)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 2012)'>2 out </Button> +<button onclick='callOleTest( 2013)'>3 out </Button> +<button onclick='callOleTest( 2014)'>1 in & 1 out </Button> +<button onclick='callOleTest( 2015)'>XInterface </Button> +<button onclick='callOleTest( 2017)'>mixed out and in </Button> + + +<p> +In Out Parameter <br> +<button onclick='callOleTest( 500)'>byte </Button> +<button onclick='callOleTest( 513)'>float</Button> +<button onclick='callOleTest( 501)'>double</Button> +<button onclick='callOleTest( 502)'>boolean</Button> +<button onclick='callOleTest( 503)'>short</Button> +<button onclick='callOleTest( 504)'>unsigned short</Button> +<button onclick='callOleTest( 505)'>long</Button> +<button onclick='callOleTest( 506)'>unsigned long</Button> +<button onclick='callOleTest( 507)'>char</Button> +<button onclick='callOleTest( 508)'>string</Button> +<button onclick='callOleTest( 509)'>any</Button> +<button onclick='callOleTest( 510)'>sequence<long> </Button> +<button onclick='callOleTest( 511)'>sequence<sequence<long> > </Button> +<button onclick='callOleTest( 512)'>XInterface </Button> +<p> + +Tests Array/Sequence conversion with Attributes. All params are of type Sequence and + the element type of the Sequence is written on the buttons. <br> +<button onclick='callOleTest( 200)'>byte </Button> +<button onclick='callOleTest( 212)'>float</Button> +<button onclick='callOleTest( 201)'>double</Button> +<button onclick='callOleTest( 202)'>boolean</Button> +<button onclick='callOleTest( 203)'>short</Button> +<button onclick='callOleTest( 204)'>unsigned short</Button> +<button onclick='callOleTest( 205)'>long</Button> +<button onclick='callOleTest( 206)'>unsigned long</Button> +<button onclick='callOleTest( 207)'>char</Button> +<button onclick='callOleTest( 208)'>string</Button> +<button onclick='callOleTest( 209)'>any</Button> +<button onclick='callOleTest( 210)'>sequence<long> </Button> +<button onclick='callOleTest( 211)'>sequence<sequence<long> > </Button> +<p> + +Test of Any parameter in a method. Any contains:<br> +<button onclick='callOleTest( 1000)'>integer </Button> +<button onclick='callOleTest( 1001)'>double </Button> +<button onclick='callOleTest( 1002)'>string</Button> +<button onclick='callOleTest( 1003)'>array</Button> +<button onclick='callOleTest( 1004)'>object</Button> +<p> +Test of Any parameter in a property. Any contains:<br> +<button onclick='callOleTest( 1010)'>integer </Button> +<button onclick='callOleTest( 1011)'>double </Button> +<button onclick='callOleTest( 1012)'>string</Button> +<button onclick='callOleTest( 1013)'>array</Button> +<button onclick='callOleTest( 1014)'>object</Button> +<P> +<button onclick='callOleTest( 1020)'>[in] float </Button> + + + +<p> + + +<h2> Visual Basic Tests </h2> +Test array /Sequence conversion and return value<br> +Template: <b> Sequence < type > method( Sequence< type > ) </b> <br> +<!--<font color= red>Multi dimensional arrays are not processed by VBSript</font> <br> --> +<button onclick='callBasic(0)'>byte</button> +<button onclick='callBasic(1)'>double</button> +<button onclick='callBasic(2)'>boolean</button> +<button onclick='callBasic(3)'>short</button> +<button onclick='callBasic(4)'>u short</button> +<button onclick='callBasic(5)'>long</button> +<button onclick='callBasic(6)'>u long</button> +<button onclick='callBasic(7)'>string</button> +<button onclick='callBasic(8)'>char</button> +<button onclick='callBasic(9)'>any</button> <br> +<button onclick='callBasic(10)'>Seq < int ></button> <br> + + +IN/Out parameter <br> +Template: <b> void method( Sequence < type > ) </b> <br> +<button onclick='callBasic(100)'>byte</button> +<button onclick='callBasic(101)'>double</button> +<button onclick='callBasic(102)'>boolean</button> +<button onclick='callBasic(103)'>short</button> +<button onclick='callBasic(104)'>u short</button> +<button onclick='callBasic(105)'>long</button> +<button onclick='callBasic(106)'>u long</button> +<button onclick='callBasic(107)'>string</button> +<button onclick='callBasic(108)'>char</button> +<button onclick='callBasic(109)'>any</button> <br> + +Simple out parameter<br> +<button onclick='callBasic(150)'>byte</button> +<!--<button onclick='callBasic(151)'>double</button> +<button onclick='callBasic(152)'>boolean</button> +<button onclick='callBasic(153)'>short</button> +<button onclick='callBasic(155)'>long</button> +<button onclick='callBasic(157)'>string</button> +<button onclick='callBasic(158)'>char</button> +<button onclick='callBasic(159)'>any</button> <br> +//--> +<br> + + +Tests Array/Sequence conversion with <b>Attributes</b>. All params are of type Sequence and + the element type of the Sequence is written on the buttons. <br> +<button onclick='callBasic( 200)'>byte </Button> +<button onclick='callBasic( 201)'>double</Button> +<button onclick='callBasic( 202)'>boolean</Button> +<button onclick='callBasic( 203)'>short</Button> +<button onclick='callBasic( 204)'>unsigned short</Button> +<button onclick='callBasic( 205)'>long</Button> +<button onclick='callBasic( 206)'>unsigned long</Button> +<button onclick='callBasic( 207)'>string</Button> +<button onclick='callBasic( 208)'>char</Button> +<button onclick='callBasic( 209)'>any</Button> +<button onclick='callBasic( 210)'>sequence<long> </Button> <br> + +In Out parameter <br> +<button onclick='callBasic( 300)'>byte</Button> + + + diff --git a/extensions/test/ole/callUnoToJava.htm b/extensions/test/ole/callUnoToJava.htm new file mode 100644 index 000000000..c5ceabf15 --- /dev/null +++ b/extensions/test/ole/callUnoToJava.htm @@ -0,0 +1,516 @@ +<HTML> +<HEAD> +<META NAME="GENERATOR" Content="Microsoft Developer Studio"> +<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> +<TITLE>Document Title</TITLE> +</HEAD> +<BODY id=theBody> + +<script language="JScript"> +function callOleTest( id) +{ + var factory= new ActiveXObject("com.sun.star.ServiceManager"); + var oletest= factory.createInstance("oletest.OleTest"); +// alert(oletest); + + switch( id) + { + case 1: // Test simple call of JScript object function from UNO + oletest.testInterface( new XCallback_Impl, 1); + break; + + case 2: + // return value is the parameter object + oletest.testInterface( new XCallback_Impl, 2); + break; + //################################################## + // OUT parameter + //################################################## + case 3: // Test out parameter of type interface + oletest.testInterface( new XCallback_Impl, 3); + break; + case 4: // Test out parameter of type struct + oletest.testInterface( new XCallback_Impl, 4); + break; + case 5: // Test out parameter of type enum + oletest.testInterface( new XCallback_Impl, 5); + break; + case 6: // Test out parameter of type sequence<any> + oletest.testInterface( new XCallback_Impl, 6); + break; + case 7: // Test out parameter of type any + oletest.testInterface( new XCallback_Impl, 7); + break; + case 8: // Test out parameter of type bool + oletest.testInterface( new XCallback_Impl, 8); + break; + case 9: // Test out parameter of type char + oletest.testInterface( new XCallback_Impl, 9); + break; + case 10: // Test out parameter of type string + oletest.testInterface( new XCallback_Impl, 10); + break; + case 11: // Test out parameter of type float + oletest.testInterface( new XCallback_Impl, 11); + break; + case 12: // Test out parameter of type double + oletest.testInterface( new XCallback_Impl, 12); + break; + case 13: // Test out parameter of type byte + oletest.testInterface( new XCallback_Impl, 13); + break; + case 14: // Test out parameter of type short + oletest.testInterface( new XCallback_Impl, 14); + break; + case 15: // Test out parameter of type long + oletest.testInterface( new XCallback_Impl, 15); + break; + case 30: // outValuesMixed + oletest.testInterface( new XCallback_Impl, 30); + break; + case 31: // outValuesAll + oletest.testInterface( new XCallback_Impl, 31); + break; + //################################################## + // IN/OUT parameter + //################################################## + + case 100: // inoutInterface + oletest.testInterface( new XCallback_Impl, 100); + break; + case 101: // inoutStruct + oletest.testInterface( new XCallback_Impl, 101); + break; + case 102: // inoutEnum + oletest.testInterface( new XCallback_Impl, 102); + break; + case 103: // inoutSeqAny + oletest.testInterface( new XCallback_Impl, 103); + break; + case 104: // inoutAny + oletest.testInterface( new XCallback_Impl, 104); + break; + case 105: // inoutBool + oletest.testInterface( new XCallback_Impl, 105); + break; + case 106: // inoutChar + oletest.testInterface( new XCallback_Impl, 106); + break; + case 107: // inoutString + oletest.testInterface( new XCallback_Impl, 107); + break; + case 108: // inoutFloat + oletest.testInterface( new XCallback_Impl, 108); + break; + case 109: // inoutDouble + oletest.testInterface( new XCallback_Impl, 109); + break; + case 110: // inoutByte + oletest.testInterface( new XCallback_Impl, 110); + break; + case 111: // inoutShort + oletest.testInterface( new XCallback_Impl, 111); + break; + case 112: // inoutLong + oletest.testInterface( new XCallback_Impl, 112); + break; + case 120: // inoutValuesAll + oletest.testInterface( new XCallback_Impl, 120); + break; + case 200: // inValues + oletest.testInterface( new XCallback_Impl, 200); + break; + + case 1000: + oletest.testInterface2(new MultiInterface(), 0); + break; + } + +} + + + +// The class -------------------------------------------- + +function XCallback_Impl() +{ + + // XCallback + this._environment= "JScript"; + + this.func1= XCallback_Impl_func1; + this.returnInterface= XCallback_Impl_returnInterface; + // ################################################# + // OUT parameter + //################################################### + this.outInterface= XCallback_Impl_outInterface; + this.outStruct= XCallback_Impl_outStruct; + this.outEnum= XCallback_Impl_outEnum; + this.outSeqAny= XCallback_Impl_outSeqAny; + this.outAny= XCallback_Impl_outAny; + this.outBool= XCallback_Impl_outBool; + this.outChar= XCallback_Impl_outChar; + this.outString= XCallback_Impl_outString; + this.outFloat= XCallback_Impl_outFloat; + this.outDouble= XCallback_Impl_outDouble; + this.outByte= XCallback_Impl_outByte; + this.outShort= XCallback_Impl_outShort; + this.outLong= XCallback_Impl_outLong; + this.outValuesMixed= XCallback_Impl_outValuesMixed; + this.outValuesAll= XCallback_Impl_outValuesAll; + // ################################################# + // IN/ OUT parameter + //################################################### + this.inoutInterface= XCallback_Impl_inoutInterface; + this.inoutStruct= XCallback_Impl_inoutStruct; + this.inoutEnum= XCallback_Impl_inoutEnum; + this.inoutSeqAny= XCallback_Impl_inoutSeqAny; + this.inoutAny= XCallback_Impl_inoutAny; + this.inoutBool= XCallback_Impl_inoutBool; + this.inoutChar= XCallback_Impl_inoutChar; + this.inoutString= XCallback_Impl_inoutString; + this.inoutFloat= XCallback_Impl_inoutFloat; + this.inoutDouble= XCallback_Impl_inoutDouble; + this.inoutByte= XCallback_Impl_inoutByte; + this.inoutShort= XCallback_Impl_inoutShort; + this.inoutLong= XCallback_Impl_inoutLong; + this.inoutValuesAll= XCallback_Impl_inoutValuesAll; + // ################################################# + // IN parameter + //################################################## + this.inValues= XCallback_Impl_inValues; + +} + + +function XCallback_Impl_func1() +{ + alert("XCallback_Impl_func1"); +} +function XCallback_Impl_returnInterface() +{ + alert("XCallback::returnInterface called"); + return new XSimple_Impl(); +} + +function XCallback_Impl_outInterface( outVal) +{ + outVal[0]= new XSimple_Impl(); +} + +function XCallback_Impl_outLong( outVal) +{ + alert("outLong"); +} +function XCallback_Impl_outStruct( outVal) +{ + var factory= new ActiveXObject("com.sun.star.ServiceManager"); + var starCoreReflection = factory.createInstance("com.sun.star.reflection.CoreReflection"); + var structClass = starCoreReflection.forName("oletest.SimpleStruct"); + var outParam= new Array(); + structClass.createObject(outParam); + var aStruct= outParam[0]; + aStruct.message= "a Struct created in JScript"; + outVal[0]= aStruct; + +} +function XCallback_Impl_outEnum( outVal) +{ + outVal[0]= 2; +} +function XCallback_Impl_outSeqAny( outVal) +{ + var ar= new Array(1,2,3); + outVal[0]= ar; +} +function XCallback_Impl_outAny( outVal) +{ + outVal[0]= "this is an Any"; +} +function XCallback_Impl_outBool( outVal) +{ + outVal[0]= true; +} +function XCallback_Impl_outChar( outVal) +{ + outVal[0]= "a"; +} +function XCallback_Impl_outString( outVal) +{ + outVal[0]= "This string was created in JScript"; +} +function XCallback_Impl_outFloat( outVal) +{ + outVal[0]= 3.14; +} +function XCallback_Impl_outDouble( outVal) +{ + outVal[0]= 3.145; +} +function XCallback_Impl_outByte( outVal) +{ + outVal[0]= 100; +} +function XCallback_Impl_outShort( outVal) +{ + outVal[0]= 1000; +} +function XCallback_Impl_outLong( outVal) +{ + outVal[0]= 1000000; +} +function XCallback_Impl_outValuesMixed( inLong, outLong, inString) +{ + alert("inVal long: " + inLong +" inString:" + inString); + outLong[0]= inLong + 1; +} +function XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool, + aChar, aString, aFloat, aDouble, aByte, aShort, aLong) +{ + this.outInterface( xSimple); + this.outStruct( aSimpleStruct); + this.outEnum( aSimpleEnum); + this.outSeqAny( seqAny); + this.outAny( aAny); + this.outBool( aBool); + this.outChar( aChar); + this.outString( aString); + this.outFloat( aFloat); + this.outDouble( aDouble); + this.outByte( aByte); + this.outShort( aShort); + this.outLong( aLong); +} + +function XCallback_Impl_inoutInterface( val) +{ + val[0].func("calling on in parameter"); + val[0]= new XSimple_Impl(); +} +function XCallback_Impl_inoutStruct( val) +{ + alert( val[0].message); + val[0].message= "property message changed in JScript"; +} +function XCallback_Impl_inoutEnum(val) +{ + alert("enum value +" + val); + val[0]= 2; +} +function XCallback_Impl_inoutSeqAny( val) +{ + var vbar = new VBArray(val[0]); + var seq= vbar.toArray(); + alert( seq[0] +" "+seq[1] +" " +seq[2]); + val[0]= new Array("jscript1", "jscript2","jscript3"); +} +function XCallback_Impl_inoutAny(val) +{ + alert( "JScript in any: " + val[0]); + val[0]= "a string from JScript"; +} +function XCallback_Impl_inoutBool(val) +{ + alert( "JScript in bool: " + val[0]); + val[0]= true; +} +function XCallback_Impl_inoutChar(val) +{ + alert( "JScript in char: " + val[0]); + val[0]= 'b'; +} +function XCallback_Impl_inoutString(val) +{ + alert( "JScript in string: " + val[0]); + val[0]= " a JScript string"; +} +function XCallback_Impl_inoutFloat(val) +{ + alert( "JScript in float: " + val[0]); + val[0]= 4.14; +} +function XCallback_Impl_inoutDouble(val) +{ + alert( "JScript in double: " + val[0]); + val[0]= 4.145; +} + +function XCallback_Impl_inoutByte(val) +{ + alert( "JScript in byte: " + val[0]); + val[0]= 100; +} +function XCallback_Impl_inoutShort(val) +{ + alert( "JScript in short: " + val[0]); + val[0]= 1000; +} +function XCallback_Impl_inoutLong(val) +{ + alert( "JScript in long: " + val[0]); + val[0]= 100000; +} +function XCallback_Impl_inoutValuesAll(aXSimple, aStruct, aEnum, aSeq, + aAny, aBool, aChar, aString, aFloat, aDouble, + aByte, aShort, aLong ) +{ + this.inoutInterface( aXSimple); + this.inoutStruct( aStruct); + this.inoutEnum( aEnum); + this.inoutSeqAny( aSeq); + this.inoutAny( aAny); + this.inoutBool( aBool); + this.inoutChar( aChar); + this.inoutString( aString); + this.inoutFloat( aFloat); + this.inoutDouble( aDouble); + this.inoutByte( aByte); + this.inoutShort( aShort); + this.inoutLong( aLong); +} + +function XCallback_Impl_inValues( aChar, aLong, aString) +{ + alert( "char : " + aChar + " long: " + aLong + " string: " + aString); +} + + +//################################################################ +// class MultiInterface implements XSimple, XSimple2, XSimple3 +//################################################################ +function MultiInterface() +{ + this._environment= "JScript"; + this._implementedInterfaces= new Array( "oletest.XSimple", "oletest.XSimple2", "oletest.XSimple3"); + // XSimple --------------- + this.getName= MultiInterface_getName; + this.func= MultiInterface_func; + this.func2= MultiInterface_func2; + this.func3= MultiInterface_func3; + // XSimple2 + this.getName2= MultiInterface_getName2; + // XSimple3 + this.getName3= MultiInterface_getName3; +} + + +function MultiInterface_getName() +{ + return "JScript XSimple called"; +} +function MultiInterface_func( message) +{ + alert("JScript object (XSimple)-- " + message); +} + +function MultiInterface_getName2() +{ + return "JScript XSimple2 called"; +} +function MultiInterface_func2( message) +{ + alert("JScript object (XSimple2) -- " + message); +} + +function MultiInterface_getName3() +{ + return "JScript XSimple3 called"; +} +function MultiInterface_func3( message) +{ + alert("JScript object (XSimple3) -- " + message); +} + + + + +//XCallback_Impl_outValuesMixed( val1, outval, val2) +//{ +//} +//XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool, +// aChar, aString, aFloat, aDouble, aByte, aShort, aLong, aUShort, aULong) +//{ +// +//} + + + +// class XSimple_Impl---------------------------------------------------------------------- +function XSimple_Impl() +{ + //XSimple + this.func= XSimple_Impl_func; +} +function XSimple_Impl_func( message) +{ + alert( "XSimple called." + message); +} + + +</script> + + + +<h2> Object in JScript</h2> + +This test passes a XCallback to an 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. +<br> +<button onclick='callOleTest( 1)'>go</Button> +<br> +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.<br> +<button onclick='callOleTest( 2)'>go</Button> +<br> +<h1> out parameter </h1> +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.<br> +<button onclick='callOleTest( 3)'>interface</Button> +<button onclick='callOleTest( 4)'>struct</Button> +<button onclick='callOleTest( 5)'>enum</Button> +<button onclick='callOleTest( 6)'>sequence<any></Button> +<button onclick='callOleTest( 7)'>any</Button> +<button onclick='callOleTest( 8)'>bool</Button> +<button onclick='callOleTest( 9)'>char</Button> +<button onclick='callOleTest( 10)'>string</Button> +<button onclick='callOleTest( 11)'>float</Button> +<button onclick='callOleTest( 12)'>double</Button> +<button onclick='callOleTest( 13)'>byte</Button> +<button onclick='callOleTest( 14)'>short</Button> +<button onclick='callOleTest( 15)'>long</Button> +<br> +Other test with out parameters <br> +<button onclick='callOleTest( 30)'>outValuesMixed</Button> +<button onclick='callOleTest( 31)'>outValuesAll</Button> +<h1> in out parameter </h1> +<button onclick='callOleTest( 100)'>interface</Button> +<button onclick='callOleTest( 101)'>struct</Button> +<button onclick='callOleTest( 102)'>enum</Button> +<button onclick='callOleTest( 103)'>seqence<any></Button> +<button onclick='callOleTest( 104)'>any</Button> +<button onclick='callOleTest( 105)'>bool</Button> +<button onclick='callOleTest( 106)'>char</Button> +<button onclick='callOleTest( 107)'>string</Button> +<button onclick='callOleTest( 108)'>float</Button> +<button onclick='callOleTest( 109)'>double</Button> +<button onclick='callOleTest( 110)'>byte</Button> +<button onclick='callOleTest( 111)'>short</Button> +<button onclick='callOleTest( 112)'>long</Button> +<br> +Other tests with inout parameters <br> +<button onclick='callOleTest( 120)'>inoutValuesAll</Button> +<h1>in parameters </h1> +<button onclick='callOleTest( 200)'>inValues</Button> + +<h1> JScript object implements several interfaces </h1> +<button onclick='callOleTest( 1000)'>go</Button> + + +</body> +</html> + + diff --git a/extensions/test/ole/cpnt/cpnt.cxx b/extensions/test/ole/cpnt/cpnt.cxx new file mode 100644 index 000000000..f569866c6 --- /dev/null +++ b/extensions/test/ole/cpnt/cpnt.cxx @@ -0,0 +1,1545 @@ +/************************************************************************* + * + * $RCSfile: cpnt.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <windows.h> +#include <atlbase.h> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <osl/diagnose.h> +#include <uno/environment.h> +#include <cppuhelper/factory.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlReflection.hpp> + + +#include <cppuhelper/implbase5.hxx> +#include <com/sun/star/uno/Reference.h> +#include <rtl/ustring> +#include <com/sun/star/uno/Reference.hxx> +#include <oletest/XTestSequence.hpp> +#include <oletest/XTestStruct.hpp> +#include <oletest/XTestOther.hpp> +#include <oletest/XTestInterfaces.hpp> +#include <oletest/XSimple.hpp> +#include <oletest/XSimple2.hpp> +#include <oletest/XSimple3.hpp> + +#include <com/sun/star/beans/Property.hpp> +using namespace cppu; +using namespace osl; +using namespace oletest; +using namespace rtl; +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 WeakImplHelper5< + XTestSequence, XTestStruct, XTestOther, XTestInterfaces, XSimple> +{ + sal_Int32 m_arrayConstructor; + Reference<XMultiServiceFactory> m_rFactory; + + Sequence<sal_Int8> m_seqByte; + Sequence<float> m_seqFloat; + Sequence<double> m_seqDouble; + Sequence<sal_Bool> m_seqBool; + Sequence<sal_Int16> m_seqShort; + Sequence<sal_uInt16> m_seqUShort; + Sequence<sal_Int32> m_seqLong; + Sequence<sal_uInt32> m_seqULong; + Sequence<sal_Unicode> m_seqChar; + Sequence<OUString> m_seqString; + Sequence<Any> m_seqAny; + Sequence<Sequence< sal_Int32> > m_seq1; + Sequence<Sequence< Sequence< sal_Int32> > > m_seq2; + Any m_any; + Sequence<Reference< XInterface > > m_seqxInterface; +public: + OComponent( const Reference<XMultiServiceFactory> & rFactory ) : + m_rFactory( rFactory ), m_arrayConstructor(0) {} + ~OComponent(); + +public: // refcounting +// sal_Bool queryInterface( Uik aUik, XInterfaceRef & rOut ); +// void acquire() { OWeakObject::acquire(); } +// void release() { OWeakObject::release(); } +// void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: // XTestSequence + virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException ); + virtual Sequence<float> 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< 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< sal_Int8 > SAL_CALL getAttrByte(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException ); + virtual Sequence< float > SAL_CALL getAttrFloat(void) throw( RuntimeException) ; + virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException ); + virtual Sequence< double > SAL_CALL getAttrDouble(void) throw( RuntimeException) ; + virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException ); + virtual Sequence< sal_Bool > SAL_CALL getAttrBool(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException ); + virtual Sequence< sal_Int16 > SAL_CALL getAttrShort(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException ); + virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException ); + virtual Sequence< sal_Int32 > SAL_CALL getAttrLong(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException ); + virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException ); + virtual Sequence< OUString > SAL_CALL getAttrString(void) throw(RuntimeException ); + virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException ); + virtual Sequence< sal_Unicode > SAL_CALL getAttrChar(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException ); + virtual Sequence< Any > SAL_CALL getAttrAny(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException ); + virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException ); + virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2(void) 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 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_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_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_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_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 Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ; + virtual Any SAL_CALL getAttrAny2(void) 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(void) throw( RuntimeException ); + + virtual Property SAL_CALL getAttrStruct(void) throw( RuntimeException ); + virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) 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(void) throw( RuntimeException ); + virtual void SAL_CALL in_float( float val) throw ( RuntimeException); + + // XTestOutParameters ------------------------------------------------------------------------ + virtual void SAL_CALL out_test(sal_Int8 rIn) throw( RuntimeException ); + + virtual void SAL_CALL out_methodByte(sal_Int8& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodFloat(float& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodDouble(double& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodBool(sal_Bool& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodShort(sal_Int16& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodUShort(sal_uInt16& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodLong(sal_Int32& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodULong(sal_uInt32& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodString(OUString& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodChar(sal_Unicode& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodAny(Any& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ); + virtual void SAL_CALL out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException ); + virtual void SAL_CALL out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException ); + virtual void SAL_CALL out_methodMulParams3(const OUString& sin, OUString& sout) 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(::com::sun::star::uno::RuntimeException); + OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); + +}; + + +OComponent::~OComponent() +{ +} + + +// Funktions ============================================================================== + +Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(RuntimeException) +{ + Reference<XInterface> xService = *new OComponent( rSMgr ); + return xService; +} + +Sequence<OUString> OComponent_getSupportedServiceNames(void) +{ + Sequence<OUString> aRet(1); + aRet.getArray()[0] = SERVICE_NAME;//ODataInputStream_getImplementationName(); + + return aRet; +} + + +extern "C" sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) +{ + if(pRegistryKey) + { + try + { + Reference<XRegistryKey> xNewKey = + reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1); + xNewKey->createKey( KEY2); + return sal_True; + + } + catch(InvalidRegistryException &) + { + OSL_ENSHURE( sal_False, "### InvalidRegistryException!\n"); + } + } + return sal_False; +} + +extern "C" void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + static void * pRet= NULL; + if( ! pRet) + { + OUString aImplName( OUString::createFromAscii( pImplName ) ); + if (pServiceManager && aImplName.equals( IMPL_NAME )) + { + Reference<XMultiServiceFactory> xMulFac( + reinterpret_cast< XMultiServiceFactory*>(pServiceManager)); + + Sequence<OUString> seqServiceNames; + Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME, + OComponent_CreateInstance, seqServiceNames); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + } + return pRet; +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + + +// XTestSequence ============================================================================ +Sequence<sal_Int8> 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<float> 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<double> 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< Reference< XInterface> > SAL_CALL methodXInterface ( const Sequence< Reference < XInterface> >& aSeq) +// throw (RuntimeException) +Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) +{ + 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<sal_Int32>& 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<sal_Int32> >& rseq2= aSeq.getConstArray()[i]; + len= rseq2.getLength(); + + for (sal_Int16 j= 0; j < rseq2.getLength(); j++){ + const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j]; + len= rseq3.getLength(); + + for (sal_Int16 k= 0; k < rseq3.getLength(); k++) + value= rseq3.getConstArray()[k]; + } + } + return aSeq; +} + + + +//--------------------------------------------------------------------------------------------- + +Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte(void) 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(void) 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(void) 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(void) 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(void) 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(void) 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(void) 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(void) 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(void) 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(void) 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(void) throw( RuntimeException) +{ + return m_seqAny; +} +void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException ) +{ + m_seqAny= AttrAny_; +} + +Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence(void) 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(void) 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; +} + +// ---------------------------------------------------------------------------- + +void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException ) +{ + rOut= 111; +} +void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException ) +{ + rOut= 3.14; +} +void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException ) +{ + rOut= 3.14; +} + +void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException ) +{ + rOut= sal_True; +} +void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException ) +{ + rOut= 222; +} +void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ) +{ + rOut= 333; +} +void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException ) +{ + rOut = 444; +} +void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException ) +{ + rOut= 555; +} +void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException ) +{ + rOut= L"a little string"; +} +void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException ) +{ + rOut= 'A'; +} +void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException) +{ + rOut <<= OUString(L"I am a string in an any"); +} +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<sal_Int32>& 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& sin, 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 in3 ) throw(RuntimeException) +{ + out1= in1 + 1; + out2= in2 + 1; +} + +void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException) +{ + OUString string( L"Property Any"); + m_any <<= string; + rOut= (XInterface*) static_cast<XTestSequence*>(this); +} + +// INOUT +void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException ) +{ + rOut += 1; +} + +void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException ) +{ + rOut= rOut== sal_True ? sal_False : sal_True; +} +void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException ) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException ) +{ + rOut= rOut + L" out string"; +} +void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException) +{ + rOut += 1; +} +void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException) +{ + TypeClass t= rOut.getValueTypeClass(); +} +void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException) +{ + 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" this string was written in the UNO component to the inout pararmeter"); + any <<= string; + rOut->setValue( OUString(L"value"), any); +} +Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException ) +{ + return rIn; +} +Any SAL_CALL OComponent::getAttrAny2(void) 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 ) +{ +} + +Property SAL_CALL OComponent::retMethodStruct(void) throw( RuntimeException ) +{ + Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID | + PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED | + PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY | + PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT ); + return a; +} + +Property SAL_CALL OComponent::getAttrStruct(void) throw( RuntimeException) +{ + Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), 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 ) +{} + +// XTestOther ================================================================================== +void SAL_CALL OComponent::other_methodAnyIn(const Any& rAny) throw( RuntimeException ) +{ +} +void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException ) +{ + rAny <<= OUString(L"Ein Any"); +} + +Any SAL_CALL OComponent::other_methodAnyRet(void) throw(RuntimeException ) +{ + Any a; + a <<= OUString(L"Ein Any"); + return a; +} +void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException) +{ + char buff[256]; + sprintf( buff, "parameter : %f", val); + MessageBox( NULL, _T(buff), _T("OleTest"), MB_OK); +} + +// XTestOutParameters ============================================================================ +void SAL_CALL OComponent::out_test(sal_Int8 rIn) throw( RuntimeException ) +{ +} + +void SAL_CALL OComponent::out_methodByte(sal_Int8& rOut) throw( RuntimeException ) +{ + rOut= 100; +} +void SAL_CALL OComponent::out_methodDouble(double& rOut) throw( RuntimeException ) +{ + rOut= 3.14; +} +void SAL_CALL OComponent::out_methodFloat(float& rOut) throw( RuntimeException ) +{ + rOut= 3.14; +} +void SAL_CALL OComponent::out_methodBool(sal_Bool& rOut) throw( RuntimeException ) +{ + rOut= sal_True; +} +void SAL_CALL OComponent::out_methodShort(sal_Int16& rOut) throw( RuntimeException ) +{ + rOut= -100; +} +void SAL_CALL OComponent::out_methodUShort(sal_uInt16& rOut) throw( RuntimeException ) +{ + rOut= 100; +} +void SAL_CALL OComponent::out_methodLong(sal_Int32& rOut) throw( RuntimeException ) +{ + rOut= -100; +} + +void SAL_CALL OComponent::out_methodULong(sal_uInt32& rOut) throw( RuntimeException ) +{ + rOut= 100; +} +void SAL_CALL OComponent::out_methodString(OUString& rOut) throw( RuntimeException ) +{ + rOut= L"I'm a string"; +} +void SAL_CALL OComponent::out_methodChar(sal_Unicode& rOut) throw( RuntimeException ) +{ + rOut= 'A'; +} +void SAL_CALL OComponent::out_methodAny(Any& rOut) throw( RuntimeException) +{ + Any a; + a <<= OUString( L"Hi"); + rOut= a; +} +void SAL_CALL OComponent::out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException ) +{ + Sequence< sal_Int32 > aseq(10); + for( sal_Int16 i= 0; i < aseq.getLength(); i++) aseq.getArray()[i]= i; + rOut= aseq; +} +void SAL_CALL OComponent::out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException ) +{ + rOut= Sequence< Sequence< sal_Int32 > >(); +} +void SAL_CALL OComponent::out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException ) +{ + rout1= 111; + rout2= 222; +} +void SAL_CALL OComponent::out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException ) +{ + rout1= 111; + rout2= 222; + rout3= L"this is a neet little string"; +} +void SAL_CALL OComponent::out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException ) +{ + sout= L"this is a neet little string"; +} + +// 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> xSimple; + SimpleStruct aSimpleStruct; + SimpleEnum aSimpleEnum; + Sequence<Any> 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; + sal_uInt16 aUShort; + sal_uInt32 aULong; + + 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<Any> seqAny; + Any aAny; + sal_Bool aBool; + sal_Unicode aChar; + OUString aString; + float aFloat; + double aDouble; + sal_Int8 aByte; + sal_Int16 aShort; + sal_Int32 aLong; + sal_uInt16 aUShort; + sal_uInt32 aULong; + 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> xSimple= static_cast<XSimple*>(this); + xCallback->inoutInterface( xSimple); + xSimple->func(L"XSimple called from OleTest"); + break; + } + case 101: + { + Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY); + if( xRefl.is()) + { + Reference<XIdlClass> 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= OUString::createFromAscii("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.14; + 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<XSimple> aXSimple= static_cast<XSimple*>(this); + + SimpleStruct aStruct; + Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY); + if( xRefl.is()) + { + Reference<XIdlClass> 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= OUString::createFromAscii("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.14; + 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; + } + + // ############################################################################ + // Call a COM object that has not been passed as parameter to a UNO component and + // hence no type information are available in the COM wrapper + // ############################################################################ + case 300: + { + Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.OleObjectFactory"); + + Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY); + + Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference<XInvocation> xInv( xIntCallback, UNO_QUERY); +//Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence<Any >& aParams,Sequence< sal_Int16 >& aOutParamIndex, +// Sequence<Any >& aOutParam ); + Sequence<sal_Int16> seqIndizes; + Sequence<Any> seqOutParams; + xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndizes, seqOutParams); + +// void outValuesAll( [out] oletest::XSimple outInterface, +// [out] SimpleStruct outStruct , +// [out] SimpleEnum outEnum, +// [out] sequence<any> 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); + if( seqOutParams.getLength() == 12) + { + Reference<XSimple> 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<Any> seqAny; + seqOutParams[3] >>= seqAny; + for( int i=0; i<seqAny.getLength(); i++) + { + OUString _s; + seqAny[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<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.OleObjectFactory"); + + Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY); + + Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference<XInvocation> xInv( xIntCallback, UNO_QUERY); + Sequence<sal_Int16> seqIndizes; + Sequence<Any> seqOutParams; + + + Any arAny[13]; + Reference<XSimple> xSimple= static_cast<XSimple*>( this); + + arAny[0] <<= xSimple; + SimpleStruct aStruct; + Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY); + if( xRefl.is()) + { + Reference<XIdlClass> 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= OUString::createFromAscii("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.14; + arAny[8] <<= _float; + double _double= 3.145; + arAny[9] <<= _double; + sal_Int8 _byte= 0xff; + arAny[10] <<= _byte; + sal_Int16 _short= 0xffff; + arAny[11] <<= _short; + sal_Int32 _long= 0xffffffff; + arAny[12] <<= _long; +// + Sequence<Any> params( arAny, 13); + + xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndizes, seqOutParams); + + if( seqOutParams.getLength() == 12) + { + Reference<XSimple> 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<Any> seqAny; + seqOutParams[3] >>= seqAny; + for( int i=0; i<seqAny.getLength(); i++) + { + OUString _s; + seqAny[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: + // in parameter +// void inValues( [in] char aChar, [in] long aLong, [in] string aString); + { + Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.OleObjectFactory"); + + Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY); + + Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback"); + Reference<XInvocation> xInv( xIntCallback, UNO_QUERY); + Sequence<sal_Int16> seqIndizes; + Sequence<Any> 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<Any>(arAny,3), seqIndizes, seqOutParams); + + break; + } + + + + + } + +} + +// XSimple -------------------------------------------------------------------------- +void SAL_CALL OComponent::func( const OUString &message)throw(::com::sun::star::uno::RuntimeException) +{ + USES_CONVERSION; + + MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK); +} +// XSimple -------------------------------------------------------------------------- +OUString SAL_CALL OComponent::getName()throw(::com::sun::star::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> xSimple2( xSimple, UNO_QUERY); + if( xSimple2.is()) + xSimple2->func2( L"OleTest is calling XSimple2"); + Reference<XSimple3> xSimple3( xSimple, UNO_QUERY); + if( xSimple3.is()) + xSimple3->func3( L"OleTest is calling XSimple3"); + + break; + } + } +} diff --git a/extensions/test/ole/cpnt/exports.dxp b/extensions/test/ole/cpnt/exports.dxp new file mode 100644 index 000000000..a265aeec0 --- /dev/null +++ b/extensions/test/ole/cpnt/exports.dxp @@ -0,0 +1,3 @@ +component_writeInfo +component_getFactory +component_getImplementationEnvironment
\ No newline at end of file diff --git a/extensions/test/ole/cpnt/makefile.mk b/extensions/test/ole/cpnt/makefile.mk new file mode 100644 index 000000000..b53519118 --- /dev/null +++ b/extensions/test/ole/cpnt/makefile.mk @@ -0,0 +1,146 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/..$/.. + +PRJNAME= extensions +TARGET= oletest +#LIBTARGET= NO +#TARGETTYPE= CUI +ENABLE_EXCEPTIONS=TRUE +NO_BSYMBOLIC= TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/cpnt.obj + +UNOUCRDEP= $(SOLARBINDIR)$/applicat.rdb $(BIN)$/oletest.rdb +UNOUCRRDB= $(SOLARBINDIR)$/applicat.rdb $(BIN)$/oletest.rdb + +UNOUCROUT= $(OUT)$/inc +INCPRE+= $(OUT)$/inc -I$(SOLARINCDIR)$/external$/atl +#INCPRE+= -I$(SOLARINCDIR)$/external$/atl +LIBCMT=msvcrtd.lib + +UNOTYPES= oletest.XTestSequence oletest.XTestStruct \ + oletest.XTestOther \ + oletest.XTestInterfaces \ + oletest.XSimple \ + oletest.XSimple2 \ + oletest.XSimple3 \ + com.sun.star.beans.PropertyAttribute \ + com.sun.star.uno.XAggregation \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.script.XInvocation \ + com.sun.star.reflection.XIdlReflection + + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(SALLIB) \ + $(VOSLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +ALLIDLFILES:= ..$/idl$/oletest.idl + +# --- Targets ------------------------------------------------------ + +.IF "$(depend)" == "" +ALL : $(BIN)$/oletest.rdb \ + ALLTAR + +.ELSE +ALL: ALLDEP +.ENDIF + +.INCLUDE : target.mk + + + +$(BIN)$/oletest.rdb: $(ALLIDLFILES) + +unoidl -I$(PRJ) -I$(SOLARIDLDIR) -Burd -OH$(BIN) $? + +regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)} + touch $@ + +#unoheader: $(BIN)$/testcppu.rdb +# +cppumaker -BUCR $(CPPUMAKERFLAGS) -O$(UNOUCROUT) $(TYPES) $(BIN)$/testcppu.rdb + diff --git a/extensions/test/ole/cpnt/readme.txt b/extensions/test/ole/cpnt/readme.txt new file mode 100644 index 000000000..62a12a1ef --- /dev/null +++ b/extensions/test/ole/cpnt/readme.txt @@ -0,0 +1,5 @@ +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.
\ No newline at end of file diff --git a/extensions/test/ole/cpptest/StdAfx.cpp b/extensions/test/ole/cpptest/StdAfx.cpp new file mode 100644 index 000000000..aee6573a1 --- /dev/null +++ b/extensions/test/ole/cpptest/StdAfx.cpp @@ -0,0 +1,68 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// stdafx.cpp : source file that includes just the standard includes +// cpptest.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 diff --git a/extensions/test/ole/cpptest/StdAfx.h b/extensions/test/ole/cpptest/StdAfx.h new file mode 100644 index 000000000..a838fba37 --- /dev/null +++ b/extensions/test/ole/cpptest/StdAfx.h @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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__84C60723_E38E_11D3_82FC_005004526AB4__INCLUDED_) +#define AFX_STDAFX_H__84C60723_E38E_11D3_82FC_005004526AB4__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include <comdef.h> +#include <tchar.h> +#include<atlbase.h> +extern CComModule _Module; +#include<atlcom.h> +#include<atlimpl.cpp> + + +// 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__84C60723_E38E_11D3_82FC_005004526AB4__INCLUDED_) diff --git a/extensions/test/ole/cpptest/cpptest.cpp b/extensions/test/ole/cpptest/cpptest.cpp new file mode 100644 index 000000000..d1c300677 --- /dev/null +++ b/extensions/test/ole/cpptest/cpptest.cpp @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: cpptest.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// cpptest.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" + +CComModule _Module; +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + + +HRESULT doTest(); + +int main(int argc, char* argv[]) +{ + HRESULT hr; + if( FAILED( hr=CoInitialize(NULL))) + { + _tprintf(_T("CoInitialize 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; + CComPtr<IUnknown> spUnkMgr; + + +// GUID idOffice= {0x3ECF78F0,0xB149,0x11D2,{0x8E,0xBE,0x00,0x10,0x5A,0xD8,0x48,0xAF}}; +// IUnknown * pUnk; +// hr= CoCreateInstance( idOffice, NULL, CLSCTX_ALL, __uuidof(IUnknown), (void**) &pUnk); + + if( FAILED(hr= spUnkMgr.CoCreateInstance(L"stardiv.uno.ServiceManager"))) + return hr; + + return S_OK; + +} diff --git a/extensions/test/ole/cpptest/cpptest.dsp b/extensions/test/ole/cpptest/cpptest.dsp new file mode 100644 index 000000000..4e0641850 --- /dev/null +++ b/extensions/test/ole/cpptest/cpptest.dsp @@ -0,0 +1,113 @@ +# Microsoft Developer Studio Project File - Name="cpptest" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=cpptest - 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 "cpptest.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 "cpptest.mak" CFG="cpptest - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "cpptest - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "cpptest - 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)" == "cpptest - 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)" == "cpptest - 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" /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 "cpptest - Win32 Release" +# Name "cpptest - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cpptest.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=.\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/cpptest/cpptest.dsw b/extensions/test/ole/cpptest/cpptest.dsw new file mode 100644 index 000000000..0cea1c2d0 --- /dev/null +++ b/extensions/test/ole/cpptest/cpptest.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "cpptest"=.\cpptest.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/extensions/test/ole/idl/oletest.idl b/extensions/test/ole/idl/oletest.idl new file mode 100644 index 000000000..6dc32ab41 --- /dev/null +++ b/extensions/test/ole/idl/oletest.idl @@ -0,0 +1,309 @@ +/************************************************************************* + * + * $RCSfile: oletest.idl,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +//#include <stardiv/uno/interface.idl> +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/script/XInvocation.idl> +//#include <stardiv/uno/beans/propset.idl> +#include <com/sun/star/beans/XPropertySet.idl> + +/*============================================================================= + + $Source: /cvs/Archiv/one/stardiv/one/chart/xcenum.idl,v 1.6 1999/04/26 10:42 + + status: proofreading done + + (c) Copyright 1998-1999, Star Office Entwicklungs GmbH, Hamburg + +=============================================================================*/ + +module oletest +{ + +[ uik(8DE309C0-8310-11d3-9EEC0050-04526AB4), ident("XTestSequence", 1.0) ] +interface XTestSequence: com::sun::star::uno::XInterface +{ + sequence<byte> methodByte( [in] sequence<byte> aSeq ); + sequence<float> methodFloat( [in] sequence<float> aSeq); + sequence<double> methodDouble( [in] sequence<double> aSeq); + sequence<boolean> methodBool( [in] sequence<boolean> aSeq); + sequence<short> methodShort( [in] sequence<short> aSeq); + sequence<unsigned short> methodUShort( [in] sequence<unsigned short> aSeq); + sequence<long> methodLong( [in] sequence<long> aSeq); + sequence<unsigned long> methodULong( [in] sequence<unsigned long> aSeq); + sequence<string> methodString( [in] sequence<string> aSeq); + sequence<char> methodChar( [in] sequence<char> aSeq); + sequence<any> methodAny ( [in] sequence<any> aSeq); + sequence<com::sun::star::uno::XInterface> methodXInterface ( [in] sequence<com::sun::star::uno::XInterface> aSeq); + sequence< sequence <long> > methodSequence( [in] sequence< sequence< long > > aSeq); + sequence< sequence <sequence <long> > > methodSequence2( [in] sequence< sequence< sequence<long> > > aSeq); + + [attribute] sequence<byte> AttrByte; + [attribute] sequence<float> AttrFloat; + [attribute] sequence<double> AttrDouble; + [attribute] sequence<boolean> AttrBool; + [attribute] sequence<short> AttrShort; + [attribute] sequence<unsigned short> AttrUShort; + [attribute] sequence<long> AttrLong; + [attribute] sequence<unsigned long> AttrULong; + [attribute] sequence<string> AttrString; + [attribute] sequence<char> AttrChar; + [attribute] sequence<any> AttrAny; + [attribute] sequence< sequence<long> > AttrSequence; + [attribute] sequence< sequence< sequence <long> > > AttrSequence2; + [attribute] sequence< com::sun::star::uno::XInterface > AttrXInterface; + + 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_methodString( [out] string rOut); + void testout_methodChar( [out] char rOut); + void testout_methodAny ( [out] any 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_methodString( [inout] string rOut); + void testinout_methodChar( [inout] char rOut); + void testinout_methodAny ( [inout] any 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); + + any methodAnyTest1( [in] any rIn); + [attribute] any AttrAny2; + +}; +[uik(EBEF02B0-8C41-11d3-9EF90050-04526AB4), ident("XTestStruct", 1.0)] +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; +}; + +[uik(E5087290-95E9-11d3-9F070050-04526AB4), ident("XTestOutParameters", 1.0)] +interface XTestOutParameters: com::sun::star::uno::XInterface +{ + void out_methodByte( [out] byte rOut ); + void out_methodDouble( [out] double rOut); + void out_methodBool( [out] boolean rOut); + void out_methodShort( [out] short rOut); + void out_methodUShort( [out] unsigned short rOut); + void out_methodLong( [out] long rOut); + void out_methodULong( [out] unsigned long rOut); + void out_methodString( [out] string rOut); + void out_methodChar( [out] char rOut); + void out_methodAny ( [out] any rOut); + void out_methodSequence( [out] sequence< long > rOut); + void out_methodSequence2( [out] sequence < sequence< long > > rOut); + + void out_methodMulParams1( [out] long rout1, [out] long rout2); + void out_methodMulParams2( [out] long rout1, [out] long rout2, [out] string rout3); + void out_methodMulParams3( [in] string sin, [out] string sout); + + +}; + +struct SimpleStruct +{ + string message; +}; + +enum SimpleEnum +{ + A, + B, + C +}; + +[uik(57F9DDE0-9293-11d3-9F000050-04526AB4), ident("XTestOthers", 1.0)] +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); +}; + + +[uik(67E59870-6EA4-11d4-832F0050-04526AB4), ident("XSimple", 1.0)] +interface XSimple: com::sun::star::uno::XInterface +{ + void func( [in] string message); + string getName(); +}; +[uik(29828AB0-79A0-11d4-83330050-04526AB4), ident("XSimple2", 1.0)] +interface XSimple2: com::sun::star::uno::XInterface +{ + void func2( [in] string message); + string getName2(); +}; +[uik(29828AB1-79A0-11d4-83330050-04526AB4), ident("XSimple3", 1.0)] +interface XSimple3: com::sun::star::uno::XInterface +{ + void func3( [in] string message); + string getName3(); +}; + +[uik(4405B9E0-6D39-11d4-832F0050-04526AB4), ident("XTestOthers", 1.0)] +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<any> outSeqAny); + void outSeqByte( [out] sequence<byte> 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<any> 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<any> 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<any> 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<byte> val); + + + +}; + + +[uik(259159C0-6D38-11d4-832F0050-04526AB4), ident("XTestOthers", 1.0)] +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); +}; + +}; // oletest + diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp new file mode 100644 index 000000000..3a6809b2b --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp @@ -0,0 +1,68 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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 diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.h b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h new file mode 100644 index 000000000..b6705c3e0 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include <stdio.h> +#include <windows.h> +#include <comdef.h> +#include <tchar.h> +#include <atlbase.h> +extern CComModule _Module; +#include<atlcom.h> +#include<atlimpl.cpp> + +// 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_) diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.cpp b/extensions/test/ole/unoTocomCalls/Test/Test.cpp new file mode 100644 index 000000000..927d02330 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.cpp @@ -0,0 +1,277 @@ +/************************************************************************* + * + * $RCSfile: Test.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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=CoInitialize(NULL))) + { + _tprintf(_T("CoInitialize 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<IUnknown> 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<IDispatch> 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 + // Does not work currently because Sequences are always converted to + // SAFEARRAY( VARIANT) + // param2= 201; + // 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<IDispatch> 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 diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.dsp b/extensions/test/ole/unoTocomCalls/Test/Test.dsp new file mode 100644 index 000000000..9572411e4 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/Test/Test.dsp @@ -0,0 +1,113 @@ +# 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/XCallback_Impl/Basic.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs new file mode 100644 index 000000000..39011d717 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs @@ -0,0 +1,26 @@ +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..e318d41ee --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs @@ -0,0 +1,26 @@ +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..484c0074a --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp @@ -0,0 +1,517 @@ +/************************************************************************* + * + * $RCSfile: Callback.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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<IDispatch> 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<IDispatch> 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) +{ + + TCHAR buff[1024]; + *pval = val+1; + wsprintf( buff, _T("param1: %d, param2 out: %d, param3: %s"), val, *pval, string); + MessageBox( NULL, buff, _T(""), 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<IDispatch> _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<IDispatch> 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.14; + 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= 0xffff; + 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<IDispatch> 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; i<count; i++) + { + var.Clear(); + hr= SafeArrayGetElement( *pArray, &i, (void*)&var); + } + + SafeArrayDestroy( *pArray); + + outSeqAny( pArray); + return S_OK; +} + +STDMETHODIMP CCallback::inoutAny(VARIANT *inoutVal) +{ + if( !inoutVal) + return E_POINTER; + USES_CONVERSION; + if( inoutVal->vt= 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= 0xffff; + 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 val) +{ + // TODO: Add your implementation code here + + return S_OK; +} 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..4a9bf025d --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h @@ -0,0 +1,167 @@ +/************************************************************************* + * + * $RCSfile: Callback.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// Callback.h : Declaration of the CCallback + +#ifndef __CALLBACK_H_ +#define __CALLBACK_H_ + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CCallback +class ATL_NO_VTABLE CCallback : + public CComObjectRootEx<CComSingleThreadModel>, + public CComCoClass<CCallback, &CLSID_Callback>, + public IDispatchImpl<ICallback, &IID_ICallback, &LIBID_XCALLBACK_IMPLLib> +{ +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(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)(); +}; + +#endif //__CALLBACK_H_ 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..357c2946b --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs @@ -0,0 +1,26 @@ +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..f848c7982 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: Simple.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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 S_OK; +} 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..8b6a632e6 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h @@ -0,0 +1,98 @@ +/************************************************************************* + * + * $RCSfile: Simple.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// Simple.h : Declaration of the CSimple + +#ifndef __SIMPLE_H_ +#define __SIMPLE_H_ + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CSimple +class ATL_NO_VTABLE CSimple : + public CComObjectRootEx<CComSingleThreadModel>, + public CComCoClass<CSimple, &CLSID_Simple>, + public IDispatchImpl<ISimple, &IID_ISimple, &LIBID_XCALLBACK_IMPLLib> +{ +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); +}; + +#endif //__SIMPLE_H_ 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..9d5edbb2d --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs @@ -0,0 +1,26 @@ +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..dc198a3b3 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp @@ -0,0 +1,72 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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 <statreg.h> +#include <statreg.cpp> +#endif + +#include <atlimpl.cpp> 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..7d6946580 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $RCSfile: StdAfx.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +#include <stdio.h> +#include <atlbase.h> +//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 <atlcom.h> +#include <stdio.h> + +//{{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) 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..4b02a1652 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp @@ -0,0 +1,134 @@ +/************************************************************************* + * + * $RCSfile: XCallback_Impl.cpp,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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 <initguid.h> +#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); +} + + 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..871b32942 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp @@ -0,0 +1,335 @@ +# 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" /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\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..8d07c46bc --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl @@ -0,0 +1,181 @@ +/************************************************************************* + * + * $RCSfile: XCallback_Impl.idl,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +// 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(unsigned char) val); + + }; + [ + 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; + }; +}; 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..1eb9f719e --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc @@ -0,0 +1,197 @@ +/************************************************************************* +* +* $RCSfile: XCallback_Impl.rc,v $ +* +* $Revision: 1.1.1.1 $ +* +* last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ +* +* The Contents of this file are made available subject to the terms of +* either of the following licenses +* +* - GNU Lesser General Public License Version 2.1 +* - Sun Industry Standards Source License Version 1.1 +* +* Sun Microsystems Inc., October, 2000 +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2000 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +* +* Sun Industry Standards Source License Version 1.1 +* ================================================= +* The contents of this file are subject to the Sun Industry Standards +* Source License Version 1.1 (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.openoffice.org/license.html. +* +* Software provided under this License is provided on an "AS IS" basis, +* WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, +* WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +* See the License for the specific provisions governing your rights and +* obligations concerning the Software. +* +* The Initial Developer of the Original Code is: Sun Microsystems, Inc.. +* +* Copyright: 2000 by Sun Microsystems, Inc. +* +* All Rights Reserved. +* +* Contributor(s): _______________________________________ +* +* +* +**************************************************************************/ + +#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/resource.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h new file mode 100644 index 000000000..087847931 --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h @@ -0,0 +1,79 @@ +/************************************************************************* + * + * $RCSfile: resource.h,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +//{{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 diff --git a/extensions/test/ole/unoTocomCalls/readme.txt b/extensions/test/ole/unoTocomCalls/readme.txt new file mode 100644 index 000000000..d02b1357a --- /dev/null +++ b/extensions/test/ole/unoTocomCalls/readme.txt @@ -0,0 +1,6 @@ +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
\ No newline at end of file diff --git a/extensions/test/pgp/TestPGP.java b/extensions/test/pgp/TestPGP.java new file mode 100644 index 000000000..7edc4a9cb --- /dev/null +++ b/extensions/test/pgp/TestPGP.java @@ -0,0 +1,180 @@ +/************************************************************************* + * + * $RCSfile: TestPGP.java,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +import java.io.IOException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyState; + +import com.sun.star.bridge.XBridge; + +// import com.sun.star.comp.bootstrap.Bootstrap; + +import com.sun.star.connection.XConnector; +import com.sun.star.connection.XConnection; + +import com.sun.star.io.BufferSizeExceededException; +import com.sun.star.io.NotConnectedException; +import com.sun.star.io.XInputStream; +import com.sun.star.io.XOutputStream; + +import com.sun.star.frame.XComponentLoader; + +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; + +import com.sun.star.text.XSimpleText; +import com.sun.star.text.XText; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; + +import com.sun.star.uno.IBridge; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.uno.XNamingService; +import com.sun.star.container.*; +import com.sun.star.lang.*; + +import com.sun.star.pgp.*; + + + +public class TestPGP { + + + static void doSomething(Object r) throws com.sun.star.uno.Exception, IOException, Exception { + XNamingService rName = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, r); + + if(rName != null) { + System.err.println("got the remote naming service !"); + Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager"); + + XMultiServiceFactory rSmgr = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr); + if(rSmgr != null) { + System.err.println("got the remote service manager !"); + } + + XSet set= (XSet)UnoRuntime.queryInterface(XSet.class, rSmgr); + if( set == null) { + System.err.println(" couldn't get XSet from ServiceFactory"); + return; + } +// try{ + SimplePGPMailerFactoryReg mailerReg= new SimplePGPMailerFactoryReg(); + XSingleServiceFactory factory= mailerReg.getServiceFactory( + "com.sun.star.pgp.SimplePGPMailerImpl", rSmgr, null, null); + + if( factory == null) { + System.err.println("couldn't create PGP factory !"); + return; + } + set.insert(factory ); + System.err.println("PGP factory inserted into service manager"); + +// }catch(Exception e ){ +// System.err.println( "exception caught in TestPGP"); +// } + + } + } + + + + static String neededServices[] = new String[] { + "com.sun.star.comp.servicemanager.ServiceManager", + "com.sun.star.comp.loader.JavaLoader", + "com.sun.star.comp.connections.Connector", + "com.sun.star.comp.connections.Acceptor" + }; + + public static void main(String argv[]) throws Exception { + if(argv.length != 1) { + System.err.println("usage : testoffice protocol:host:port"); + System.exit(-1); + } + +// try { + com.sun.star.comp.servicemanager.ServiceManager smgr = new com.sun.star.comp.servicemanager.ServiceManager(); + smgr.addFactories(neededServices, null); + + XConnector xConnector = (XConnector)smgr.createInstance("com.sun.star.connection.Connector"); + XConnection xConnection = xConnector.connect(argv[0]); + + String rootOid = "classic_uno"; + IBridge iBridge = UnoRuntime.getBridgeByName("java", null, "remote", null, new Object[]{"iiop", xConnection, null}); + + Object rInitialObject = iBridge.mapInterfaceFrom(rootOid, XInterface.class); +// Object rInitialObject = xBridge.getInstance("NamingService"); + + if(rInitialObject != null) { + System.err.println("got the remote object"); + doSomething(rInitialObject); + } +// } +// catch (Exception exception) { +// System.err.println("Exception thrown:" + exception); +// } + } +} + diff --git a/extensions/test/pgp/makefile.mk b/extensions/test/pgp/makefile.mk new file mode 100644 index 000000000..6c703c502 --- /dev/null +++ b/extensions/test/pgp/makefile.mk @@ -0,0 +1,161 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + + + +PRJ=..$/.. + +PRJNAME := extensions +#PACKAGE := com$/sun$/star$/pgp +PACKAGE := +TARGET := test_com_sun_star_pgp + + +# --- Settings ----------------------------------------------------- +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + + +# Files -------------------------------------------------------- + + +APPLICATRDB := $(SOLARBINDIR)$/applicat.rdb +RDB := $(APPLICATRDB) + +JARFILES= jurt.jar + +GENJAVACLASSFILES= \ + $(CLASSDIR)$/com$/sun$/star$/beans$/PropertyValue.class \ + $(CLASSDIR)$/com$/sun$/star$/beans$/PropertyState.class \ + $(CLASSDIR)$/com$/sun$/star$/container$/XSet.class \ + + +#$(CLASSDIR)$/com$/sun$/star$/awt$/FocusEvent.class + +# $(CLASSDIR)$/com$/sun$/star$/awt$/InputEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/KeyEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/MouseEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/WindowEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/PaintEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/Rectangle.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XFocusListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XKeyListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XMouseListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XMouseMotionListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XWindow.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XWindowListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/awt$/XPaintListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/bridge$/XBridge.class \ +# $(CLASSDIR)$/com$/sun$/star$/container$/XIndexAccess.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/FrameAction.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/FrameActionEvent.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XComponentLoader.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XController.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrame.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrameActionListener.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrames.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XFramesSupplier.class \ +# $(CLASSDIR)$/com$/sun$/star$/frame$/XModel.class \ +# $(CLASSDIR)$/com$/sun$/star$/io$/BufferSizeExceededException.class \ +# $(CLASSDIR)$/com$/sun$/star$/io$/NotConnectedException.class \ +# $(CLASSDIR)$/com$/sun$/star$/io$/XInputStream.class \ +# $(CLASSDIR)$/com$/sun$/star$/io$/XOutputStream.class \ +# $(CLASSDIR)$/com$/sun$/star$/lang$/IndexOutOfBoundsException.class \ +# $(CLASSDIR)$/com$/sun$/star$/lang$/XComponent.class \ +# $(CLASSDIR)$/com$/sun$/star$/lang$/XMultiServiceFactory.class \ +# $(CLASSDIR)$/com$/sun$/star$/lang$/XServiceInfo.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XSimpleText.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XText.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XTextContent.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XTextCursor.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XTextDocument.class \ +# $(CLASSDIR)$/com$/sun$/star$/text$/XTextRange.class \ +# $(CLASSDIR)$/com$/sun$/star$/uno$/XNamingService.class \ +# $(CLASSDIR)$/com$/sun$/star$/uno$/Enum.class + + +JAVACLASSFILES= \ + $(CLASSDIR)$/$(PACKAGE)$/TestPGP.class + + +TYPES={$(subst,.class, $(subst,$/,. $(subst,$(CLASSDIR)$/,-T $(GENJAVACLASSFILES))))} +GENJAVAFILES = {$(subst,.class,.java $(subst,$/class, $(GENJAVACLASSFILES)))} +JAVAFILES= $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) $(GENJAVAFILES) + + +# --- Targets ------------------------------------------------------ + + +.IF "$(depend)" == "" +ALL : $(GENJAVAFILES) ALLTAR +.ELSE +ALL: ALLDEP +.ENDIF + +.INCLUDE : target.mk + +$(GENJAVAFILES) : $(RDB) +# +javamaker -BUCR -O$(OUT) $(TYPES) $(RDB) + +javamaker @$(mktmp -BUCR -O$(OUT) $(TYPES) $(RDB)) + +$(JAVACLASSFILES) : $(GENJAVAFILES) diff --git a/extensions/test/pgp/readme.txt b/extensions/test/pgp/readme.txt new file mode 100644 index 000000000..f6f6a1871 --- /dev/null +++ b/extensions/test/pgp/readme.txt @@ -0,0 +1,34 @@ +The program TestPGP instantiates a SimplePGPMailerFactory and adds + it to the ServiceManager obtained from a running StarOffice. +Then PGP can be used from within StarOffice. + +Prerequisites: +StarOffice needs an entry in Office/user/sofficerc under the Common + section: + + Port2=socket:hamburg-11070:1111 // old style +as of 569 m +Connection=socket,hamburg-11070,port=1111;iiop; + +Please note the semicolons! + + hamburg-11070 is the host running the office and 1111 is a + freely choosable port number. + + + For the program to run make sure that the office has access + to classes.zip, unoil.jar, jurt.jar, sandbox.jar, pgp.jar + and swingall.jar. + + Therefore do the necessary entries in + Office/user/config/javarc + under SystemClasspath. + +There is a bug with jdk1.1.8, therfore use 1.2 instead. + +The TestPGP is called without ;iiop; : + +java TestPGP "socket,host=localhost,port=1111" + + + diff --git a/extensions/test/sax/exports.dxp b/extensions/test/sax/exports.dxp new file mode 100644 index 000000000..e4bc69d23 --- /dev/null +++ b/extensions/test/sax/exports.dxp @@ -0,0 +1,2 @@ +exService_writeRegEntry +exService_getFactory diff --git a/extensions/test/sax/factory.hxx b/extensions/test/sax/factory.hxx new file mode 100644 index 000000000..394702df9 --- /dev/null +++ b/extensions/test/sax/factory.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * $RCSfile: factory.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +XInterfaceRef OSaxWriterTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +UString OSaxWriterTest_getServiceName( ) THROWS( () ); +UString OSaxWriterTest_getImplementationName( ) THROWS( () ); +Sequence<UString> OSaxWriterTest_getSupportedServiceNames( ) THROWS( () ); + diff --git a/extensions/test/sax/makefile.mk b/extensions/test/sax/makefile.mk new file mode 100644 index 000000000..d3ec2da75 --- /dev/null +++ b/extensions/test/sax/makefile.mk @@ -0,0 +1,102 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=extensions +TARGET=testsax +USE_DEFFILE=TRUE +ENABLE_EXCEPTIONS=TRUE +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + + + +OBJFILES = $(SLO)$/testsax.obj $(SLO)$/testwriter.obj + +LIB1TARGET= $(SLB)$/$(TARGET).lib +LIB1OBJFILES= $(OBJFILES) + + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) + +SHL1STDLIBS= \ + $(USRLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(ONELIB) \ + $(TOOLSLIB) + +SHL1LIBS= $(LIB1TARGET) +SHL1IMPLIB= i$(TARGET) +SHL1DEPN= makefile.mk $(SHL1LIBS) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/extensions/test/sax/testsax.cxx b/extensions/test/sax/testsax.cxx new file mode 100644 index 000000000..8b777776a --- /dev/null +++ b/extensions/test/sax/testsax.cxx @@ -0,0 +1,951 @@ +/************************************************************************* + * + * $RCSfile: testsax.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include <stdio.h> +#include <string.h> +#include <smart/com/sun/star/test/XSimpleTest.hxx> + +#include <rtl/wstring.hxx> +#include <osl/time.h> +//#include <vos/dynload.hxx> +//#include <vos/diagnose.hxx> +#include <usr/weak.hxx> +#include <tools/string.hxx> +#include <vos/conditn.hxx> +#include <assert.h> + +#include <smart/com/sun/star/io/XOutputStream.hxx> +#include <smart/com/sun/star/xml/sax/SAXParseException.hxx> +#include <smart/com/sun/star/xml/sax/XParser.hxx> +#include <smart/com/sun/star/xml/sax/XExtendedDocumentHandler.hxx> + +#include <smart/com/sun/star/lang/XMultiServiceFactory.hxx> // for the multiservice-factories +#include <usr/factoryhlp.hxx> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE + +#include "factory.hxx" + +#ifdef _USE_NAMESPACE +using namespace rtl; +using namespace vos; +using namespace usr; +#endif + + +#define BUILD_ERROR(expr, Message)\ + {\ + m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \ + m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \ + String str; \ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \ + }\ + ((void)0) + + +#define WARNING_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \ + String str;\ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \ + return; \ + }\ + ((void)0) + +#define ERROR_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + BUILD_ERROR(expr, Message );\ + return; \ + }\ + ((void)0) + +#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \ + if( !(expr)) { \ + BUILD_ERROR(expr,Message);\ + m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\ + return; \ + } \ + ((void)0) + +/**** +* test szenarios : +* +* +* +****/ + + + +class OSaxParserTest : + public XSimpleTest, + public OWeakObject +{ +public: + OSaxParserTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory ) + { + + } + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XParserRef &r ); + void testNamespaces( const XParserRef &r ); + void testFile( const XParserRef &r ); + void testEncoding( const XParserRef &rParser ); + void testPerformance( const XParserRef &rParser ); + +private: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + XMultiServiceFactoryRef m_rFactory; +}; + + + +/** +* for external binding +* +* +**/ +XInterfaceRef OSaxParserTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OSaxParserTest *p = new OSaxParserTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + + +UString OSaxParserTest_getServiceName( ) THROWS( () ) +{ + return L"test.com.sun.star.xml.sax.Parser"; +} + +UString OSaxParserTest_getImplementationName( ) THROWS( () ) +{ + return L"test.extensions.xml.sax.Parser"; +} + +Sequence<UString> OSaxParserTest_getSupportedServiceNames( ) THROWS( () ) +{ + Sequence<UString> aRet(1); + + aRet.getArray()[0] = OSaxParserTest_getImplementationName( ); + + return aRet; +} + + +BOOL OSaxParserTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OSaxParserTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.xml.sax.Parser" == TestName ) { + XParserRef parser( TestObject , USR_QUERY ); + + ERROR_ASSERT( parser.is() , "XDataInputStream cannot be queried" ); + } +} + + +INT32 OSaxParserTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.xml.sax.Parser" == TestName ) { + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else { + + XParserRef parser( TestObject , USR_QUERY ); + + if( 1 == hTestHandle ) { + testSimple( parser ); + } + else if( 2 == hTestHandle ) { + testNamespaces( parser ); + } + else if( 3 == hTestHandle ) { + testEncoding( parser ); + } + else if( 4 == hTestHandle ) { + testFile( parser ); + } + else if( 5 == hTestHandle ) { + testPerformance( parser ); + } + } + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( hTestHandle >= 6) { + // all tests finished. + hTestHandle = -1; + } + } + else { + BUILD_ERROR( 0 , "service not supported by test." ); + } + return hTestHandle; +} + + + +BOOL OSaxParserTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > OSaxParserTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > OSaxParserTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > OSaxParserTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + +XInputStreamRef createStreamFromSequence( const Sequence<BYTE> seqBytes , XMultiServiceFactoryRef &xSMgr ) +{ + XInterfaceRef xOutStreamService = xSMgr->createInstance( L"com.sun.star.io.Pipe" ); + assert( xOutStreamService.is() ); + XOutputStreamRef rOutStream( xOutStreamService , USR_QUERY ); + assert( rOutStream.is() ); + + XInputStreamRef rInStream( xOutStreamService , USR_QUERY ); + assert( rInStream.is() ); + + rOutStream->writeBytes( seqBytes ); + rOutStream->flush(); + rOutStream->closeOutput(); + + return rInStream; +} + +XInputStreamRef createStreamFromFile( const char *pcFile , XMultiServiceFactoryRef &xSMgr ) +{ + FILE *f = fopen( pcFile , "rb" ); + XInputStreamRef r; + + if( f ) { + fseek( f , 0 , SEEK_END ); + int nLength = ftell( f ); + fseek( f , 0 , SEEK_SET ); + + Sequence<BYTE> seqIn(nLength); + fread( seqIn.getArray() , nLength , 1 , f ); + + r = createStreamFromSequence( seqIn , xSMgr ); + fclose( f ); + } + return r; +} + + + + + + + + + +#define PCHAR_TO_USTRING(x) StringToUString(String(x),CHARSET_PC_1252) +#define USTRING_TO_PCHAR(x) UStringToString(x,CHARSET_PC_437).GetStr() + + + +class TestDocumentHandler : + public XExtendedDocumentHandler, + public XEntityResolver, + public XErrorHandler, + public OWeakObject +{ +public: + TestDocumentHandler( XMultiServiceFactoryRef &r , BOOL bPrint ) + { + m_xSMgr = r; + m_bPrint = bPrint; + } + + +public: + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + + +public: // Error handler + virtual void error(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) ) + { + printf( "Error !\n" ); + THROW( SAXException( L"error from error handler" , XInterfaceRef() , aSAXParseException ) ); + } + virtual void fatalError(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) ) + { + printf( "Fatal Error !\n" ); + } + virtual void warning(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) ) + { + printf( "Warning !\n" ); + } + + +public: // ExtendedDocumentHandler + + virtual void startDocument(void) THROWS( (SAXException, UsrSystemException) ) + { + m_iLevel = 0; + m_iElementCount = 0; + m_iAttributeCount = 0; + m_iWhitespaceCount =0; + m_iCharCount=0; + if( m_bPrint ) { + printf( "document started\n" ); + } + } + virtual void endDocument(void) THROWS( (SAXException, UsrSystemException) ) + { + if( m_bPrint ) { + printf( "document finished\n" ); + printf( "(ElementCount %d),(AttributeCount %d),(WhitespaceCount %d),(CharCount %d)\n", + m_iElementCount, m_iAttributeCount, m_iWhitespaceCount , m_iCharCount ); + } + } + virtual void startElement(const UString& aName, const XAttributeListRef& xAttribs) + THROWS( (SAXException,UsrSystemException) ) + { + + if( m_rLocator.is() ) { + if( m_bPrint ) + printf( "%s(%d):" , USTRING_TO_PCHAR( m_rLocator->getSystemId() ) , + m_rLocator->getLineNumber() ); + } + if( m_bPrint ) { + int i; + for( i = 0; i < m_iLevel ; i ++ ) { + printf( " " ); + } + printf( "<%s> " , USTRING_TO_PCHAR( aName ) ); + + for( i = 0 ; i < xAttribs->getLength() ; i ++ ) { + printf( "(%s,%s,'%s')" , USTRING_TO_PCHAR( xAttribs->getNameByIndex( i ) ) , + USTRING_TO_PCHAR( xAttribs->getTypeByIndex( i ) ) , + USTRING_TO_PCHAR( xAttribs->getValueByIndex( i ) ) ); + } + printf( "\n" ); + } + m_iLevel ++; + m_iElementCount ++; + m_iAttributeCount += xAttribs->getLength(); + } + virtual void endElement(const UString& aName) THROWS( (SAXException,UsrSystemException) ) + { + assert( m_iLevel ); + m_iLevel --; + if( m_bPrint ) { + int i; + for( i = 0; i < m_iLevel ; i ++ ) { + printf( " " ); + } + printf( "</%s>\n" , USTRING_TO_PCHAR( aName ) ); + } + } + + virtual void characters(const UString& aChars) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) { + int i; + for( i = 0; i < m_iLevel ; i ++ ) { + printf( " " ); + } + printf( "%s\n" , USTRING_TO_PCHAR( aChars ) ); + } + m_iCharCount += aChars.len(); + } + virtual void ignorableWhitespace(const UString& aWhitespaces) THROWS( (SAXException,UsrSystemException) ) + { + m_iWhitespaceCount += aWhitespaces.len(); + } + + virtual void processingInstruction(const UString& aTarget, const UString& aData) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) + printf( "PI : %s,%s\n" , USTRING_TO_PCHAR( aTarget ) , USTRING_TO_PCHAR( aData ) ); + } + + virtual void setDocumentLocator(const XLocatorRef& xLocator) THROWS( (SAXException,UsrSystemException) ) + { + m_rLocator = xLocator; + } + + virtual InputSource resolveEntity(const UString& sPublicId, const UString& sSystemId) + THROWS( (SAXException,UsrSystemException) ) + { + InputSource source; + source.sSystemId = sSystemId; + source.sPublicId = sPublicId; + source.aInputStream = createStreamFromFile( USTRING_TO_PCHAR( sSystemId ) , m_xSMgr ); + + return source; + } + + virtual void startCDATA(void) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) { + printf( "CDataStart :\n" ); + } + } + virtual void endCDATA(void) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) { + printf( "CEndStart :\n" ); + } + } + virtual void comment(const UString& sComment) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) { + printf( "<!--%s-->\n" , USTRING_TO_PCHAR( sComment ) ); + } + } + virtual void unknown(const UString& sString) THROWS( (SAXException,UsrSystemException) ) + { + if( m_bPrint ) { + printf( "UNKNOWN : {%s}\n" , USTRING_TO_PCHAR( sString ) ); + } + } + + virtual void allowLineBreak( void) THROWS( (SAXException, UsrSystemException ) ) + { + + } + + +public: + int m_iLevel; + int m_iElementCount; + int m_iAttributeCount; + int m_iWhitespaceCount; + int m_iCharCount; + BOOL m_bPrint; + + XMultiServiceFactoryRef m_xSMgr; + XLocatorRef m_rLocator; +}; + +BOOL TestDocumentHandler::queryInterface( Uik aUik , XInterfaceRef & rOut ) +{ + if( aUik == XDocumentHandler::getSmartUik() ) { + rOut = (XDocumentHandler * )this; + } + else if ( aUik == XExtendedDocumentHandler::getSmartUik() ) { + rOut = (XExtendedDocumentHandler *) this; + } + else if ( aUik == XEntityResolver::getSmartUik() ) { + rOut = (XEntityResolver *) this; + } + else if ( aUik == XErrorHandler::getSmartUik() ) { + rOut = (XErrorHandler * ) this; + } + else { + return OWeakObject::queryInterface( aUik , rOut ); + } + return TRUE; +} + + + + +void OSaxParserTest::testSimple( const XParserRef &rParser ) +{ + + char TestString[] = + "<!DOCTYPE personnel [\n" + "<!ENTITY testInternal \"internal Test!\">\n" + "<!ENTITY test SYSTEM \"external_entity.xml\">\n" + "]>\n" + + "<personnel>\n" + "<person> fjklsfdklsdfkl\n" + "fjklsfdklsdfkl\n" + "<?testpi pidata?>\n" + "&testInternal;\n" + "<HUHU x='5' y='kjfd'> blahuhu\n" + "<HI> blahi\n" + " <![CDATA[<greeting>Hello, '+1+12world!</greeting>]]>\n" + " <!-- huhu <jdk> -->\n" + "<?testpi pidata?>\n" + "</HI>\n" + "aus XMLTest\n" + "</HUHU>\n" + "</person>\n" + "</personnel>\n\n\n"; + + Sequence<BYTE> seqBytes( strlen( TestString ) ); + memcpy( seqBytes.getArray() , TestString , strlen( TestString ) ); + + + XInputStreamRef rInStream; + UString sInput; + rInStream = createStreamFromSequence( seqBytes , m_rFactory ); + sInput = UString( L"internal" ); + + if( rParser.is() ) { + InputSource source; + + source.aInputStream = rInStream; + source.sSystemId = sInput; + + TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE ); + XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY ); + XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY ); + + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); + + TRY { + rParser->parseStream( source ); + ERROR_ASSERT( pDocHandler->m_iElementCount == 4 , "wrong element count" ); + ERROR_ASSERT( pDocHandler->m_iAttributeCount == 2 , "wrong attribut count" ); + ERROR_ASSERT( pDocHandler->m_iCharCount == 130 , "wrong char count" ); + ERROR_ASSERT( pDocHandler->m_iWhitespaceCount == 0, "wrong whitespace count" ); + } + CATCH( SAXParseException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH( SAXException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + + } + AND_CATCH( Exception , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 1 , "unknown exception" ); + } + END_CATCH; + + } + + +} + +void OSaxParserTest::testNamespaces( const XParserRef &rParser ) +{ + + char TestString[] = + "<?xml version='1.0'?>\n" + "<!-- all elements here are explicitly in the HTML namespace -->\n" + "<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>\n" + "<html:head><html:title>Frobnostication</html:title></html:head>\n" + "<html:body><html:p>Moved to \n" + "<html:a href='http://frob.com'>here.</html:a></html:p></html:body>\n" + "</html:html>\n"; + + Sequence<BYTE> seqBytes( strlen( TestString ) ); + memcpy( seqBytes.getArray() , TestString , strlen( TestString ) ); + + + XInputStreamRef rInStream; + UString sInput; + + rInStream = createStreamFromSequence( seqBytes , m_rFactory ); + sInput = UString( L"internal" ); + + if( rParser.is() ) { + InputSource source; + + source.aInputStream = rInStream; + source.sSystemId = sInput; + + TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE ); + XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY ); + XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY ); + + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); + + TRY { + rParser->parseStream( source ); + ERROR_ASSERT( pDocHandler->m_iElementCount == 6 , "wrong element count" ); + ERROR_ASSERT( pDocHandler->m_iAttributeCount == 2 , "wrong attribut count" ); + ERROR_ASSERT( pDocHandler->m_iCharCount == 33, "wrong char count" ); + ERROR_ASSERT( pDocHandler->m_iWhitespaceCount == 0 , "wrong whitespace count" ); + } + CATCH( SAXParseException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH( SAXException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + + } + AND_CATCH( Exception , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 1 , "unknown exception" ); + } + END_CATCH; + } +} + +void OSaxParserTest::testEncoding( const XParserRef &rParser ) +{ + char TestString[] = + "<?xml version='1.0' encoding=\"iso-8859-1\"?>\n" + "<!-- all elements here are explicitly in the HTML namespace -->\n" + "<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>\n" + "<html:head><html:title>Frobnostication</html:title></html:head>\n" + "<html:body><html:p>Moved to ß\n" + "<html:a href='http://frob.com'>here.</html:a></html:p></html:body>\n" + "</html:html>\n"; + + Sequence<BYTE> seqBytes( strlen( TestString ) ); + memcpy( seqBytes.getArray() , TestString , strlen( TestString ) ); + + + XInputStreamRef rInStream; + UString sInput; + + rInStream = createStreamFromSequence( seqBytes , m_rFactory ); + sInput = UString( L"internal" ); + + if( rParser.is() ) { + InputSource source; + + source.aInputStream = rInStream; + source.sSystemId = sInput; + + TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE ); + XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY ); + XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY ); + + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); + TRY { + rParser->parseStream( source ); + } + CATCH( SAXParseException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH( SAXException , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + + } + AND_CATCH( Exception , e ) { + BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 1 , "unknown exception" ); + } + END_CATCH; + + } + +} + +void OSaxParserTest::testFile( const XParserRef & rParser ) +{ + + XInputStreamRef rInStream = createStreamFromFile( "testsax.xml" , m_rFactory ); + UString sInput = UString( PCHAR_TO_USTRING( "testsax.xml" ) ); + + + if( rParser.is() && rInStream.is() ) { + InputSource source; + + source.aInputStream = rInStream; + source.sSystemId = sInput; + + TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , TRUE ); + XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY ); + XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY ); + XErrorHandlerRef rErrorHandler( ( XErrorHandler * )pDocHandler , USR_QUERY ); + + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); + rParser->setErrorHandler( rErrorHandler ); + + TRY { + rParser->parseStream( source ); + } + CATCH( SAXParseException , e ) { + UsrAny any; + any.set( &e , SAXParseException_getReflection() ); + while(TRUE) { + SAXParseException *pEx; + if( any.getReflection() == SAXParseException_getReflection() ) { + pEx = ( SAXParseException * ) any.get(); + printf( "%s\n" , UStringToString( pEx->Message , CHARSET_SYSTEM ).GetStr() ); + any = pEx->WrappedException; + } + else { + break; + } + } + } + AND_CATCH( SAXException , e ) { + printf( "%s\n" , UStringToString( e.Message , CHARSET_SYSTEM ).GetStr() ); + + } + AND_CATCH( Exception , e ) { + printf( "normal exception ! %s\n", e.getName() ); + } + AND_CATCH_ALL() { + printf( "any exception !!!!\n" ); + } + END_CATCH; + } +} + +void OSaxParserTest::testPerformance( const XParserRef & rParser ) +{ + + XInputStreamRef rInStream = createStreamFromFile( "testPerformance.xml" , m_rFactory ); + UString sInput = UString( PCHAR_TO_USTRING( "testperformance.xml" ) ); + + if( rParser.is() && rInStream.is() ) { + InputSource source; + + source.aInputStream = rInStream; + source.sSystemId = sInput; + + TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE ); + XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY ); + XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY ); + XErrorHandlerRef rErrorHandler( ( XErrorHandler * )pDocHandler , USR_QUERY ); + + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); + rParser->setErrorHandler( rErrorHandler ); + + TRY { + TimeValue aStartTime, aEndTime; + osl_getSystemTime( &aStartTime ); + rParser->parseStream( source ); + osl_getSystemTime( &aEndTime ); + + double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0); + double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0); + + printf( "Performance reading : %g s\n" , fEnd - fStart ); + + } + CATCH( SAXParseException , e ) { + UsrAny any; + any.set( &e , SAXParseException_getReflection() ); + while(TRUE) { + SAXParseException *pEx; + if( any.getReflection() == SAXParseException_getReflection() ) { + pEx = ( SAXParseException * ) any.get(); + printf( "%s\n" , UStringToString( pEx->Message , CHARSET_SYSTEM ).GetStr() ); + any = pEx->WrappedException; + } + else { + break; + } + } + } + AND_CATCH( SAXException , e ) { + printf( "%s\n" , UStringToString( e.Message , CHARSET_SYSTEM ).GetStr() ); + + } + AND_CATCH( Exception , e ) { + printf( "normal exception ! %s\n", e.getName() ); + } + AND_CATCH_ALL() { + printf( "any exception !!!!\n" ); + } + END_CATCH; + } + +} + + +extern "C" +{ +BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry( + const UNO_INTERFACE(XRegistryKey)* xUnoKey) + +{ + XRegistryKeyRef xKey; + uno2smart(xKey, *xUnoKey); + + UString str = UString( L"/" ) + OSaxParserTest_getImplementationName() + UString( L"/UNO/SERVICES" ); + XRegistryKeyRef xNewKey = xKey->createKey( str ); + xNewKey->createKey( OSaxParserTest_getServiceName() ); + + str = UString( L"/" ) + OSaxWriterTest_getImplementationName() + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OSaxWriterTest_getServiceName() ); + + return TRUE; +} + + +UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory +( + const wchar_t* implementationName, + const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact, + const UNO_INTERFACE(XRegistryKey)* +) +{ + UNO_INTERFACE(XInterface) xUnoRet = {0, 0}; + + XInterfaceRef xRet; + XMultiServiceFactoryRef xSMgr; + UString aImplementationName(implementationName); + + uno2smart(xSMgr, *xUnoFact); + + if (aImplementationName == OSaxWriterTest_getImplementationName() ) + { + xRet = createSingleFactory( xSMgr, implementationName, + OSaxWriterTest_CreateInstance, + OSaxWriterTest_getSupportedServiceNames() ); + } + else if (aImplementationName == OSaxParserTest_getImplementationName() ) + { + xRet = createSingleFactory( xSMgr, implementationName, + OSaxParserTest_CreateInstance, + OSaxParserTest_getSupportedServiceNames() ); + } + if (xRet.is()) + { + smart2uno(xRet, xUnoRet); + } + + return xUnoRet; +} + +} + + diff --git a/extensions/test/sax/testwriter.cxx b/extensions/test/sax/testwriter.cxx new file mode 100644 index 000000000..bcb9664a8 --- /dev/null +++ b/extensions/test/sax/testwriter.cxx @@ -0,0 +1,811 @@ +/************************************************************************* + * + * $RCSfile: testwriter.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +//#include <tools/presys.h> +#include <vector> +//#include <tools/postsys.h> +#include <smart/com/sun/star/test/XSimpleTest.hxx> +#include <smart/com/sun/star/lang/XMultiServiceFactory.hxx> // for the multiservice-factories + +#include <stdio.h> + +#include <smart/com/sun/star/io/XActiveDataSource.hxx> +#include <smart/com/sun/star/io/XOutputStream.hxx> +#include <smart/com/sun/star/xml/sax/SAXParseException.hxx> +#include <smart/com/sun/star/xml/sax/XParser.hxx> +#include <smart/com/sun/star/xml/sax/XExtendedDocumentHandler.hxx> + +#include <rtl/wstring.hxx> +#include <osl/time.h> +#include <usr/weak.hxx> +#include <tools/string.hxx> +#include <assert.h> + +#include <usr/factoryhlp.hxx> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE + + +#ifdef _USE_NAMESPACE +using namespace std; +using namespace rtl; +using namespace vos; +using namespace usr; +#endif + + +#define BUILD_ERROR(expr, Message)\ + {\ + m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \ + m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \ + String str; \ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \ + }\ + ((void)0) + + +#define WARNING_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \ + String str;\ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \ + return; \ + }\ + ((void)0) + +#define ERROR_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + BUILD_ERROR(expr, Message );\ + return; \ + }\ + ((void)0) + +#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \ + if( !(expr)) { \ + BUILD_ERROR(expr,Message);\ + m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\ + return; \ + } \ + ((void)0) + +/**** +* test szenarios : +* +* +* +****/ + + +class OFileWriter : + public XOutputStream, + public OWeakObject +{ +public: + OFileWriter( char *pcFile ) { strcpy( m_pcFile , pcFile ); m_f = 0; } + + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ) + { + if( XOutputStream::getSmartUik() == aUik ) { + rOut = (XOutputStream *) this; + } + else return OWeakObject::queryInterface( aUik , rOut ); + + return TRUE; + } + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual void writeBytes(const Sequence< BYTE >& aData) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ); + virtual void flush(void) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ); + virtual void closeOutput(void) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ); + + +private: + char m_pcFile[256]; + FILE *m_f; +}; + + +void OFileWriter::writeBytes(const Sequence< BYTE >& aData) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ) +{ + if( ! m_f ) { + m_f = fopen( m_pcFile , "w" ); + } + + fwrite( aData.getConstArray() , 1 , aData.getLen() , m_f ); + +} + + +void OFileWriter::flush(void) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ) +{ + fflush( m_f ); +} + +void OFileWriter::closeOutput(void) + THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) ) +{ + fclose( m_f ); + m_f = 0; +} + + +class OSaxWriterTest : + public XSimpleTest, + public OWeakObject +{ +public: + OSaxWriterTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory ) + { + + } + ~OSaxWriterTest() {} + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XExtendedDocumentHandlerRef &r ); + void testExceptions( const XExtendedDocumentHandlerRef &r ); + void testDTD( const XExtendedDocumentHandlerRef &r ); + void testPerformance( const XExtendedDocumentHandlerRef &r ); + void writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s); + +private: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + XMultiServiceFactoryRef m_rFactory; + +}; + + + +/*---------------------------------------- +* +* Attributlist implementation +* +*----------------------------------------*/ +struct AttributeListImpl_impl; +class AttributeListImpl : + public XAttributeList, + public OWeakObject +{ +public: + AttributeListImpl(); + AttributeListImpl( const AttributeListImpl & ); + ~AttributeListImpl(); + +public: + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual INT16 getLength(void) THROWS( (UsrSystemException) ); + virtual UString getNameByIndex(INT16 i) THROWS( (UsrSystemException) ); + virtual UString getTypeByIndex(INT16 i) THROWS( (UsrSystemException) ); + virtual UString getTypeByName(const UString& aName) THROWS( (UsrSystemException) ); + virtual UString getValueByIndex(INT16 i) THROWS( (UsrSystemException) ); + virtual UString getValueByName(const UString& aName) THROWS( (UsrSystemException) ); + +public: + void addAttribute( const UString &sName , const UString &sType , const UString &sValue ); + void clear(); + +private: + struct AttributeListImpl_impl *m_pImpl; +}; + + +struct TagAttribute +{ + TagAttribute(){} + TagAttribute( const UString &sName, const UString &sType , const UString &sValue ) + { + this->sName = sName; + this->sType = sType; + this->sValue = sValue; + } + + UString sName; + UString sType; + UString sValue; +}; + +struct AttributeListImpl_impl +{ + AttributeListImpl_impl() + { + // performance improvement during adding + vecAttribute.reserve(20); + } + vector<struct TagAttribute> vecAttribute; +}; + + + +INT16 AttributeListImpl::getLength(void) THROWS( (UsrSystemException) ) +{ + return m_pImpl->vecAttribute.size(); +} + + +AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) +{ + m_pImpl = new AttributeListImpl_impl; + *m_pImpl = *(r.m_pImpl); +} + +UString AttributeListImpl::getNameByIndex(INT16 i) THROWS( (UsrSystemException) ) +{ + if( i < m_pImpl->vecAttribute.size() ) { + return m_pImpl->vecAttribute[i].sName; + } + return UString(); +} + + +UString AttributeListImpl::getTypeByIndex(INT16 i) THROWS( (UsrSystemException) ) +{ + if( i < m_pImpl->vecAttribute.size() ) { + return m_pImpl->vecAttribute[i].sType; + } + return UString(); +} + +UString AttributeListImpl::getValueByIndex(INT16 i) THROWS( (UsrSystemException) ) +{ + if( i < m_pImpl->vecAttribute.size() ) { + return m_pImpl->vecAttribute[i].sValue; + } + return UString(); + +} + +UString AttributeListImpl::getTypeByName( const UString& sName ) THROWS( (UsrSystemException) ) +{ + vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin(); + + for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { + if( (*ii).sName == sName ) { + return (*ii).sType; + } + } + return UString(); +} + +UString AttributeListImpl::getValueByName(const UString& sName) THROWS( (UsrSystemException) ) +{ + vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin(); + + for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) { + if( (*ii).sName == sName ) { + return (*ii).sValue; + } + } + return UString(); +} + + +BOOL AttributeListImpl::queryInterface( Uik aUik, XInterfaceRef & rOut ) +{ + if( aUik == XAttributeList::getSmartUik() ) { + rOut = (XAttributeList * )this; + } + else { + return OWeakObject::queryInterface( aUik , rOut ); + } + return TRUE; +} + + +AttributeListImpl::AttributeListImpl() +{ + m_pImpl = new AttributeListImpl_impl; +} + + + +AttributeListImpl::~AttributeListImpl() +{ + delete m_pImpl; +} + + +void AttributeListImpl::addAttribute( const UString &sName , + const UString &sType , + const UString &sValue ) +{ + m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) ); +} + +void AttributeListImpl::clear() +{ + vector<struct TagAttribute> dummy; + m_pImpl->vecAttribute.swap( dummy ); + + assert( ! getLength() ); +} + + + + + + + + + + + +/** +* for external binding +* +* +**/ +XInterfaceRef OSaxWriterTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OSaxWriterTest *p = new OSaxWriterTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + +UString OSaxWriterTest_getServiceName( ) THROWS( () ) +{ + return L"test.com.sun.star.xml.sax.Writer"; +} + +UString OSaxWriterTest_getImplementationName( ) THROWS( () ) +{ + return L"test.extensions.xml.sax.Writer"; +} + +Sequence<UString> OSaxWriterTest_getSupportedServiceNames( ) THROWS( () ) +{ + Sequence<UString> aRet(1); + + aRet.getArray()[0] = OSaxWriterTest_getImplementationName( ); + + return aRet; +} + + +BOOL OSaxWriterTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OSaxWriterTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.xml.sax.Writer" == TestName ) { + XDocumentHandlerRef doc( TestObject , USR_QUERY ); + XExtendedDocumentHandlerRef ext( TestObject , USR_QUERY ); + XActiveDataSourceRef source( TestObject , USR_QUERY ); + + ERROR_ASSERT( doc.is() , "XDocumentHandler cannot be queried" ); + ERROR_ASSERT( ext.is() , "XExtendedDocumentHandler cannot be queried" ); + ERROR_ASSERT( source.is() , "XActiveDataSource cannot be queried" ); + } + else { + BUILD_ERROR( 0 , "wrong test" ); + } +} + + +INT32 OSaxWriterTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.xml.sax.Writer" == TestName ) { + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else { + + XExtendedDocumentHandlerRef writer( TestObject , USR_QUERY ); + + if( 1 == hTestHandle ) { + testSimple( writer ); + } + else if( 2 == hTestHandle ) { + testExceptions( writer ); + } + else if( 3 == hTestHandle ) { + testDTD( writer ); + } + else if( 4 == hTestHandle ) { + testPerformance( writer ); + } + } + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( hTestHandle >= 5) { + // all tests finished. + hTestHandle = -1; + } + } + else { + BUILD_ERROR( 0 , "service not supported by test." ); + } + return hTestHandle; +} + + + +BOOL OSaxWriterTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > OSaxWriterTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > OSaxWriterTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > OSaxWriterTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + +void OSaxWriterTest::writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s) +{ + int nMax = s.len(); + int nStart = 0; + + Sequence<UINT16> seq( s.len() ); + memcpy( seq.getArray() , s.getStr() , s.len() * sizeof( UINT16 ) ); + + for( int n = 1 ; n < nMax ; n++ ){ + if( 32 == seq.getArray()[n] ) { + r->allowLineBreak(); + r->characters( s.copy( nStart , n - nStart ) ); + nStart = n; + } + } + r->allowLineBreak(); + r->characters( s.copy( nStart , n - nStart ) ); + + +} + + + +void OSaxWriterTest::testSimple( const XExtendedDocumentHandlerRef &r ) +{ + UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter " + L"wohl Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile " + L"bis zum bitteren Ende schreibt."; + + OFileWriter *pw = new OFileWriter("output.xml"); + AttributeListImpl *pList = new AttributeListImpl; + + XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY ); + XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY ); + + XActiveDataSourceRef source( r , USR_QUERY ); + + ERROR_ASSERT( ref.is() , "no output stream" ); + ERROR_ASSERT( source.is() , "no active data source" ); + + source->setOutputStream( ref ); + + r->startDocument(); + + pList->addAttribute( L"Arg1" , L"CDATA" , L"bla\n u" ); + pList->addAttribute( L"Arg2" , L"CDATA" , L"blub" ); + + r->startElement( L"tag1" , rList ); + r->ignorableWhitespace( L"" ); + + r->characters( L"huhu" ); + r->ignorableWhitespace( L"" ); + + r->startElement( L"hi" , rList ); + r->ignorableWhitespace( L"" ); + + // the enpassant must be converted & -> & + r->characters( L"ü" ); + + // Test added for mib. Tests if errors during conversions occurs + r->ignorableWhitespace( UString() ); + sal_Char array[256]; + for( sal_Int32 n = 32 ; n < 254 ; n ++ ) { + array[n-32] = n; + } + array[254-32] = 0; + r->characters( + StringToUString( array , RTL_TEXTENCODING_SYMBOL ) + ); + r->ignorableWhitespace( UString() ); + + // '>' must not be converted + r->startCDATA(); + r->characters( L">fsfsdf<" ); + r->endCDATA(); + r->ignorableWhitespace( UString() ); + + writeParagraph( r , testParagraph ); + + + r->ignorableWhitespace( UString() ); + r->comment( L"Dies ist ein Kommentar !" ); + r->ignorableWhitespace( UString() ); + + r->startElement( L"emptytagtest" , rList ); + r->endElement( L"emptytagtest" ); + + r->endElement( L"hi" ); + r->ignorableWhitespace( L"" ); + + r->endElement( L"tag1" ); + r->endDocument(); + +} + +void OSaxWriterTest::testExceptions( const XExtendedDocumentHandlerRef & r ) +{ + + OFileWriter *pw = new OFileWriter("output2.xml"); + AttributeListImpl *pList = new AttributeListImpl; + + XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY ); + XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY ); + + XActiveDataSourceRef source( r , USR_QUERY ); + + ERROR_ASSERT( ref.is() , "no output stream" ); + ERROR_ASSERT( source.is() , "no active data source" ); + + source->setOutputStream( ref ); + + { // startDocument must be called before start element + BOOL bException = TRUE; + TRY { + r->startElement( L"huhu" , rList ); + bException = FALSE; + } + CATCH( SAXException ,e ) { + + } + END_CATCH; + ERROR_ASSERT( bException , "expected exception not thrown !" ); + } + + r->startDocument(); + + r->startElement( L"huhu" , rList ); + r->startCDATA(); + + { + BOOL bException = TRUE; + TRY{ + r->startElement( L"huhu" , rList ); + bException = FALSE; + } + CATCH( SAXException ,e ) { + + } + END_CATCH; + ERROR_ASSERT( bException , "expected exception not thrown !" ); + } + + r->endCDATA(); + r->endElement( L"hi" ); + + r->endDocument(); +} + + +void OSaxWriterTest::testDTD(const XExtendedDocumentHandlerRef &r ) +{ + OFileWriter *pw = new OFileWriter("outputDTD.xml"); + AttributeListImpl *pList = new AttributeListImpl; + + XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY ); + XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY ); + + XActiveDataSourceRef source( r , USR_QUERY ); + + ERROR_ASSERT( ref.is() , "no output stream" ); + ERROR_ASSERT( source.is() , "no active data source" ); + + source->setOutputStream( ref ); + + + r->startDocument(); + r->unknown( L"<!DOCTYPE iCalendar >\n" ); + r->startElement( L"huhu" , rList ); + + r->endElement( L"huhu" ); + r->endDocument(); +} + +void OSaxWriterTest::testPerformance(const XExtendedDocumentHandlerRef &r ) +{ + OFileWriter *pw = new OFileWriter("testPerformance.xml"); + AttributeListImpl *pList = new AttributeListImpl; + + UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter " + L"wohl > Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile " + L"bis zum bitteren Ende schreibt."; + + + XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY ); + XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY ); + + XActiveDataSourceRef source( r , USR_QUERY ); + + ERROR_ASSERT( ref.is() , "no output stream" ); + ERROR_ASSERT( source.is() , "no active data source" ); + + source->setOutputStream( ref ); + + TimeValue aStartTime, aEndTime; + osl_getSystemTime( &aStartTime ); + + + r->startDocument(); + // just write a bunch of xml tags ! + // for performance testing + sal_Int32 i2; + for( i2 = 0 ; i2 < 15 ; i2 ++ ) + { + r->startElement( UString( L"tag" ) + UString::valueOf( i2 ), rList ); + for( sal_Int32 i = 0 ; i < 450 ; i ++ ) + { + r->ignorableWhitespace( L""); + r->startElement( L"huhu" , rList ); + r->characters( testParagraph ); +// writeParagraph( r , testParagraph ); + + r->ignorableWhitespace( L""); + r->endElement( L"huhu" ); + } + } + for( i2 = 14 ; i2 >= 0 ; i2-- ) + { + r->ignorableWhitespace( L""); + r->endElement( UString( L"tag" ) + UString::valueOf( i2 ) ); + } + + r->endDocument(); + + osl_getSystemTime( &aEndTime ); + + double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0); + double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0); + + printf( "Performance writing : %g s\n" , fEnd - fStart ); +} diff --git a/extensions/test/stm/datatest.cxx b/extensions/test/stm/datatest.cxx new file mode 100644 index 000000000..9cf43c7f7 --- /dev/null +++ b/extensions/test/stm/datatest.cxx @@ -0,0 +1,1108 @@ +/************************************************************************* + * + * $RCSfile: datatest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <smart/com/sun/star/test/XSimpleTest.hxx> +#include <smart/com/sun/star/io/XObjectOutputStream.hxx> +#include <smart/com/sun/star/io/XObjectInputStream.hxx> +#include <smart/com/sun/star/io/XActiveDataSink.hxx> +#include <smart/com/sun/star/io/XActiveDataSource.hxx> +#include <smart/com/sun/star/io/XConnectable.hxx> +#include <smart/com/sun/star/io/XMarkableStream.hxx> + +#include <smart/com/sun/star/lang/XServiceInfo.hxx> + +#include <smart/com/sun/star/beans/XPropertySet.hxx> + +#include <usr/services.hxx> +#include <usr/factoryhlp.hxx> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE +#include <usr/weak.hxx> // OWeakObject + +#include <vos/conditn.hxx> +#include <vos/mutex.hxx> +#include <vos/thread.hxx> + +#include <assert.h> +#include <string.h> + +#include "testfactreg.hxx" + +#ifndef _VOS_NO_NAMESPACE +using namespace vos; +using namespace usr; +#endif + +#define DATASTREAM_TEST_MAX_HANDLE 1 + +/**** +* The following test class tests XDataInputStream and XDataOutputStream at equal terms, +* so when errors occur, it may be in either one implementation. +* The class also uses stardiv.uno.io.pipe. If problems occur, make sure to run also the +* pipe test routines ( test.com.sun.star.io.pipe ). +* +* +*****/ + +class ODataStreamTest : + public XSimpleTest, + public OWeakObject +{ +public: + ODataStreamTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory ){} + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XDataInputStreamRef & , const XDataOutputStreamRef &); + +protected: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + + XMultiServiceFactoryRef m_rFactory; +}; + + +BOOL ODataStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void ODataStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.DataInputStream" == TestName ) { + XConnectableRef connect( TestObject , USR_QUERY ); + XActiveDataSinkRef active( TestObject , USR_QUERY ); + XInputStreamRef input( TestObject , USR_QUERY ); + XDataInputStreamRef dataInput( TestObject , USR_QUERY ); + + WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" ); + WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" ); + ERROR_ASSERT( input.is() , "XInputStream cannot be queried" ); + ERROR_ASSERT( dataInput.is() , "XDataInputStream cannot be queried" ); + + + } + else if( L"com.sun.star.io.DataInputStream" == TestName ) { + XConnectableRef connect( TestObject , USR_QUERY ); + XActiveDataSourceRef active( TestObject , USR_QUERY ); + XOutputStreamRef output( TestObject , USR_QUERY ); + XDataOutputStreamRef dataOutput( TestObject , USR_QUERY ); + + WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" ); + WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" ); + ERROR_ASSERT( output.is() , "XInputStream cannot be queried" ); + ERROR_ASSERT( dataOutput.is(), "XDataInputStream cannot be queried" ); + + } + + XServiceInfoRef info( TestObject, USR_QUERY ); + ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); + if( info.is() ) + { + ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); + ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" ); + } + +} + + +INT32 ODataStreamTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.DataInputStream" == TestName || + L"com.sun.star.io.DataOutputStream" == TestName ) { + + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else { + XActiveDataSinkRef rSink( TestObject, USR_QUERY ); + XActiveDataSourceRef rSource( TestObject , USR_QUERY ); + + XDataInputStreamRef rInput( TestObject , USR_QUERY ); + XDataOutputStreamRef rOutput( TestObject , USR_QUERY ); + + + XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe"); + + XInputStreamRef rPipeInput( x , USR_QUERY ); + XOutputStreamRef rPipeOutput( x , USR_QUERY ); + + if( ! rSink.is() ) { + x = m_rFactory->createInstance( L"com.sun.star.io.DataInputStream" ); + x->queryInterface( XDataInputStream::getSmartUik() , rInput ); + x->queryInterface( XActiveDataSink::getSmartUik() , rSink ); + } + else if ( !rSource.is() ) { + + x = m_rFactory->createInstance( L"com.sun.star.io.DataOutputStream" ); + x->queryInterface( XDataOutputStream::getSmartUik() , rOutput ); + x->queryInterface( XActiveDataSource::getSmartUik() , rSource ); + } + + assert( rPipeInput.is() ); + assert( rPipeOutput.is() ); + rSink->setInputStream( rPipeInput ); + rSource->setOutputStream( rPipeOutput ); + + assert( rSink->getInputStream().is() ); + assert( rSource->getOutputStream().is() ); + + if( 1 == hTestHandle ) { + testSimple( rInput , rOutput ); + } + } + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( hTestHandle >= 2) { + // all tests finished. + hTestHandle = -1; + } + } + else { + BUILD_ERROR( 0 , "service not supported by test." ); + } + return hTestHandle; +} + + + +BOOL ODataStreamTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > ODataStreamTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > ODataStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > ODataStreamTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + +void ODataStreamTest::testSimple( const XDataInputStreamRef &rInput, + const XDataOutputStreamRef &rOutput ) +{ + rOutput->writeLong( 0x34ff3c ); + rOutput->writeLong( 0x34ff3d ); + + ERROR_ASSERT( 0x34ff3c == rInput->readLong() , "long read/write mismatch" ); + ERROR_ASSERT( 0x34ff3d == rInput->readLong() , "long read/write mismatch" ); + + rOutput->writeByte( 0x87 ); + ERROR_ASSERT( 0x87 == rInput->readByte() , "byte read/write mismatch" ); + + rOutput->writeBoolean( 25 ); + ERROR_ASSERT( rInput->readBoolean() , "boolean read/write mismatch" ); + + rOutput->writeBoolean( FALSE ); + ERROR_ASSERT( ! rInput->readBoolean() , "boolean read/write mismatch" ); + + rOutput->writeFloat( (float) 42.42 ); + ERROR_ASSERT( rInput->readFloat() == ((float)42.42) , "float read/write mismatch" ); + + rOutput->writeDouble( (double) 42.42 ); + ERROR_ASSERT( rInput->readDouble() == 42.42 , "double read/write mismatch" ); + + rOutput->writeUTF( L"Live long and prosper !" ); + ERROR_ASSERT( rInput->readUTF() == L"Live long and prosper !" , + "UTF read/write mismatch" ); + + Sequence<wchar_t> wc(0x10001); + for( int i = 0 ; i < 0x10000 ; i ++ ) { + wc.getArray()[i] = L'c'; + } + wc.getArray()[0x10000] = 0; + UString str( wc.getArray() , 0x10000 ); + rOutput->writeUTF( str ); + ERROR_ASSERT( rInput->readUTF() == str , "error reading 64k block" ); + + rOutput->closeOutput(); + TRY { + rInput->readLong(); + ERROR_ASSERT( 0 , "eof-exception does not occur !" ); + } + CATCH ( IOException ,e ){ + //ok + e.getName(); + } + AND_CATCH_ALL() { + ERROR_ASSERT( 0 , "wrong exception after reading beyond eof" ); + } + END_CATCH; + + ERROR_ASSERT( ! rInput->readBytes( Sequence<BYTE> (1) , 1 ), + "stream must be on eof !" ); + + rInput->closeInput(); + + TRY { + rOutput->writeByte( 1 ); + ERROR_ASSERT( 0 , "writing still possible though chain must be interrupted" ); + } + CATCH( IOException , e ) + { + e.getName(); + // ok + } + AND_CATCH_ALL() { + ERROR_ASSERT( 0 , "IOException expected, but another exception was thrown" ); + } + END_CATCH; + +} + + + +/** +* for external binding +* +* +**/ +XInterfaceRef ODataStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + ODataStreamTest *p = new ODataStreamTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + +Sequence<UString> ODataStreamTest_getSupportedServiceNames( int i) THROWS( () ) +{ + Sequence<UString> aRet(1); + + aRet.getArray()[0] = ODataStreamTest_getImplementationName( i); + + + return aRet; +} + +UString ODataStreamTest_getServiceName( int i) THROWS( () ) +{ + if( 1 == i ) { + return L"test.com.sun.star.io.DataInputStream"; + } + else { + return L"test.com.sun.star.io.DataOutputStream"; + } +} + +UString ODataStreamTest_getImplementationName( int i) THROWS( () ) +{ + if( 1 == i ) { + return L"test.com.sun.star.comp.extensions.stm.DataInputStream"; + } + else { + return L"test.com.sun.star.comp.extensions.stm.DataOutputStream"; + } +} + + +/**------------------------------------------------------ +* +* +* +* +* +*------------------------------------------------------*/ +class MyPersistObject : + public XPersistObject, + public XPropertySet, + public OWeakObject +{ +public: + MyPersistObject( ) : m_sServiceName( OMyPersistObject_getServiceName() ) + {} + MyPersistObject( const UString & sServiceName ) : m_sServiceName( sServiceName ) + {} + ~MyPersistObject() + {} + +public: + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: + virtual UString getServiceName(void) const THROWS( (UsrSystemException) ); + virtual void write(const XObjectOutputStreamRef& OutStream) THROWS( (IOException, UsrSystemException) ); + virtual void read(const XObjectInputStreamRef& InStream) THROWS( (IOException, UsrSystemException) ); + +public: + + virtual XPropertySetInfoRef getPropertySetInfo(void) const THROWS( (UsrSystemException) ); + virtual void setPropertyValue(const UString& aPropertyName, const UsrAny& aValue) + THROWS( ( UnknownPropertyException, + PropertyVetoException, + IllegalArgumentException, + WrappedTargetException, + UsrSystemException) ); + virtual UsrAny getPropertyValue(const UString& PropertyName) const + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ); + virtual void addPropertyChangeListener( const UString& aPropertyName, + const XPropertyChangeListenerRef& xListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ); + virtual void removePropertyChangeListener( const UString& aPropertyName, + const XPropertyChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ); + virtual void addVetoableChangeListener( const UString& PropertyName, + const XVetoableChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ); + virtual void removeVetoableChangeListener( const UString& PropertyName, + const XVetoableChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ); + +public: + INT32 m_l; + float m_f; + double m_d; + BOOL m_b; + BYTE m_byte; + wchar_t m_c; + UString m_s; + XPersistObjectRef m_ref; + UString m_sServiceName; +}; + + + +XPropertySetInfoRef MyPersistObject::getPropertySetInfo(void) const THROWS( (UsrSystemException) ) +{ + return XPropertySetInfoRef(); +} + +void MyPersistObject::setPropertyValue(const UString& aPropertyName, const UsrAny& aValue) + THROWS( ( UnknownPropertyException, + PropertyVetoException, + IllegalArgumentException, + WrappedTargetException, + UsrSystemException) ) +{ + if( L"long" == aPropertyName ) { + m_l = aValue.getINT32(); + } + else if ( L"float" == aPropertyName ) { + m_f = aValue.getFloat(); + } + else if( L"double" == aPropertyName ) { + m_d = aValue.getDouble(); + } + else if( L"bool" == aPropertyName ) { + m_b = aValue.getBOOL(); + } + else if( L"byte" == aPropertyName ) { + m_byte = aValue.getBYTE(); + } + else if( L"char" == aPropertyName ) { + m_c = aValue.getChar(); + } + else if( L"string" == aPropertyName ) { + m_s = aValue.getString(); + } + else if( L"object" == aPropertyName ) { + if( aValue.getReflection() == XPersistObject_getReflection() ) { + XPersistObjectRef *pRef = (XPersistObjectRef*) aValue.get(); + if( pRef ) { + m_ref = *pRef; + } + else { + m_ref = 0; + } + } + else + { + m_ref = 0; + } + } +} + + +UsrAny MyPersistObject::getPropertyValue(const UString& aPropertyName) const + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ) +{ + UsrAny aValue; + if( L"long" == aPropertyName ) { + aValue.setINT32( m_l ); + } + else if ( L"float" == aPropertyName ) { + aValue.setFloat( m_f ); + } + else if( L"double" == aPropertyName ) { + aValue.setDouble( m_d ); + } + else if( L"bool" == aPropertyName ) { + aValue.setBOOL( m_b ); + } + else if( L"byte" == aPropertyName ) { + aValue.setBYTE( m_byte ); + } + else if( L"char" == aPropertyName ) { + aValue.setChar( m_c ); + } + else if( L"string" == aPropertyName ) { + aValue.setString( m_s ); + } + else if( L"object" == aPropertyName ) { + aValue.set( &m_ref , XPersistObject_getReflection() ); + } + return aValue; +} + + +void MyPersistObject::addPropertyChangeListener( const UString& aPropertyName, + const XPropertyChangeListenerRef& xListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ) +{ + +} + +void MyPersistObject::removePropertyChangeListener( const UString& aPropertyName, + const XPropertyChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ) +{ +} +void MyPersistObject::addVetoableChangeListener(const UString& PropertyName, + const XVetoableChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ) +{ + +} + +void MyPersistObject::removeVetoableChangeListener( const UString& PropertyName, + const XVetoableChangeListenerRef& aListener) + THROWS( ( UnknownPropertyException, + WrappedTargetException, + UsrSystemException) ) +{ + +} + + + +BOOL MyPersistObject::queryInterface( Uik aUik , XInterfaceRef &rOut ) +{ + if( XPersistObject::getSmartUik() == aUik ) { + rOut = ( XPersistObject * ) this; + } + else if( XPropertySet::getSmartUik() == aUik ) { + rOut = ( XPropertySet * ) this; + } + else + return OWeakObject::queryInterface( aUik , rOut ); + + return TRUE; +} + +UString MyPersistObject::getServiceName() const THROWS( (UsrSystemException) ) +{ + return m_sServiceName; +} + +void MyPersistObject::write( const XObjectOutputStreamRef & rOut ) + THROWS( (IOException,UsrSystemException)) +{ + rOut->writeLong( m_l); + rOut->writeFloat( m_f ); + rOut->writeDouble( m_d ); + rOut->writeBoolean( m_b ); + rOut->writeByte( m_byte ); + rOut->writeChar( m_c ); + rOut->writeUTF( m_s ); + rOut->writeObject( m_ref ); +} + + +void MyPersistObject::read( const XObjectInputStreamRef & rIn ) + THROWS( (IOException, UsrSystemException) ) +{ + m_l = rIn->readLong(); + m_f = rIn->readFloat(); + m_d = rIn->readDouble(); + m_b = rIn->readBoolean(); + m_byte = rIn->readByte(); + m_c = rIn->readChar(); + m_s = rIn->readUTF(); + m_ref = rIn->readObject(); +} + +XInterfaceRef OMyPersistObject_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) + THROWS((Exception)) +{ + MyPersistObject *p = new MyPersistObject( ); + XInterfaceRef xService = *p; + return xService; +} + +Sequence<UString> OMyPersistObject_getSupportedServiceNames( ) THROWS( () ) +{ + Sequence<UString> aRet(1); + aRet.getArray()[0] = OMyPersistObject_getImplementationName(); + return aRet; +} + +UString OMyPersistObject_getServiceName( ) THROWS( () ) +{ + return L"test.com.sun.star.io.PersistTest"; +} + +UString OMyPersistObject_getImplementationName( ) THROWS( () ) +{ + return L"test.com.sun.star.io.PersistTest"; +} + + +// --------------------------------------------- +// ----------------------------------------------- +class OObjectStreamTest : + public ODataStreamTest +{ +public: + OObjectStreamTest( const XMultiServiceFactoryRef &r) : ODataStreamTest(r) {} +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + +private: + void OObjectStreamTest::testObject( const XObjectOutputStreamRef &rOut, + const XObjectInputStreamRef &rIn ); + +private: +}; + + + + +BOOL OObjectStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return ODataStreamTest::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OObjectStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + + + if( L"com.sun.star.io.ObjectInputStream" == TestName ) { + ODataStreamTest::testInvariant( TestName , TestObject ); + XObjectInputStreamRef dataInput( TestObject , USR_QUERY ); + XMarkableStreamRef markable( TestObject , USR_QUERY ); + ERROR_ASSERT( dataInput.is() , "XObjectInputStream cannot be queried" ); + ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" ); + } + else if( L"com.sun.star.io.ObjectOutputStream" == TestName ) { + ODataStreamTest::testInvariant( TestName , TestObject ); + XMarkableStreamRef markable( TestObject , USR_QUERY ); + XObjectOutputStreamRef dataOutput( TestObject , USR_QUERY ); + ERROR_ASSERT( dataOutput.is(), "XObjectOutputStream cannot be queried" ); + ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" ); + } + + XServiceInfoRef info( TestObject, USR_QUERY ); + ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); + if( info.is() ) + { + ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); + ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" ); + } + +} + +INT32 OObjectStreamTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.ObjectInputStream" == TestName || + L"com.sun.star.io.ObjectOutputStream" == TestName ) { + + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else if( DATASTREAM_TEST_MAX_HANDLE >= hTestHandle ) { + INT32 hOldHandle = hTestHandle; + hTestHandle = ODataStreamTest::test( L"com.sun.star.io.DataInputStream" , + TestObject , hTestHandle ); + if( hTestHandle == -1 ){ + hTestHandle = hOldHandle; + } + } + else { + + XActiveDataSinkRef rSink( TestObject, USR_QUERY ); + XActiveDataSourceRef rSource( TestObject , USR_QUERY ); + + XObjectInputStreamRef rInput( TestObject , USR_QUERY ); + XObjectOutputStreamRef rOutput( TestObject , USR_QUERY ); + + + XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe"); + + XInputStreamRef rPipeInput( x , USR_QUERY ); + XOutputStreamRef rPipeOutput( x , USR_QUERY ); + + x = m_rFactory->createInstance( L"com.sun.star.io.MarkableInputStream" ); + XInputStreamRef markableInput( x , USR_QUERY ); + XActiveDataSinkRef markableSink( x , USR_QUERY ); + + x = m_rFactory->createInstance( L"com.sun.star.io.MarkableOutputStream" ); + XOutputStreamRef markableOutput( x , USR_QUERY ); + XActiveDataSourceRef markableSource( x , USR_QUERY ); + + assert( markableInput.is() ); + assert( markableOutput.is() ); + assert( markableSink.is() ); + assert( markableSource.is() ); + + markableSink->setInputStream( rPipeInput ); + markableSource->setOutputStream( rPipeOutput ); + + if( ! rSink.is() ) { + x = m_rFactory->createInstance( L"com.sun.star.io.ObjectInputStream" ); + x->queryInterface( XObjectInputStream::getSmartUik() , rInput ); + x->queryInterface( XActiveDataSink::getSmartUik() , rSink ); + } + else if ( !rSource.is() ) { + x = m_rFactory->createInstance( L"com.sun.star.io.ObjectOutputStream" ); + x->queryInterface( XObjectOutputStream::getSmartUik() , rOutput ); + x->queryInterface( XActiveDataSource::getSmartUik() , rSource ); + } + + assert( rPipeInput.is() ); + assert( rPipeOutput.is() ); + + rSink->setInputStream( markableInput ); + rSource->setOutputStream( markableOutput ); + + assert( rSink->getInputStream().is() ); + assert( rSource->getOutputStream().is() ); + + if( 1 + DATASTREAM_TEST_MAX_HANDLE == hTestHandle ) { + testObject( rOutput , rInput); + } + rInput->closeInput(); + rOutput->closeOutput(); + + } + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( hTestHandle > 1 +DATASTREAM_TEST_MAX_HANDLE ) { + // all tests finished. + hTestHandle = -1; + } + } + else { + BUILD_ERROR( 0 , "service not supported by test." ); + } + return hTestHandle; +} + + +BOOL compareMyPropertySet( XPropertySetRef &r1 , XPropertySetRef &r2 ) +{ + BOOL b = TRUE; + + if( r1->getPropertyValue( L"long" ).getReflection() == Void_getReflection() || + r2->getPropertyValue( L"long" ).getReflection() == Void_getReflection() ) { + + // one of the objects is not the correct propertyset ! + return FALSE; + } + + b = b && ( r1->getPropertyValue( L"long" ).getINT32() == + r2->getPropertyValue( L"long" ).getINT32() ); + + b = b && ( r1->getPropertyValue( L"float" ).getFloat() == + r2->getPropertyValue( L"float" ).getFloat() ); + + b = b && ( r1->getPropertyValue( L"double" ).getDouble() == + r2->getPropertyValue( L"double" ).getDouble() ); + + b = b && ( r1->getPropertyValue( L"bool" ).getBOOL() == + r2->getPropertyValue( L"bool" ).getBOOL() ); + + b = b && ( r1->getPropertyValue( L"byte" ).getBYTE() == + r2->getPropertyValue( L"byte" ).getBYTE() ); + + b = b && ( r1->getPropertyValue( L"char" ).getChar() == + r2->getPropertyValue( L"char" ).getChar() ); + + b = b && ( r1->getPropertyValue( L"string" ).getString() == + r2->getPropertyValue( L"string" ).getString() ); + + UsrAny o1 = r1->getPropertyValue( L"object" ); + UsrAny o2 = r2->getPropertyValue( L"object" ); + + if( o1.getReflection() == XPersistObject_getReflection() ) { + + if( o2.getReflection() == XPersistObject_getReflection() ) { + XPersistObjectRef rPersist1 = *((XPersistObjectRef*) o1.get()); + XPersistObjectRef rPersist2 = *((XPersistObjectRef*) o2.get()); + XPropertySetRef rProp1( rPersist1 , USR_QUERY ); + XPropertySetRef rProp2( rPersist2 , USR_QUERY ); + + if( rProp1.is() && rProp2.is() && ! ( rProp1 == rProp2 ) + &&( rProp1 != r1 )) { + compareMyPropertySet( rProp1 , rProp2 ); + } + } + else { + b = FALSE; + } + } + else { + if( o2.getReflection() == XPersistObject_getReflection() ) { + b = FALSE; + } + } + + return b; +} + +void OObjectStreamTest::testObject( const XObjectOutputStreamRef &rOut, + const XObjectInputStreamRef &rIn ) +{ + ERROR_ASSERT( rOut.is() , "no objectOutputStream" ); + ERROR_ASSERT( rIn.is() , "no objectInputStream" ); + + XMultiServiceFactoryRef xProv = getProcessServiceManager(); + ERROR_ASSERT( xProv.is() , "no global service manager" ); + + + // tests, if saving an object with an unknown service name allows + // reading the data behind the object ! + { + XInterfaceRef x = * new MyPersistObject( L"bla blubs" ); + + XPersistObjectRef persistRef( x , USR_QUERY ); + ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" ); + + rOut->writeObject( persistRef ); + rOut->writeLong( (INT32) 0xdeadbeef ); + + ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); + + TRY + { + XPersistObjectRef xReadPersistRef = rIn->readObject(); + ERROR_ASSERT( 0 , "expected exception not thrown" ); + } + CATCH( IOException , e ) + { + // all is ok + } + + ERROR_ASSERT( (INT32) 0xdeadbeef == rIn->readLong() , + "wrong data after object with unknown service name." ); + } + + { + XInterfaceRef x = xProv->createInstance(L"test.com.sun.star.io.PersistTest"); + XPersistObjectRef persistRef( x , USR_QUERY ); + + ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" ); + + XPropertySetRef rProp( persistRef , USR_QUERY ); + ERROR_ASSERT( rProp.is() , "test object is no property set " ); + + UsrAny any; + any.setINT32( 0x83482 ); + rProp->setPropertyValue( L"long" , any ); + + any.setFloat( 42.23 ); + rProp->setPropertyValue( L"float" , any ); + + any.setDouble( 233.321412 ); + rProp->setPropertyValue( L"double" , any ); + + any.setBOOL( TRUE ); + rProp->setPropertyValue( L"bool" , any ); + + any.setBYTE( 130 ); + rProp->setPropertyValue( L"byte" , any ); + + any.setChar( 'h' ); + rProp->setPropertyValue( L"char" , any ); + + any.setString( L"hi du !" ); + rProp->setPropertyValue( L"string" , any ); + + any.set( &persistRef, XPersistObject_getReflection() ); // try a self reference + rProp->setPropertyValue( L"object" , any ); + + // do read and write + rOut->writeObject( persistRef ); + ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); + XPersistObjectRef xReadPersistRef = rIn->readObject( ); + + XPropertySetRef rPropRead( xReadPersistRef , USR_QUERY ); + ERROR_ASSERT( compareMyPropertySet( rProp , rPropRead ) , "objects has not been read properly !" ); + + // destroy selfreferences + rProp->setPropertyValue( L"object", UsrAny() ); + rPropRead->setPropertyValue( L"object", UsrAny() ); + } + + { + XMarkableStreamRef markableOut( rOut , USR_QUERY ); + ERROR_ASSERT( markableOut.is() , "markable stream cannot be queried" ); + + // do the same thing multiple times to check if + // buffering and marks work correctly + for( int i = 0 ; i < 2000 ; i ++ ) { + + XInterfaceRef x = xProv->createInstance(L"test.com.sun.star.io.PersistTest"); + XPersistObjectRef persistRef( x , USR_QUERY ); + + XPropertySetRef rProp( persistRef , USR_QUERY ); + ERROR_ASSERT( rProp.is() , "test object is no property set " ); + + UsrAny any; + any.setINT32( 0x83482 ); + rProp->setPropertyValue( L"long" , any ); + + any.setFloat( 42.23 ); + rProp->setPropertyValue( L"float" , any ); + + any.setDouble( 233.321412 ); + rProp->setPropertyValue( L"double" , any ); + + any.setBOOL( TRUE ); + rProp->setPropertyValue( L"bool" , any ); + + any.setBYTE( 130 ); + rProp->setPropertyValue( L"byte" , any ); + + any.setChar( 'h' ); + rProp->setPropertyValue( L"char" , any ); + + any.setString( L"hi du !" ); + rProp->setPropertyValue( L"string" , any ); + + + x = xProv->createInstance(L"test.com.sun.star.io.PersistTest"); + XPersistObjectRef persist2ndRef( x , USR_QUERY ); + + + // Note : persist2ndRef contains coincident values, but also coincident values must be + // saved properly ! + any.set( &persist2ndRef, XPersistObject_getReflection() ); // try a self reference + rProp->setPropertyValue( L"object" , any ); + + // simply test, if markable operations and object operations do not interfere + INT32 nMark = markableOut->createMark(); + + // do read and write + rOut->writeObject( persistRef ); + + // further markable tests ! + INT32 nOffset = markableOut->offsetToMark( nMark ); + markableOut->jumpToMark( nMark ); + markableOut->deleteMark( nMark ); + markableOut->jumpToFurthest(); + + + + + + ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" ); + XPersistObjectRef xReadPersistRef = rIn->readObject( ); + + XPropertySetRef rProp1( persistRef , USR_QUERY ); + XPropertySetRef rProp2( xReadPersistRef , USR_QUERY ); + ERROR_ASSERT( compareMyPropertySet( rProp1, rProp2) , "objects has not been read properly !" ); + } + } +} + + +XInterfaceRef OObjectStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OObjectStreamTest *p = new OObjectStreamTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + +Sequence<UString> OObjectStreamTest_getSupportedServiceNames( int i) THROWS( () ) +{ + Sequence<UString> aRet(1); + aRet.getArray()[0] = OObjectStreamTest_getImplementationName( i); + return aRet; +} + +UString OObjectStreamTest_getServiceName( int i) THROWS( () ) +{ + if( 1 == i ) { + return L"test.com.sun.star.io.ObjectInputStream"; + } + else { + return L"test.com.sun.star.io.ObjectOutputStream"; + } +} + +UString OObjectStreamTest_getImplementationName( int i) THROWS( () ) +{ + if( 1 == i ) { + return L"test.com.sun.star.comp.extensions.stm.ObjectInputStream"; + } + else { + return L"test.com.sun.star.comp.extensions.stm.ObjectOutputStream"; + } +} + + diff --git a/extensions/test/stm/exports.dxp b/extensions/test/stm/exports.dxp new file mode 100644 index 000000000..e4bc69d23 --- /dev/null +++ b/extensions/test/stm/exports.dxp @@ -0,0 +1,2 @@ +exService_writeRegEntry +exService_getFactory diff --git a/extensions/test/stm/makefile.mk b/extensions/test/stm/makefile.mk new file mode 100644 index 000000000..f2781bca5 --- /dev/null +++ b/extensions/test/stm/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (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.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=extensions +TARGET=teststm +USE_DEFFILE=TRUE +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- +OBJFILES= $(SLO)$/pipetest.obj $(SLO)$/testfactreg.obj $(SLO)$/datatest.obj \ + $(SLO)$/marktest.obj +CXXFILES = pipetest.cxx testfactreg.cxx datatest.cxx marktest.cxx + +SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX) +LIB1TARGET= $(SLB)$/$(TARGET).lib + +SHL1STDLIBS= \ + $(USRLIB) \ + $(VOSLIB) \ + $(SALLIB) \ + $(TOOLSLIB) + +LIB1OBJFILES= $(OBJFILES) +SHL1LIBS= $(LIB1TARGET) +SHL1IMPLIB= i$(TARGET) +SHL1DEPN= makefile.mk $(SHL1LIBS) +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/extensions/test/stm/marktest.cxx b/extensions/test/stm/marktest.cxx new file mode 100644 index 000000000..34569f20b --- /dev/null +++ b/extensions/test/stm/marktest.cxx @@ -0,0 +1,718 @@ +/************************************************************************* + * + * $RCSfile: marktest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <smart/com/sun/star/test/XSimpleTest.hxx> +#include <smart/com/sun/star/io/XMarkableStream.hxx> +#include <smart/com/sun/star/io/XActiveDataSink.hxx> +#include <smart/com/sun/star/io/XActiveDataSource.hxx> +#include <smart/com/sun/star/io/XConnectable.hxx> + +#include <smart/com/sun/star/lang/XServiceInfo.hxx> + + +#include <usr/factoryhlp.hxx> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE +#include <usr/weak.hxx> // OWeakObject + +#include <vos/conditn.hxx> +#include <vos/mutex.hxx> +#include <vos/thread.hxx> + +#include <assert.h> +#include <string.h> + +#include "testfactreg.hxx" + + +#ifndef _VOS_NO_NAMESPACE +using namespace vos; +using namespace usr; +#endif + + + +class OMarkableOutputStreamTest : + public XSimpleTest, + public OWeakObject +{ +public: + OMarkableOutputStreamTest( const XMultiServiceFactoryRef & rFactory ); + ~OMarkableOutputStreamTest(); + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: // implementation names + static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () ); + static UString getImplementationName_Static() THROWS( () ); + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XOutputStreamRef &r, const XInputStreamRef &rInput ); + +private: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + XMultiServiceFactoryRef m_rFactory; + +}; + +OMarkableOutputStreamTest::OMarkableOutputStreamTest( const XMultiServiceFactoryRef &rFactory ) + : m_rFactory( rFactory ) +{ + +} + +OMarkableOutputStreamTest::~OMarkableOutputStreamTest() +{ + +} + + +BOOL OMarkableOutputStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OMarkableOutputStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + XServiceInfoRef info( TestObject, USR_QUERY ); + ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); + if( info.is() ) + { + ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); + ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" ); + } +} + + +INT32 OMarkableOutputStreamTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.MarkableOutputStream" == TestName ) { + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else { + XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe"); + XOutputStreamRef rPipeOutput( x , USR_QUERY ); + XInputStreamRef rPipeInput( x , USR_QUERY ); + + XActiveDataSourceRef source( TestObject , USR_QUERY ); + source->setOutputStream( rPipeOutput ); + + XOutputStreamRef rOutput( TestObject , USR_QUERY ); + + assert( rPipeInput.is() ); + assert( rOutput.is() ); + if( 1 == hTestHandle ) { + // checks usual streaming + testSimple( rOutput , rPipeInput ); + } + } + + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( 2 == hTestHandle ) { + // all tests finished. + hTestHandle = -1; + } + } + else { + THROW( IllegalArgumentException() ); + } + return hTestHandle; +} + + + +BOOL OMarkableOutputStreamTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > OMarkableOutputStreamTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > OMarkableOutputStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > OMarkableOutputStreamTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + + +void OMarkableOutputStreamTest::testSimple( const XOutputStreamRef &rOutput , + const XInputStreamRef &rInput ) +{ + XMarkableStreamRef rMarkable( rOutput , USR_QUERY ); + + ERROR_ASSERT( rMarkable.is() , "no MarkableStream implemented" ); + + // first check normal input/output facility + char pcStr[] = "Live long and prosper !"; + + Sequence<BYTE> seqWrite( strlen( pcStr )+1 ); + memcpy( seqWrite.getArray() , pcStr , seqWrite.getLen() ); + + Sequence<BYTE> seqRead( seqWrite.getLen() ); + + int nMax = 10,i; + + for( i = 0 ; i < nMax ; i ++ ) { + rOutput->writeBytes( seqWrite ); + rInput->readBytes( seqRead , rInput->available() ); + ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , + "error during read/write/skip" ); + } + + // Check buffer resizing + nMax = 3000; + for( i = 0 ; i < nMax ; i ++ ) { + rOutput->writeBytes( seqWrite ); + } + + for( i = 0 ; i < nMax ; i ++ ) { + rInput->readBytes( seqRead , seqWrite.getLen() ); + ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , + "error during read/write" ); + } + + // Check creating marks ! + INT32 nMark = rMarkable->createMark(); + + for( i = 0 ; i < nMax ; i ++ ) { + rOutput->writeBytes( seqWrite ); + } + + ERROR_ASSERT( 0 == rInput->available() , "bytes available though mark is holded" ); + + ERROR_ASSERT( nMax*seqWrite.getLen() == rMarkable->offsetToMark( nMark ) , + "offsetToMark failure" ); + + rMarkable->deleteMark( nMark ); + ERROR_ASSERT( nMax*seqWrite.getLen() == rInput->available(),"bytes are not available though mark has been deleted" ); + + rInput->skipBytes( nMax*seqWrite.getLen() ); + ERROR_ASSERT( 0 == rInput->available(), "skip bytes failure" ); + + TRY { + rMarkable->jumpToMark( nMark ); + ERROR_ASSERT( 0 , "jump to non existing mark possible !" ); + } + CATCH ( IllegalArgumentException , e ) + { + e;// ok, exception was thrown + } + END_CATCH; + + // test putting marks not at the end of the stream! + ERROR_ASSERT( 0 == rInput->available(), "stream isn't clean" ); + { + Sequence< BYTE > aByte(256); + + for( i = 0 ; i < 256 ; i ++ ) + { + aByte.getArray()[i] = i; + } + INT32 nMark1 = rMarkable->createMark(); + + rOutput->writeBytes( aByte ); + rMarkable->jumpToMark( nMark1 ); + aByte.realloc( 10 ); + rOutput->writeBytes( aByte ); + + INT32 nMark2 = rMarkable->createMark( ); + + for( i = 0 ; i < 10 ; i ++ ) + { + aByte.getArray()[i] = i+10; + } + + rOutput->writeBytes( aByte ); + + // allow the bytes to be written ! + rMarkable->jumpToFurthest(); + rMarkable->deleteMark( nMark1 ); + rMarkable->deleteMark( nMark2 ); + + ERROR_ASSERT( 256 == rInput->available(), "in between mark failure" ); + rInput->readBytes( aByte ,256); + for( i = 0 ; i < 256 ; i ++ ) + { + ERROR_ASSERT( i == aByte.getArray()[i] , "in between mark failure" ); + } + } + + { + // now a more extensive mark test ! + Sequence<BYTE> as[4]; + INT32 an[4]; + + for( i = 0 ; i < 4 ; i ++ ) { + as[i].realloc(1); + as[i].getArray()[0] = i; + an[i] = rMarkable->createMark(); + rOutput->writeBytes( as[i] ); + } + + // check offset to mark + for( i = 0 ; i < 4 ; i ++ ) { + ERROR_ASSERT( rMarkable->offsetToMark( an[i] ) == 4-i , "offsetToMark failure" ); + } + + rMarkable->jumpToMark( an[1] ); + ERROR_ASSERT( rMarkable->offsetToMark( an[3] ) == -2 , "offsetToMark failure" ); + + rMarkable->jumpToFurthest( ); + ERROR_ASSERT( rMarkable->offsetToMark( an[0] ) == 4 , "offsetToMark failure" ); + + // now do a rewrite ! + for( i = 0 ; i < 4 ; i ++ ) { + rMarkable->jumpToMark( an[3-i] ); + rOutput->writeBytes( as[i] ); + } + // NOTE : CursorPos 1 + + // now delete the marks ! + for( i = 0 ; i < 4 ; i ++ ) { + rMarkable->deleteMark( an[i] ); + } + ERROR_ASSERT( rInput->available() == 1 , "wrong number of bytes flushed" ); + + rMarkable->jumpToFurthest(); + + ERROR_ASSERT( rInput->available() == 4 , "wrong number of bytes flushed" ); + + rInput->readBytes( seqRead , 4 ); + + ERROR_ASSERT( 3 == seqRead.getArray()[0] , "rewrite didn't work" ); + ERROR_ASSERT( 2 == seqRead.getArray()[1] , "rewrite didn't work" ); + ERROR_ASSERT( 1 == seqRead.getArray()[2] , "rewrite didn't work" ); + ERROR_ASSERT( 0 == seqRead.getArray()[3] , "rewrite didn't work" ); + + rOutput->closeOutput(); + rInput->closeInput(); + } + +} + +/*** +* the test methods +* +****/ + + + + + +/** +* for external binding +* +* +**/ +XInterfaceRef OMarkableOutputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OMarkableOutputStreamTest *p = new OMarkableOutputStreamTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + + + +Sequence<UString> OMarkableOutputStreamTest_getSupportedServiceNames(void) THROWS( () ) +{ + Sequence<UString> aRet(1); + aRet.getArray()[0] = OMarkableOutputStreamTest_getImplementationName(); + + return aRet; +} + +UString OMarkableOutputStreamTest_getServiceName() THROWS( () ) +{ + return L"test.com.sun.star.io.MarkableOutputStream"; +} + +UString OMarkableOutputStreamTest_getImplementationName() THROWS( () ) +{ + return L"test.com.sun.starextensions.stm.MarkableOutputStream"; +} + + + + + + + +//----------------------------------------------------- +// Input stream + + +class OMarkableInputStreamTest : + public XSimpleTest, + public OWeakObject +{ +public: + OMarkableInputStreamTest( const XMultiServiceFactoryRef & rFactory ); + ~OMarkableInputStreamTest(); + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: // implementation names + static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () ); + static UString getImplementationName_Static() THROWS( () ); + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XOutputStreamRef &r, const XInputStreamRef &rInput ); + +private: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + XMultiServiceFactoryRef m_rFactory; + +}; + +OMarkableInputStreamTest::OMarkableInputStreamTest( const XMultiServiceFactoryRef &rFactory ) + : m_rFactory( rFactory ) +{ + +} + +OMarkableInputStreamTest::~OMarkableInputStreamTest() +{ + +} + + +BOOL OMarkableInputStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OMarkableInputStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.MarkableInputStream" == TestName ) { + XServiceInfoRef info( TestObject, USR_QUERY ); + ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); + if( info.is() ) + { + ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); + ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" ); + } + } + else { + THROW( IllegalArgumentException() ); + } +} + + +INT32 OMarkableInputStreamTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.MarkableInputStream" == TestName ) { + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else { + XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe"); + XOutputStreamRef rPipeOutput( x , USR_QUERY ); + XInputStreamRef rPipeInput( x , USR_QUERY ); + + XActiveDataSinkRef sink( TestObject , USR_QUERY ); + sink->setInputStream( rPipeInput ); + + XInputStreamRef rInput( TestObject , USR_QUERY ); + + assert( rPipeOutput.is() ); + assert( rInput.is() ); + if( 1 == hTestHandle ) { + // checks usual streaming + testSimple( rPipeOutput , rInput ); + } + } + + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( 2 == hTestHandle ) { + // all tests finished. + hTestHandle = -1; + } + } + else { + THROW( IllegalArgumentException() ); + } + return hTestHandle; +} + + + +BOOL OMarkableInputStreamTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > OMarkableInputStreamTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > OMarkableInputStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > OMarkableInputStreamTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + + +void OMarkableInputStreamTest::testSimple( const XOutputStreamRef &rOutput , + const XInputStreamRef &rInput ) +{ + XMarkableStreamRef rMarkable( rInput , USR_QUERY ); + + Sequence<BYTE> seqWrite( 256 ); + Sequence<BYTE> seqRead(10); + + for( int i = 0 ; i < 256 ; i ++ ) + { + seqWrite.getArray()[i] = i; + } + + rOutput->writeBytes( seqWrite ); + ERROR_ASSERT( 256 == rInput->available() , "basic read/write failure" ); + + rInput->readBytes( seqRead , 10 ); + ERROR_ASSERT( 9 == seqRead.getArray()[9] , "basic read/write failure" ); + + INT32 nMark = rMarkable->createMark(); + + rInput->skipBytes( 50 ); + ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" ); + ERROR_ASSERT( 50 == rMarkable->offsetToMark( nMark ) , "marking error" ); + + rMarkable->jumpToMark( nMark ); + ERROR_ASSERT( 256-10 == rInput->available() , "marking error" ); + + rInput->readBytes( seqRead , 10 ); + ERROR_ASSERT( 10 == seqRead.getArray()[0] , "marking error" ); + + // pos 20 + { + INT32 nInBetweenMark = rMarkable->createMark( ); + rMarkable->jumpToMark( nMark ); + rMarkable->jumpToMark( nInBetweenMark ); + + rInput->readBytes( seqRead , 10 ); + ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" ); + + rMarkable->deleteMark( nMark ); + + // Check if releasing the first bytes works correct. + rMarkable->jumpToMark( nInBetweenMark); + rInput->readBytes( seqRead , 10 ); + ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" ); + + rMarkable->deleteMark( nInBetweenMark ); + } + + rMarkable->jumpToFurthest(); + ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" ); + + + ERROR_ASSERT( 100 == rInput->readSomeBytes( seqRead , 100 ) , "wrong results using readSomeBytes" ); + ERROR_ASSERT( 96 == rInput->readSomeBytes( seqRead , 1000) , "wrong results using readSomeBytes" ); + rOutput->closeOutput(); + rInput->closeInput(); +} + +/*** +* the test methods +* +****/ + + + + + +/** +* for external binding +* +* +**/ +XInterfaceRef OMarkableInputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OMarkableInputStreamTest *p = new OMarkableInputStreamTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + + + +Sequence<UString> OMarkableInputStreamTest_getSupportedServiceNames(void) THROWS( () ) +{ + Sequence<UString> aRet(1); + aRet.getArray()[0] = OMarkableInputStreamTest_getImplementationName(); + + return aRet; +} + +UString OMarkableInputStreamTest_getServiceName() THROWS( () ) +{ + return L"test.com.sun.star.io.MarkableInputStream"; +} + +UString OMarkableInputStreamTest_getImplementationName() THROWS( () ) +{ + return L"test.com.sun.star.extensions.stm.MarkableInputStream"; +} diff --git a/extensions/test/stm/pipetest.cxx b/extensions/test/stm/pipetest.cxx new file mode 100644 index 000000000..7b65813ed --- /dev/null +++ b/extensions/test/stm/pipetest.cxx @@ -0,0 +1,483 @@ +/************************************************************************* + * + * $RCSfile: pipetest.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <smart/com/sun/star/test/XSimpleTest.hxx> +#include <smart/com/sun/star/io/XOutputStream.hxx> +#include <smart/com/sun/star/io/XInputStream.hxx> + +#include <smart/com/sun/star/lang/XServiceInfo.hxx> + +#include <usr/factoryhlp.hxx> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE +#include <usr/weak.hxx> // OWeakObject + +#include <vos/conditn.hxx> +#include <vos/mutex.hxx> +#include <vos/thread.hxx> + +#include <assert.h> +#include <string.h> + +#include "testfactreg.hxx" +#define IMPLEMENTATION_NAME L"test.com.sun.star.comp.extensions.stm.Pipe" +#define SERVICE_NAME L"test.com.sun.star.io.Pipe" + +#ifndef _VOS_NO_NAMESPACE +using namespace vos; +using namespace usr; +#endif + +class WriteToStreamThread : + public OThread +{ + +public: + + WriteToStreamThread( XOutputStreamRef xOutput , int iMax ) + { + m_output = xOutput; + m_iMax = iMax; + } + + virtual ~WriteToStreamThread() {} + + +protected: + + /// Working method which should be overridden. + virtual void run() { + for( int i = 0 ; i < m_iMax ; i ++ ) { + m_output->writeBytes( createIntSeq(i) ); + } + m_output->closeOutput(); + } + + /** Called when run() is done. + * You might want to override it to do some cleanup. + */ + virtual void onTerminated() + { + delete this; + } + + +private: + + XOutputStreamRef m_output; + int m_iMax; +}; + + + +class OPipeTest : + public XSimpleTest, + public OWeakObject +{ +public: + OPipeTest( const XMultiServiceFactoryRef & rFactory ); + ~OPipeTest(); + +public: // refcounting + BOOL queryInterface( Uik aUik, XInterfaceRef & rOut ); + void acquire() { OWeakObject::acquire(); } + void release() { OWeakObject::release(); } + void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); } + +public: // implementation names + static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () ); + static UString getImplementationName_Static() THROWS( () ); + +public: + virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject) + THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual INT32 test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ); + + virtual BOOL testPassed(void) THROWS( ( UsrSystemException) ); + virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) ); + virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) ); + virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) ); + +private: + void testSimple( const XInterfaceRef & ); + void testBufferResizing( const XInterfaceRef & ); + void testMultithreading( const XInterfaceRef & ); + +private: + Sequence<UsrAny> m_seqExceptions; + Sequence<UString> m_seqErrors; + Sequence<UString> m_seqWarnings; + +}; + + + +OPipeTest::OPipeTest( const XMultiServiceFactoryRef &rFactory ) +{ + +} + +OPipeTest::~OPipeTest() +{ + +} + + +BOOL OPipeTest::queryInterface( Uik uik , XInterfaceRef &rOut ) +{ + if( XSimpleTest::getSmartUik() == uik ) { + rOut = (XSimpleTest *) this; + } + else { + return OWeakObject::queryInterface( uik , rOut ); + } + return TRUE; +} + + +void OPipeTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject ) + THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + XServiceInfoRef info( TestObject, USR_QUERY ); + ERROR_ASSERT( info.is() , "XServiceInfo not supported !" ); + if( info.is() ) + { + ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" ); + ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" ); + } + +} + + +INT32 OPipeTest::test( const UString& TestName, + const XInterfaceRef& TestObject, + INT32 hTestHandle) THROWS( ( IllegalArgumentException, + UsrSystemException) ) +{ + if( L"com.sun.star.io.Pipe" == TestName ) { + TRY { + if( 0 == hTestHandle ) { + testInvariant( TestName , TestObject ); + } + else if( 1 == hTestHandle ) { + testSimple( TestObject ); + } + else if( 2 == hTestHandle ) { + testBufferResizing( TestObject ); + } + else if( 3 == hTestHandle ) { + testMultithreading( TestObject ); + } + } + CATCH( Exception , e ) { + BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ); + } + AND_CATCH_ALL() { + BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" ); + } + END_CATCH; + + hTestHandle ++; + + if( 4 == hTestHandle ) { + // all tests finished. + hTestHandle = -1; + } + } + else { + THROW( IllegalArgumentException() ); + } + return hTestHandle; +} + + + +BOOL OPipeTest::testPassed(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors.getLen() == 0; +} + + +Sequence< UString > OPipeTest::getErrors(void) THROWS( (UsrSystemException) ) +{ + return m_seqErrors; +} + + +Sequence< UsrAny > OPipeTest::getErrorExceptions(void) THROWS( (UsrSystemException) ) +{ + return m_seqExceptions; +} + + +Sequence< UString > OPipeTest::getWarnings(void) THROWS( (UsrSystemException) ) +{ + return m_seqWarnings; +} + + +/*** +* the test methods +* +****/ + + +void OPipeTest::testSimple( const XInterfaceRef &r ) +{ + + XInputStreamRef input( r , USR_QUERY ); + XOutputStreamRef output( r , USR_QUERY ); + + ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); + ERROR_ASSERT( output.is() , "queryInterface onXOutputStream failed" ); + + // basic read/write + Sequence<BYTE> seqWrite = createSeq( "Hallo, du Ei !" ); + + Sequence<BYTE> seqRead; + for( int i = 0 ; i < 5000 ; i ++ ) { + output->writeBytes( seqWrite ); + input->readBytes( seqRead , input->available() ); + + ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) , + "error during read/write/skip" ); + ERROR_ASSERT( 0 == input->available() , + "error during read/write/skip" ); + + // available shouldn't return a negative value + input->skipBytes( seqWrite.getLen() - 5 ); + ERROR_ASSERT( 0 == input->available() , "wrong available after skip" ); + + // 5 bytes should be available + output->writeBytes( seqWrite ); + ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " ); + + input->readBytes( seqRead , 5 ); + ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , + (char*) &( seqWrite.getArray()[seqWrite.getLen()-5] ) ), + "write/read mismatich" ); + + } + + output->writeBytes( seqWrite ); + ERROR_ASSERT( seqWrite.getLen() == input->available(), "wrong available() after write" ); + + ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" ); + ERROR_ASSERT( seqWrite.getLen() -10 == input->readSomeBytes( seqRead , 100 ) , + "something wrong with readSomeBytes" ); + + + output->closeOutput(); + TRY { + output->writeBytes( Sequence<BYTE> (100) ); + ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" ); + } + CATCH (IOException , e ) { + e; // just to suppress warning during compile + } + END_CATCH; + + ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" ); + + input->closeInput(); + TRY { + input->readBytes( seqRead , 1 ); + ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" ); + } + CATCH( IOException , e ) { + e; // just to suppress warning during compile + } + END_CATCH; + +} + +void OPipeTest::testBufferResizing( const XInterfaceRef &r ) +{ + + int iMax = 20000; + XInputStreamRef input( r , USR_QUERY ); + XOutputStreamRef output( r , USR_QUERY ); + + ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); + ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); + + Sequence<BYTE> seqRead; + + // this is just to better check the + // internal buffers + output->writeBytes( Sequence<BYTE>(100) ); + input->readBytes( Sequence<BYTE>() , 100); + + for( int i = 0 ; i < iMax ; i ++ ) { + output->writeBytes( createIntSeq( i ) ); + } + + for( i = 0 ; i < iMax ; i ++ ) { + input->readBytes( seqRead, createIntSeq(i).getLen() ); + ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , + (char*) createIntSeq(i).getArray() ) , + "written/read mismatch\n" ); + } + + output->closeOutput(); + ERROR_ASSERT( ! input->readBytes( seqRead , 1 ) , "eof not reached !" ); + input->closeInput(); +} + + + +void OPipeTest::testMultithreading( const XInterfaceRef &r ) +{ + + + int iMax = 30000; + + XInputStreamRef input( r , USR_QUERY ); + XOutputStreamRef output( r , USR_QUERY ); + + ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" ); + ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" ); + + Sequence<BYTE> seqRead; + + // deletes itself + OThread *p = new WriteToStreamThread( output, iMax ); + + ERROR_ASSERT( p , "couldn't create thread for testing !\n" ); + + p->create(); + + for(int i = 0 ; TRUE ; i ++ ) { + if( 0 == input->readBytes( seqRead, createIntSeq(i).getLen() ) ) { + // eof reached ! + break; + } + + ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() , + (char*) createIntSeq(i).getArray() ) , + "written/read mismatch\n" ); + } + + ERROR_ASSERT( i == iMax , "less elements read than written !"); + input->closeInput(); +} + +/* { + TRY { + XInterfaceRef x = xSMgr->createInstance( strService ); + + XInputStreamRef input( x , USR_QUERY ); + XOutputStreamRef output( x , USR_QUERY ); + + assert( output.is() ); + while( TRUE ) { + // basic read/write + Sequence<BYTE> seqWrite( 500 ); + output->writeBytes( seqWrite ); + + } + } + CATCH( IOException , e ) { + printf( "%s %s\n" , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() , + UStringToString( e.Message , CHARSET_SYSTEM ).GetCharStr() ); + } + } +*/ + + + + +/** +* for external binding +* +* +**/ +XInterfaceRef OPipeTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)) +{ + OPipeTest *p = new OPipeTest( rSMgr ); + XInterfaceRef xService = *p; + return xService; +} + + + +Sequence<UString> OPipeTest_getSupportedServiceNames(void) THROWS( () ) +{ + Sequence<UString> aRet(1); + aRet.getArray()[0] = OPipeTest_getImplementationName(); + + return aRet; +} + +UString OPipeTest_getServiceName() THROWS( () ) +{ + return SERVICE_NAME; +} + +UString OPipeTest_getImplementationName() THROWS( () ) +{ + return IMPLEMENTATION_NAME; +} diff --git a/extensions/test/stm/testfactreg.cxx b/extensions/test/stm/testfactreg.cxx new file mode 100644 index 000000000..69ab2a723 --- /dev/null +++ b/extensions/test/stm/testfactreg.cxx @@ -0,0 +1,203 @@ +/************************************************************************* + * + * $RCSfile: testfactreg.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include <string.h> + +#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE + +#include <usr/factoryhlp.hxx> +#include "testfactreg.hxx" + + +#ifndef _VOS_NO_NAMESPACE +using namespace vos; +using namespace usr; +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry( + const UNO_INTERFACE(XRegistryKey)* xUnoKey) + +{ + XRegistryKeyRef xKey; + uno2smart(xKey, *xUnoKey); + + UString str = UString( L"/" ) + OPipeTest_getImplementationName() + UString( L"/UNO/SERVICES" ); + XRegistryKeyRef xNewKey = xKey->createKey( str ); + xNewKey->createKey( OPipeTest_getServiceName() ); + + str = UString( L"/" ) + ODataStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( ODataStreamTest_getServiceName(1) ); + + str = UString( L"/" ) + ODataStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( ODataStreamTest_getServiceName(2) ); + + str = UString( L"/" ) + OObjectStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OObjectStreamTest_getServiceName(1) ); + + str = UString( L"/" ) + OObjectStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OObjectStreamTest_getServiceName(2) ); + + str = UString( L"/" ) + OMarkableOutputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() ); + + str = UString( L"/" ) + OMarkableInputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OMarkableInputStreamTest_getServiceName() ); + + str = UString( L"/" ) + OMyPersistObject_getImplementationName() + UString( L"/UNO/SERVICES" ); + xNewKey = xKey->createKey( str ); + xNewKey->createKey( OMyPersistObject_getServiceName() ); + + return TRUE; +} + + +UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory +( + const wchar_t* implementationName, + const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact, + const UNO_INTERFACE(XRegistryKey)* +) +{ + UNO_INTERFACE(XInterface) xUnoRet = {0, 0}; + + XInterfaceRef xRet; + XMultiServiceFactoryRef xSMgr; + UString aImplementationName(implementationName); + + uno2smart(xSMgr, *xUnoFact); + + if (aImplementationName == OPipeTest_getImplementationName() ) + { + xRet = createSingleFactory( xSMgr, implementationName, + OPipeTest_CreateInstance, + OPipeTest_getSupportedServiceNames() ); + } + else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) { + xRet = createSingleFactory( xSMgr , implementationName, + ODataStreamTest_CreateInstance, + ODataStreamTest_getSupportedServiceNames(1) ); + } + else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) { + xRet = createSingleFactory( xSMgr , implementationName, + ODataStreamTest_CreateInstance, + ODataStreamTest_getSupportedServiceNames(2) ); + } + else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) { + xRet = createSingleFactory( xSMgr , implementationName, + OObjectStreamTest_CreateInstance, + OObjectStreamTest_getSupportedServiceNames(1) ); + } + else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) { + xRet = createSingleFactory( xSMgr , implementationName, + OObjectStreamTest_CreateInstance, + OObjectStreamTest_getSupportedServiceNames(2) ); + } + else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) { + xRet = createSingleFactory( xSMgr , implementationName, + OMarkableOutputStreamTest_CreateInstance, + OMarkableOutputStreamTest_getSupportedServiceNames() ); + } + else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) { + xRet = createSingleFactory( xSMgr , implementationName, + OMarkableInputStreamTest_CreateInstance, + OMarkableInputStreamTest_getSupportedServiceNames() ); + } + else if( aImplementationName == OMyPersistObject_getImplementationName() ) { + xRet = createSingleFactory( xSMgr , implementationName, + OMyPersistObject_CreateInstance, + OMyPersistObject_getSupportedServiceNames() ); + } + if (xRet.is()) + { + smart2uno(xRet, xUnoRet); + } + + return xUnoRet; +} + +#ifdef __cplusplus +} +#endif + +Sequence<BYTE> createSeq( char * p ) +{ + Sequence<BYTE> seq( strlen( p )+1 ); + strcpy( (char * ) seq.getArray() , p ); + return seq; +} + +Sequence<BYTE> createIntSeq( INT32 i ) +{ + char pcCount[20]; + sprintf( pcCount , "%d" , i ); + return createSeq( pcCount ); +} + diff --git a/extensions/test/stm/testfactreg.hxx b/extensions/test/stm/testfactreg.hxx new file mode 100644 index 000000000..57f81b50f --- /dev/null +++ b/extensions/test/stm/testfactreg.hxx @@ -0,0 +1,144 @@ +/************************************************************************* + * + * $RCSfile: testfactreg.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:16:56 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +XInterfaceRef OPipeTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> OPipeTest_getSupportedServiceNames(void) THROWS( () ); +UString OPipeTest_getServiceName() THROWS( () ); +UString OPipeTest_getImplementationName() THROWS( () ); + +XInterfaceRef ODataStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> ODataStreamTest_getSupportedServiceNames( int i) THROWS( () ); +UString ODataStreamTest_getServiceName( int i) THROWS( ( ) ); +UString ODataStreamTest_getImplementationName( int i) THROWS( () ); + +XInterfaceRef OMarkableOutputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> OMarkableOutputStreamTest_getSupportedServiceNames(void) THROWS( () ); +UString OMarkableOutputStreamTest_getServiceName() THROWS( () ); +UString OMarkableOutputStreamTest_getImplementationName() THROWS( () ); + +XInterfaceRef OMarkableInputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> OMarkableInputStreamTest_getSupportedServiceNames(void) THROWS( () ); +UString OMarkableInputStreamTest_getServiceName() THROWS( () ); +UString OMarkableInputStreamTest_getImplementationName() THROWS( () ); + +XInterfaceRef OObjectStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> OObjectStreamTest_getSupportedServiceNames( int i) THROWS( () ); +UString OObjectStreamTest_getServiceName( int i) THROWS( () ); +UString OObjectStreamTest_getImplementationName( int i) THROWS( () ); + +XInterfaceRef OMyPersistObject_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception)); +Sequence<UString> OMyPersistObject_getSupportedServiceNames( ) THROWS( () ); +UString OMyPersistObject_getServiceName( ) THROWS( () ); +UString OMyPersistObject_getImplementationName( ) THROWS( () ); + +Sequence<BYTE> createSeq( char * p ); +Sequence<BYTE> createIntSeq( INT32 i ); + +#define BUILD_ERROR(expr, Message)\ + {\ + m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \ + m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \ + String str; \ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToOUString( str , CHARSET_SYSTEM ); \ + }\ + ((void)0) + + +#define WARNING_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \ + String str;\ + str += __FILE__;\ + str += " "; \ + str += "(" ; \ + str += __LINE__ ;\ + str += ")\n";\ + str += "[ " ; \ + str += #expr; \ + str += " ] : " ; \ + str += Message; \ + m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToOUString( str , CHARSET_SYSTEM ); \ + return; \ + }\ + ((void)0) + +#define ERROR_ASSERT(expr, Message) \ + if( ! (expr) ) { \ + BUILD_ERROR(expr, Message );\ + return; \ + }\ + ((void)0) + +#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \ + if( !(expr)) { \ + BUILD_ERROR(expr,Message);\ + m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\ + return; \ + } \ + ((void)0) |