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 28 #if ! defined INCLUDED_CLI_ENVIRONMENT_H 29 #define INCLUDED_CLI_ENVIRONMENT_H 30 31 #include "cli_base.h" 32 #using <mscorlib.dll> 33 34 using namespace System; 35 using namespace System::Collections; 36 using namespace System::Runtime::Serialization; 37 38 namespace cli_uno 39 { 40 41 public __gc class Cli_environment 42 { 43 static System::String* sOidPart; 44 static Hashtable* m_objects; 45 static System::Runtime::Serialization::ObjectIDGenerator* m_IDGen; 46 inline static System::String* createKey(System::String* oid, System::Type* t); 47 48 #if OSL_DEBUG_LEVEL >= 1 49 int _numRegisteredObjects; 50 #endif 51 52 public: 53 54 static Cli_environment() 55 { 56 m_objects = Hashtable::Synchronized(new Hashtable()); 57 m_IDGen = new System::Runtime::Serialization::ObjectIDGenerator(); 58 System::Text::StringBuilder* buffer = new System::Text::StringBuilder(256); 59 Guid gd = Guid::NewGuid(); 60 buffer->Append(S";cli[0];"); 61 buffer->Append(gd.ToString()); 62 sOidPart = buffer->ToString(); 63 } 64 65 inline Cli_environment(); 66 67 ~Cli_environment(); 68 69 /** 70 Registers an UNO object as being mapped by this bridge. The resulting 71 cli object is represents all interfaces of the UNO object. Therefore the 72 object can be registered only with its OID; a type is not necessary. 73 */ 74 Object* registerInterface(Object* obj, System::String* oid); 75 /** 76 Registers a CLI object as being mapped by this bridge. The resulting 77 object represents exactly one UNO interface. 78 */ 79 Object* registerInterface(Object* obj, System::String* oid, System::Type* type); 80 81 /** 82 By revoking an interface it is declared that the respective interface has 83 not been mapped. The proxy implementations call revoke interface in their 84 destructors. 85 */ 86 inline void revokeInterface(System::String* oid); 87 88 void revokeInterface(System::String* oid, System::Type* type); 89 /** 90 * Retrieves an interface identified by its object id and type from this 91 * environment. 92 * 93 * @param oid object id of interface to be retrieved 94 * @param type the type description of the interface to be retrieved 95 * @see com.sun.star.uno.IEnvironment#getRegisteredInterface 96 */ 97 Object* getRegisteredInterface(System::String* oid, System::Type* type); 98 99 /** 100 * Generates a worldwide unique object identifier (oid) for the given object. It is 101 * guaranteed, that subsequent calls to the method with the same object 102 * will give the same id. 103 * <p> 104 * @return the generated oid. 105 * @param object the object for which a Oid should be generated. 106 */ 107 static System::String* getObjectIdentifier(Object* obj); 108 109 }; 110 111 } //namespace cli_uno 112 113 114 #endif 115