Autor Beitrag
Dhakiyah
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Mi 25.08.10 09:48 
Hab ein OpenOffice Document geöffnet und gefüllt und möchte es jetzt als PDF speichern, automatisiert über Delphi.
Hab aber absolut keine Ahnung wie...

_________________
Es ist soooo flauschig !!!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 25.08.10 09:54 
Wie füllst du es? (Wie erfolgt die Automatisierung)

_________________
Markus Kinzler.
Dhakiyah Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Mi 25.08.10 09:58 
???

Ich mache einen create, öffne das Dokument, fülle die Textmarken... Ich weiß nicht was du meinst...

_________________
Es ist soooo flauschig !!!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 25.08.10 10:12 
Und wie erfolgt der Zugriff?

_________________
Markus Kinzler.
Dhakiyah Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Mi 25.08.10 10:16 
ausblenden volle Höhe Delphi-Quelltext
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:
function TOLE_OpenOffice.Connect:boolean;
var rueckgabe : boolean;
begin
    try
      Service := CreateOleObject('com.sun.star.ServiceManager');
      Desktop := Service.createInstance('com.sun.star.frame.Desktop');
      rueckgabe := true;
    except
      rueckgabe := false;
    end;
    result := rueckgabe;
end;



function TOLE_OpenOffice.Open:boolean;
var rueckgabe : boolean;
begin
  try
    Document := Desktop.LoadComponentFromURL(
              'private:factory/swriter',
              '_blank',
              0,
              VarArrayCreate([0, - 1], varVariant));
    rueckgabe := true;
    setze_Doc_Type('s');
  except
    rueckgabe := false;
  end;
  result := rueckgabe;
end;


function TOLE_OpenOffice.ErsetzeBookmark(name,inhalt:String):boolean;
var objtext, tc, bm, li: Variant;
    i : integer;
    rueckgabe : boolean;
begin
  rueckgabe := false;
  try
    objText := Document.getText;
    tc := objText.createTextcursor;
    li := Document.Bookmarks.getElementNames;
    for i := VarArrayLowBound(li,1to VarArrayHighBound(li,1do
    begin
      if (uppercase(li[i]) =  uppercase(name)) then
      begin
        bm := Document.Bookmarks.getbyName(li[i]);
        tc := Document.Text.createTextCursorByRange(bm.Anchor);
        tc.string := inhalt;
        rueckgabe := true;
      end;
    end;
  except
    rueckgabe := false;
  end;
  result := rueckgabe;
end;


Meinst du das???

_________________
Es ist soooo flauschig !!!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 25.08.10 10:28 
Ja.
Sollte mit .StoreAsURL() oder .StoreToURL() gehen

wiki.services.openof...ki/Saving_a_document

_________________
Markus Kinzler.
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Mi 25.08.10 10:33 
ausblenden Delphi-Quelltext
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:
function TOLE_OpenOffice.SaveFileasPDF(sFile: String): boolean;
var  wProperties, fOpenOffice: variant;
     rueckgabe: Boolean;
begin
  try
    wProperties := VarArrayCreate([03], varVariant);
    wProperties[0] := Service.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    wProperties[0].Name := 'FilterName';
    case Doc_Type of
      oodtcalc    : wProperties[0].Value := 'calc_pdf_Export';
      oodtwriter  : wProperties[0].Value := 'writer_pdf_Export';
      oodtdraw    : wProperties[0].Value := 'draw_pdf_Export';
      oodtmath    : wProperties[0].Value := 'math_pdf_Export';
      oodtunknown : wProperties[0].Value := 'writer_pdf_Export';
    end;


    wProperties[1] := create_PropertyValue('CompressionMode''1');
    wProperties[2] := create_PropertyValue('Pages''All');
    wProperties[3] := create_PropertyValue('Overwrite', TRUE);
    Document.StoreToURL(ToOOPfad(sFile), wProperties);
    rueckgabe := true;
  except
    rueckgabe := false;
  end;
  result := rueckgabe;
end;

Die überflüssigen Doc_Types einfach rauswerfen, für Writer also
ausblenden Delphi-Quelltext
1:
wProperties[0].Value := 'writer_pdf_Export';					

nur verwenden, ich hab da mal die Unit weiter aufgebohrt.

_________________
mfg. Joel
Dhakiyah Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 327
Erhaltene Danke: 5

Windows 7
Delphi XE2
BeitragVerfasst: Mi 25.08.10 10:45 
So gings:

ausblenden Delphi-Quelltext
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:
function TOLE_OpenOffice.SaveFileasPDF(sFile: String): boolean;
var  wProperties, fOpenOffice: variant;
     rueckgabe: Boolean;
begin
  try
    wProperties := VarArrayCreate([03], varVariant);
    wProperties[0] := Service.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    wProperties[0].Name := 'FilterName';
//    case Doc_Type of
//      oodtcalc    : wProperties[0].Value := 'calc_pdf_Export';
//      oodtwriter  :
      wProperties[0].Value := 'writer_pdf_Export';
//      oodtdraw    : wProperties[0].Value := 'draw_pdf_Export';
//      oodtmath    : wProperties[0].Value := 'math_pdf_Export';
//      oodtunknown : wProperties[0].Value := 'writer_pdf_Export';
//    end;


//    wProperties[1] := create_PropertyValue('CompressionMode', '1');
//    wProperties[2] := create_PropertyValue('Pages', 'All');
//    wProperties[3] := create_PropertyValue('Overwrite', TRUE);
    Document.StoreToURL(ToOOPfad(sFile), wProperties);
    rueckgabe := true;
  except
    rueckgabe := false;
  end;
  result := rueckgabe;
end;


Oder braucht man das auskommentierte?

_________________
Es ist soooo flauschig !!!
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Mi 25.08.10 12:14 
oh ich vergaß
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function TOLE_OpenOffice.create_PropertyValue(PropName: string; PropValue: variant): variant;
begin
    Result := Service.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
    Result .Name := PropName;
    Result .Value := PropValue;
end;


Darum wird das

ausblenden Delphi-Quelltext
1:
2:
3:
    wProperties[1] := create_PropertyValue('CompressionMode''1');
    wProperties[2] := create_PropertyValue('Pages''All');
    wProperties[3] := create_PropertyValue('Overwrite', TRUE);


nicht funktioniert haben.

Aber wie ich festgestellt habe werden diese Properties scheinbar eh nicht mehr unterstützt, der Code ist schon ein wenig älter.

_________________
mfg. Joel