lib/LaTeXML/Core/Box.pm

filter: Statementstmt 20.1% 30 / 149 Branchbran 0.0% 0 / 64 Conditioncond 0.0% 0 / 111 MC/DCmcdc 0.0% 0 / 66 Subroutinesub 21.4% 9 / 42 Podpod 37.5% 12 / 32 totaltotal 10.9% 51 / 464 CC 71 SCAR 39.6
CC
71
Cov
9%
getSize
174.1
Box
110.0
computeSizeStore
90.0
CRAP 52.2
« lib/LaTeXML/Post/OpenMath.pm ↑ Summary lib/LaTeXML/Post/Scan.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Core::Box | #
3 # | Digested objects produced in the Stomach | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> #_# | #
10 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
11 # \=========================================================ooo==U==ooo=/ #
12 package LaTeXML::Core::Box;
13 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use LaTeXML::Common::Dimension qw(Dimension);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use LaTeXML::Common::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use base qw(LaTeXML::Common::Object);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 our @EXPORT = (
22 qw( &Box ),
23 );
24  
25 5 DebuggableFeature('size', "Box sizing");
26 #======================================================================
27 # Exported constructors
28  
29 sub Box {
30 0 ▶ my ($string, $font, $locator, $tokens, %properties) = @_;
Subroutine Box: not called CC=10 SCAR=47.0
Pod documented
31 0 ▶ $font = $STATE->lookupValue('font') unless defined $font;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $font 0 0 0
32 0 ▶ $locator = $STATE->getStomach->getGullet->getLocator unless defined $locator;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $locator 0 0 0
33 0 ▶ $tokens = LaTeXML::Core::Token::T_OTHER($string) if $string && !defined $tokens;
Branch: 1 branch
BranchTrueFalseTotal
if $string and not defined $tokens 0 0 0
Condition0%0/3
$string and not defined $tokens
!ll&&!rl&&r
000
MC/DC0%0/2
$string and not defined $tokens
$string not defined $tokens
Truth table0%0/3
A and not(B)
A= $stringB= not defined $tokens
ABresult
0X0
100
111
34 0 my $state = $STATE;
35 0 ▶ if ($state->lookupValue('IN_MATH')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->lookupValue('IN_MATH')) { } 0 0 0
36 0 ▶ my $attr = (defined $string) && $state->lookupValue('math_token_attributes_' . $string);
Condition0%0/3
defined $string && $state->lookupValue('math_token_attributes_' . $string)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $string && $state->lookupValue('math_token_attributes_' . $string)
defined $string $state->lookupValue('math_token_attributes_' . $string)
Truth table0%0/3
A && B
A= defined $stringB= $state->lookupValue('math_token_attributes_' . $string)
ABresult
0X0
100
111
37 0 ▶ my $usestring = ($attr && $$attr{replace}) || $string;
Condition0%0/6
$attr && $attr->{'replace'} || $string
l!l&&r!l&&!r
000
$attr and $attr->{"replace"}
!ll&&!rl&&r
000
MC/DC0%0/3
$attr && $attr->{'replace'} || $string
$attr $attr->{"replace"} $string
Truth table0%0/5
A and B || C
A= $attrB= $attr->{"replace"}C= $string
ABCresult
11X1
0X11
1011
0X00
1000
38 0 ▶ return LaTeXML::Core::Box->new($usestring, $font->specialize($string), $locator, $tokens,
Branch: 1 branch
BranchTrueFalseTotal
$attr ? : 0 0 0
39 mode => 'math', ($attr ? %$attr : ()), %properties); }
40 else {
41 0 return LaTeXML::Core::Box->new($string, $font, $locator, $tokens, %properties); } }
42  
43 #======================================================================
44 # Box Object
45  
46 sub new {
47 0 ▶ my ($class, $string, $font, $locator, $tokens, %properties) = @_;
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
48 0 return bless { string => $string,
49 tokens => $tokens,
50 properties => { font => $font, locator => $locator, %properties }
51 }, $class; }
52  
53 # Accessors
54 sub isaBox {
55 0 ▶ return 1; }
Subroutine isaBox: not called CC=1 SCAR=6.9
Pod documented
56  
57 sub getString {
58 0 ▶ my ($self) = @_;
Subroutine getString: not called CC=1 SCAR=6.9
Pod documented
59 0 return $$self{string}; } # Return the string contents of the box
60  
61 sub getFont {
62 0 ▶ my ($self) = @_;
Subroutine getFont: not called CC=1 SCAR=6.9
Pod documented
63 0 return $$self{properties}{font}; } # and if undef ????
64  
65 sub setFont {
66 0 ▶ my ($self, $font) = @_;
Subroutine setFont: not called CC=1 SCAR=6.9
Pod undocumented
67 0 $$self{properties}{font} = $font;
68 0 return; }
69  
70 sub isMath {
71 0 ▶ my ($self) = @_;
Subroutine isMath: not called CC=2 SCAR=17.9
Pod documented
72 0 ▶ return ($$self{properties}{mode} || 'text') eq 'math'; }
Condition0%0/2
$self->{'properties'}{'mode'} || 'text'
l!l
00
MC/DC0%0/1
$self->{'properties'}{'mode'} || 'text'
$self->{'properties'}{'mode'}
Truth table0%0/2
A
A= $self->{'properties'}{'mode'}
Aresult
11
00
73  
74 sub getLocator {
75 0 ▶ my ($self) = @_;
Subroutine getLocator: not called CC=1 SCAR=6.9
Pod documented
76 0 return $$self{properties}{locator}; }
77  
78 sub getSource {
79 0 ▶ my ($self) = @_;
Subroutine getSource: not called CC=1 SCAR=6.9
Pod undocumented
80 0 return $$self{properties}{locator}; }
81  
82 # So a Box can stand in for a List
83 sub unlist {
84 0 ▶ my ($self) = @_;
Subroutine unlist: not called CC=1 SCAR=6.9
Pod documented
85 0 return ($self); } # Return list of the boxes
86  
87 sub getBody {
88 0 ▶ my ($self) = @_;
Subroutine getBody: not called CC=1 SCAR=6.9
Pod undocumented
89 0 return $self; }
90  
91 sub revert {
92 0 ▶ my ($self) = @_;
Subroutine revert: not called CC=2 SCAR=17.9
Pod documented
93 0 ▶ return ($$self{tokens} ? $$self{tokens}->unlist : ()); }
Branch: 1 branch
BranchTrueFalseTotal
$self->{'tokens'} ? : 0 0 0
94  
95 sub toString {
96 0 ▶ my ($self) = @_;
Subroutine toString: not called CC=2 SCAR=17.9
Pod documented
97 0 ▶ return $$self{string} // ''; }
Condition0%0/2
$self->{"string"} // ""
l!l
00
MC/DC0%0/1
$self->{"string"} // ""
$self->{"string"}
Truth table0%0/2
A
A= $self->{"string"}
Aresult
11
00
98  
99 # Methods for overloaded operators
100 sub stringify {
101 0 ▶ my ($self) = @_;
Subroutine stringify: not called CC=6 SCAR=37.4
Pod documented
102 0 my $type = ref $self;
103 0 $type =~ s/^LaTeXML::Core:://;
104 0 ▶ my $font = (defined $$self{properties}{font}) && $$self{properties}{font}->stringify; # show font, too, if interesting
Condition0%0/3
defined $self->{'properties'}{'font'} && $self->{'properties'}{'font'}->stringify
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{'properties'}{'font'} && $self->{'properties'}{'font'}->stringify
defined $self->{'properties'}{'font'} $self->{'properties'}{'font'}->stringify
Truth table0%0/3
A && B
A= defined $self->{'properties'}{'font'}B= $self->{'properties'}{'font'}->stringify
ABresult
0X0
100
111
105 return $type . '['
106 . (defined $$self{string} ? $$self{string}
107 0 ▶ : (defined $$self{tokens} ? '[' . ToString($$self{tokens}) . ']' : ''))
Branch: 3 branches
BranchTrueFalseTotal
defined $self->{'string'} ? : 0 0 0
defined $self->{'tokens'} ? : 0 0 0
$font && $font ne 'Font[]' ? : 0 0 0
Condition0%0/3
$font and $font ne "Font[]"
!ll&&!rl&&r
000
MC/DC0%0/2
$font and $font ne "Font[]"
$font $font ne "Font[]"
Truth table0%0/3
A and B
A= $fontB= $font ne "Font[]"
ABresult
0X0
100
111
108 . ($font && ($font ne 'Font[]') ? ' ' . $font : '')
109 . ']'; }
110  
111 # Should this compare fonts too?
112 sub equals {
113 0 ▶ my ($a, $b) = @_;
Subroutine equals: not called CC=4 SCAR=30.0
Pod documented
114 0 ▶ return (defined $b) && ((ref $a) eq (ref $b)) && ($$a{string} eq $$b{string}) && ($$a{properties}{font}->equals($$b{properties}{font})); }
Condition0%0/9
defined $b && ref $a eq ref $b && $a->{'string'} eq $b->{'string'} && $a->{'properties'}{'font'}->equals($b->{'properties'}{'font'})
!ll&&!rl&&r
000
defined $b and ref $a eq ref $b and $a->{"string"} eq $b->{"string"}
!ll&&!rl&&r
000
defined $b and ref $a eq ref $b
!ll&&!rl&&r
000
MC/DC0%0/4
defined $b && ref $a eq ref $b && $a->{'string'} eq $b->{'string'} && $a->{'properties'}{'font'}->equals($b->{'properties'}{'font'})
defined $b ref $a eq ref $b $a->{"string"} eq $b->{"string"} $a->{'properties'}{'font'}->equals($b->{'properties'}{'font'})
Truth table0%0/5
A and B and C && D
A= defined $bB= ref $a eq ref $bC= $a->{"string"} eq $b->{"string"}D= $a->{'properties'}{'font'}->equals($b->{'properties'}{'font'})
ABCDresult
0XXX0
10XX0
110X0
11100
11111
115  
116 sub beAbsorbed {
117 0 ▶ my ($self, $document) = @_;
Subroutine beAbsorbed: not called CC=6 SCAR=37.4
Pod documented
118 0 my $string = $$self{string};
119 0 ▶ my $mode = $$self{properties}{mode} || 'text';
Condition0%0/2
$self->{'properties'}{'mode'} || 'text'
l!l
00
MC/DC0%0/1
$self->{'properties'}{'mode'} || 'text'
$self->{'properties'}{'mode'}
Truth table0%0/2
A
A= $self->{'properties'}{'mode'}
Aresult
11
00
120 return (((defined $string) && ($string ne '')) || $$self{properties}{width} # ?
121 ? ($mode eq 'math'
122 0 ? $document->insertMathToken($string, %{ $$self{properties} })
123 0 ▶ : $document->openText($string, $$self{properties}{font}))
Branch: 2 branches
BranchTrueFalseTotal
defined $string && $string ne '' || $self->{'properties'}{'width'} ? : 0 0 0
$mode eq 'math' ? : 0 0 0
Condition0%0/6
defined $string and $string ne "" or $self->{"properties"}{"width"}
l!l&&r!l&&!r
000
defined $string and $string ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined $string and $string ne "" or $self->{"properties"}{"width"}
defined $string $string ne "" $self->{"properties"}{"width"}
Truth table0%0/5
A and B or C
A= defined $stringB= $string ne ""C= $self->{"properties"}{"width"}
ABCresult
11X1
0X11
1011
0X00
1000
124 : undef); }
125  
126 sub getProperty {
127 0 ▶ my ($self, $key) = @_;
Subroutine getProperty: not called CC=4 SCAR=30.0
Pod undocumented
128 0 ▶ if ($key eq 'isSpace') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'isSpace') { } 0 0 0
129 0 ▶ return $$self{properties}{$key} if defined $$self{properties}{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"properties"}{$key} 0 0 0
130 0 my $tex = LaTeXML::Core::Token::UnTeX($$self{tokens}); # !
131 0 ▶ return (defined $tex) && ($tex =~ /^\s*$/); } # Check the TeX code, not (just) the string!
Condition0%0/3
defined $tex && $tex =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tex && $tex =~ /^\s*$/
defined $tex $tex =~ /^\s*$/
Truth table0%0/3
A && B
A= defined $texB= $tex =~ /^\s*$/
ABresult
0X0
100
111
132 else {
133 0 return $$self{properties}{$key}; } }
134  
135 sub getProperties {
136 0 ▶ my ($self) = @_;
Subroutine getProperties: not called CC=1 SCAR=6.9
Pod undocumented
137 0 return %{ $$self{properties} }; }
138  
139 sub getPropertiesRef {
140 0 ▶ my ($self) = @_;
Subroutine getPropertiesRef: not called CC=1 SCAR=6.9
Pod undocumented
141 0 return $$self{properties}; }
142  
143 sub setProperty {
144 0 ▶ my ($self, $key, $value) = @_;
Subroutine setProperty: not called CC=1 SCAR=6.9
Pod undocumented
145 0 $$self{properties}{$key} = $value;
146 0 return; }
147  
148 sub setProperties {
149 0 ▶ my ($self, %props) = @_;
Subroutine setProperties: not called CC=3 SCAR=24.8
Pod undocumented
150 0 ▶ while (my ($key, $value) = each %props) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %props) 0 0 0
151 0 ▶ $$self{properties}{$key} = $value if defined $value; }
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
152 0 return; }
153  
154 # For the dimensions of boxes, we'll store the (lazily) computed size as:
155 # cwidth, cheight, cdepth
156 # and the explicitly requested/assigned size as
157 # width, height, depth.
158 # Generally speaking, an XML element should only get width, height, depth
159 # attributes when they were explicitly set.
160 # However, when requesting the size of a box, you'd get either (w/ explicit size overriding)
161 sub getWidth {
162 0 ▶ my ($self, %options) = @_;
Subroutine getWidth: not called CC=4 SCAR=30.0
Pod undocumented
163 0 my $props = $self->getPropertiesRef;
164 0 ▶ $self->computeSizeStore(%options) unless (defined $$props{width}) or (defined $$props{cwidth});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"width"} or defined $props->{"cwidth"} 0 0 0
Condition0%0/3
defined $props->{"width"} or defined $props->{"cwidth"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $props->{"width"} or defined $props->{"cwidth"}
defined $props->{"width"} defined $props->{"cwidth"}
Truth table0%0/3
A or B
A= defined $props->{"width"}B= defined $props->{"cwidth"}
ABresult
1X1
011
000
165 0 ▶ return $$props{width} || $$props{cwidth}; }
Condition0%0/3
$props->{'width'} || $props->{'cwidth'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'width'} || $props->{'cwidth'}
$props->{'width'} $props->{'cwidth'}
Truth table0%0/3
A || B
A= $props->{'width'}B= $props->{'cwidth'}
ABresult
1X1
011
000
166  
167 sub getHeight {
168 0 ▶ my ($self, %options) = @_;
Subroutine getHeight: not called CC=4 SCAR=30.0
Pod undocumented
169 0 my $props = $self->getPropertiesRef;
170 0 ▶ $self->computeSizeStore(%options) unless (defined $$props{height}) or (defined $$props{cheight});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"height"} or defined $props->{"cheight"} 0 0 0
Condition0%0/3
defined $props->{"height"} or defined $props->{"cheight"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $props->{"height"} or defined $props->{"cheight"}
defined $props->{"height"} defined $props->{"cheight"}
Truth table0%0/3
A or B
A= defined $props->{"height"}B= defined $props->{"cheight"}
ABresult
1X1
011
000
171 0 ▶ return $$props{height} || $$props{cheight}; }
Condition0%0/3
$props->{'height'} || $props->{'cheight'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'height'} || $props->{'cheight'}
$props->{'height'} $props->{'cheight'}
Truth table0%0/3
A || B
A= $props->{'height'}B= $props->{'cheight'}
ABresult
1X1
011
000
172  
173 sub getDepth {
174 0 ▶ my ($self, %options) = @_;
Subroutine getDepth: not called CC=4 SCAR=30.0
Pod undocumented
175 0 my $props = $self->getPropertiesRef;
176 0 ▶ $self->computeSizeStore(%options) unless (defined $$props{depth}) or (defined $$props{cdepth});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"depth"} or defined $props->{"cdepth"} 0 0 0
Condition0%0/3
defined $props->{"depth"} or defined $props->{"cdepth"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $props->{"depth"} or defined $props->{"cdepth"}
defined $props->{"depth"} defined $props->{"cdepth"}
Truth table0%0/3
A or B
A= defined $props->{"depth"}B= defined $props->{"cdepth"}
ABresult
1X1
011
000
177 0 ▶ return $$props{depth} || $$props{cdepth}; }
Condition0%0/3
$props->{'depth'} || $props->{'cdepth'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'depth'} || $props->{'cdepth'}
$props->{'depth'} $props->{'cdepth'}
Truth table0%0/3
A || B
A= $props->{'depth'}B= $props->{'cdepth'}
ABresult
1X1
011
000
178  
179 sub getTotalHeight {
180 0 ▶ my ($self, %options) = @_;
Subroutine getTotalHeight: not called CC=7 SCAR=40.3
Pod undocumented
181 0 my $props = $self->getPropertiesRef;
182 $self->computeSizeStore(%options)
183 unless ((defined $$props{height}) or (defined $$props{cheight}))
184 0 ▶ && ((defined $$props{depth}) or (defined $$props{cdepth}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"height"} || defined $props->{"cheight"} and defined $props->{"depth"} || defined $props->{"cdepth"} 0 0 0
Condition0%0/9
defined $props->{"height"} || defined $props->{"cheight"} and defined $props->{"depth"} || defined $props->{"cdepth"}
!ll&&!rl&&r
000
defined $props->{"height"} or defined $props->{"cheight"}
l!l&&r!l&&!r
000
defined $props->{"depth"} or defined $props->{"cdepth"}
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $props->{"height"} || defined $props->{"cheight"} and defined $props->{"depth"} || defined $props->{"cdepth"}
defined $props->{"height"} defined $props->{"cheight"} defined $props->{"depth"} defined $props->{"cdepth"}
Truth table0%0/7
A or B and C or D
A= defined $props->{"height"}B= defined $props->{"cheight"}C= defined $props->{"depth"}D= defined $props->{"cdepth"}
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
185 0 ▶ my $h = $$props{height} || $$props{cheight};
Condition0%0/3
$props->{'height'} || $props->{'cheight'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'height'} || $props->{'cheight'}
$props->{'height'} $props->{'cheight'}
Truth table0%0/3
A || B
A= $props->{'height'}B= $props->{'cheight'}
ABresult
1X1
011
000
186 0 ▶ my $d = $$props{depth} || $$props{cdepth};
Condition0%0/3
$props->{'depth'} || $props->{'cdepth'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'depth'} || $props->{'cdepth'}
$props->{'depth'} $props->{'cdepth'}
Truth table0%0/3
A || B
A= $props->{'depth'}B= $props->{'cdepth'}
ABresult
1X1
011
000
187 0 return $h->add($d); }
188  
189 sub setWidth {
190 0 ▶ my ($self, $width) = @_;
Subroutine setWidth: not called CC=1 SCAR=6.9
Pod undocumented
191 0 my $props = $self->getPropertiesRef;
192 0 $$props{width} = $width;
193 0 return; }
194  
195 sub setHeight {
196 0 ▶ my ($self, $height) = @_;
Subroutine setHeight: not called CC=1 SCAR=6.9
Pod undocumented
197 0 my $props = $self->getPropertiesRef;
198 0 $$props{height} = $height;
199 0 return; }
200  
201 sub setDepth {
202 0 ▶ my ($self, $depth) = @_;
Subroutine setDepth: not called CC=1 SCAR=6.9
Pod undocumented
203 0 my $props = $self->getPropertiesRef;
204 0 $$props{depth} = $depth;
205 0 return; }
206  
207 sub getSize {
208 0 ▶ my ($self, %options) = @_;
Subroutine getSize: not called CC=14 SCAR=51.6
Pod undocumented
209 0 my $props = $self->getPropertiesRef;
210 5 ▶ no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
211 $self->computeSizeStore(%options)
212 unless (defined $$props{cwidth})
213 && (defined $$props{cheight})
214 0 ▶ && (defined $$props{cdepth});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cwidth"} and defined $props->{"cheight"} and defined $props->{"cdepth"} 0 0 0
Condition0%0/6
defined $props->{"cwidth"} and defined $props->{"cheight"} and defined $props->{"cdepth"}
!ll&&!rl&&r
000
defined $props->{"cwidth"} and defined $props->{"cheight"}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $props->{"cwidth"} and defined $props->{"cheight"} and defined $props->{"cdepth"}
defined $props->{"cwidth"} defined $props->{"cheight"} defined $props->{"cdepth"}
Truth table0%0/4
A and B and C
A= defined $props->{"cwidth"}B= defined $props->{"cheight"}C= defined $props->{"cdepth"}
ABCresult
0XX0
10X0
1100
1111
215 Debug("SIZE of $self"
216 . "\n preassigned: " . _showsize($$props{width}, $$props{height}, $$props{depth})
217 . "\n calculated : " . _showsize($$props{cwidth}, $$props{cheight}, $$props{cdepth})
218 0 ▶ . "\n w/options " . join(',', map { $_ . "=" . ToString($options{$_}); } sort keys %options)
Condition0%0/9
$props->{'width'} || $props->{'cwidth'}
l!l&&r!l&&!r
000
$props->{'height'} || $props->{'cheight'}
l!l&&r!l&&!r
000
$props->{'depth'} || $props->{'cdepth'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'width'} || $props->{'cwidth'}
$props->{'width'} $props->{'cwidth'}
MC/DC0%0/2
$props->{'height'} || $props->{'cheight'}
$props->{'height'} $props->{'cheight'}
MC/DC0%0/2
$props->{'depth'} || $props->{'cdepth'}
$props->{'depth'} $props->{'cdepth'}
Truth table0%0/3
A || B
A= $props->{'width'}B= $props->{'cwidth'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'height'}B= $props->{'cheight'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'depth'}B= $props->{'cdepth'}
ABresult
1X1
011
000
219 . "\n =>: " . _showsize($$props{width} || $$props{cwidth}, $$props{height} || $$props{cheight}, $$props{depth} || $$props{cdepth})
220 0 ▶ . "\n Of " . ToString($self)) if $LaTeXML::DEBUG{size};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"size"} 0 0 0
221 return ($$props{width} || $$props{cwidth},
222 $$props{height} || $$props{cheight},
223 $$props{depth} || $$props{cdepth},
224 $$props{cwidth} || $$props{width},
225 $$props{cheight} || $$props{height},
226 0 ▶ $$props{cdepth} || $$props{depth}); }
Condition0%0/18
$props->{'width'} || $props->{'cwidth'}
l!l&&r!l&&!r
000
$props->{'height'} || $props->{'cheight'}
l!l&&r!l&&!r
000
$props->{'depth'} || $props->{'cdepth'}
l!l&&r!l&&!r
000
$props->{'cwidth'} || $props->{'width'}
l!l&&r!l&&!r
000
$props->{'cheight'} || $props->{'height'}
l!l&&r!l&&!r
000
$props->{'cdepth'} || $props->{'depth'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$props->{'width'} || $props->{'cwidth'}
$props->{'width'} $props->{'cwidth'}
MC/DC0%0/2
$props->{'height'} || $props->{'cheight'}
$props->{'height'} $props->{'cheight'}
MC/DC0%0/2
$props->{'depth'} || $props->{'cdepth'}
$props->{'depth'} $props->{'cdepth'}
MC/DC0%0/2
$props->{'cwidth'} || $props->{'width'}
$props->{'cwidth'} $props->{'width'}
MC/DC0%0/2
$props->{'cheight'} || $props->{'height'}
$props->{'cheight'} $props->{'height'}
MC/DC0%0/2
$props->{'cdepth'} || $props->{'depth'}
$props->{'cdepth'} $props->{'depth'}
Truth table0%0/3
A || B
A= $props->{'width'}B= $props->{'cwidth'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'height'}B= $props->{'cheight'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'depth'}B= $props->{'cdepth'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'cwidth'}B= $props->{'width'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'cheight'}B= $props->{'height'}
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $props->{'cdepth'}B= $props->{'depth'}
ABresult
1X1
011
000
227  
228 sub _showsize {
229 0 ▶ my ($w, $h, $d) = @_;
Subroutine _showsize: not called CC=4 SCAR=30.0
230 0 ▶ return ($w ? ToString($w) : '<none>') . " x " . ($h ? ToString($h) : '<none>') . " + " . ($d ? ToString($d) : '<none>'); }
Branch: 3 branches
BranchTrueFalseTotal
$w ? : 0 0 0
$h ? : 0 0 0
$d ? : 0 0 0
231  
232 # for debugging....
233 sub showSize {
234 0 ▶ my ($self) = @_;
Subroutine showSize: not called CC=1 SCAR=6.9
Pod undocumented
235 0 return '[' . ToString($self->getWidth) . ' x ' . ToString($self->getHeight) . ' + ' . ToString($self->getDepth) . ']'; }
236  
237 #omg
238 # Fake computing the dimensions of strings (typically single chars).
239 # Eventually, this needs to link into real font data
240 sub computeSizeStore {
241 0 ▶ my ($self, %options) = @_;
Subroutine computeSizeStore: not called CC=9 SCAR=45.0
Pod undocumented
242 0 my $props = $self->getPropertiesRef;
243 0 ▶ $options{width} = $$props{width} if $$props{width};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"width"} 0 0 0
244 0 ▶ $options{height} = $$props{height} if $$props{height};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"height"} 0 0 0
245 0 ▶ $options{depth} = $$props{depth} if $$props{depth};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"depth"} 0 0 0
246 0 ▶ $options{vattach} = $$props{vattach} if $$props{vattach};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"vattach"} 0 0 0
247 0 ▶ $options{layout} = $$props{layout} if $$props{layout};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"layout"} 0 0 0
248 0 my ($w, $h, $d) = $self->computeSize(%options);
249 0 ▶ $$props{cwidth} = $w unless defined $$props{cwidth};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cwidth"} 0 0 0
250 0 ▶ $$props{cheight} = $h unless defined $$props{cheight};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cheight"} 0 0 0
251 0 ▶ $$props{cdepth} = $d unless defined $$props{cdepth};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cdepth"} 0 0 0
252 0 return; }
253  
254 sub computeSize {
255 0 ▶ my ($self, %options) = @_;
Subroutine computeSize: not called CC=2 SCAR=17.9
Pod undocumented
256 0 ▶ my $font = $self->getProperty('font') || LaTeXML::Common::Font->textDefault;
Condition0%0/3
$self->getProperty('font') || 'LaTeXML::Common::Font'->textDefault
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->getProperty('font') || 'LaTeXML::Common::Font'->textDefault
$self->getProperty('font') 'LaTeXML::Common::Font'->textDefault
Truth table0%0/3
A || B
A= $self->getProperty('font')B= 'LaTeXML::Common::Font'->textDefault
ABresult
1X1
011
000
257 0 return $font->computeStringSize($$self{string}, %options); }
258  
259 #======================================================================
260 5 1;
261  
262 __END__
« lib/LaTeXML/Post/OpenMath.pm ↑ Summary lib/LaTeXML/Post/Scan.pm »