SWF/Tag/Place.pm untested

filter: Statementstmt 0.0% 0 / 135 Branchbran 0.0% 0 / 72 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 222 CC 37 SCAR 52.0
CC
37
Cov
0%
buildContent
342.0
parseContent
132.0
dumpContent
110.0
CRAP 181.8
1 package IO::SWF::Tag::Place;
2  
3 use strict;
4 use warnings;
5  
6 use base 'IO::SWF::Tag::Base';
7  
8 use IO::SWF::Bit;
9 use IO::SWF::Tag;
10 use IO::SWF::Type::CXFORM;
11 use IO::SWF::Type::String;
12 use IO::SWF::Type::CXFORMWITHALPHA;
13 use IO::SWF::Type::CLIPACTIONS;
14  
15 __PACKAGE__->mk_accessors( qw(
16 _characterId
17 _depth
18 _matrix
19 _colorTransform
20 _ratio
21 _name
22 _clipDepth
23 _clipActions
24 _placeFlagHasClipActions
25 _placeFlagHasClipDepth
26 _placeFlagHasName
27 _placeFlagHasRatio
28 _placeFlagHasColorTransform
29 _placeFlagHasMatrix
30 _placeFlagHasCharacter
31 _placeFlagMove
32 ));
33  
34 sub parseContent {
35 my ($self, $tagCode, $content, $opts_href) = @_;
36 my $reader = IO::SWF::Bit->new();
37 $reader->input($content);
38  
39 if ($tagCode == 4) {
40 #4: // PlaceObject
41 $self->_characterId($reader->getUI16LE());
42 $self->_depth($reader->getUI16LE());
43 $self->_matrix(IO::SWF::Type::MATRIX::parse($reader));
44 if ($reader->hasNextData()) { # optional
45 $self->_colorTransform(IO::SWF::Type::CXFORM::parse($reader));
46 }
47 }
48 elsif ($tagCode == 26) {
49 # 26: // PlaceObject2
50 # placeFlag
51 $self->_placeFlagHasClipActions($reader->getUIBit());
52 $self->_placeFlagHasClipDepth($reader->getUIBit());
53 $self->_placeFlagHasName($reader->getUIBit());
54 $self->_placeFlagHasRatio($reader->getUIBit());
55 $self->_placeFlagHasColorTransform($reader->getUIBit());
56 $self->_placeFlagHasMatrix($reader->getUIBit());
57 $self->_placeFlagHasCharacter($reader->getUIBit());
58 $self->_placeFlagMove($reader->getUIBit());
59 #
60 $self->_depth($reader->getUI16LE());
61 if ($self->_placeFlagHasCharacter) {
62 $self->_characterId($reader->getUI16LE());
63 }
64 if ($self->_placeFlagHasMatrix) {
65 $self->_matrix(IO::SWF::Type::MATRIX::parse($reader));
66 }
67 if ($self->_placeFlagHasColorTransform) {
68 $self->_colorTransform(IO::SWF::Type::CXFORMWITHALPHA::parse($reader));
69 }
70 if ($self->_placeFlagHasRatio) {
71 $self->_ratio($reader->getUI16LE());
72 }
73 if ($self->_placeFlagHasName) {
74 $self->_name(IO::SWF::Type::String::parse($reader));
75 }
76 if ($self->_placeFlagHasClipDepth) {
77 $self->_clipDepth($reader->getUI16LE());
78 }
79 if ($self->_placeFlagHasClipActions) {
80 $self->_clipActions(IO::SWF::Type::CLIPACTIONS::parse($reader, $opts_href));
81 }
82 }
83 return 1;
84 }
85  
86 sub dumpContent {
87 my ($self, $tagCode, $opts_href) = @_;
88  
89 if (defined $self->_characterId) {
90 print "\tCharacterId: ".$self->_characterId."\n";
91 }
92 if (defined $self->_depth) {
93 print "\tDepth: ".$self->_depth."\n";
94 }
95 if (defined $self->_matrix) {
96 $opts_href->{'indent'} = 2;
97 print "\tMatrix:\n".IO::SWF::Type::MATRIX::string($self->_matrix, $opts_href)."\n";
98 }
99 if (defined $self->_colorTransform) {
100 if ($tagCode == 4) { # PlaceObject
101 print "\tColorTransform: ".IO::SWF::Type::CXFORM::string($self->_colorTransform)."\n";
102 } else {
103 print "\tColorTransform: ".IO::SWF::Type::CXFORMWITHALPHA::string($self->_colorTransform)."\n";
104 }
105 }
106 if (defined $self->_ratio) {
107 print "\tRatio: ".$self->_ratio."\n";
108 }
109 if (defined $self->_name) {
110 print "\tName:".$self->_name."\n";
111 }
112 if (defined $self->_clipDepth) {
113 print "\tClipDepth:".$self->_clipDepth."\n";
114 }
115 if (defined $self->_clipActions) {
116 print "\tClipActions:\n";
117 print "\t".IO::SWF::Type::CLIPACTIONS::string($self->_clipActions, $opts_href)."\n";
118 }
119 }
120  
121 sub buildContent {
122 my ($self, $tagCode, $opts_href) = @_;
123 my $writer = IO::SWF::Bit->new();
124  
125 if ($tagCode == 4) {
126 # 4: // PlaceObject
127 $self->_characterId($writer->getUI16LE());
128 $self->_depth($writer->getUI16LE());
129 $self->_matrix(IO::SWF::Type::MATRIX::parse($writer));
130 if ($writer->hasNextData()) { # optional
131 $self->_colorTransform(IO::SWF::Type::CXFORM::parse($writer));
132 }
133 }
134 elsif ($tagCode == 26) {
135 # 26: // PlaceObject2
136 #
137 if (defined $self->_characterId) {
138 $self->_placeFlagHasCharacter(1);
139 } else {
140 $self->_placeFlagHasCharacter(0);
141 }
142 if (defined $self->_matrix) {
143 $self->_placeFlagHasMatrix(1);
144 } else {
145 $self->_placeFlagHasMatrix(0);
146 }
147 if (defined $self->_colorTransform) {
148 $self->_placeFlagHasColorTransform(1);
149 } else {
150 $self->_placeFlagHasColorTransform(0);
151 }
152 if (defined $self->_ratio) {
153 $self->_placeFlagHasRatio(1);
154 } else {
155 $self->_placeFlagHasRatio(0);
156 }
157 if (defined $self->_name) {
158 $self->_placeFlagHasName(1);
159 } else {
160 $self->_placeFlagHasName(0);
161 }
162 if (defined $self->_clipDepth) {
163 $self->_placeFlagHasClipDepth(1);
164 } else {
165 $self->_placeFlagHasClipDepth(0);
166 }
167 if (defined $self->_clipActions) {
168 $self->_placeFlagHasClipActions(1);
169 } else {
170 $self->_placeFlagHasClipActions(0);
171 }
172 # placeFlag
173 $writer->putUIBit($self->_placeFlagHasClipActions);
174 $writer->putUIBit($self->_placeFlagHasClipDepth);
175 $writer->putUIBit($self->_placeFlagHasName);
176 $writer->putUIBit($self->_placeFlagHasRatio);
177 $writer->putUIBit($self->_placeFlagHasColorTransform);
178 $writer->putUIBit($self->_placeFlagHasMatrix);
179 $writer->putUIBit($self->_placeFlagHasCharacter);
180 $writer->putUIBit($self->_placeFlagMove);
181 #
182 $writer->putUI16LE($self->_depth);
183 if ($self->_placeFlagHasCharacter) {
184 $writer->putUI16LE($self->_characterId);
185 }
186 if ($self->_placeFlagHasMatrix) {
187 IO::SWF::Type::MATRIX::build($writer, $self->_matrix);
188 }
189 if ($self->_placeFlagHasColorTransform) {
190 IO::SWF::Type::CXFORMWITHALPHA::build($writer, $self->_colorTransform);
191 }
192 if ($self->_placeFlagHasRatio) {
193 $writer->putUI16LE($self->_ratio);
194 }
195 if ($self->_placeFlagHasName) {
196 IO::SWF::Type::String::build($writer, $self->_name);
197 }
198 if ($self->_placeFlagHasClipDepth) {
199 $writer->putUI16LE($self->_clipDepth);
200 }
201 if ($self->_placeFlagHasClipActions) {
202 IO::SWF::Type::CLIPACTIONS::build($writer, $self->_clipActions, $opts_href);
203 }
204 }
205 return $writer->output();
206 }
207  
208 1;