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

📄 qexport4odt.pas

📁 Advanced.Export.Component.v4.01.rar,delphi 第三方控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
    ODTFile.WriteSpecificNode(1016, '', [], []);
    ODTFile.WriteSpecificNode(1030, '', [], []);
  end;
  //Default Data style w/o layer borders
  if TypeOfRow = 1 then
  begin
    ODTFile.WriteSpecificNode(16, '', [], []);
    for i := 0 to Length(FBufferRow) - 1 do
    begin
      if (ODTOptions.StripStyle = sstNone) then
      begin
        if (i < Length(FBufferRow) - 1) then
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['DataCellStyle', 'string'])
        else
        begin
          if ODTOptions.Border.BorderStyle = bsODFSolid then
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['EnderDataCellStyle', 'string'])
          else
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['DataCellStyle', 'string']);
        end;
        ODTFile.WriteSpecificNode(18, FBufferRow[i], ['text:style-name'],
          ['DataStyle']);
      end
      else
      begin
        //Column-style
        if (ODTOptions.StripStyle = sstColumn) then
        begin
          Num := (i + 1) mod ODTOptions.StripStylesList.Count;
          if Num = 0 then
            Num := ODTOptions.StripStylesList.Count;
          if (i < Length(FBufferRow) - 1) then
             ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string'])
          else
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['EnderStripCellStyle' + IntToStr(Num), 'string'])
            else
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end;
        end;
        //Row-style
        if (ODTOptions.StripStyle = sstRow) then
        begin
          Num := FRowCounter mod ODTOptions.StripStylesList.Count;
          if Num = 0 then
            Num := ODTOptions.StripStylesList.Count;
          if (i < Length(FBufferRow) - 1) then
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string'])
          else
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['EnderStripCellStyle' + IntToStr(Num), 'string'])
           else
             ODTFile.WriteSpecificNode(17, '', ['table:style-name',
               'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end;
        end;
        ODTFile.WriteSpecificNode(18, FBufferRow[i], ['text:style-name'],
          ['StripStyle' + IntToStr(Num)]);
      end;
      ODTFile.WriteSpecificNode(1017, '', [], []);
    end;
    ODTFile.WriteSpecificNode(1016, '', [], []);
  end;
  //Default Caption row style with layer borders
  if TypeOfRow = 2 then
  begin
    if not AllowCaptions then Exit;
    ODTFile.WriteSpecificNode(30, '', [], []);
    ODTFile.WriteSpecificNode(16, '', [], []);
    for i := 0 to Length(FBufferRow) - 1 do
    begin
      if (i < Columns.Count - 1) then
      begin
        if ODTOptions.Border.BorderStyle = bsODFSolid then
          ODTFile.WriteSpecificNode(17, '', ['table:style-name',
            'office:value-type'], ['LayerCaptionCellRow', 'string'])
        else
          ODTFile.WriteSpecificNode(17, '', ['table:style-name',
            'office:value-type'], ['CaptionCellRow', 'string']);
      end
      else
      begin
        if ODTOptions.Border.BorderStyle = bsODFSolid then
          ODTFile.WriteSpecificNode(17, '', ['table:style-name',
            'office:value-type'], ['LayerEnderCaptionCellRow', 'string'])
        else
          ODTFile.WriteSpecificNode(17, '', ['table:style-name',
            'office:value-type'], ['CaptionCellRow', 'string']);
      end;
      ODTFile.WriteSpecificNode(18, FBufferRow[i], ['text:style-name'],
        ['CaptionRow']);
      ODTFile.WriteSpecificNode(1017, '', [], []);
    end;
    ODTFile.WriteSpecificNode(1016, '', [], []);
    ODTFile.WriteSpecificNode(1030, '', [], []);
  end;
  //Default Data style with layer borders
  if TypeOfRow = 3 then
  begin
    ODTFile.WriteSpecificNode(16, '', [], []);
    for i := 0 to Length(FBufferRow) - 1 do
    begin
      if (ODTOptions.StripStyle = sstNone) then
      begin
        if (i < Length(FBufferRow) - 1) then
        begin
          if ODTOptions.Border.BorderStyle = bsODFSolid then
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['LayerDataCellStyle', 'string'])
          else
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['DataCellStyle', 'string']);
        end
        else
        begin
          if ODTOptions.Border.BorderStyle = bsODFSolid then
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['LayerEnderDataCellStyle', 'string'])
          else
            ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['DataCellStyle', 'string']);
        end;
        ODTFile.WriteSpecificNode(18, FBufferRow[i], ['text:style-name'],
          ['DataStyle']);
      end
      else
      begin
        //Column-style
        if (ODTOptions.StripStyle = sstColumn) then
        begin
          Num := (i + 1) mod ODTOptions.StripStylesList.Count;
          if Num = 0 then
            Num := ODTOptions.StripStylesList.Count;
          if (i < Length(FBufferRow) - 1) then
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['LayerStripCellStyle' + IntToStr(Num), 'string'])
            else
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end
          else
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
             ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['LayerEnderStripCellStyle' + IntToStr(Num), 'string'])
            else
             ODTFile.WriteSpecificNode(17, '', ['table:style-name',
              'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end;
        end;
        //Row-style
        if (ODTOptions.StripStyle = sstRow) then
        begin
          Num := FRowCounter mod ODTOptions.StripStylesList.Count;
          if Num = 0 then
            Num := ODTOptions.StripStylesList.Count;
          if (i < Length(FBufferRow) - 1) then
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['LayerStripCellStyle' + IntToStr(Num), 'string'])
            else
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end
          else
          begin
            if ODTOptions.Border.BorderStyle = bsODFSolid then
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['LayerEnderStripCellStyle' + IntToStr(Num), 'string'])
            else
              ODTFile.WriteSpecificNode(17, '', ['table:style-name',
                'office:value-type'], ['StripCellStyle' + IntToStr(Num), 'string']);
          end;
        end;
        ODTFile.WriteSpecificNode(18, FBufferRow[i], ['text:style-name'],
          ['StripStyle' + IntToStr(Num)]);
      end;
      ODTFile.WriteSpecificNode(1017, '', [], []);
    end;
    ODTFile.WriteSpecificNode(1016, '', [], []);
  end;
end;

procedure TQExport4ODT.WriteCaptionRow;
var
  I: Integer;
  CurrValue: WideString;
begin
  for i := 0 to Columns.Count - 1 do
  begin
    CurrValue := GetColCaption(i);
    FBufferRow[i] := ReplaceSymbols(CurrValue);
  end;
end;

//Buffer conception - allocate current row in memory
//If WriteDataRow executed, it means, that another one row exists
//Then we can move buffered data into file and form another buffer
//If this method hasn't executed, then the last row formed inside
//After Export method
procedure TQExport4ODT.WriteDataRow;
var
  I: Integer;
  CurrValue: WideString;
begin
  //Here called the buffered row writing
  //null parameter is for Caption row - need to form correct styles
  //other parameters - for default
  if (FRowCounter = 0) then
    WriteBufferedRow(0)
  else
    WriteBufferedRow(1);
  ClearBufferedRow;
  for I := 0 to ExportRow.Count - 1 do
  begin
    Formats.ApplyParams;
    CurrValue := GetExportedValue(ExportRow[I]);
    Formats.RestoreSeparators;
    FBufferRow[I] := ReplaceSymbols(CurrValue);
  end;
  Inc(FRowCounter);
end;

{ TQExportODTOptions }

procedure TQExportODTOptions.Assign(Source: TPersistent);
begin
  if Source is TQExportODTOptions then begin
    HeaderStyle := (Source as TQExportODTOptions).HeaderStyle;
    FooterStyle := (Source as TQExportODTOptions).FooterStyle;
    CaptionRowStyle := (Source as TQExportODTOptions).CaptionRowStyle;
    DataStyle := (Source as TQExportODTOptions).DataStyle;
    Border.BorderStyle := (Source as TQExportODTOptions).Border.BorderStyle;
    Border.BorderWidth := (Source as TQExportODTOptions).Border.BorderWidth;
    Border.BorderColor := (Source as TQExportODTOptions).Border.BorderColor;
    StripStylesList := (Source as TQExportODTOptions).StripStylesList;
    StripStyle := (Source as TQExportODTOptions).StripStyle;
    Exit;
  end;
  inherited;
end;

function TQExportODTOptions.CheckFontInList(FontName: string): Boolean;
var
  I: Integer;
begin
  Result := false;
  for I := 0 to FontList.Count - 1 do
    if (FontName = FontList[I]) then
    begin
      Result := true;
      Exit;
    end;
end;

constructor TQExportODTOptions.Create(Holder: TPersistent);
begin
  inherited Create;
  FHolder := Holder;
  FHeaderStyle := TODTParagraphStyle.Create(nil);
  FFooterStyle := TODTParagraphStyle.Create(nil);
  FCaptionRowStyle := TODTCellParagraphStyle.Create(nil);
  FDataStyle := TODTCellParagraphStyle.Create(nil);
  FStripStyle := sstNone;
  FStripStylesList := TODTStylesList.Create(Self);
  FFontList := TStringList.Create;
  FBorder := TODFBorder.Create;
  FBorder.BorderStyle := bsODFSolid;
end;

destructor TQExportODTOptions.Destroy;
begin
  FHeaderStyle.Free;
  FFooterStyle.Free;
  FCaptionRowStyle.Free;
  FDataStyle.Free;
  FStripStylesList.Free;
  FFontList.Free;
  FBorder.Free;
  inherited;
end;

function TQExportODTOptions.GetOwner: TPersistent;
begin
  Result := FHolder;
end;


procedure TQExportODTOptions.SetCaptionStyle(const Value: TODTCellParagraphStyle);
begin
  FCaptionRowStyle.Assign(Value);
end;

procedure TQExportODTOptions.SetDataStyle(const Value: TODTCellParagraphStyle);
begin
  FDataStyle.Assign(Value);
end;

procedure TQExportODTOptions.SetFooterStyle(const Value: TODTParagraphStyle);
begin
  FFooterStyle.Assign(Value);
end;

procedure TQExportODTOptions.SetHeaderStyle(const Value: TODTParagraphStyle);
begin
  FHeaderStyle.Assign(Value);
end;

procedure TQExportODTOptions.SetStripStyles(const Value: TODTStylesList);
begin
  FStripStylesList.Assign(Value);
end;

end.

⌨️ 快捷键说明

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