1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69:
| function convertToURL(winAddr: String): String; var sv : Variant; x: Integer; sLow, UTF8Addr, prefix: String; begin sLow:= AnsiLowerCase(winAddr); prefix:= ''; for x:= 1 to High(URLprefix) do if Pos(URLprefix[x], sLow) = 1 then begin winAddr:= Copy(winAddr, Length(URLprefix[x]) +1, 2000); if x>1 then prefix:= URLprefix[x]; Break; end; if (Length(prefix) = 0) and (Pos('@', sLow) > 0) then Result:= 'mailto:' +winAddr else begin sv:= Vertrieb.OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider'); UTF8Addr:= sv.getFileURLFromSystemPath('', winAddr); Result:= prefix +UTF8Addr; end; end;
function convertFromURL(URLaddr: String): String; var sv : Variant; x: Integer; sLow, winAddr, prefix: String; begin sLow:= AnsiLowerCase(URLaddr); prefix:= ''; for x:= 1 to High(URLprefix) do if Pos(URLprefix[x], sLow) = 1 then begin if x>1 then begin URLaddr:= Copy(URLaddr, Length(URLprefix[x]) +1, 2000); prefix:= URLprefix[x]; end; Break; end; sv:= Vertrieb.OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider'); winAddr:= sv.getSystemPathFromFileURL(URLaddr); if Length(prefix) <> 0 then winAddr:= StringReplace(winAddr, '\', '/', [rfReplaceAll]); Result:= prefix +winAddr; end;
procedure OpenCalc; var Path : String; Par : Variant;
begin with Form1 do begin
Par := VarArrayCreate([0, - 1], varVariant); OpenOffice := CreateOleObject('com.sun.star.ServiceManager'); StarDesktop := OpenOffice.createInstance('com.sun.star.frame.Desktop'); sv := OpenOffice.createInstance('com.sun.star.ucb.FileContentProvider'); Path := sv.getFileURLFromSystemPath('', FilePath); excel := StarDesktop.loadComponentFromURL( Path, '_blank', 0, Par ); Sheet := excel.Sheets.getByName( WorkSheet );
end; end;
|