Automation OpenOffice with C language

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Automation OpenOffice with C language

Postby PabloF » Sun Apr 12, 2015 8:32 pm

Hi there,

Please anyone explain to me how does this idea of interfaces, modules, service, struct is realized with OLE dispatch.
I managed to make connection to OpenOffice, create a sheet, fill it out, everything using Autowrap function, that dispatches functions from UNO API.
for example:
Code: Select all   Expand viewCollapse view
   CoInitialize (NULL);   // Initialize COM for this thread...
   bUsed = TRUE;
   CLSID clsid;   // Get CLSID for our server...
   HRESULT hr = CLSIDFromProgID (L"com.sun.star.ServiceManager", &clsid);
   if (FAILED (hr)) {   ::MessageBox (NULL, "CLSIDFromProgID() failed", "Error", 0x10010); return FALSE; }
   // Start server and get IDispatch...
   hr = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, (void**) &pOOApp);
   if (FAILED(hr))  {::MessageBox (NULL, "OpenOffice not registered properly", "Error", 0x10010);return FALSE;   }
   // Get Desktop and its assoc. IDispatch...
   VARIANT result;
   VARIANT param1;
   VariantInit(&result);
   VariantInit (&param1);
   param1.vt = VT_BSTR;      // it's a UNICODE string
   param1.bstrVal = ::SysAllocString (L"com.sun.star.frame.Desktop");
   AutoWrap (DISPATCH_METHOD, &result, pOOApp, L"createInstance", 1, param1);
   
   pdispDesktop = result.pdispVal; // IDispatch* 
   pdispDesktop->AddRef ();


This is Basic would be one or two lines of code.
Unfortunately in C it's a real pain.

I need to merge cells in a sheet.
I managed to create a Cell object, change it's color, and that's it.

I know I have to use XMergeable, I found it in the API documentation, but I have no clue how to create an instance of it.
I tried to create an instance of XMergeable from different IDispatch objects, representing a sheet, a document, an application.
Nothing, I cannot create it.
As a matter of fact, documentation states what objects are there, and what is connected to what, but I still cannot figure out connections, how can I get the object of given class.

Please give me something, that will allow me to understand it.
On this forum I have found only 3 posts about using UNO API in C, is this really ancient history ?

Regards
Pablo
Last edited by floris v on Sun Apr 12, 2015 9:52 pm, edited 1 time in total.
Reason: Removed icon used for threads with link to bug report
OpenOffice 4.1.1 Windows all types
PabloF
 
Posts: 1
Joined: Sun Apr 12, 2015 8:09 pm

Re: Automation OpenOffice with C language

Postby Villeroy » Sun Apr 12, 2015 9:11 pm

Virtually nobody automates Openoffice with C and this is a user forum.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26417
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest