using ReportGeneration.Interface;
using System;
using System.IO;
using System.Text;
using Microsoft.VisualBasic.CompilerServices;

namespace ReportGeneration.Abstract;

public abstract class DocumentGeneratorBase : StreamWriterBase, IDocumentGenerator
{
  /// <inheritdoc />
  protected DocumentGeneratorBase()
  {
  }

  /// <inheritdoc />
  protected DocumentGeneratorBase(Stream stream) : base(stream)
  {
  }

  /// <inheritdoc />
  protected DocumentGeneratorBase(string filePath) : base(File.Open(filePath, FileMode.Create,
    FileAccess.Write))
  {
  }

  /// <inheritdoc />
  protected DocumentGeneratorBase(Stream stream, Encoding encoding) : base(stream, encoding)
  {
  }

  #region Writing

  /// <inheritdoc />
  public virtual IDocumentGenerator Append(string? text = default)
  {
    Write(text);
    return this;
  }

  /// <inheritdoc />
  public virtual IDocumentGenerator AppendLine(string? text = default)
  {
    WriteLine(text);
    return this;
  }

  /// <inheritdoc />
  public abstract IDocumentGenerator AppendHeading(int level, string text);

  /// <inheritdoc />
  public abstract IDocumentGenerator AppendParagraph(string? text = default);

  /// <inheritdoc />
  public abstract IDocumentGenerator AppendTable(int columns, Action<ITableGenerator> table);

  #endregion

  /// <inheritdoc />
  public abstract string FormatImage(string path, IBounds? bounds = default);
}