Shukla:

I am currently working on a project that generates documents from a database (user variables, text marks, tables, and some formatting, i.e. standard stuff) using UNO C++ from inside an MFC application. I did not find any difficulties and the docs pretty much explain anything you need, but there are no prepared Visual Studio solutions. You should get the bootstrap example to work, then the rest is pretty much self-explanatory. I am using Visual Studio 2012, but I doubt that VS2010 behaves differently.

If there is sufficient interest, I could write a small Visual Studio centric HowTo, but right now I am pretty busy with my own project.

Here are a few pointers:

(1) Some C++ headers declare symbols that clash with internal symbols of cl. There are quite a few ways around this problem, without recompiling the UNO libs. (2) Implement the Java examples from the Developer's Guide in C++. There is a 1 to 1 mapping from Java (and UNO) to C++ language constructs and this is well documented. While learning, I found it very useful to benefit from the better documented Java interface (with Javadocs). (3) Be consistent with character encodings. For external sources I use UTF-8 exclusively which is easy to map to the UNO C++ string representation using WideCharToMultiByte() and MultiByteToWideChar(). (4) As long as you use the UNO libraries from the distribution package, you cannot build native 64bit applications.

MFC specific:
(1) The current bootstrap code is very general and hardly requires any configuration, but I don't like the flashing console window. I put more or less the equivalent stuff into InitInstance() and ExitInstance() of the application object to avoid starting with a separate app. (2) Any data processing is done inside OnIdle() in my project. A separate thread should also be easy to implement. (3) Some operations (e.g. tables with computed values) require a short waiting period, or some values are not initially updated inside the resulting OpenOffice document. I haven't had the time to look at the UNO source code to find why you need a waiting period here and there. The occasional waiting period is also required for console applications.

I hope this helps a a bit.

jg

Reply via email to