I have been trying to port some Delphi code to windows and I have it all running, but am running into some
issues with OpenOffice.
The code works fine on delphi, the problem appears to be a issue with variant arrays and strings.
For example:
This does not work and openoffice can't find the file:
fDocument.StoreToURL('file:///'+ StringReplace(FileName, '\', '/', [rfIgnoreCase, rfReplaceAll]), wProperties);
however this does work:
fDocument.StoreToURL('file:///C:/Users/20659/Desktop/junk0/Rpt.pdf', wProperties);
I tried converting the variable version to UTF and Ansistring, but it simply does not work if the string has any parts that are from a
string var.
I then tried this:
var
url:string;
url:= UTF8toAnsi(format('file:///%s',[StringReplace(FileName, '\', '/', [rfReplaceAll,rfIgnoreCase])]));
still bombs out.
The other isssue is with VarArrayCreate
for example:
var
wProperties : Variant;
wProperties := VarArrayCreate([0, 0], varVariant);
wProperties[0] := MakePropertyValue('Hidden', True); //this tells open office to not display a window when opening the doc
fDocument := fDesktop.loadComponentFromURL(''file:///C:/Users/20659/Desktop/junk0/NJMoOutsourcingRpt.xls'', '_blank', 0, wProperties);
OpenOffice simply does not like the VarArray created by FP/Lazarus and when the doc loads it ignores the wProperties sent as the last arg.
I am using version 0.9.30.2 from Nov 2011. I am going to try one of the slightly newer daily snapshots with FP 2.6 and see if it's any better.
I also have the compiler switch set for Delphi Mode.