Hi,
I have integrated LibreOffice into our Delphi application and would like to load documents directly from memory. For that I need to create a SequenceInputStream and then populate it with the raw file data.
I can create the SequenceInputStream without issue, but for the life of me I cannot figure out how to populate it from e.g. an array of bytes. Here is a small test case:
program SequenceInputStream;
{$APPTYPE CONSOLE}
uses
  System.SysUtils, System.Win.ComObj, Winapi.ActiveX;
var
  ServiceManager: Variant;
function CreateSequenceInputStreamFromByteArray(const AByteArray: TBytes): Variant;
var
  LVariantByteArray: Variant;
begin
  LVariantByteArray := AByteArray;
  Result := ServiceManager.createInstance('com.sun.star.io.SequenceInputStream');
  //EOleError with message 'Method 'createStreamFromSequence' not supported by automation object'.
  Result.createStreamFromSequence(LVariantByteArray);
  //EOleException with message 'com.sun.star.lang.IllegalArgumentException: Wrong number of arguments!'.
  Result.initialize(LVariantByteArray);
end;
var
  LByteArray: TBytes;
  LMyStream: Variant;
begin
  CoInitialize(nil);
  ServiceManager := CreateOleObject('com.sun.star.ServiceManager');
  try
    SetLength(LByteArray, 10000);
    LMyStream := CreateSequenceInputStreamFromByteArray(LByteArray);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
According to the documentation there should be a “createStreamFromSequence” method, but that doesn’t seem accessible. If It try to call it it returns the error ‘Method ‘createStreamFromSequence’ not supported by automation object’.
“intialize” is available, but it doesn’t accept the array of bytes in any format that I have tried. The error message is ‘com.sun.star.lang.IllegalArgumentException: Wrong number of arguments!’.
Does anyone know how to populate a SequenceInputStream via Delphi code?
Thanks!
 
      
    
