Inserting a value into a XComponentContext
chris.sherlock79 at gmail.com
Mon Dec 1 13:58:26 PST 2014
OK, I've worked it out. What happens is that
is actually getting the concrete class ComponentContext, which implements
XNameContainer and XContainerContext.
All you need to do is to instantiate a new Reference< XNameContainer > like
Reference< container::XNameContainer > xNameContainer( xContext, UNO_QUERY
You can then insert and remove properties at will.
On Mon, Dec 1, 2014 at 11:31 AM, Andrew Pitonyak <andrew at pitonyak.org>
> No stress on the number of mails.
> I did not think that you could change a context after it was created...
> But I would certainly try if I had a need. I know very little about this
> Chris Sherlock <chris.sherlock79 at gmail.com> wrote:
> Oh, and sorry for the number of emails, but I guess I'm assuming that you
> can add a new property key at any point by insertByName()...
> Thanks in advance, UNO is a little tricky at this level. At least that's
> what I find... from what I can tell, it really comes down to the
> cppuhelper::ComponentContext class which implements the XNameContainer
> interface. *Please* correct me if I'm wrong :-)
> On Mon, Dec 1, 2014 at 10:29 AM, Chris Sherlock <
> chris.sherlock79 at gmail.com> wrote:
>> So what about the following approach:
>> Reference< XComponentContext > xContext =
>> ::cppu::ContextEntry_Init aContextInfo =
>> ::cppu::ContextEntry_Init("testkey", uno::Any() ),
>> xNewContext = ::cppu::createComponentContext(aContextInfo,
>> sizeof(aContextInfo) / sizeof (aHandlerContextInfo), xContext);
>> Then to get access to the container, I use something like this:
>> Reference< container::XNameContainer > xNameContainer( xContext,
>> UNO_QUERY );
>> Is this the right approach? Will the delegate ComponentContext work?
>> On Mon, Dec 1, 2014 at 12:25 AM, Andrew Pitonyak <andrew at pitonyak.org>
>>> Guessing from memory and not east for me to verify at the Moment, but I
>>> thought that the context was read only. I think that of you want to add
>>> values you need to create a new one with the desired named value pairs.
>>> Are you able to inspect an object to see of it supports setting
>>> I have done very little in this area and don't remember...
>>> Chris Sherlock <chris.sherlock79 at gmail.com> wrote:
>>> Hi all,
>>> How do you insert a value to be retrieved later into an
>>> XComponentContext reference?
>>> I see there is a XNameContainer, which is created by comphelper::NameContainer_createInstance(::cppu::UnoType<sal_Int32>::get())
>>> or whatever value you want. From here you then do insertByName.
>>> However, how do you then insert this into the component context?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the LibreOffice