Hi,
from the first view the problem seems to be that the
loadComponentFromURL() just can not load the new document to the same
frame "testdoc" and throws an exception. The exception is not handled in
the source code, so it is unexpected and let the office crash.
Best regards,
Mikhail.
On 01/05/10 16:49, SlumberMan wrote:
Hi all,
I have a question about OOo UNO programming in C++ language that how
could I load a file in an exist frame?
For instance, I create a blank doc with loadComponentFromURL() in
sentence d), and the component is loaded in a new frame named "testdoc".
Sentence e,f,g,h are for test. The result of these sentences is "Frame
name : testdoc Frame status : 1" in the terminal which running the
program.
And sentence i has problem. The system only return a "Segment Fault".
Any Ideas? TIA
(omit all error handle codes)
------------------------------- C++ code ---------------------------------
a) Reference< XComponentContext> xContext( ::cppu::bootstrap() );
b) Reference< XMultiComponentFactory> xServiceManager(
xContext->getServiceManager() );
c) Reference< XComponentLoader> xComponentLoader(
xServiceManager->createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.frame.Desktop" ) ),
xContext ),
UNO_QUERY_THROW );
d) Reference< XComponent> xComponent =
xComponentLoader->loadComponentFromURL(
OUString::createFromAscii( "private:factory/swriter" ),
OUString( RTL_CONSTASCII_USTRINGPARAM( "testdoc" ) ),
8, // if not exist, then create it
Sequence< ::com::sun::star::beans;:PropertyValue>() );
e) Reference< XFrame> xFrame(
xServiceManager->createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.frame.Desktop" ) ),
xContext ),
UNO_QUERY_THROW );
f) xFrame->findFrame( OUString::createFromAscii("testdoc"), 23 );
g) printf( "Frame name : %s\t", OUStringToOString( xFrame->getName(),
RTL_TEXTENCODING_ASCII_US ).getStr() );
h) printf( "Frame status : %d\n", xFrame->isActive() );
i) xComponent = xComponentLoader->loadComponentFromURL(
OUString::createFromAscii( "file:///mytestURL" ),
OUString( RTL_CONSTASCII_USTRINGPARAM( "testdoc" ) ),
23 // search from all frames
Sequence< ::com::sun::star::beans;:PropertyValue>() );
------------------------ end of C++ code -----------------------------
Best regards
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]