- Timestamp:
- 2013-01-16T18:56:21+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/html-to-expeditee/trunk/src/perllib/ExpediteeFrameIO.pm
r26730 r26731 70 70 sub convertStyleToAttr 71 71 { 72 my ($css_attr ) = @_;72 my ($css_attr,$compute_font) = @_; 73 73 74 74 my $exp_attr = {}; … … 79 79 my $exp_font_size = "18"; 80 80 81 # if (defined $css_attr->{'font-family'}) { 82 # $font_family = $font_family_lookup->[$css_attr->{'font-family'}]; 83 # } 84 85 if (defined $css_attr->{'font-size'}) { 81 if(defined $compute_font){ 82 if($compute_font eq "true"){ 83 84 if (defined $css_attr->{'font-size'}) { 86 85 87 my $css_font_size = $css_attr->{'font-size'}; 88 $exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size); 89 90 } 91 92 if(defined $css_attr->{'font-family'}){ 93 my $obtain_font_family = $css_attr->{'font-family'}; 94 my $new_exp_font_family = CssStyleToExpAttr::convert_font_family($obtain_font_family); 95 96 if(defined $new_exp_font_family){ 97 $exp_font_family = $new_exp_font_family; 86 my $css_font_size = $css_attr->{'font-size'}; 87 my $new_exp_font_size = CssStyleToExpAttr::convert_font_size($css_font_size); 88 89 if(defined $new_exp_font_size){ 90 $exp_font_size = $new_exp_font_size; 91 } 92 } 93 94 if(defined $css_attr->{'font-family'}){ 95 my $obtain_font_family = $css_attr->{'font-family'}; 96 my $new_exp_font_family = CssStyleToExpAttr::convert_font_family($obtain_font_family); 97 98 if(defined $new_exp_font_family){ 99 $exp_font_family = $new_exp_font_family; 100 } 101 } 102 103 #obtain font style/weight - bold, italic or bold-italic. 104 105 if(defined $css_attr->{'font-style'}){ 106 my $css_font_style = $css_attr->{'font-style'}; 107 my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_style); 108 109 if(defined $new_exp_font_face){ 110 $exp_font_face = $new_exp_font_face; 111 } 112 } 113 114 if(defined $css_attr->{'font-weight'}){ 115 my $css_font_face = $css_attr->{'font-weight'}; 116 my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_face); 117 118 if(defined $new_exp_font_face){ 119 $exp_font_face = $new_exp_font_face; 120 } 121 } 122 123 if(defined $css_attr->{'font-style'} && defined $css_attr->{'font-weight'}){ 124 my $font_face_param = $css_attr->{'font-weight'}.'-'.$css_attr->{'font-style'}; 125 my $new_exp_font_face = CssStyleToExpAttr::convert_font_face($font_face_param); 126 127 if(defined $new_exp_font_face){ 128 $exp_font_face = $new_exp_font_face; 129 } 130 } 131 132 # color 133 if(defined $css_attr->{'color'}){ 134 my $css_color = $css_attr->{'color'}; 135 136 my $exp_color = CssStyleToExpAttr::convert_color($css_color); 137 138 $exp_attr->{'d'} = $exp_color; 139 } 98 140 } 99 141 } 100 142 101 my $css_font_style; 102 my $css_font_face; 103 104 if(defined $css_attr->{'font-style'}){ 105 $css_font_style = $css_attr->{'font-style'}; 106 $exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_style); 107 } 108 109 if(defined $css_attr->{'font-weight'}){ 110 $css_font_face = $css_attr->{'font-weight'}; 111 $exp_font_face = CssStyleToExpAttr::convert_font_face($css_font_face); 112 } 113 114 if(defined $css_attr->{'font-style'} && defined $css_attr->{'font-weight'}){ 115 my $font_face_param = $css_attr->{'font-weight'}.'-'.$css_attr->{'font-style'}; 116 $exp_font_face = CssStyleToExpAttr::convert_font_face($font_face_param); 117 } 118 119 $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size; 143 $exp_attr->{'f'} = $exp_font_family.$exp_font_face.$exp_font_size; 120 144 121 145 # background color 122 123 124 146 if (defined $css_attr->{'background-color'}) { 125 147 my $css_color = $css_attr->{'background-color'}; … … 129 151 $exp_attr->{'e'} = $exp_color; 130 152 } 131 153 154 155 132 156 return $exp_attr; 133 157 } … … 251 275 $attr_copy{'P'} = "$x $y"; 252 276 $attr_copy{'T'} = $text; 253 $attr_copy{'w'} = "-$w" if (defined $w); 277 #$attr_copy{'w'} = "-$w" if (defined $w); 278 $attr_copy{'w'} = "$w" if (defined $w); 254 279 255 280 return $self->_addItem("T",\%attr_copy); … … 534 559 $self->writeStatisticsSection(); 535 560 536 537 538 561 close(FOUT); 539 562 $status = 1; … … 550 573 { 551 574 my $self = shift @_; 552 my ($html_node ) = @_;575 my ($html_node,$compute_font) = @_; 553 576 554 577 my $type = $html_node->{'type'}; 555 578 556 579 if ($type eq "rect") { … … 561 584 my $yt = $rect->{'yt'}; 562 585 my $yb = $rect->{'yb'}; 563 586 564 587 my $attr = convertStyleToAttr($html_node->{'style'}); 565 588 … … 606 629 } 607 630 elsif ($type eq "text") { 608 631 609 632 my $text = $html_node->{'text'}; 610 633 611 634 my $x = $html_node->{'xl'}; 612 635 my $y = $html_node->{'yt'}; 613 my $w = $html_node->{'xr'} - $x +1; 614 615 my $attr = convertStyleToAttr($html_node->{'style'}); 636 #my $w = $html_node->{'xr'} - $x +1; 637 638 my $w = undef; 639 640 if(defined $html_node->{'width'}){ 641 $w = $html_node->{'width'} - 5; #take away 5px for extra space. 642 } 643 644 my $attr = convertStyleToAttr($html_node->{'style'},$compute_font); 616 645 617 646 # fudge factor for now (based on default font size used) … … 630 659 my $childNodes = $html_node->{'childNodes'}; 631 660 foreach my $child_node (@$childNodes) { 632 $self->buildFrame($child_node );661 $self->buildFrame($child_node,$compute_font); 633 662 } 634 663 }
Note:
See TracChangeset
for help on using the changeset viewer.