1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #if ! defined INCLUDED_CLI_ENVIRONMENT_H 29*cdf0e10cSrcweir #define INCLUDED_CLI_ENVIRONMENT_H 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "cli_base.h" 32*cdf0e10cSrcweir #using <mscorlib.dll> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir using namespace System; 35*cdf0e10cSrcweir using namespace System::Collections; 36*cdf0e10cSrcweir using namespace System::Runtime::Serialization; 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir namespace cli_uno 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir public __gc class Cli_environment 42*cdf0e10cSrcweir { 43*cdf0e10cSrcweir static System::String* sOidPart; 44*cdf0e10cSrcweir static Hashtable* m_objects; 45*cdf0e10cSrcweir static System::Runtime::Serialization::ObjectIDGenerator* m_IDGen; 46*cdf0e10cSrcweir inline static System::String* createKey(System::String* oid, System::Type* t); 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL >= 1 49*cdf0e10cSrcweir int _numRegisteredObjects; 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir public: 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir static Cli_environment() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir m_objects = Hashtable::Synchronized(new Hashtable()); 57*cdf0e10cSrcweir m_IDGen = new System::Runtime::Serialization::ObjectIDGenerator(); 58*cdf0e10cSrcweir System::Text::StringBuilder* buffer = new System::Text::StringBuilder(256); 59*cdf0e10cSrcweir Guid gd = Guid::NewGuid(); 60*cdf0e10cSrcweir buffer->Append(S";cli[0];"); 61*cdf0e10cSrcweir buffer->Append(gd.ToString()); 62*cdf0e10cSrcweir sOidPart = buffer->ToString(); 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir inline Cli_environment(); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir ~Cli_environment(); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir /** 70*cdf0e10cSrcweir Registers an UNO object as being mapped by this bridge. The resulting 71*cdf0e10cSrcweir cli object is represents all interfaces of the UNO object. Therefore the 72*cdf0e10cSrcweir object can be registered only with its OID; a type is not necessary. 73*cdf0e10cSrcweir */ 74*cdf0e10cSrcweir Object* registerInterface(Object* obj, System::String* oid); 75*cdf0e10cSrcweir /** 76*cdf0e10cSrcweir Registers a CLI object as being mapped by this bridge. The resulting 77*cdf0e10cSrcweir object represents exactly one UNO interface. 78*cdf0e10cSrcweir */ 79*cdf0e10cSrcweir Object* registerInterface(Object* obj, System::String* oid, System::Type* type); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /** 82*cdf0e10cSrcweir By revoking an interface it is declared that the respective interface has 83*cdf0e10cSrcweir not been mapped. The proxy implementations call revoke interface in their 84*cdf0e10cSrcweir destructors. 85*cdf0e10cSrcweir */ 86*cdf0e10cSrcweir inline void revokeInterface(System::String* oid); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void revokeInterface(System::String* oid, System::Type* type); 89*cdf0e10cSrcweir /** 90*cdf0e10cSrcweir * Retrieves an interface identified by its object id and type from this 91*cdf0e10cSrcweir * environment. 92*cdf0e10cSrcweir * 93*cdf0e10cSrcweir * @param oid object id of interface to be retrieved 94*cdf0e10cSrcweir * @param type the type description of the interface to be retrieved 95*cdf0e10cSrcweir * @see com.sun.star.uno.IEnvironment#getRegisteredInterface 96*cdf0e10cSrcweir */ 97*cdf0e10cSrcweir Object* getRegisteredInterface(System::String* oid, System::Type* type); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir /** 100*cdf0e10cSrcweir * Generates a worldwide unique object identifier (oid) for the given object. It is 101*cdf0e10cSrcweir * guaranteed, that subsequent calls to the method with the same object 102*cdf0e10cSrcweir * will give the same id. 103*cdf0e10cSrcweir * <p> 104*cdf0e10cSrcweir * @return the generated oid. 105*cdf0e10cSrcweir * @param object the object for which a Oid should be generated. 106*cdf0e10cSrcweir */ 107*cdf0e10cSrcweir static System::String* getObjectIdentifier(Object* obj); 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir }; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir } //namespace cli_uno 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir #endif 115