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".
Could anyone give me some hint? 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

--
===========================================
Yuelin Zhuang   --   Testing 3, RedFlag2000
MSN :                 [email protected]
E-mail:          [email protected]
===========================================


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to