Uno/Cpp/Snippet/FreeReference
From Apache OpenOffice Wiki
		
		
		
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#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
  ...
}