Содержание
Delphi + OpenOffice: процедуры для работы с таблицами

ooInsertRow Вставка новой строки в таблицу
ooDeleteRow Удаление строки из таблицы
ooSelectRow Выделение строки в таблице
ooSelectCell Выделение ячейки
ooMergCell Объединение ячеек
ooSplitCell Разделение ячейки
ooDrawBorder Прорисовка бордюра ячейки
ooGoRight Переход вправо
ooGoLeft Переход влево
ooGoUp Переход вверх
ooGoDown Переход вниз
ooNextCell Переход в следующую ячейку
ooPrevCell Переход в предыдущую ячейку
ooParaKeepTogether Связать таблицу со следующим абзацем (свойства таблицы)


procedure ooInsertRow;

Вставка новой строки в таблицу. Новая строка вставляется ниже той, на которой стоит курсор во время вызова процедуры.

procedure TOpenOffice.ooInsertRow;
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:InsertRows','',0,oArray);

end;


procedure ooDeleteRow;

Удаление текущей строки из таблицы.

procedure TOpenOffice.ooDeleteRow;
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:DeleteRows','',0,oArray);

end;


procedure ooSelectRow;

Выделение текущей строки в таблице.

procedure TOpenOffice.ooSelectRow;
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:EntireRow','',0,oArray);

end;


procedure ooSelectCell(kol:integer);
kol - количество ячеек

Выделение ячеек в таблице. Будет выделена текущая ячейка и следующие за ней в количестве, указанном во входящем параметре.

procedure TOpenOffice.ooSelectCell(kol:integer);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0:variant;
    oFrame:variant;
    i:integer;
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:='';
  propertyValue0.Value:=0 ;
  oArgs[0]:=propertyValue0;
  oFrame:=Document.getCurrentController.getFrame;
  oDispatcher.executeDispatch(oFrame,'.uno:EntireCell','',0,oArgs);
  if kol>1 then
    for i:=1 to kol-1 do
      oDispatcher.executeDispatch(oFrame,'.uno:JumpToNextCell','',0,oArgs);

end;


procedure ooMergCell;

Объединение выделенных ячеек в одну.

procedure TOpenOffice.ooMergCell;
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:MergeCells','',0,oArray);

end;


procedure ooSplitCell(kol:integer);
kol - количество ячеек

Разделение текущей ячейки на количество ячеек, указанное во входящем параметре.

procedure TOpenOffice.ooSplitCell(kol:integer);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0,propertyValue1,propertyValue2: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);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue2);
  oArgs:=VarArrayCreate([0,2],varVariant);
  propertyValue0.Name:='Amount';
  propertyValue0.Value:=kol;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='Horizontal';
  propertyValue1.Value:=false;
  oArgs[1]:=propertyValue1;
  propertyValue2.Name:='Proportional';
  propertyValue2.Value:=false;
  oArgs[2]:=propertyValue2;
  oFrame:=Document.getCurrentController.getFrame;
  oDispatcher.executeDispatch(oFrame,'.uno:SplitCell','',0,oArgs);

end;


procedure ooDrawBorder(Top:boolean;Bottom:boolean);
top, bottom - определяют прорисовку верхнего и нижнего бордюра соответственно

Прорисовка бордюра ячейки. Процедуру необходимо использовать для каждой ячейки отдельно. Если параметр Top (Bottom) = True будет прорисован верхний (нижний) бордюр, если = False - бордюр станет невидимым.

procedure TOpenOffice.ooDrawBorder(Top:boolean;Bottom:boolean);
var oDispatcher,oArgs,oArgs1,oArgs2,oArgs3:variant;
    CoreReflection,propertyValue0,propertyValue1,propertyValue2:variant;
    propertyValue3,propertyValue4,propertyValue5:variant;
    propertyValue6,propertyValue7,propertyValue8:variant;
    propertyValue9,propertyValue10,propertyValue11,propertyValue12:variant;
    oFrame:variant;
    Array1:array[0..2,0..2,0..2,0..2] of integer;
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);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue2);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue3);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue4);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue5);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue6);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue7);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue8);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue9);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue10);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue11);
  CoreReflection.forName('com.sun.star.beans.PropertyValue').createObject(propertyValue12);
  oArgs:=VarArrayCreate([0,4],varVariant);
  oArgs1:=VarArrayCreate([0,7],varVariant);
  oArgs2:=VarArrayCreate([0,3],varinteger);
  oArgs3:=VarArrayCreate([0,3],varinteger);

  oArgs2[0]:=0;
  oArgs2[1]:=0;
  oArgs2[2]:=2;
  oArgs2[3]:=0;
  oArgs3[0]:=0;
  oArgs3[1]:=0;
  oArgs3[2]:=0;
  oArgs3[3]:=0;

  propertyValue0.Name:='BorderInner.Horizontal';
  propertyValue0.value:=oArgs2 ;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='BorderInner.Vertical';
  propertyValue1.Value:=oArgs2 ;
  oArgs[1]:=propertyValue1;
  propertyValue2.Name:='BorderInner.Flags';
  propertyValue2.Value:=3 ;
  oArgs[2]:=propertyValue2;
  propertyValue3.Name:='BorderInner.ValidFlags';
  propertyValue3.Value:=127 ;
  oArgs[3]:=propertyValue3;
  propertyValue4.Name:='BorderInner.DefaultDistance';
  propertyValue4.Value:=0 ;
  oArgs[4]:=propertyValue4;
  oFrame:=Document.getCurrentController.getFrame;
  oDispatcher.executeDispatch(oFrame,'.uno:BorderInner','',0,oArgs);
  propertyValue5.Name:='BorderOuter.LeftBorder';
  propertyValue5.Value:=oArgs2 ;
  oArgs1[0]:=propertyValue5;
  propertyValue6.Name:='BorderOuter.LeftDistance';
  propertyValue6.Value:=97 ;
  oArgs1[1]:=propertyValue6;
  propertyValue7.Name:='BorderOuter.RightBorder';
  propertyValue7.Value:=oArgs2 ;
  oArgs1[2]:=propertyValue7;
  propertyValue8.Name:='BorderOuter.RightDistance';
  propertyValue8.Value:=97 ;
  oArgs1[3]:=propertyValue8;
  propertyValue9.Name:='BorderOuter.TopBorder';
  if Top=True then propertyValue9.Value:=oArgs2 else propertyValue9.Value:=oArgs3;
  oArgs1[4]:=propertyValue9;
  propertyValue10.Name:='BorderOuter.TopDistance';
  propertyValue10.Value:=97 ;
  oArgs1[5]:=propertyValue10;
  propertyValue11.Name:='BorderOuter.BottomBorder';
  if Bottom=True then propertyValue11.Value:=oArgs2 else propertyValue11.Value:=oArgs3 ;
  oArgs1[6]:=propertyValue11;
  propertyValue12.Name:='BorderOuter.BottomDistance';
  propertyValue12.Value:=97  ;
  oArgs1[7]:=propertyValue12;
  oFrame:=Document.getCurrentController.getFrame;
  oDispatcher.executeDispatch(oFrame,'.uno:BorderOuter','',0,oArgs1);

end;


procedure ooGoRight(col:integer);
col - количество ячеек (символов)

При вызове происходит перемещение курсора вправо на количество ячеек (символов), указанное во входящем параметре. Для перехода между ячейками таблицы с помощью этой процедуры они должны быть пустыми.

procedure TOpenOffice.ooGoRight(col:integer);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0,propertyValue1:variant;
    oFrame:variant;
    i:integer;
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:='Count';
  propertyValue0.Value:=1;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='Select';
  propertyValue1.Value:=False;
  oArgs[1]:=propertyValue1;
  oFrame:=Document.getCurrentController.getFrame;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:GoRight','',0,oArgs);

end;


procedure ooGoleft(col:integer;flag:boolean);
col - количество ячеек (символов)
flag - определяет будет ли выделяться текст при переходе

При вызове происходит перемещение курсора влево на количество ячеек (символов), указанное во входящем параметре. Для перехода между ячейками таблицы с помощью этой процедуры они должны быть пустыми. Если параметр flag = True - перемещение курсора будет происходить с выделением текста.

procedure TOpenOffice.ooGoleft(col:Integer;flag:boolean);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0,propertyValue1:variant;
    oFrame:variant;
    i:integer;
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:='Count';
  propertyValue0.Value:=1;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='Select';
  propertyValue1.Value:=flag;
  oArgs[1]:=propertyValue1;
  oFrame:=Document.getCurrentController.getFrame;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:GoLeft','',0,oArgs);

end;


procedure ooGoUp(col:integer);
col - количество ячеек (строк)

При вызове происходит перемещение курсора вверх на количество ячеек (строк), указанное во входящем параметре. Для перехода между ячейками таблицы с помощью этой процедуры в ячейке должно быть не более одной строки.

procedure TOpenOffice.ooGoUp(col: Integer);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0,propertyValue1:variant;
    oFrame:variant;
    i:integer;
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:='Count';
  propertyValue0.Value:=1;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='Select';
  propertyValue1.Value:=False;
  oArgs[1]:=propertyValue1;
  oFrame:=Document.getCurrentController.getFrame;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:GoUp','',0,oArgs);

end;


procedure ooGoDown(col:integer; selected:boolean);
col - количество ячеек (строк)
selected - определяет будет ли выделяться текст при переходе

При вызове происходит перемещение курсора вниз на количество ячеек (строк), указанное во входящем параметре. Для перехода между ячейками таблицы с помощью этой процедуры в ячейке должно быть не более одной строки. Если параметр selected = True - перемещение курсора будет происходить с выделением текста.

procedure TOpenOffice.ooGoDown(col:Integer; selected:boolean);
var oDispatcher,oArgs:variant;
    CoreReflection,propertyValue0,propertyValue1:variant;
    oFrame:variant;
    i:integer;
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:='Count';
  propertyValue0.Value:=1;
  oArgs[0]:=propertyValue0;
  propertyValue1.Name:='Select';
  propertyValue1.Value:=selected;
  oArgs[1]:=propertyValue1;
  oFrame:=Document.getCurrentController.getFrame;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:GoDown','',0,oArgs);

end;


procedure ooNextCell(col:integer);
col - количество ячеек

Переход в следующую ячейку. При вызове происходит переход вперед на количество ячеек, указанное во входящем параметре. Если до перехода было выполнено выделение текста, оно не будет снято, а ячейки, по которым будет происходить перемещение, также будут выделяться.

procedure TOpenOffice.ooNextCell(col:integer);
var oDispatcher,oArray:variant;
    CoreReflection,propertyValue0:variant;
    oFrame:variant;
    i:integer;
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;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:JumpToNextCell','',0,oArray);

end;


procedure ooPrevCell(col:integer);
col - количество ячеек

Переход в предыдущую ячейку. При вызове происходит переход назад на количество ячеек, указанное во входящем параметре. Если до перехода было выполнено выделение текста, оно не будет снято, а ячейки, по которым будет происходить перемещение, также будут выделяться.

procedure TOpenOffice.ooPrevCell(col:integer);
var oDispatcher,oArray:variant;
    CoreReflection,propertyValue0:variant;
    oFrame:variant;
    i:integer;
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;
  for I:=1 to col do
    oDispatcher.executeDispatch(oFrame,'.uno:JumpToPrevCell','',0,oArray);

end;


procedure ooParaKeepTogether;

При вызове устанавливается свойство таблицы "Связать со следующим абзацем".

procedure TOpenOffice.ooParaKeepTogether;
var oDispatcher,oArray:variant;
    CoreReflection,propertyValue0:variant;
    oFrame:variant;
    i:integer;
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:='ParaKeepTogether';
  propertyValue0.Value:=true;
  oArray[0]:=propertyValue0;
  oFrame:=Document.getCurrentController.getFrame;
  oDispatcher.executeDispatch(oFrame,'.uno:ParaKeepTogether','',0,oArray);

end;

Содержание

© re-stichka.narod.ru
При публикации данного материала ссылка на источник обязательна

Hosted by uCoz