Ignore:
Timestamp:
2012-01-11T11:17:00+13:00 (12 years ago)
Author:
davidb
Message:

Some initial work at converting CSS style information into Expeditee attributes

Location:
gs3-extensions/html-to-expeditee/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm

    r24938 r24939  
    6565    return $fdate;
    6666}
     67
     68sub convertStyleToAttr
     69{
     70    my ($css_attr) = @_;
     71
     72    my $exp_attr = {};
     73
     74    if (defined $css_attr->{'background-color'}) {
     75    $exp_attr->{'e'} = $css_attr->{'background-color'};
     76    }
     77
     78    # load up some defaults for font information
     79    my $font_family = "s"; # t
     80    my $font_face = "r";
     81    my $font_size = "14";
     82
     83#    if (defined $css_attr->{'font-family'}) {
     84#   $font_family = $font_family_lookup->[$css_attr->{'font-family'}];
     85#    }
     86
     87#    if (defined $css_attr->{'font-size'}) {
     88#   $font_size = convert_font_size($css_attr->{'font-size'});
     89#    }
     90
     91#    if (defined $css_attr->{'font-face'}) {
     92#   $font = conver_font_face($css_attr->{'font-face'});
     93#    }
     94
     95    return $exp_attr;
     96}
     97
    6798
    6899sub _nextFreeId
     
    166197    # fudge factor for now (based on default font size used)
    167198    $y += 16; # y-value of text item in Expeditee is it's base line
     199    $x += 4;
    168200
    169201    my %attr_copy = %$attr; # make a private copy of 'attr'
     
    406438    my $yb = $rect->{'yb'};
    407439
    408     my $attr = {};
     440    my $attr = convertStyleToAttr($html_node->{'style'});
    409441
    410442    $self->addRect($xl,$yt,$xr,$yb,$attr);
     
    417449    my $y = $html_node->{'y'};
    418450
    419     my $attr = {};
     451    my $attr = convertStyleToAttr($html_node->{'style'});
    420452
    421453    $self->addText($x,$y,$text,$attr);
     
    442474
    443475    if (open(FNOUT,">$filename")) {
    444     binmode(FOUT,":utf8");
     476    binmode(FNOUT,":utf8");
    445477   
    446478    print FNOUT "$last_frame_number\n";
  • gs3-extensions/html-to-expeditee/trunk/src/src/js/html-to-expeditee.js

    r24935 r24939  
    5252}
    5353
    54 function getStyle(el,styleProp)
     54function getStyle(node,styleProp)
    5555{
    56     var x = document.getElementById(el);
    57     if (x.currentStyle) {
    58     var y = x.currentStyle[styleProp];
     56    if (node.currentStyle) {
     57    var y = node.currentStyle[styleProp];
    5958    }
    6059    else if (window.getComputedStyle) {
    61     var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
     60    var y = document.defaultView.getComputedStyle(node,null).getPropertyValue(styleProp);
    6261    }
    6362    return y;
     
    138137        jsonNode.rect = rect;
    139138   
     139
     140        var style = {};
     141
     142        style["font-family"] = getStyle(node,"font-family");
     143        style["background-color"] = getStyle(node,"background-color");
     144
     145        jsonNode.style = style
     146
    140147            var jsonChildNodes = [];
    141148
Note: See TracChangeset for help on using the changeset viewer.