1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef __JSCRIPTCLASSES_HXX 28 #define __JSCRIPTCLASSES_HXX 29 30 31 #pragma warning (push,1) 32 #pragma warning (disable:4548) 33 34 #include <tools/presys.h> 35 //#include "stdafx.h" 36 #define STRICT 37 #define _WIN32_WINNT 0x0400 38 #define _WIN32_DCOM 39 #if OSL_DEBUG_LEVEL > 0 40 //#define _ATL_DEBUG_INTERFACES 41 #endif 42 #include <atlbase.h> 43 extern CComModule _Module; 44 #include <atlcom.h> 45 #include <tools/postsys.h> 46 47 #pragma warning (pop) 48 #pragma warning (disable:4505) 49 // disable "unreferenced local function has been removed" globally 50 51 #include "comifaces.hxx" 52 53 54 55 // Sequences are represented by prepending "[]", e.g. []char, [][]byte, [][][]object, etc. 56 57 // To make a JScriptValue object to an out parameter, call 58 // "InitOutParam" and to make it a in/out parameter call 59 // "InitInOutParam" 60 61 // If the object represents an out parameter then the value can after the call 62 // be retrived by "Get". 63 64 // From JavaScript the functions Get, Set, InitOutParam and InitInOutParam are 65 // used, that is they are accessible through IDispatch. The functions are used 66 // by the bridge. 67 68 class JScriptValue: 69 public CComObjectRootEx<CComMultiThreadModel>, 70 public IJScriptValueObject, 71 public IDispatch 72 { 73 public: 74 JScriptValue(); 75 virtual ~JScriptValue(); 76 77 BEGIN_COM_MAP(JScriptValue) 78 COM_INTERFACE_ENTRY(IDispatch) 79 COM_INTERFACE_ENTRY(IJScriptValueObject) 80 END_COM_MAP() 81 82 // IDispatch ------------------------------------------- 83 STDMETHOD( GetTypeInfoCount)(UINT *pctinfo); 84 85 STDMETHOD( GetTypeInfo)( UINT iTInfo, 86 LCID lcid, 87 ITypeInfo **ppTInfo); 88 89 STDMETHOD( GetIDsOfNames)( REFIID riid, 90 LPOLESTR *rgszNames, 91 UINT cNames, 92 LCID lcid, 93 DISPID *rgDispId); 94 95 STDMETHOD( Invoke)( DISPID dispIdMember, 96 REFIID riid, 97 LCID lcid, 98 WORD wFlags, 99 DISPPARAMS *pDispParams, 100 VARIANT *pVarResult, 101 EXCEPINFO *pExcepInfo, 102 UINT *puArgErr); 103 // IJScriptOutParam -------------------------------------- 104 105 STDMETHOD( Set)( VARIANT type, VARIANT value); 106 STDMETHOD( Get)( VARIANT *val); 107 STDMETHOD( InitOutParam)(); 108 STDMETHOD( InitInOutParam)( VARIANT type, VARIANT value); 109 STDMETHOD( IsOutParam)( VARIANT_BOOL * flag); 110 STDMETHOD( IsInOutParam)( VARIANT_BOOL * flag); 111 STDMETHOD( GetValue)( BSTR* type, VARIANT *value); 112 113 114 CComVariant m_varValue; 115 CComBSTR m_bstrType; 116 unsigned m_bOutParam: 1; 117 unsigned m_bInOutParam: 1; 118 119 }; 120 121 // If a class is implemented in JScript, then its method 122 class JScriptOutParam: 123 public CComObjectRootEx<CComMultiThreadModel>, 124 public IDispatch 125 { 126 public: 127 JScriptOutParam(); 128 virtual ~JScriptOutParam(); 129 130 BEGIN_COM_MAP(JScriptOutParam) 131 COM_INTERFACE_ENTRY(IDispatch) 132 END_COM_MAP() 133 134 // IDispatch ------------------------------------------- 135 STDMETHOD( GetTypeInfoCount)(UINT *pctinfo); 136 137 STDMETHOD( GetTypeInfo)( UINT iTInfo, 138 LCID lcid, 139 ITypeInfo **ppTInfo); 140 141 STDMETHOD( GetIDsOfNames)( REFIID riid, 142 LPOLESTR *rgszNames, 143 UINT cNames, 144 LCID lcid, 145 DISPID *rgDispId); 146 147 STDMETHOD( Invoke)( DISPID dispIdMember, 148 REFIID riid, 149 LCID lcid, 150 WORD wFlags, 151 DISPPARAMS *pDispParams, 152 VARIANT *pVarResult, 153 EXCEPINFO *pExcepInfo, 154 UINT *puArgErr); 155 156 157 private: 158 CComVariant m_varValue; 159 }; 160 161 #endif 162