using System;
using System.IO;
using System.Text;
using ReportGeneration.Interface;

namespace ReportGeneration.Abstract;

public abstract class SubItemDocumentGeneratorBase : DocumentGeneratorBase
{
  protected SubItemDocumentGeneratorBase()
  {
  }

  protected SubItemDocumentGeneratorBase(Stream stream) : base(stream)
  {
  }

  protected SubItemDocumentGeneratorBase(string filePath) : base(filePath)
  {
  }

  protected SubItemDocumentGeneratorBase(Stream stream, Encoding encoding) : base(stream, encoding)
  {
  }

  /// <inheritdoc />
  public override IDocumentGenerator AppendTable(int columns, Action<ITableGenerator> table)
  {
    Write(() => MakeTable(columns, new MemoryStream()), table);
    return this;
  }

  protected abstract ITableGenerator MakeTable(int columns, Stream stream);
}