Hi,
i suggest that you take a look into the SDK examples and read the First
Steps and Professional UNO chapter of the Developers Guide. You don't
have to read the whole ProfUNO chapter but you should read the C++
binding and the fundamental concepts.
Maybe some parts of the Components chapter are also interesting.
In general it isn't so difficult and it's probably simply new for you
because it's similar to normal C++ programming but you have to take care
of some special requirements.
The whole API is defined in IDL. The IDL type definitions are translated
into a binary representation (type library, rdb). For C++ you have to
generate header files for the types you will need in your program. That
is done with the cppumaker tool. You can simply generate all header with:
cppumaker -BUCR -O.\<myheader_or_whatever> <office_program_dir>\types.rdb
Prepare your compiler to include the <myheader_or_whatever> directory
and include the necessary types in your example (see SDK examples)
To bootstrap UNO and start an office automatically you should use the
simple bootstrap mechanism (see for example the TestCppComponent.cxx
example in <sdk>\examples\DevelopersGuide\Components\CppComponent.
Build your binary normally, rename it to _mybinary, copy the
unoapploader binary from <sdk>\platform\bin in the same directory of
your binary and rename it to mybinary. The renamed unoapploader binary
prepare an environment for your binary and starts your binary
automatically. The bootstrap function will automatically start the
default office and return the global component context from the office
which you can use for all further API stuff in your application (see the
examples)
Juergen
Pierre-André wrote:
Hi all,
I am having problems building some code. What I do not understand is the steps
needed for the code to give a program : when to link the program, what is the
rdb file used for, when to compile and with which options and dependencies ?
I would like to create a main() program. This program would call an object
"MyObject". This Object would encapsulate all the code related to the
OpenOffice API. A sample of what the code looks like is given below.
The problem is that I do not really know how things must be done, and thus
getting the program to compile is really difficult. Is there any
documentation about this ? Because, in the doc, it explains it for doing
components, but not how to use it from outside !
Thanks,
Pierre-André
- main.cxx
#include "my_object.h"
int
main()
{
my_object u;
std::string s = "Yop";
u.myfunc( s );
return 0;
}
- my_object.h
class MyObject
{
public :
// Constructor. Connects itself to an OpenOffice's instance.
MyObject();
// Does something
void myfunc( const std::string &s );
};
- my_object.cpp
// Some includes
#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::frame;
using namespace rtl;
using namespace cppu;
using namespace std;
// Constructor.
MyObject::MyObject()
{
// connect to OpenOffice instance using UNO API.
// some code.
Reference< XComponentContext > xContext( ::cppu::bootstrap() );
...
}
void MyObject::myfunc( const std::string &s )
{
cout << "s = " << s << endl;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]