Difference between revisions of "MainOOConnectFR"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (New page: <source lang="cpp"> //Listing 0b Again our starting main Code int main( ) { //retrieve an instance of the remote service manager Reference< XMultiServiceFactory > rOfficeServiceManager...)
 
m
Line 2: Line 2:
 
//Listing 0b Again our starting main Code
 
//Listing 0b Again our starting main Code
 
int main( ) {
 
int main( ) {
//retrieve an instance of the remote service manager
+
//retrouve une instance service manager distant avec notre ooConnect()
 
     Reference< XMultiServiceFactory > rOfficeServiceManager;
 
     Reference< XMultiServiceFactory > rOfficeServiceManager;
 
     rOfficeServiceManager = ooConnect();
 
     rOfficeServiceManager = ooConnect();
 
     if( rOfficeServiceManager.is() ){
 
     if( rOfficeServiceManager.is() ){
         printf( "Connected sucessfully to the office\n" );
+
         printf( "Connecté avec succès à OpenOffice\n" );
 
     }
 
     }
  
Line 13: Line 13:
 
     OUString::createFromAscii( "com.sun.star.frame.Desktop" ));
 
     OUString::createFromAscii( "com.sun.star.frame.Desktop" ));
  
//query for the XComponentLoader interface
+
//demande de l'interface XComponentLoader interface
 
     Reference< XComponentLoader > rComponentLoader (Desktop, UNO_QUERY);
 
     Reference< XComponentLoader > rComponentLoader (Desktop, UNO_QUERY);
 
     if( rComponentLoader.is() ){
 
     if( rComponentLoader.is() ){
Line 29: Line 29:
 
}
 
}
 
</source>
 
</source>
Ce code est appelé un [[UNO_registery_and_Bootstrapping#The_Bootstrap|programme d'amorce]] et utilise :  
+
Ce code est appelé un [[Documentation/FR/Base_de_registres#Le_d.C3.A9marrage_.28Bootstrap.29|programme d'amorce ou de démarrage]] et utilise :  
 
# les interfaces <idl>com.sun.star.lang.XMultiServiceFactory</idl>, <idl>com.sun.star.uno.XInterface</idl>, <idl>com.sun.star.frame.XComponentLoader</idl> et <idl>com.sun.star.lang.XComponent</idl> interfaces
 
# les interfaces <idl>com.sun.star.lang.XMultiServiceFactory</idl>, <idl>com.sun.star.uno.XInterface</idl>, <idl>com.sun.star.frame.XComponentLoader</idl> et <idl>com.sun.star.lang.XComponent</idl> interfaces
 
# le service <idl>com.sun.star.frame.Desktop</idl>,
 
# le service <idl>com.sun.star.frame.Desktop</idl>,

Revision as of 16:56, 7 May 2009

//Listing 0b Again our starting main Code
int main( ) {
//retrouve une instance service manager distant avec notre ooConnect()
    Reference< XMultiServiceFactory > rOfficeServiceManager;
    rOfficeServiceManager = ooConnect();
    if( rOfficeServiceManager.is() ){
        printf( "Connecté avec succès à OpenOffice\n" );
    }
 
//get the desktop service using createInstance returns an XInterface type
    Reference< XInterface  > Desktop = rOfficeServiceManager->createInstance(
    OUString::createFromAscii( "com.sun.star.frame.Desktop" ));
 
//demande de l'interface XComponentLoader interface
    Reference< XComponentLoader > rComponentLoader (Desktop, UNO_QUERY);
    if( rComponentLoader.is() ){
        	printf( "XComponentloader successfully instanciated\n" );
    	}
 
//get an instance of the spreadsheet
    Reference< XComponent > xcomponent = rComponentLoader->loadComponentFromURL(
	OUString::createFromAscii("private:factory/scalc"),
        OUString::createFromAscii("_blank"),
        0,
        Sequence < ::com::sun::star::beans::PropertyValue >());
// add code here
    return 0;
}

Ce code est appelé un programme d'amorce ou de démarrage et utilise :

  1. les interfaces com.sun.star.lang.XMultiServiceFactory, com.sun.star.uno.XInterface, com.sun.star.frame.XComponentLoader et com.sun.star.lang.XComponent interfaces
  2. le service com.sun.star.frame.Desktop,
  3. la structure UNO com.sun.star.beans.PropertyValue.

Rappelez-vous que chaque fois que vous demandez une interface vous devez ajouter des lignes de code si elles n'existent pas dans le code source ainsi que dans le makefile. Je vais en général ajouter des commentaires pour éviter les omissions. Vois pouvez trouver plus d'explications ici (si vous n'êtes pas un débutant).

Template:Documentation/Note Template:Documentation/Note

Personal tools