Uno/Cpp/Snippet/FreeReference
From Apache OpenOffice Wiki
#include <cppu/EnvGuards.hxx>
...
{
com::sun::star::uno::Reference<XFoo> ref(...)
...
cppu::FreeReference<XFoo> free_xFoo(xFoo);
cppu::EnvGuard otherEnv(cppu::Environment("just another env"));
free_xFoo->doSomething(); // the free reference ensures that the correct environment etc. gets activated before invokation
...
}