1*6da5f311SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6da5f311SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6da5f311SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6da5f311SAndrew Rist * distributed with this work for additional information 6*6da5f311SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6da5f311SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6da5f311SAndrew Rist * "License"); you may not use this file except in compliance 9*6da5f311SAndrew Rist * with the License. You may obtain a copy of the License at 10*6da5f311SAndrew Rist * 11*6da5f311SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6da5f311SAndrew Rist * 13*6da5f311SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6da5f311SAndrew Rist * software distributed under the License is distributed on an 15*6da5f311SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6da5f311SAndrew Rist * KIND, either express or implied. See the License for the 17*6da5f311SAndrew Rist * specific language governing permissions and limitations 18*6da5f311SAndrew Rist * under the License. 19*6da5f311SAndrew Rist * 20*6da5f311SAndrew Rist *************************************************************/ 21*6da5f311SAndrew Rist 22*6da5f311SAndrew Rist 23cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ 24cdf0e10cSrcweir #define _CPPUHELPER_COMPONENT_CONTEXT_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 27cdf0e10cSrcweir #include <com/sun/star/lang/XSingleComponentFactory.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir 30cdf0e10cSrcweir namespace cppu 31cdf0e10cSrcweir { 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** Context entries init struct calling createComponentContext(). 34cdf0e10cSrcweir */ 35cdf0e10cSrcweir struct ContextEntry_Init 36cdf0e10cSrcweir { 37cdf0e10cSrcweir /** late init denotes a object that will be raised when first get() is calling for it 38cdf0e10cSrcweir 39cdf0e10cSrcweir The context implementation expects either a ::com::sun::star::lang::XSingleComponentFactory 40cdf0e10cSrcweir object as value (to instanciate the object) or a string as value for raising 41cdf0e10cSrcweir a service via the used service manager. 42cdf0e10cSrcweir */ 43cdf0e10cSrcweir bool bLateInitService; 44cdf0e10cSrcweir /** name of context value 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir ::rtl::OUString name; 47cdf0e10cSrcweir /** context value 48cdf0e10cSrcweir */ 49cdf0e10cSrcweir ::com::sun::star::uno::Any value; 50cdf0e10cSrcweir 51cdf0e10cSrcweir /** Default ctor. 52cdf0e10cSrcweir */ 53cdf0e10cSrcweir inline ContextEntry_Init() SAL_THROW( () ) 54cdf0e10cSrcweir : bLateInitService( false ) 55cdf0e10cSrcweir {} 56cdf0e10cSrcweir /** Ctor. 57cdf0e10cSrcweir 58cdf0e10cSrcweir @param name_ 59cdf0e10cSrcweir name of entry 60cdf0e10cSrcweir @param value_ 61cdf0e10cSrcweir value of entry 62cdf0e10cSrcweir @param bLateInitService_ 63cdf0e10cSrcweir whether this entry is a late-init named object entry 64cdf0e10cSrcweir (value is object factory or service string) 65cdf0e10cSrcweir */ ContextEntry_Initcppu::ContextEntry_Init66cdf0e10cSrcweir inline ContextEntry_Init( 67cdf0e10cSrcweir ::rtl::OUString const & name_, 68cdf0e10cSrcweir ::com::sun::star::uno::Any const & value_, 69cdf0e10cSrcweir bool bLateInitService_ = false ) SAL_THROW( () ) 70cdf0e10cSrcweir : bLateInitService( bLateInitService_ ), 71cdf0e10cSrcweir name( name_ ), 72cdf0e10cSrcweir value( value_ ) 73cdf0e10cSrcweir {} 74cdf0e10cSrcweir }; 75cdf0e10cSrcweir 76cdf0e10cSrcweir /** Creates a component context with the given entries. 77cdf0e10cSrcweir 78cdf0e10cSrcweir @param pEntries array of entries 79cdf0e10cSrcweir @param nEntries number of entries 80cdf0e10cSrcweir @param xDelegate delegation to further context, if value was not found 81cdf0e10cSrcweir @return new context object 82cdf0e10cSrcweir */ 83cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > 84cdf0e10cSrcweir SAL_CALL createComponentContext( 85cdf0e10cSrcweir ContextEntry_Init const * pEntries, sal_Int32 nEntries, 86cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xDelegate = 87cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) 88cdf0e10cSrcweir SAL_THROW( () ); 89cdf0e10cSrcweir 90cdf0e10cSrcweir } 91cdf0e10cSrcweir 92cdf0e10cSrcweir #endif 93