OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

C++. Disconnect from OO.

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
danilabagroff
General User
General User


Joined: 08 Feb 2008
Posts: 13

PostPosted: Fri Feb 27, 2009 6:53 am    Post subject: C++. Disconnect from OO. Reply with quote

Hello all

I'll tried to find correctly solution, but...

I make a TCP connection to the OO and after processing my document I want to properly close this connection. How can I do this?

Code:

      Reference <XComponentContext> x_component_context(::cppu::bootstrap());
      _x_multi_component_factory_client = Reference <XMultiComponentFactory> (x_component_context->getServiceManager());

      _x_interface = Reference <XInterface>(_x_multi_component_factory_client->createInstanceWithContext(OUString::createFromAscii("com.sun.star.bridge.UnoUrlResolver" ), x_component_context));
      Reference <XUnoUrlResolver> resolver(_x_interface, UNO_QUERY);
      _x_interface = Reference <XInterface> (resolver->resolve(connection_string), UNO_QUERY);
        Reference <XPropertySet> x_prop_set(_x_interface, UNO_QUERY);
        x_prop_set->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= x_component_context;

        Reference <XMultiComponentFactory> x_multi_component_factory_server(x_component_context->getServiceManager());
        _x_component_loader = Reference <XComponentLoader>(x_multi_component_factory_server->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), x_component_context), UNO_QUERY);


* I tried to use dispose(), but running instance of OO was crashed.
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Fri Feb 27, 2009 9:05 am    Post subject: Reply with quote

Here is a solution in Java :
Solution to close OOo connection (MessageDispatcher Thread) http://www.oooforum.org/forum/viewtopic.phtml?t=35455&highlight=
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
danilabagroff
General User
General User


Joined: 08 Feb 2008
Posts: 13

PostPosted: Sun Mar 01, 2009 2:39 pm    Post subject: Reply with quote

I tried do the same with c++

Code:

Reference <XComponentContext> x_component_context(::cppu::bootstrap());

Reference <XConnector> x_connector(x_component_context->getServiceManager()->createInstanceWithContext(OUString::createFromAscii("com.sun.star.connection.Connector"), x_component_context), UNO_QUERY);
Reference <XConnection> x_connection = x_connector->connect(connection_string);

Reference <XBridgeFactory> x_bridge_factory(x_component_context->getServiceManager()->createInstanceWithContext(OUString::createFromAscii("com.sun.star.bridge.BridgeFactory"), x_component_context), UNO_QUERY);

_x_bridge = x_bridge_factory->createBridge(OUString::createFromAscii(""), OUString::createFromAscii("urp"), x_connection, Reference <XInstanceProvider> ());

Reference <XComponent> x_component(_x_bridge, UNO_QUERY);

Reference <XMultiComponentFactory> x_multi_component_factory(_x_bridge->getInstance(OUString::createFromAscii("StarOffice.ServiceManager")), UNO_QUERY);

Reference <XPropertySet> x_propery_set(x_multi_component_factory, UNO_QUERY);
x_propery_set->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= x_component_context;

Reference <XMultiComponentFactory> x_multi_component_factory_server(x_component_context->getServiceManager());
_x_component_loader = Reference <XComponentLoader>(x_multi_component_factory_server->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), x_component_context), UNO_QUERY);


I have segfault on: x_bridge_factory->createBridge

with:
0xb7f2ed20 in com::sun::star::uno::Reference<com::sun::star::bridge::XBridge>::set (this=0x804c31c, pInterface=0x80900dc)
at /usr/lib/openoffice/sdk/include/com/sun/star/uno/Reference.hxx:242
242 pOld->release();

Will be greate, if somebody have any ideas.
Back to top
View user's profile Send private message
danilabagroff
General User
General User


Joined: 08 Feb 2008
Posts: 13

PostPosted: Mon Mar 02, 2009 2:29 am    Post subject: Reply with quote

Solved.

Code:

Reference <XComponentContext> x_component_context(::cppu::bootstrap());

Reference <XConnector> x_connector(x_component_context->getServiceManager()->createInstanceWithContext(OUString::createFromAscii("com.sun.star.connection.Connector"), x_component_context), UNO_QUERY);
Reference <XConnection> x_connection = x_connector->connect(connection_string);

Reference <XBridgeFactory> x_bridge_factory(x_component_context->getServiceManager()->createInstanceWithContext(OUString::createFromAscii("com.sun.star.bridge.BridgeFactory"), x_component_context), UNO_QUERY);

_x_bridge = x_bridge_factory->createBridge(OUString(), OUString::createFromAscii("urp"), x_connection, 0);

Reference <XComponent> x_component(_x_bridge, UNO_QUERY);

Reference <XMultiComponentFactory> x_multi_component_factory(_x_bridge->getInstance(OUString::createFromAscii("StarOffice.ServiceManager")), UNO_QUERY);

Reference <XPropertySet> x_propery_set(x_multi_component_factory, UNO_QUERY);
x_propery_set->getPropertyValue(OUString::createFromAscii("DefaultContext")) >>= x_component_context;

Reference <XMultiComponentFactory> x_multi_component_factory_server(x_component_context->getServiceManager());
_x_component_loader = Reference <XComponentLoader>(x_multi_component_factory_server->createInstanceWithContext(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")), x_component_context), UNO_QUERY);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group