OLE, "Struct" problem with StarOffice

as

New Member
Hi,

I have a problem using OLE automation which need a "struct" definition:

This is a small portion of VB code I wish to translate to use with Progress 4GL:

Sub usePropertySet()

/* QUESTION: What is the equivalent of this déclaration in 4GL ?*/
Dim starStruct(1) As Object


/* QUESTION How can I reproduce the following mechanism ? */
' create a object for VBA, from the first element
Call starStructClass.CreateObject(starStruct(1))

' Set the values
starStruct(0).Name = "FilterName"
starStruct(0).Value = "swriter: Rich Text Format"

' create a object for VBA, from the first element
Call starStructClass.CreateObject(starStruct(1))

starStruct(1).Name = "ReadOnly"
starStruct(1).Value = True

' load the document
Set starDocument = starDesktop.loadComponentfromURL("c:\MyRTF.rtf", "_blank", 0, starStruct())


End Sub

I have to developp OLE functionalities with StarOffice (Office suite by Sun). I use to developp this kind of program easyly with Microsoft Office, but with Star Office, I just can launch the application and create a desktop, but I can not open or create a document because StarOffice functions wait for a Struct parameter...

Any Ideas or work around ?

Thanks in advance !

André.

:confused:
 

as

New Member
Hi Masternoob !

I'm afraid it will take a long time before you get an answer. As you can see, eleven years later, I'm still waiting :D. (yes, I'm still using Progress)

Unfortunaltely, I haven't any solution. So I wish you good luck !;) And, let me know if you solve the problem. Who knows ...?

Regards,
André.
 

trx

Member
There is no easy solution to this problem, because AFAIK OpenEdge lacks array support. However you can deal with this problem using external programs / modules:
1) Create your own COM object that will deal with array functions - so some objects you call with ABL and some with your COM object, see for example: http://www.oooforum.org/forum/viewtopic.phtml?t=72973
2) Do everything using external program, for example below is simple OpenOffice XLS-to-CSV converter (Pascal/Delphi).
Code:
uses
  SysUtils,
  ComObj,
  Variants,
  ActiveX,
  Dialogs;

var  StarOffice : Variant;
      StarDesktop : Variant;
      CoreReflection : Variant;
      PropertyValue_A : Variant;
      PropertyValue_B : Variant;
      LoadParams : Variant;
      SaveParams : Variant;
      Document : Variant;
      xlsFileName : string;
      csvFileName : string;

begin
    xlsFileName := ParamStr(1);
    csvFileName := ParamStr(2);

    Coinitialize(nil);

    StarOffice := CreateOleObject('com.sun.star.ServiceManager');
    StarDesktop := StarOffice.createInstance('com.sun.star.frame.Desktop');
    CoreReflection := StarOffice.createInstance('com.sun.star.reflection.CoreReflection');

    CoreReflection
           .forName('com.sun.star.beans.PropertyValue')
           .createObject(PropertyValue_A);

    CoreReflection
           .forName('com.sun.star.beans.PropertyValue')
           .createObject(PropertyValue_B);


    PropertyValue_A.Name := 'ReadOnly';
    PropertyValue_A.Value := true;

    PropertyValue_B.Name := 'Hidden';
    PropertyValue_B.Value := true;

    LoadParams := VarArrayCreate([0, 1], varVariant);
    LoadParams[0] := PropertyValue_A;
    LoadParams[1] := PropertyValue_B;

    Document := StarDesktop.LoadComponentFromURL( xlsFileName, '_blank', 0,  LoadParams);

    PropertyValue_A.Name  := 'FilterName';
    PropertyValue_A.Value := 'Text - txt - csv (StarCalc)';

    PropertyValue_B.Name  := 'FilterOptions';
    PropertyValue_B.Value := '59,34,0,1'; 

    SaveParams := VarArrayCreate([0, 1], varVariant);
    SaveParams[0] := PropertyValue_A;
    SaveParams[1] := PropertyValue_B;
    Document.storeAsUrl( csvFileName, SaveParams);
    Document.dispose;
end.

If you use Linux then you can use unoconv if you need format conversion or pyuno and some libraries (like http://www.oooforum.org/forum/viewtopic.phtml?p=56015) if you want to create OO/Excel spreadsheets.
 
Top