⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseodfclass4.pas

📁 Advanced.Export.Component.v4.01.rar,delphi 第三方控件
💻 PAS
📖 第 1 页 / 共 4 页
字号:
procedure TODSCellParagraphStyle.LoadFromIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    VerticalAligment := TODFTextVerticalAligment(ReadInteger(Section,
      S_ODF_VertAlignment, Integer(taODFBottom)));
    Border.BorderStyle := TODFBorderStyle(ReadInteger(Section, S_ODF_BorderStyle,
      Integer(bsODFNone)));
    Border.BorderWidth := ReadInteger(Section, S_ODF_BorderWidth, 1);
    Border.BorderColor := ReadInteger(Section, S_ODF_BorderColor, clBlack);
  end;
end;

procedure TODSCellParagraphStyle.SaveToIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    WriteInteger(Section, S_ODF_VertAlignment, Integer(VerticalAligment));
    WriteInteger(Section, S_ODF_BorderStyle, Integer(Border.BorderStyle));
    WriteInteger(Section, S_ODF_BorderWidth, Border.BorderWidth);
    WriteInteger(Section, S_ODF_BorderColor, Border.BorderColor);
  end;
end;

procedure TODSCellParagraphStyle.SetBorder(const Value: TODFBorder);
begin
 FBorder.Assign(Value);
end;

procedure TODSCellParagraphStyle.SetDefault;
begin
  inherited;
  FVerticalAligment := taODFBottom;
  FBorder := TODFBorder.Create;
end;

{ TODTCellParagraphStyle }

procedure TODTCellParagraphStyle.Assign(Source: TPersistent);
begin
  if Source is TODTCellParagraphStyle then
  begin
    VerticalAligment := (Source as TODTCellParagraphStyle).VerticalAligment;
    inherited Assign(Source as TODTParagraphStyle);
    Exit;
  end;
  inherited;
end;

constructor TODTCellParagraphStyle.Create(Collection: TCollection);
begin
  inherited;
end;

destructor TODTCellParagraphStyle.Destroy;
begin
  inherited;
end;


procedure TODTCellParagraphStyle.LoadFromIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    VerticalAligment := TODFTextVerticalAligment(ReadInteger(Section,
      S_ODF_VertAlignment, Integer(taODFBottom)));
  end;
end;

procedure TODTCellParagraphStyle.SaveToIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    WriteInteger(Section, S_ODF_VertAlignment, Integer(VerticalAligment));
  end;
end;

procedure TODTCellParagraphStyle.SetDefault;
begin
  inherited;
  FVerticalAligment := taODFBottom;
end;

{ TODFBorder }

procedure TODFBorder.Assign(Source: TPersistent);
begin
  if Source is TODFBorder then
  begin
    BorderStyle := (Source as TODFBorder).BorderStyle;
    BorderWidth := (Source as TODFBorder).BorderWidth;
    BorderColor := (Source as TODFBorder).BorderColor;
    Exit;
  end;
  inherited;
end;

constructor TODFBorder.Create;
begin
  SetDefault;
end;


procedure TODFBorder.SetBorderWidth(const Value: Integer);
begin
  if (Value <> BorderWidth) then
  begin
    if (Value <= 0) then
      FBorderWidth := 0;
    if (Value > 10) then
      FBorderWidth := 10;
    if (Value <= 10) and (Value > 0) then
      FBorderWidth := Value;
  end;
end;

procedure TODFBorder.SetDefault;
begin
  FBorderStyle := bsODFNone;
  FBorderWidth := 1;
  FBorderColor := clBlack;
end;

procedure DrawODTCellSample(PaintBox: TPaintBox; odtStyle: TODTCellParagraphStyle);
  procedure FillBackground;
  begin
    if odtStyle.AllowBackground
      then  PaintBox.Canvas.Brush.Color := odtStyle.BackgroundColor
      else  PaintBox.Canvas.Brush.Color := clWhite;
    PaintBox.Canvas.FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height));
  end;

  procedure OutText;
  const
    TXT = 'Aa Zz';
  var
    H, W, X, Y: integer;
  begin
    with PaintBox.Canvas.Font do begin
      Name := odtStyle.Font.Name;
      Size := odtStyle.Font.Size;
      Charset := odtStyle.Font.Charset;
      Color := odtStyle.Font.Color;
      Style := odtStyle.Font.Style;
    end;

    H := PaintBox.Canvas.TextHeight(TXT);
    W := PaintBox.Canvas.TextWidth(TXT);
    if H > PaintBox.Height then
      H := PaintBox.Height;
    if W > PaintBox.Width then
      W := PaintBox.Width;

    case odtStyle.Alignment of
      taODFLeft,
      taODFJustify: X := 5;
      taODFCenter: X := (PaintBox.Width - PaintBox.Canvas.TextWidth(TXT)) div 2;
      taODFRight: X := PaintBox.Width - 5 - PaintBox.Canvas.TextWidth(TXT);
      else X := 0;
    end;

    case odtStyle.VerticalAligment of
      taODFTop: Y := 5;
      taODFMiddle: Y := (PaintBox.Height - PaintBox.Canvas.TextHeight(TXT)) div 2;
      taODFBottom: Y := PaintBox.Height - 5 - PaintBox.Canvas.TextHeight(TXT);
      else Y := 0;
    end;

    if odtStyle.AllowHighlight and
         (odtStyle.HighlightColor <> odtStyle.BackgroundColor) then begin
      PaintBox.Canvas.Brush.Color := odtStyle.HighlightColor;
      PaintBox.Canvas.FillRect(Rect(X, Y, X + W, Y + H));
    end;

    PaintBox.Canvas.TextOut(X, Y, TXT);

  end;

begin
  FillBackground;
  OutText;
end;

procedure DrawODTTextSample(PaintBox: TPaintBox; odtStyle: TODTParagraphStyle);
  procedure FillBackground;
  begin
    if odtStyle.AllowBackground
      then  PaintBox.Canvas.Brush.Color := odtStyle.BackgroundColor
      else  PaintBox.Canvas.Brush.Color := clWhite;
    PaintBox.Canvas.FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height));
  end;

  procedure OutText;
  const
    TXT = 'Aa Zz';
  var
    H, W, X, Y: integer;
  begin
    with PaintBox.Canvas.Font do begin
      Name := odtStyle.Font.Name;
      Size := odtStyle.Font.Size;
      Charset := odtStyle.Font.Charset;
      Color := odtStyle.Font.Color;
      Style := odtStyle.Font.Style;
    end;

    H := PaintBox.Canvas.TextHeight(TXT);
    W := PaintBox.Canvas.TextWidth(TXT);
    if H > PaintBox.Height then
      H := PaintBox.Height;
    if W > PaintBox.Width then
      W := PaintBox.Width;

    case odtStyle.Alignment of
      taODFLeft,
      taODFJustify: X := 5;
      taODFCenter: X := (PaintBox.Width - PaintBox.Canvas.TextWidth(TXT)) div 2;
      taODFRight: X := PaintBox.Width - 5 - PaintBox.Canvas.TextWidth(TXT);
      else X := 0;
    end;
    Y := (PaintBox.Height - PaintBox.Canvas.TextHeight(TXT)) div 2;

    if odtStyle.AllowHighlight and
         (odtStyle.HighlightColor <> odtStyle.BackgroundColor) then begin
      PaintBox.Canvas.Brush.Color := odtStyle.HighlightColor;
      PaintBox.Canvas.FillRect(Rect(X, Y, X + W, Y + H));
    end;

    PaintBox.Canvas.TextOut(X, Y, TXT);

  end;

begin
  FillBackground;
  OutText;
end;

procedure DrawODSSample(PaintBox: TPaintBox; odsStyle: TODSCellParagraphStyle);

  procedure FillBackground;
  begin
    if odsStyle.AllowBackground
      then  PaintBox.Canvas.Brush.Color := odsStyle.BackgroundColor
      else  PaintBox.Canvas.Brush.Color := clWhite;
    PaintBox.Canvas.FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height));
  end;

  procedure OutText;
  const
    TXT = 'Aa Zz';
  var
    X, Y: integer;
  begin
    with PaintBox.Canvas.Font do begin
      Name := odsStyle.Font.Name;
      Size := odsStyle.Font.Size;
      Charset := odsStyle.Font.Charset;
      Color := odsStyle.Font.Color;
      Style := odsStyle.Font.Style;
    end;

    case odsStyle.Alignment of
      taODFLeft,
      taODFJustify: X := 5;
      taODFCenter: X := (PaintBox.Width - PaintBox.Canvas.TextWidth(TXT)) div 2;
      taODFRight: X := PaintBox.Width - 5 - PaintBox.Canvas.TextWidth(TXT);
      else X := 0;
    end;

    case odsStyle.VerticalAligment of
      taODFTop: Y := 5;
      taODFMiddle: Y := (PaintBox.Height - PaintBox.Canvas.TextHeight(TXT)) div 2;
      taODFBottom: Y := PaintBox.Height - 5 - PaintBox.Canvas.TextHeight(TXT);
      else Y := 0;
    end;
    PaintBox.Canvas.TextOut(X, Y, TXT);
  end;

begin
  FillBackground;
  OutText;
end;

{ TODSStripCellParagraphStyle }

procedure TODSStripCellParagraphStyle.Assign(Source: TPersistent);
begin
  if Source is TODSStripCellParagraphStyle then
  begin
    FUseDataStyleBorder :=
      (Source as TODSStripCellParagraphStyle).UseDataStyleBorder;
    inherited Assign(Source as TODSCellParagraphStyle);
    Exit;
  end;
  inherited;
end;

constructor TODSStripCellParagraphStyle.Create(Collection: TCollection);
begin
  inherited;
end;

function TODSStripCellParagraphStyle.GetStripBorder: TODFBorder;
begin
  Result := nil;
  if FUseDataStyleBorder and (Collection is TODSStylesList) and
    (TODSStylesList(Collection).Holder is TQExportODSOptions) then
      Result := TQExportODSOptions(TODSStylesList(Collection).Holder).DataStyle.Border
  else
  if not FUseDataStyleBorder then
    Result := Border;
end;

procedure TODSStripCellParagraphStyle.LoadFromIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    UseDataStyleBorder := ReadBool(Section, S_ODS_UseDataStyleBorder, true);
  end;
end;

procedure TODSStripCellParagraphStyle.SaveToIniFile(IniFile: TQIniFile;
  const Section: string);
begin
  inherited;
  with IniFile do begin
    WriteBool(Section, S_ODS_UseDataStyleBorder, UseDataStyleBorder);
  end;
end;

procedure TODSStripCellParagraphStyle.SetDefault;
begin
  inherited;
  FUseDataStyleBorder := True;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -