- Код: Выделить всё
type
{ TOdtTableLineProperties }
TOdtTableLineProperties = class
private
FBreakAfter: TBreak; // атр, разрыв страницы после колонки/строки
FBreakBefore: TBreak; // атр, разрыв страницы до колонки/строки
FUseOptimalSize: boolean; // атр, оптимальная ширина/высота колонки/строки
public
constructor Create;
destructor Destroy;
function Equal(aObject: TOdtTableLineProperties): boolean; // УРИВЕРСАЛЬНАЯ ФУНКЦИЯ СРАВНЕНИЯ
property BreakAfter: TBreak read FBreakAfter write FBreakAfter;
property BreakBefore: TBreak read FBreakBefore write FBreakBefore;
property UseOptimalSize: boolean read FUseOptimalSize write FUseOptimalSize;
end;
type
{ TOdtTableColumnProperties }
TOdtTableColumnProperties = class(TOdtTableLineProperties)
private
FSymbol: string; // часть значения атрибута - символьное обозначение колонки A,B,C...
FWidth: TSizes; // атр, абс определяет фикс ширину колонки
FRelWidth: TSizes; // атр, относительная ширина колонки
public
constructor Create;
destructor Destroy;
property Symbol: string read FSymbol write FSymbol;
property Width: TSizes read FWidth write FWidth;
property RelWidth: TSizes read FRelWidth write FRelWidth;
end;
type
TOdtTableColsProperties = Specialize TFPGList<TOdtTableColumnProperties>; // массив свойств колонок
type
{ TOdtTableRowProperties }
TOdtTableRowProperties = class(TOdtTableLineProperties)
private
FBackgroundColor: TColor; // цвет строки
FKeepTogether: TKeepWithNext; // атр, не отрывать строку от соседних?
FMinHeight: TSizes; // атр, минимальная высота строки
FHeight: TSizes; // атр, высота строки
//FBackgroundImage // не реализовано
public
constructor Create;
destructor Destroy;
property BackgroundColor: TColor read FBackgroundColor write FBackgroundColor default 0;
property KeepTogether: TKeepWithNext read FKeepTogether write FKeepTogether;
property MinHeight: TSizes read FMinHeight write FMinHeight;
property Height: TSizes read FHeight write FHeight;
end;
...
...
...
// УНИВЕРСАЛЬНАЯ ФУНКЦИЯ СРАВНЕНИЯ
function TOdtTableLineProperties.Equal(Obj: TOdtTableLineProperties): boolean;
begin
If Obj is TOdtTableColumnProperties then
...
If Obj is TOdtTableRowProperties then
...
end;
Добавлено спустя 31 минуту 59 секунд:
функция должна выглядеть примерно так
- Код: Выделить всё
if FBreakAfter<>Obj.BreakAfter then exit(false);
if FBreakBefore<>Obj.BreakBefore then exit(false);
if FUseOptimalSize<>Obj.UseOptimalSize then exit(false);
if Obj is TOdtTableColumnProperties then begin
if FSymbol<>TOdtTableColumnProperties(Obj).Symbol then exit(false);
if Changed(FWidth,TOdtTableColumnProperties(Obj).Width) then exit(false);
if Changed(FRelWidth,TOdtTableColumnProperties(Obj).RelWidth) then exit(false);
end;
if Obj is TOdtTableRowProperties then begin
if FBackgroundColor<>TOdtTableRowProperties(Obj).BackgroundColor then exit(false);
if FKeepTogether<>TOdtTableRowProperties(Obj).KeepTogether then exit(false);
if Changed(FMinHeight,TOdtTableRowProperties(Obj).MinHeight) then exit(false);
if Changed(FHeight,TOdtTableRowProperties(Obj).Height) then exit(false);
end;
result:=true;
однако доступа к свойствам классов-потомков видимо нет... как-то можно вытянуть их свойства?
Добавлено спустя 4 минуты 24 секунды:
видимо придётся переопределять эту функцию для потомков и переносить конфликтные строки...