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
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 (¶m1);
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 ();
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