Модератор: Модераторы
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, EditBtn, MaskEdit, ComObj, Variants, LCLProc;
var
Form1: TForm1;
Server: Variant;
Desktop : Variant;
LoadParams : Variant;
Document : Variant;
TextCursor : Variant;
BookmarksSupplier: Variant;
Bookmark: Variant;
instext: string;
sss: Variant;
const
ServerName = 'com.sun.star.ServiceManager';
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
try
Server := CreateOleObject(ServerName);
except
ShowMessage('Не установлен OpenOffice');
Exit;
end;
Desktop := Server.CreateInstance('com.sun.star.frame.Desktop');
LoadParams := VarArrayCreate([0, -1], varVariant);
{Open document}
{ sss:='';
sss:=ExtractFilePath(ParamStrUTF8(0));
sss:= StringReplace(sss, ':', '|', [rfReplaceAll, rfIgnoreCase]);
sss:= StringReplace(sss, '\', '/', [rfReplaceAll, rfIgnoreCase]);
sss:='file:///'+sss+'1.odt';
}
sss:='';
sss = 'file:///c|/1.odt';
Document := Desktop.LoadComponentFromURL(sss,'_blank', 0, LoadParams);
{
TextCursor := Document.Text.CreateTextCursor;
BookmarksSupplier:=Document.getBookmarks;
Bookmark:=BookmarksSupplier.getByName('a1').getAnchor;
instext:='работает';
Bookmark.setString(instext);
}
//Document.Close(True);
//Document:=Unassigned;
Server:= Unassigned;
end;
sss:='file:///c|/1.odt';
Document := Desktop.LoadComponentFromURL(variant(sss),'_blank', 0, LoadParams);
xcod писал(а):а так будет работать?
- Код: Выделить всё
sss:='file:///c|/1.odt';
Document := Desktop.LoadComponentFromURL(variant(sss),'_blank', 0, LoadParams);
instext:='работает';
Bookmark.setString(instext);
BookmarksSupplier:=Document.getBookmarks;
Bookmark:=BookmarksSupplier.getByName('a1').getAnchor;
instext:='работает';
Bookmark.setString(instext);
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, EditBtn, MaskEdit, ComObj, Variants, LCLProc;
var
Form1: TForm1;
Server: Variant;
Desktop : Variant;
LoadParams : Variant;
Document : Variant;
TextCursor : Variant;
BookmarksSupplier: Variant;
Bookmark: Variant;
instext: string;
sss: Variant;
const
ServerName = 'com.sun.star.ServiceManager';
implementation
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
try
Server := CreateOleObject(ServerName);
except
ShowMessage('Не установлен OpenOffice');
Exit;
end;
Desktop := Server.CreateInstance('com.sun.star.frame.Desktop');
LoadParams := VarArrayCreate([0, -1], varVariant);
{Open document}
sss:='';
sss:=ExtractFilePath(ParamStrUTF8(0));
sss:= StringReplace(sss, ':', '|', [rfReplaceAll, rfIgnoreCase]);
sss:= StringReplace(sss, '\', '/', [rfReplaceAll, rfIgnoreCase]);
sss:='file:///'+sss+'1.odt';
Document := Desktop.LoadComponentFromURL(variant(sss),'_blank', 0, LoadParams);
TextCursor := Document.Text.CreateTextCursor;
BookmarksSupplier:=Document.getBookmarks;
Bookmark:=BookmarksSupplier.getByName('a1').getAnchor;
instext:='работает';
Bookmark.setString(instext);
Server:= Unassigned;
end;
sant писал(а):************************************************************************************************************************
как я понимаю по умолчанию lazarus работает с utf-8 как нормально записать строчку
в open office writer?
Подскажите,что не так?
Bookmark.setString(UTF8toAnsi(instext))
Desktop.LoadComponentFromURL('file:///c|/1.odt','_blank', 0, LoadParams);
Bookmark:=BookmarksSupplier.getByName(UTF8Decode(b_text)).getAnchor;
Bookmark.setString(UTF8Decode(i_text));
PrintPar := VarArrayCreate([0, 2], varVariant);
PrintPar[0]:= MakePropertyValue('RangeText','2');
PrintPar[1]:= MakePropertyValue('Copies','1');
PrintPar[2]:= MakePropertyValue('Collate','true');
Document.Print(PrintPar);
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 33