Hi,
I have a question about UNO Reference<> in C++. What I would like to do is the
following : I want to connect to a listening office, and then have an object
which keeps a reference to the connection. That way, I can open a connection
with the constructor or a function of the object, and call functions to
"talk" with the office.
Also, I do not want to declare the #include related to the interfaces in my
(eg : #include <cppuhelper/bootstrap.hxx>) header file. That way, when using
the object in a .cpp file, for example in a main.cpp, I do not need to
include the headers in the compile line.
So, what I have done looks like that :
file.hxx
// Trick to avoid the #includes of OpenOffice in order to use XInterface and
// Reference< >.
namespace com
{
namespace sun
{
namespace star
{
namespace uno
{
class XInterface;
template< class interface_type >
class Reference;
}
}
}
}
using namespace com::sun::star::uno;
class MyClass
{
public:
connect();
set_text();
private :
// OK
XInterface* rInstance2;
// Not OK because needs to be a pointer or a reference.
Reference< XInterface > rInstance;
};
file.cxx
connect()
{
...
rInstance = rResolver->resolve( OUString::createFromAscii(
"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) );
...
}
set_text()
{
...
Reference< XDesktop > xdesktop( rInstance, UNO_QUERY );
...
}
But, for now, I am not able to declare "Reference< XInterface > rInstance".
What would be the right way to do things ? To make rInstance a reference (&)
to a Reference< XInterface > ?
Reference< XInterface > & rInstance;
To connect to the listening office in each method wanting to access to objects
(which would be long, I suppose) ? Use a global variable in the cxx file (bad
style programming) ?
Thanks,
Cheers,
Pierre-Andre
--
StarXpert - www.starxpert.fr
e-mail : [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]