lib/LaTeXML/Core/Box.pm

filter: Statementstmt 20.2% 33 / 163 Branchbran 0.0% 0 / 78 Conditioncond 0.0% 0 / 122 MC/DCmcdc 0.0% 0 / 71 Subroutinesub 23.2% 10 / 43 Podpod 37.5% 12 / 32 totaltotal 10.8% 55 / 509 CC 82 SCAR 44.2
CC
82
Cov
9%
Box
306.0
getSize
174.1
beAbsorbed
90.0
CRAP 83.4
« lib/LaTeXML/Util/WWW.pm ↑ Summary lib/LaTeXML/Core/Document.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 0 ▶sub Box {
Subroutine Box: not called CC=17 SCAR=57.2
Pod documented
30 0 my ($string, $font, $locator, $tokens, %properties) = @_;
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 ▶ if ($properties{isSpace} && ($properties{width} || $properties{height} || $properties{depth})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($properties{"isSpace"} and $properties{"width"} || $properties{"height"} || $properties{"depth"}) 0 0 0
Condition0%0/9
$properties{"isSpace"} and $properties{"width"} || $properties{"height"} || $properties{"depth"}
!ll&&!rl&&r
000
$properties{"width"} or $properties{"height"} or $properties{"depth"}
l!l&&r!l&&!r
000
$properties{"width"} or $properties{"height"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$properties{"isSpace"} and $properties{"width"} || $properties{"height"} || $properties{"depth"}
$properties{"isSpace"} $properties{"width"} $properties{"height"} $properties{"depth"}
Truth table0%0/5
A and B or C or D
A= $properties{"isSpace"}B= $properties{"width"}C= $properties{"height"}D= $properties{"depth"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
35 0 ▶ $properties{width} = Dimension(0) unless defined $properties{width};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $properties{"width"} 0 0 0
36 0 ▶ $properties{height} = Dimension(0) unless defined $properties{height};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $properties{"height"} 0 0 0
37 0 ▶ $properties{depth} = Dimension(0) unless defined $properties{depth}; }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $properties{"depth"} 0 0 0
38 0 my $state = $STATE;
39 0 ▶ if ($state->lookupValue('IN_MATH')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->lookupValue('IN_MATH')) { } 0 0 0
40 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
41 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
42 0 ▶ return LaTeXML::Core::Box->new($usestring, $font->specialize($string), $locator, $tokens,
Branch: 1 branch
BranchTrueFalseTotal
$attr ? : 0 0 0
43 mode => 'math', ($attr ? %$attr : ()), %properties); }
44 else {
45 0 return LaTeXML::Core::Box->new($string, $font, $locator, $tokens, %properties); } }
46  
47 #======================================================================
48 # Box Object
49  
50 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
51 0 my ($class, $string, $font, $locator, $tokens, %properties) = @_;
52 0 return bless { string => $string,
53 tokens => $tokens,
54 properties => { font => $font, locator => $locator, %properties }
55 }, $class; }
56  
57 # Accessors
58 0 ▶sub isaBox {
Subroutine isaBox: not called CC=1 SCAR=6.9
Pod documented
59 0 return 1; }
60  
61 0 ▶sub getString {
Subroutine getString: not called CC=1 SCAR=6.9
Pod documented
62 0 my ($self) = @_;
63 0 return $$self{string}; } # Return the string contents of the box
64  
65 0 ▶sub getFont {
Subroutine getFont: not called CC=1 SCAR=6.9
Pod documented
66 0 my ($self) = @_;
67 0 return $$self{properties}{font}; } # and if undef ????
68  
69 0 ▶sub setFont {
Subroutine setFont: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my ($self, $font) = @_;
71 0 $$self{properties}{font} = $font;
72 0 return; }
73  
74 0 ▶sub isMath {
Subroutine isMath: not called CC=2 SCAR=17.9
Pod documented
75 0 my ($self) = @_;
76 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
77  
78 0 ▶sub getLocator {
Subroutine getLocator: not called CC=1 SCAR=6.9
Pod documented
79 0 my ($self) = @_;
80 0 return $$self{properties}{locator}; }
81  
82 0 ▶sub getSource {
Subroutine getSource: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my ($self) = @_;
84 0 return $$self{properties}{locator}; }
85  
86 # So a Box can stand in for a List
87 0 ▶sub unlist {
Subroutine unlist: not called CC=1 SCAR=6.9
Pod documented
88 0 my ($self) = @_;
89 0 return ($self); } # Return list of the boxes
90  
91 0 ▶sub getBody {
Subroutine getBody: not called CC=1 SCAR=6.9
Pod undocumented
92 0 my ($self) = @_;
93 0 return $self; }
94  
95 0 ▶sub revert {
Subroutine revert: not called CC=2 SCAR=17.9
Pod documented
96 0 my ($self) = @_;
97 0 ▶ return ($$self{tokens} ? $$self{tokens}->unlist : ()); }
Branch: 1 branch
BranchTrueFalseTotal
$self->{'tokens'} ? : 0 0 0
98  
99 0 ▶sub toString {
Subroutine toString: not called CC=2 SCAR=17.9
Pod documented
100 0 my ($self) = @_;
101 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
102  
103 # Methods for overloaded operators
104 0 ▶sub stringify {
Subroutine stringify: not called CC=6 SCAR=37.4
Pod documented
105 0 my ($self) = @_;
106 0 my $type = ref $self;
107 0 $type =~ s/^LaTeXML::Core:://;
108 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
109 return $type . '['
110 . (defined $$self{string} ? $$self{string}
111 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
112 . ($font && ($font ne 'Font[]') ? ' ' . $font : '')
113 . ']'; }
114  
115 # Should this compare fonts too?
116 0 ▶sub equals {
Subroutine equals: not called CC=4 SCAR=30.0
Pod documented
117 0 my ($a, $b) = @_;
118 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
119  
120 0 ▶sub beAbsorbed {
Subroutine beAbsorbed: not called CC=9 SCAR=45.0
Pod documented
121 0 my ($self, $document) = @_;
122 0 my $string = $$self{string};
123 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
124  
125 # Guard via the absorb limit to avoid infinite loops
126 0 ▶ if ($LaTeXML::ABSORB_LIMIT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($LaTeXML::ABSORB_LIMIT) 0 0 0
127 0 ▶ my $absorb_counter = $STATE->lookupValue('absorb_count') || 0;
Condition0%0/2
$LaTeXML::Core::Box::STATE->lookupValue('absorb_count') || 0
l!l
00
MC/DC0%0/1
$LaTeXML::Core::Box::STATE->lookupValue('absorb_count') || 0
$LaTeXML::Core::Box::STATE->lookupValue('absorb_count')
Truth table0%0/2
A
A= $LaTeXML::Core::Box::STATE->lookupValue('absorb_count')
Aresult
11
00
128 0 $STATE->assignValue(absorb_count => ++$absorb_counter, 'global');
129 0 ▶ if ($absorb_counter > $LaTeXML::ABSORB_LIMIT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($absorb_counter > $LaTeXML::ABSORB_LIMIT) 0 0 0
130 0 Fatal('timeout', 'absorb_limit', $self,
131 "Whatsit absorb limit of $LaTeXML::ABSORB_LIMIT exceeded, infinite loop?"); } }
132  
133 return (((defined $string) && ($string ne '')) || $$self{properties}{width} # ?
134 ? ($mode eq 'math'
135 0 ? $document->insertMathToken($string, %{ $$self{properties} })
136 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
137 : undef); }
138  
139 0 ▶sub getProperty {
Subroutine getProperty: not called CC=4 SCAR=30.0
Pod undocumented
140 0 my ($self, $key) = @_;
141 0 ▶ if ($key eq 'isSpace') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'isSpace') { } 0 0 0
142 0 ▶ return $$self{properties}{$key} if defined $$self{properties}{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"properties"}{$key} 0 0 0
143 0 my $tex = LaTeXML::Core::Token::UnTeX($$self{tokens}); # !
144 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
145 else {
146 0 return $$self{properties}{$key}; } }
147  
148 0 ▶sub getProperties {
Subroutine getProperties: not called CC=1 SCAR=6.9
Pod undocumented
149 0 my ($self) = @_;
150 0 return %{ $$self{properties} }; }
151  
152 0 ▶sub getPropertiesRef {
Subroutine getPropertiesRef: not called CC=1 SCAR=6.9
Pod undocumented
153 0 my ($self) = @_;
154 0 return $$self{properties}; }
155  
156 0 ▶sub setProperty {
Subroutine setProperty: not called CC=1 SCAR=6.9
Pod undocumented
157 0 my ($self, $key, $value) = @_;
158 0 $$self{properties}{$key} = $value;
159 0 return; }
160  
161 0 ▶sub setProperties {
Subroutine setProperties: not called CC=3 SCAR=24.8
Pod undocumented
162 0 my ($self, %props) = @_;
163 0 ▶ while (my ($key, $value) = each %props) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %props) 0 0 0
164 0 ▶ $$self{properties}{$key} = $value if defined $value; }
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 0 0
165 0 return; }
166  
167 # For the dimensions of boxes, we'll store the (lazily) computed size as:
168 # cwidth, cheight, cdepth
169 # and the explicitly requested/assigned size as
170 # width, height, depth.
171 # Generally speaking, an XML element should only get width, height, depth
172 # attributes when they were explicitly set.
173 # However, when requesting the size of a box, you'd get either (w/ explicit size overriding)
174 0 ▶sub getWidth {
Subroutine getWidth: not called CC=4 SCAR=30.0
Pod undocumented
175 0 my ($self, %options) = @_;
176 0 my $props = $self->getPropertiesRef;
177 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
178 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
179  
180 0 ▶sub getHeight {
Subroutine getHeight: not called CC=4 SCAR=30.0
Pod undocumented
181 0 my ($self, %options) = @_;
182 0 my $props = $self->getPropertiesRef;
183 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
184 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
185  
186 0 ▶sub getDepth {
Subroutine getDepth: not called CC=4 SCAR=30.0
Pod undocumented
187 0 my ($self, %options) = @_;
188 0 my $props = $self->getPropertiesRef;
189 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
190 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
191  
192 0 ▶sub getTotalHeight {
Subroutine getTotalHeight: not called CC=7 SCAR=40.3
Pod undocumented
193 0 my ($self, %options) = @_;
194 0 my $props = $self->getPropertiesRef;
195 $self->computeSizeStore(%options)
196 unless ((defined $$props{height}) or (defined $$props{cheight}))
197 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
198 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
199 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
200 0 return $h->add($d); }
201  
202 0 ▶sub setWidth {
Subroutine setWidth: not called CC=1 SCAR=6.9
Pod undocumented
203 0 my ($self, $width) = @_;
204 0 my $props = $self->getPropertiesRef;
205 0 $$props{width} = $width;
206 0 return; }
207  
208 0 ▶sub setHeight {
Subroutine setHeight: not called CC=1 SCAR=6.9
Pod undocumented
209 0 my ($self, $height) = @_;
210 0 my $props = $self->getPropertiesRef;
211 0 $$props{height} = $height;
212 0 return; }
213  
214 0 ▶sub setDepth {
Subroutine setDepth: not called CC=1 SCAR=6.9
Pod undocumented
215 0 my ($self, $depth) = @_;
216 0 my $props = $self->getPropertiesRef;
217 0 $$props{depth} = $depth;
218 0 return; }
219  
220 0 ▶sub getSize {
Subroutine getSize: not called CC=14 SCAR=51.6
Pod undocumented
221 0 my ($self, %options) = @_;
222 0 my $props = $self->getPropertiesRef;
223 5 ▶ no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
224 $self->computeSizeStore(%options)
225 unless (defined $$props{cwidth})
226 && (defined $$props{cheight})
227 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
228 Debug("SIZE of $self"
229 . "\n preassigned: " . _showsize($$props{width}, $$props{height}, $$props{depth})
230 . "\n calculated : " . _showsize($$props{cwidth}, $$props{cheight}, $$props{cdepth})
231 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
232 . "\n =>: " . _showsize($$props{width} || $$props{cwidth}, $$props{height} || $$props{cheight}, $$props{depth} || $$props{cdepth})
233 0 ▶ . "\n Of " . ToString($self)) if $LaTeXML::DEBUG{size};
Branch: 1 branch
BranchTrueFalseTotal
if $LaTeXML::DEBUG{"size"} 0 0 0
234 return ($$props{width} || $$props{cwidth},
235 $$props{height} || $$props{cheight},
236 $$props{depth} || $$props{cdepth},
237 $$props{cwidth} || $$props{width},
238 $$props{cheight} || $$props{height},
239 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
240  
241 0 ▶sub _showsize {
Subroutine _showsize: not called CC=4 SCAR=30.0
242 0 my ($w, $h, $d) = @_;
243 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
244  
245 # for debugging....
246 0 ▶sub showSize {
Subroutine showSize: not called CC=1 SCAR=6.9
Pod undocumented
247 0 my ($self) = @_;
248 0 return '[' . ToString($self->getWidth) . ' x ' . ToString($self->getHeight) . ' + ' . ToString($self->getDepth) . ']'; }
249  
250 #omg
251 # Fake computing the dimensions of strings (typically single chars).
252 # Eventually, this needs to link into real font data
253 0 ▶sub computeSizeStore {
Subroutine computeSizeStore: not called CC=9 SCAR=42.3
Pod undocumented
254 0 my ($self, %options) = @_;
255 5 ▶ no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
256 0 my $props = $self->getPropertiesRef;
257 0 ▶ $options{width} = $$props{width} if $$props{width};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"width"} 0 0 0
258 0 ▶ $options{height} = $$props{height} if $$props{height};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"height"} 0 0 0
259 0 ▶ $options{depth} = $$props{depth} if $$props{depth};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"depth"} 0 0 0
260 0 ▶ $options{vattach} = $$props{vattach} if $$props{vattach};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"vattach"} 0 0 0
261 0 ▶ $options{layout} = $$props{layout} if $$props{layout};
Branch: 1 branch
BranchTrueFalseTotal
if $props->{"layout"} 0 0 0
262 0 my ($w, $h, $d) = $self->computeSize(%options);
263 0 ▶ $$props{cwidth} = $w unless defined $$props{cwidth};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cwidth"} 0 0 0
264 0 ▶ $$props{cheight} = $h unless defined $$props{cheight};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cheight"} 0 0 0
265 0 ▶ $$props{cdepth} = $d unless defined $$props{cdepth};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $props->{"cdepth"} 0 0 0
266 0 return; }
267  
268 0 ▶sub computeSize {
Subroutine computeSize: not called CC=3 SCAR=24.8
Pod undocumented
269 0 my ($self, %options) = @_;
270 0 ▶ if (my $body = $self->getProperty('body')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $body = $self->getProperty("body")) 0 0 0
271 0 return $body->computeSize(%options); }
272 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
273 0 return $font->computeStringSize($$self{string}, %options); }
274  
275 #======================================================================
276 5 1;
277  
278 __END__
« lib/LaTeXML/Util/WWW.pm ↑ Summary lib/LaTeXML/Core/Document.pm »