oocInit | Инициализация таблицы Calc |
oocInit1 |
Инициализация таблицы Calc как шаблона |
oocPrintString |
Запись в текущую ячейку |
oocGoLeft |
Переход от текущей ячейки влево |
oocGoRight |
Переход от текущей ячейки вправо |
oocGoUp |
Переход от текущей ячейки вверх |
oocGoDown |
Переход от текущей ячейки вниз |
oocGoSheet |
Переход на другой лист |
oocGetString |
Чтение из текущей ячейки |
oocGoHome |
Переход в начало листа |
oocDelete |
Удаление содержимого |
oocSaveDoc |
Сохранение текущего документа в формате Excel'97 |
procedure TOpenOffice.oocInit(dotname:string); var sb:string; begin //если шаблон пустой, то документ создается с чистого бланка if dotname='' then sb:='private:factory/scalc' else sb:='file:///'+dotname; StarOffice:=CreateOleObject('com.sun.star.ServiceManager'); StarDesktop:=StarOffice.CreateInstance('com.sun.star.frame.Desktop'); Document:=StarDesktop.LoadComponentFromURL(sb,'_blank',0,VarArrayCreate([0,-1],varVariant)); end; |
procedure TOpenOffice.oocInit1(dotname:string); var sb:string; LoadParams:Variant; PropertyValue:Variant; CoreReflection:Variant; begin //если шаблон пустой, то документ создается с чистого бланка if dotname='' then sb:='private:factory/scalc' else sb:='file:///'+dotname; LoadParams := VarArrayCreate([0,0], varVariant); 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); PropertyValue.Name := 'AsTemplate'; PropertyValue.Value := True; LoadParams[0] := PropertyValue; Document:=StarDesktop.LoadComponentFromURL(sb,'_blank',0,LoadParams); end; |
procedure TOpenOffice.oocPrintString(sb:string); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); oArgs:=VarArrayCreate([0,0],varVariant); propertyValue0.Name:='StringName'; propertyValue0.Value:=sb; oArgs[0]:=propertyValue0; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:EnterString','',0,oArgs); end; |
procedure TOpenOffice.oocGoLeft(n:integer); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0,propertyValue1:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue1); oArgs:=VarArrayCreate([0,1],varVariant); propertyValue0.Name:='By'; propertyValue0.Value:=n; oArgs[0]:=propertyValue0; propertyValue1.Name:='Sel'; propertyValue1.Value:=False; oArgs[1]:=propertyValue1; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:GoLeft','',0,oArgs); end; |
procedure TOpenOffice.oocGoRight(n:integer); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0,propertyValue1:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue1); oArgs:=VarArrayCreate([0,1],varVariant); propertyValue0.Name:='By'; propertyValue0.Value:=n; oArgs[0]:=propertyValue0; propertyValue1.Name:='Sel'; propertyValue1.Value:=False; oArgs[1]:=propertyValue1; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:GoRight','',0,oArgs); end; |
procedure TOpenOffice.oocGoUp(n:integer); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0,propertyValue1:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue1); oArgs:=VarArrayCreate([0,1],varVariant); propertyValue0.Name:='By'; propertyValue0.Value:=n; oArgs[0]:=propertyValue0; propertyValue1.Name:='Sel'; propertyValue1.Value:=False; oArgs[1]:=propertyValue1; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:GoUp','',0,oArgs); end; |
procedure TOpenOffice.oocGoDown(n:integer); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0,propertyValue1:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue1); oArgs:=VarArrayCreate([0,1],varVariant); propertyValue0.Name:='By'; propertyValue0.Value:=n; oArgs[0]:=propertyValue0; propertyValue1.Name:='Sel'; propertyValue1.Value:=False; oArgs[1]:=propertyValue1; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:GoDown','',0,oArgs); end; |
procedure TOpenOffice.oocGoSheet(n:integer); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); oArgs:=VarArrayCreate([0,0],varVariant); propertyValue0.Name:='Nr'; propertyValue0.Value:=n; oArgs[0]:=propertyValue0; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:JumpToTable','',0,oArgs); end; |
function TOpenOffice.oocGetString(SheetName:string;x,y:integer):string; var WorkBook,Sheet,Cell:variant; begin oocGetString:=''; WorkBook:=Document.getSheets; Sheet:=WorkBook.GetByName(SheetName); Cell:=Sheet.getCellByPosition(x,y); oocGetString:=VarToStr(Cell.String); end; |
procedure TOpenOffice.oocGoHome; var oDispatcher,oArgs:variant; CoreReflection,propertyValue0:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); oArgs:=VarArrayCreate([0,0],varVariant); propertyValue0.Name:='Sel'; propertyValue0.Value:=False; oArgs[0]:=propertyValue0; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:GoToStart','',0,oArgs); end; |
procedure TOpenOffice.oocDelete; var oDispatcher,oArray:variant; CoreReflection,propertyValue0:variant; oFrame:variant; begin oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); oArray:=VarArrayCreate([0,0],varVariant); propertyValue0.Name:=''; propertyValue0.Value:=0; oArray[0]:=propertyValue0; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:ClearContents','',0,oArray); end; |
procedure TOpenOffice.oocSaveDoc(way:string); var oDispatcher,oArgs:variant; CoreReflection,propertyValue0,propertyValue1,propertyValue2:variant; oFrame:variant; begin way:=StringReplace(way,'\','/',[rfReplaceAll]); oDispatcher:=StarOffice.createInstance('com.sun.star.frame.DispatchHelper'); CoreReflection:=StarOffice.createInstance('com.sun.star.reflection.CoreReflection'); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue0); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue1); CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue2); oArgs:=VarArrayCreate([0,2],varVariant); propertyValue0.Name:='URL'; propertyValue0.Value:='file:///'+way; oArgs[0]:=propertyValue0; propertyValue1.Name:='FilterName'; propertyValue1.Value:='MS Excel 97'; oArgs[1]:=propertyValue1; propertyValue2.Name:='SelectionOnly'; propertyValue2.Value:=True; oArgs[2]:=propertyValue2; oFrame:=Document.getCurrentController.getFrame; oDispatcher.executeDispatch(oFrame,'.uno:SaveAs','',0,oArgs); end; |