package FormatHTML;

# PACKAGE : FormatHTML
# PURPOSE : Contains the Folio View V4 specific tags information
# AUTHOR  : William Chesters (WilliamC@dai.ed.ac.uk)
# CREATED : 1 Sep 1998
#-----------------------------------------------------------------------------

# Modification History Log
# ========================
# Who                      When       What
#-----------------------------------------
# Williamc@dai.ed.ac.uk    31/08/98   Write
# Tim@paneris.co.uk        31/08/98   Rename
#-----------------------------------------


use DX::Format;

@ISA = ('Format');


%default_values = (
    'baseshift'          => 0,
    'alignment'          => 'left',
#    for (temp_int = 0; temp_int < max_tabs; temp_int++)
#    {
#           "tabs[temp_int]"  => 0,  
#    }
    'tabstops'           => [], # tabstopsParse('1,2,"foo"');  
    'left_indent'        => 0,  
    'first_line_indent'  => 0,
    'right_indent'       => 0,  
    'leading'            => 0,
    'space_before'       => 0,
    'space_after'        => 0,
    'grid_lock_flag'     => 1,
    'language'           => " ",
    'hyphenation'        => " ",
    'rule_above'        => new Rule,
    'rule_below'        => new Rule,
    'drop_cap'           => 0,
    'dc_char_count'      => 0,
    'dc_line_count'      => 0,
    'keep_with'          => 0,
    'keep_together'      => 0,
    'kt_start_line'      => 0,
    'kt_end_line'        => 0,


    'plain'              => 1, 
    'bold'               => 0,
    'italic'             => 0,   
    'outline'            => 0,
    'shadow'             => 0, 
    'underline'          => 0,
    'wordunderline'      => 0,
    'strikethrough'      => 0,
    'all_caps'           => 0,  
    'small_caps'         => 0,   
    'superscript'        => 0,
    'subscript'          => 0,
    'superior'           => 0,
    'font_name'          => 'Times-Roman',
    'font_size'          => 10,
    'colour'             => ' ',
    'shade_percent'      => 0,
    'hscale_percent'     => 0,
    'vscale_percent'     => 0,
    'kern'               => 0,
    'track'              => 0, 

);


sub concreteAttribValueOutput {
  my ($self, $attrib, $value) = @_;

  if ($value =~ /[^a-zA-Z0-9.]/) {
    $value =~ s/\"/\\\"/g;
    $value = "\"$value\"";
  }

  "$attrib='$value'";
}

sub blockOutput {
  shift;
  "<" . join(' ', @_) . ">";
}

# for each kind of attribute, define 
#   EITHER 
#      <attrib>Output, 
#   OR
#      <attrib>Attribute and <attrib>Value
#
# in the latter case the default Format::attribOutput will use
# <attrib>Attribute and <attrib>Value in conjunction with the supplied 
# concreteAttribValueOutput above

sub nameAttribute {
  'P';
}

sub recordOutput {
  'P';
}

sub paraOutput {
  'P';
}

sub breakOutput {
  'BR';
}

sub tabOutput {
  '&nbsp;';
}

sub asciiOutput {
  my $code = shift;
  "&#$code;";
}

# Attribute Outputs
#--------------------------------------

sub alignmentAttribute {
  'align';
}

$alignmentValues = {
  'left' => 'LEFT',
  'right' => 'RIGHT',
  'centre' => 'CENTER',
  'justify' => 'FULL'
};

sub alignmentValue {
  $alignmentValues{$_[1]};
}

sub all_capsOutput { # Default is off
  undef;
}
sub first_line_indentOutput { # Default is 0
  undef;
}
sub grid_lock_flagOutput { # Default is TRUE
  undef;
}
sub keep_togetherOutput { # Default is off
  undef;
}
sub keep_withOutput { # Default is off
  undef;
}
sub languageOutput { # Default is  
  undef;
}
sub leadingOutput { # Default is 0
  undef;
}
sub left_indentOutput { # Default is 0
  undef;
}

sub font_nameAttribute {
  'NAME';
}

sub font_sizeAttribute {
  'SIZE';
}

sub boldOutput {
  $_[1]->{bold} ? 'B' : '/B';
}

sub italicOutput {
  $_[1]->{italic} ? 'I' : '/I';
}

sub underlineOutput {
  $_[1]->{italic} ? 'I' : '/I';
}

sub strikethroughOutput {
  undef;
}


sub verticalOffsetAttribute {
  undef;
}

sub hscale_percentOutput {
  undef;
}

sub colourOutput {
  undef;
}

sub smallCapsOutput {
  undef;
}

sub outlineOutput {
  undef;
}

sub definitionOutput {
  my $self = shift;
  my $name = shift;

  $self->definition_header .
  $self->definition_footer ;
}


sub invocationOutput {
  undef;
}


sub header
{
  return <<end_of_text;
<html>
 <head>
  <META NAME='generator'      CONTENT='http://www.paneris.co.uk/'>
 </head>
 <body>
end_of_text
}

sub footer
{
  return " </body>\n</html>\n";
}

sub definition_footer
{
  undef;
}

sub definition_header
{
  undef;
}

sub new {
  bless {};
}

sub copy {

    my($self) = shift;

    # Create the anonymous hash reference to hold the object's data.

    my %copy = %$self;

    return bless \%copy;  
}


1;

