| 1 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 2010 Ars Aperta, Itaapy, Pierlis, Talend. | ||||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 2014 Jean-Marie Gouarné. | ||||||||||||||||||||||||||||||||||
| 5 | # Author: Jean-Marie Gouarné <jean.marie.gouarne@online.fr> | ||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||
| 7 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use 5.010_001; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 11 | # The ODF Document class definition | ||||||||||||||||||||||||||||||||||
| 12 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 13 | package ODF::lpOD::Document; | ||||||||||||||||||||||||||||||||||
| 14 | 2 | our $VERSION = '1.013'; | |||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use constant PACKAGE_DATE => '2014-04-30T08:27:07'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 2 | *forget = *DESTROY; | |||||||||||||||||||||||||||||||||
| 21 | 2 | *container = *get_container; | |||||||||||||||||||||||||||||||||
| 22 | 2 | *body = *get_body; | |||||||||||||||||||||||||||||||||
| 23 | 2 | *add_part = *add_file; | |||||||||||||||||||||||||||||||||
| 24 | 2 | *register_style = *insert_style; | |||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||
| 27 | #--- specific constructors --------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | sub get_from_uri | ||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_from_uri: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 31 | 0 | my $resource = shift; | |||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | unless ($resource) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||
| 34 | 0 | alert "Missing source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | 0 | return ODF::lpOD::Document->new(@_, uri => $resource); | |||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | sub create_from_template | ||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
create_from_template: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 41 | 0 | my $resource = shift; | |||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless ($resource) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||
| 44 | 0 | alert "Missing template"; return FALSE; | |||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | 0 | return ODF::lpOD::Document->new(@_, template => $resource); | |||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||
| 50 | sub get | ||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 52 | 0 | my $caller = shift; | |||||||||||||||||||||||||||||||||
| 53 | 0 | return ODF::lpOD::Document->new(uri => shift, @_); | |||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||
| 56 | sub create | ||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 58 | 0 | my $caller = shift; | |||||||||||||||||||||||||||||||||
| 59 | 0 | return ODF::lpOD::Document->new(type => shift, @_); | |||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | sub _create | ||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
_create: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 64 | 0 | my $type = shift; | |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | unless ($type) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||||
| 67 | 0 | alert "Missing document type"; return FALSE; | |||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||
| 69 | 0 | return ODF::lpOD::Document->new(@_, type => $type); | |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||
| 72 | #--- generic constructor & destructor ---------------------------------------- | ||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | sub new | ||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 76 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 77 | 0 | my $self = { @_ }; | |||||||||||||||||||||||||||||||||
| 78 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->{uri} //= $self->{source}; delete $self->{source}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"uri"} //= $self->{"source"}
MC/DC0%0/2
$self->{"uri"} //= $self->{"source"}
$self->{"uri"}
$self->{"source"}
Truth table0%0/3
A //= B
A= $self->{"uri"}B= $self->{"source"}
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($self->{type}) # new document, type provided | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||
| 82 | my $template = ODF::lpOD::Common::template($self->{type}) | ||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | (template => $template) or return undef; | ||||||||||||||||||||||||||||||||||
| 86 | 0 | my $meta = $self->get_part(META); | |||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ($meta) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||
| 89 | 0 | my $d = iso_date; | |||||||||||||||||||||||||||||||||
| 90 | 0 | $meta->set_creation_date($d); | |||||||||||||||||||||||||||||||||
| 91 | 0 | $meta->set_modification_date($d); | |||||||||||||||||||||||||||||||||
| 92 | 0 | $meta->set_editing_duration('PT00H00M00S'); | |||||||||||||||||||||||||||||||||
| 93 | 0 | $meta->set_generator("ODF::lpOD $ODF::lpOD::VERSION"); | |||||||||||||||||||||||||||||||||
| 94 | 0 | $meta->set_initial_creator(); | |||||||||||||||||||||||||||||||||
| 95 | 0 | $meta->set_creator(); | |||||||||||||||||||||||||||||||||
| 96 | 0 | $meta->set_editing_cycles(1); | |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||
| 99 | elsif ($self->{template}) | ||||||||||||||||||||||||||||||||||
| 100 | { | ||||||||||||||||||||||||||||||||||
| 101 | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||||
| 102 | (template => $self->{template}) | ||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||
| 105 | elsif ($self->{uri}) # existing document, path provided | ||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||
| 107 | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | (uri => $self->{uri}) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $self->{pretty} //= ($self->{indent} // lpod->debug); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$self->{"indent"} // "ODF::lpOD::Common"->debug
MC/DC0%0/3
$self->{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$self->{"pretty"}
$self->{"indent"}
"ODF::lpOD::Common"->debug
Truth table0%0/4
A //= B // C
A= $self->{"pretty"}B= $self->{"indent"}C= "ODF::lpOD::Common"->debug
| |||||||||||||||||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 116 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 117 | 0 | foreach my $part_name ($self->loaded_xmlparts) | |||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | next unless $part_name && $self->{$part_name}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$part_name and $self->{$part_name}
MC/DC0%0/2
$part_name and $self->{$part_name}
$part_name
$self->{$part_name}
Truth table0%0/3
A and B
A= $part_nameB= $self->{$part_name}
| |||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->{$part_name}->forget; | |||||||||||||||||||||||||||||||||
| 121 | 0 | delete $self->{$part_name}; | |||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||
| 123 | 0 | delete $self->{xmlparts}; | |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | $self->{container} && $self->{container}->DESTROY; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 125 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | #--- XML part detection ------------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | sub is_xmlpart | ||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_xmlpart: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 132 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return ODF::lpOD::XMLPart::class_of($name) ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||
| 136 | #--- document part accessors ------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||
| 138 | sub get_container | ||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_container: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 141 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 142 | 0 | my $container = $self->{container}; | |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | unless ($container || is_false($opt{warning})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$container or is_false($opt{"warning"})
MC/DC0%0/2
$container or is_false($opt{"warning"})
$container
is_false($opt{"warning"})
Truth table0%0/3
A or B
A= $containerB= is_false($opt{"warning"})
| |||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||
| 145 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||
| 147 | 0 | return $container; | |||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | sub contains | ||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
contains: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 154 | 0 | return $container->contains(@_); | |||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | sub parts | ||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
parts: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 159 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 161 | 0 | return $container->parts; | |||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | sub get_stored_part | ||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_stored_part: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 168 | 0 | return $container->get_stored_part(@_); | |||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | sub get_xmlpart | ||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_xmlpart: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 173 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 175 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $part_name = shift or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | unless ($self->{$part_name}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||
| 181 | my $xmlpart = ODF::lpOD::XMLPart->new | ||||||||||||||||||||||||||||||||||
| 182 | ( | ||||||||||||||||||||||||||||||||||
| 183 | container => $container, | ||||||||||||||||||||||||||||||||||
| 184 | part => $part_name, | ||||||||||||||||||||||||||||||||||
| 185 | pretty => $self->{pretty}, | ||||||||||||||||||||||||||||||||||
| 186 | @_ | ||||||||||||||||||||||||||||||||||
| 187 | 0 | ); | |||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | unless ($xmlpart) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||
| 190 | 0 | alert "Unavailable part"; return FALSE; | |||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||
| 192 | 0 | $self->{$part_name} = $xmlpart; | |||||||||||||||||||||||||||||||||
| 193 | 0 | $self->{$part_name}->{document} = $self; | |||||||||||||||||||||||||||||||||
| 194 | 0 | push @{$self->{xmlparts}}, $part_name; | |||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||
| 196 | 0 | return $self->{$part_name}; | |||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | sub loaded_xmlparts | ||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
loaded_xmlparts: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 201 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return undef unless $self->{xmlparts}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | return wantarray ? @{$self->{xmlparts}} : $self->{xmlparts}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||
| 206 | sub get_body | ||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 208 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 209 | 0 | return $self->content->get_body(@_); | |||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | sub get_part | ||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_part: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 214 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 216 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 217 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (is_xmlpart($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||
| 220 | 0 | return $self->get_xmlpart($part_name, @_); | |||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||
| 222 | else | ||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||
| 224 | 0 | return $container->get_part($part_name, @_); | |||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | sub content | ||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
content: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 230 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 231 | 0 | return $self->get_xmlpart(CONTENT, @_); | |||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||
| 234 | sub meta | ||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 237 | 0 | return $self->get_xmlpart(META, @_); | |||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | sub styles | ||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
styles: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 242 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 243 | 0 | return $self->get_xmlpart(STYLES, @_); | |||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||
| 246 | sub manifest | ||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
manifest: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 248 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 249 | 0 | return $self->get_xmlpart(MANIFEST, @_); | |||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||
| 252 | sub get_parts | ||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_parts: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 254 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 256 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 257 | 0 | return $container->get_parts; | |||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||
| 260 | sub set_part | ||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_part: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 262 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||
| 265 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 266 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||
| 268 | 0 | return $self->{container}->set_part(@_); | |||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | sub del_part | ||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
del_part: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 273 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||
| 276 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 277 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||
| 279 | 0 | return $self->{container}->del_part(@_); | |||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||
| 282 | sub add_file | ||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
add_file: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||
| 287 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 288 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||
| 290 | 0 | my $source = shift; | |||||||||||||||||||||||||||||||||
| 291 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | my $path = $opt{path} || $opt{part}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{'path'} || $opt{'part'}
MC/DC0%0/2
$opt{'path'} || $opt{'part'}
$opt{'path'}
$opt{'part'}
Truth table0%0/3
A || B
A= $opt{'path'}B= $opt{'part'}
| |||||||||||||||||||||||||||||||||||
| 293 | 0 | delete @opt{qw(path part)}; | |||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | unless ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ($opt{type} && $opt{type} =~ /^image/) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"type"} and $opt{"type"} =~ /^image/
MC/DC0%0/2
$opt{"type"} and $opt{"type"} =~ /^image/
$opt{"type"}
$opt{"type"} =~ /^image/
Truth table0%0/3
A and B
A= $opt{"type"}B= $opt{"type"} =~ /^image/
| |||||||||||||||||||||||||||||||||||
| 297 | { | ||||||||||||||||||||||||||||||||||
| 298 | 0 | my $filename = file_parse($source); | |||||||||||||||||||||||||||||||||
| 299 | 0 | $path = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||
| 302 | 0 | $path = $self->{container}->add_file($source, $path, %opt); | |||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||
| 305 | 0 | my $manifest = $self->get_part(MANIFEST); | |||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if ($manifest) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 307 | { | ||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $type = $opt{type} || file_type($source); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{'type'} || file_type($source)
MC/DC0%0/2
$opt{'type'} || file_type($source)
$opt{'type'}
file_type($source)
Truth table0%0/3
A || B
A= $opt{'type'}B= file_type($source)
| |||||||||||||||||||||||||||||||||||
| 309 | 0 | $manifest->set_entry($path, type => $type); | |||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||
| 312 | 0 | return $path; | |||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | sub add_image_file | ||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
add_image_file: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 317 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $source = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||
| 321 | 0 | alert "No available ODF container"; | |||||||||||||||||||||||||||||||||
| 322 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||
| 324 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 325 | 0 | my ($filename, $sourcepath, $suffix) = file_parse($source); | |||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | unless ($filename) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||
| 328 | 0 | alert "No valid file name in $source"; | |||||||||||||||||||||||||||||||||
| 329 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | my $type = $opt{type} || file_type($source) || "image/$suffix"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
$opt{'type'} || file_type($source) || "image/$suffix"
$opt{"type"} or file_type($source)
MC/DC0%0/2
$opt{'type'} || file_type($source) || "image/$suffix"
$opt{"type"}
file_type($source)
Truth table0%0/3
A or B
A= $opt{"type"}B= file_type($source)
| |||||||||||||||||||||||||||||||||||
| 332 | 0 | my $path = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | $suffix //= 'unknown'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$suffix //= "unknown"
MC/DC0%0/1
$suffix //= "unknown"
$suffix
Truth table0%0/2
A
A= $suffix
| |||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||
| 335 | 0 | my ($link, $size); | |||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 337 | { | ||||||||||||||||||||||||||||||||||
| 338 | 0 | my $buffer = load_file($source, ':raw'); | |||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | unless ($buffer) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||
| 341 | 0 | alert "Resource $source not available"; | |||||||||||||||||||||||||||||||||
| 342 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||
| 344 | 0 | $size = image_size(\$buffer); | |||||||||||||||||||||||||||||||||
| 345 | 0 | $link = $self->add_file | |||||||||||||||||||||||||||||||||
| 346 | ( | ||||||||||||||||||||||||||||||||||
| 347 | $buffer, | ||||||||||||||||||||||||||||||||||
| 348 | string => TRUE, | ||||||||||||||||||||||||||||||||||
| 349 | path => $path, | ||||||||||||||||||||||||||||||||||
| 350 | type => $type, | ||||||||||||||||||||||||||||||||||
| 351 | @_ | ||||||||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||||||||
| 353 | 0 | return ($link, $size); | |||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | else | ||||||||||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||||||||
| 357 | 0 | $link = $self->add_file | |||||||||||||||||||||||||||||||||
| 358 | ( | ||||||||||||||||||||||||||||||||||
| 359 | $source, | ||||||||||||||||||||||||||||||||||
| 360 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 361 | path => $path, | ||||||||||||||||||||||||||||||||||
| 362 | type => $type, | ||||||||||||||||||||||||||||||||||
| 363 | @_ | ||||||||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||||||||
| 365 | 0 | return $link; | |||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | sub get_mimetype | ||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_mimetype: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 371 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | unless ($self->{mimetype}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||
| 374 | 0 | $self->{mimetype} = $self->{container}->get_mimetype; | |||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||
| 376 | 0 | return $self->{mimetype}; | |||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||
| 379 | sub set_mimetype | ||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_mimetype: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 381 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||||||||
| 384 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 385 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | 0 | return $self->{container}->set_mimetype(shift); | |||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||
| 390 | sub get_type | ||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 392 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my $mt = $self->get_mimetype or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 394 | 0 | $mt =~ s/.*opendocument\.//; | |||||||||||||||||||||||||||||||||
| 395 | 0 | return $mt; | |||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||
| 398 | sub save | ||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 400 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 402 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 403 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | $opt{pretty} //= ($opt{indent} // lpod->debug); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$opt{"pretty"} //= $opt{"indent"} // "ODF::lpOD::Common"->debug
$opt{"indent"} // "ODF::lpOD::Common"->debug
MC/DC0%0/3
$opt{"pretty"} //= $opt{"indent"} // "ODF::lpOD::Common"->debug
$opt{"pretty"}
$opt{"indent"}
"ODF::lpOD::Common"->debug
Truth table0%0/4
A //= B // C
A= $opt{"pretty"}B= $opt{"indent"}C= "ODF::lpOD::Common"->debug
| |||||||||||||||||||||||||||||||||||
| 405 | 0 | my $pretty = $opt{pretty}; | |||||||||||||||||||||||||||||||||
| 406 | 0 | delete @opt{qw(pretty indent)}; | |||||||||||||||||||||||||||||||||
| 407 | 0 | foreach my $part_name ($self->loaded_xmlparts) | |||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||
| 409 | 0 | ▶ | next unless $part_name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | my $part = $self->{$part_name} or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $part->store(pretty => $pretty) if is_true($part->{update}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||
| 413 | 0 | return $container->save(%opt); | |||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||
| 416 | #--- required insertion context retrieval ------------------------------------ | ||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||
| 418 | sub get_required_context | ||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_required_context: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 420 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 421 | 0 | my $elt = shift; | |||||||||||||||||||||||||||||||||
| 422 | 0 | my ($part_name, $path) = $elt->context_path; | |||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if ($part_name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | $path ||= '/'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$path ||= "/"
MC/DC0%0/1
$path ||= "/"
$path
Truth table0%0/2
A
A= $path
| |||||||||||||||||||||||||||||||||||
| 426 | 0 | return $self->get_element($part_name, $path); | |||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||
| 428 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | #--- context import & replacement -------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | sub substitute_context | ||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_context: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 435 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 436 | 0 | my $doc = shift; | |||||||||||||||||||||||||||||||||
| 437 | 0 | my $part = shift; | |||||||||||||||||||||||||||||||||
| 438 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | my $origin = $doc->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 440 | or return undef; | ||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | my $destination = $self->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 442 | or return undef; | ||||||||||||||||||||||||||||||||||
| 443 | 0 | return $destination->substitute_children($origin); | |||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||
| 446 | #--- direct element retrieval ------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||
| 448 | sub get_element | ||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 450 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 451 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 452 | 0 | my $part = $self->get_part($part_name); | |||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | unless ($part) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||
| 455 | 0 | alert "Unknown or not available document part"; | |||||||||||||||||||||||||||||||||
| 456 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||
| 458 | 0 | return $part->get_element(@_); | |||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||
| 461 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 463 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 464 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 465 | 0 | my $part = $self->get_part($part_name); | |||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | unless ($part) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||
| 468 | 0 | alert "Unknown or not available document part"; | |||||||||||||||||||||||||||||||||
| 469 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||
| 471 | 0 | return $part->get_elements(@_); | |||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||
| 474 | sub get_headings | ||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_headings: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 476 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 477 | 0 | return $self->get_part(CONTENT)->get_headings(@_); | |||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||
| 480 | sub get_changes | ||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_changes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 482 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my $part = $self->get_part(CONTENT) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 484 | 0 | return $part->get_changes(@_); | |||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||
| 487 | sub get_change | ||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_change: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 489 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | my $part = $self->get_part(CONTENT) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 491 | 0 | return $part->get_change(@_); | |||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||
| 494 | #--- style handling ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||
| 496 | sub get_default_style | ||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_default_style: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 498 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 499 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 500 | 0 | $family =~ s/ /-/g; | |||||||||||||||||||||||||||||||||
| 501 | 0 | my $xp = '//style:default-style[@style:family="' . | |||||||||||||||||||||||||||||||||
| 502 | $family . '"]'; | ||||||||||||||||||||||||||||||||||
| 503 | 0 | return $self->get_element(STYLES, $xp); | |||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||
| 506 | sub get_outline_style | ||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_outline_style: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 508 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 509 | 0 | my $xp = '//text:outline-style'; | |||||||||||||||||||||||||||||||||
| 510 | 0 | return $self->get_element(STYLES, $xp); | |||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||
| 513 | sub get_style | ||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_style: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 515 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 516 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | unless ($family) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 518 | { | ||||||||||||||||||||||||||||||||||
| 519 | 0 | alert "Missing style family"; return undef; | |||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||
| 521 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 522 | 0 | $family =~ s/ /-/g; | |||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 524 | { | ||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if ($family eq 'outline') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 526 | { | ||||||||||||||||||||||||||||||||||
| 527 | 0 | return $self->get_outline_style; | |||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||
| 529 | else | ||||||||||||||||||||||||||||||||||
| 530 | { | ||||||||||||||||||||||||||||||||||
| 531 | 0 | return $self->get_default_style($family); | |||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||
| 534 | 0 | my $style; my $xp; | |||||||||||||||||||||||||||||||||
| 535 | 0 | my $f = $family; $f =~ s/[ _]/-/g; | |||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ($family eq 'list') | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 537 | { | ||||||||||||||||||||||||||||||||||
| 538 | 0 | $xp = '//text:list-style[@style:name="' . | |||||||||||||||||||||||||||||||||
| 539 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||
| 541 | elsif ($family =~ /(master|page-layout)/) | ||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||
| 543 | 0 | $xp = '//style:' . $f . '[@style:name="' . | |||||||||||||||||||||||||||||||||
| 544 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||
| 546 | elsif ($family eq 'data') | ||||||||||||||||||||||||||||||||||
| 547 | { | ||||||||||||||||||||||||||||||||||
| 548 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||
| 549 | 0 | $xp = '//number:' . $name . '-style' . | |||||||||||||||||||||||||||||||||
| 550 | '[@style:name="' . $n . '"]'; | ||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||
| 552 | elsif ($family eq 'gradient') | ||||||||||||||||||||||||||||||||||
| 553 | { | ||||||||||||||||||||||||||||||||||
| 554 | 0 | $xp = '//draw:gradient[@draw:name="' . | |||||||||||||||||||||||||||||||||
| 555 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||
| 557 | else | ||||||||||||||||||||||||||||||||||
| 558 | { | ||||||||||||||||||||||||||||||||||
| 559 | 0 | $xp = '//style:style[@style:name="' . | |||||||||||||||||||||||||||||||||
| 560 | $name . | ||||||||||||||||||||||||||||||||||
| 561 | '"][@style:family="' . | ||||||||||||||||||||||||||||||||||
| 562 | $f . | ||||||||||||||||||||||||||||||||||
| 563 | '"]'; | ||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||
| 565 | return | ||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | $self->get_element(STYLES, $xp) | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_element("styles.xml", $xp) // $self->get_element("content.xml", $xp)
MC/DC0%0/2
$self->get_element("styles.xml", $xp) // $self->get_element("content.xml", $xp)
$self->get_element("styles.xml", $xp)
$self->get_element("content.xml", $xp)
Truth table0%0/3
A // B
A= $self->get_element("styles.xml", $xp)B= $self->get_element("content.xml", $xp)
| |||||||||||||||||||||||||||||||||||
| 567 | // | ||||||||||||||||||||||||||||||||||
| 568 | $self->get_element(CONTENT, $xp); | ||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||
| 571 | sub get_styles | ||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_styles: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 573 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 574 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | unless ($family) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||
| 577 | 0 | alert "Missing style family"; return undef; | |||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if (ODF::lpOD::DataStyle->is_numeric_family($family)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 580 | { | ||||||||||||||||||||||||||||||||||
| 581 | 0 | return $self->get_data_styles($family, @_); | |||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||
| 583 | 0 | my $xp; | |||||||||||||||||||||||||||||||||
| 584 | 0 | my $f = $family; $f =~ s/[ _]/-/g; | |||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | if ($family eq 'list') | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 586 | { | ||||||||||||||||||||||||||||||||||
| 587 | 0 | $xp = '//text:list-style'; | |||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||
| 589 | ▶ | elsif ($family eq 'master' || $family eq 'page layout') | |||||||||||||||||||||||||||||||||
|
Condition0%0/3
$family eq "master" or $family eq "page layout"
MC/DC0%0/2
$family eq "master" or $family eq "page layout"
$family eq "master"
$family eq "page layout"
Truth table0%0/3
A or B
A= $family eq "master"B= $family eq "page layout"
| |||||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||||
| 591 | 0 | $xp = '//style:' . $f; | |||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||
| 593 | elsif ($family eq 'gradient') | ||||||||||||||||||||||||||||||||||
| 594 | { | ||||||||||||||||||||||||||||||||||
| 595 | 0 | $xp = '//draw:gradient'; | |||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||
| 597 | else | ||||||||||||||||||||||||||||||||||
| 598 | { | ||||||||||||||||||||||||||||||||||
| 599 | 0 | $xp = '//style:style[@style:family="' . $f . '"]'; | |||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||
| 602 | return ( | ||||||||||||||||||||||||||||||||||
| 603 | 0 | $self->get_elements(STYLES, $xp), | |||||||||||||||||||||||||||||||||
| 604 | $self->get_elements(CONTENT, $xp) | ||||||||||||||||||||||||||||||||||
| 605 | ); | ||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||
| 608 | sub get_data_styles | ||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_data_styles: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 610 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 611 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | my $filter = $family ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 613 | 'number:' . $family . '-style' : | ||||||||||||||||||||||||||||||||||
| 614 | qr'number:.*-style'; | ||||||||||||||||||||||||||||||||||
| 615 | 0 | my @ns = (); | |||||||||||||||||||||||||||||||||
| 616 | 0 | foreach my $part (STYLES, CONTENT) | |||||||||||||||||||||||||||||||||
| 617 | { | ||||||||||||||||||||||||||||||||||
| 618 | 0 | my $r = $self->get_part($part)->get_root; | |||||||||||||||||||||||||||||||||
| 619 | push @ns, $_->get_descendants($filter) | ||||||||||||||||||||||||||||||||||
| 620 | 0 | for $r->get_elements(qr'office:(automatic-|)styles'); | |||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||
| 622 | 0 | return @ns; | |||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||
| 625 | sub get_data_style | ||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_data_style: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 627 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 628 | 0 | my ($family, $name) = @_; | |||||||||||||||||||||||||||||||||
| 629 | 0 | my $xp = "//number:$family-style"; | |||||||||||||||||||||||||||||||||
| 630 | 0 | $xp .= '[@style:name="' . $name . '"]'; | |||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | return $self->get_element(STYLES, $xp) | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_element("styles.xml", $xp) // $self->get_element("content.xml", $xp)
MC/DC0%0/2
$self->get_element("styles.xml", $xp) // $self->get_element("content.xml", $xp)
$self->get_element("styles.xml", $xp)
$self->get_element("content.xml", $xp)
Truth table0%0/3
A // B
A= $self->get_element("styles.xml", $xp)B= $self->get_element("content.xml", $xp)
| |||||||||||||||||||||||||||||||||||
| 632 | // | ||||||||||||||||||||||||||||||||||
| 633 | $self->get_element(CONTENT, $xp); | ||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||
| 636 | sub check_stylename | ||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
check_stylename: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 638 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 639 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | my $name = shift || $style->get_name; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $style->get_name
MC/DC0%0/2
shift() || $style->get_name
shift()
$style->get_name
Truth table0%0/3
A || B
A= shift()B= $style->get_name
| |||||||||||||||||||||||||||||||||||
| 641 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | unless ($name && $family) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $family
MC/DC0%0/2
$name and $family
$name
$family
Truth table0%0/3
A and B
A= $nameB= $family
| |||||||||||||||||||||||||||||||||||
| 643 | { | ||||||||||||||||||||||||||||||||||
| 644 | 0 | alert "Missing style name and/or family"; | |||||||||||||||||||||||||||||||||
| 645 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | if ($self->get_style($family, $name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 648 | { | ||||||||||||||||||||||||||||||||||
| 649 | 0 | alert "Non unique style"; | |||||||||||||||||||||||||||||||||
| 650 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||
| 652 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||
| 655 | sub select_style_context | ||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
select_style_context: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 657 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 658 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 659 | 0 | my $context = $self->get_required_context($style); | |||||||||||||||||||||||||||||||||
| 660 | 0 | ▶ | return $context if $context; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 661 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 662 | 0 | my $xp; | |||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | my $part_name = is_true($opt{default}) ? STYLES : $opt{part}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 664 | 0 | ▶ | if (is_true($opt{default}) || defined_false($opt{automatic})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
is_true($opt{"default"}) or defined_false($opt{"automatic"})
MC/DC0%0/2
is_true($opt{"default"}) or defined_false($opt{"automatic"})
is_true($opt{"default"})
defined_false($opt{"automatic"})
Truth table0%0/3
A or B
A= is_true($opt{"default"})B= defined_false($opt{"automatic"})
| |||||||||||||||||||||||||||||||||||
| 665 | { | ||||||||||||||||||||||||||||||||||
| 666 | 0 | $part_name = STYLES; delete $opt{automatic}; | |||||||||||||||||||||||||||||||||
| 667 | 0 | $xp = '//office:styles'; | |||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||
| 669 | else | ||||||||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||||||||
| 671 | 0 | $part_name = $opt{part}; | |||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if (is_true($opt{automatic})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 673 | { | ||||||||||||||||||||||||||||||||||
| 674 | 0 | $xp = '//office:automatic-styles'; | |||||||||||||||||||||||||||||||||
| 675 | 0 | ▶ | $part_name ||= CONTENT; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$part_name ||= "content.xml"
MC/DC0%0/1
$part_name ||= "content.xml"
$part_name
Truth table0%0/2
A
A= $part_name
| |||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||
| 677 | else | ||||||||||||||||||||||||||||||||||
| 678 | { | ||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | if (!defined $part_name) | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 680 | { | ||||||||||||||||||||||||||||||||||
| 681 | 0 | $part_name = STYLES; | |||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | $xp = is_true($opt{automatic}) ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 683 | '//office:automatic-styles' : | ||||||||||||||||||||||||||||||||||
| 684 | '//office:styles'; | ||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||
| 686 | elsif ($part_name eq STYLES) | ||||||||||||||||||||||||||||||||||
| 687 | { | ||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | $xp = is_true($opt{automatic}) ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 689 | '//office:automatic-styles' : | ||||||||||||||||||||||||||||||||||
| 690 | '//office:styles'; | ||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||
| 692 | elsif ($part_name eq CONTENT) | ||||||||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||||||||
| 694 | 0 | $xp = '//office:automatic-styles'; | |||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||
| 698 | 0 | $context = $self->get_element($part_name, $xp); | |||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 700 | { | ||||||||||||||||||||||||||||||||||
| 701 | 0 | alert "Wrong document structure; style insertion failure"; | |||||||||||||||||||||||||||||||||
| 702 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||
| 704 | 0 | return $context; | |||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||
| 707 | sub insert_regular_style | ||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_regular_style: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 709 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 710 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 711 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | my $context = $self->select_style_context($style, %opt) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 713 | or return undef; | ||||||||||||||||||||||||||||||||||
| 714 | 0 | ▶ | if (is_true($opt{default})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 715 | { | ||||||||||||||||||||||||||||||||||
| 716 | 0 | $style->check_tag('style:default-style'); | |||||||||||||||||||||||||||||||||
| 717 | 0 | $style->set_name(undef); | |||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||
| 719 | else | ||||||||||||||||||||||||||||||||||
| 720 | { | ||||||||||||||||||||||||||||||||||
| 721 | 0 | ▶ | my $name = $opt{name} || $style->get_name; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{'name'} || $style->get_name
MC/DC0%0/2
$opt{'name'} || $style->get_name
$opt{'name'}
$style->get_name
Truth table0%0/3
A || B
A= $opt{'name'}B= $style->get_name
| |||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | return undef unless $self->check_stylename($style, $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 723 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 724 | 0 | $style->set_name($name); | |||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||
| 726 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||
| 729 | sub insert_special_style | ||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_special_style: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 731 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 732 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 733 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | my $context = $self->select_style_context($style, %opt) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 735 | or return undef; | ||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | my $name = $opt{name} || $style->get_name; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{'name'} || $style->get_name
MC/DC0%0/2
$opt{'name'} || $style->get_name
$opt{'name'}
$style->get_name
Truth table0%0/3
A || B
A= $opt{'name'}B= $style->get_name
| |||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | return undef unless $self->check_stylename($style, $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 738 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 739 | 0 | $style->set_name($name); | |||||||||||||||||||||||||||||||||
| 740 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||
| 743 | sub insert_outline_style | ||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_outline_style: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 745 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 746 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | my $context = $self->select_style_context($style) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | my $old = $self->get_style('outline'); $old && $old->delete; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 749 | 0 | $style->set_name(undef); | |||||||||||||||||||||||||||||||||
| 750 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 751 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||
| 754 | sub insert_default_style | ||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_default_style: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 756 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 757 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 758 | 0 | my $context = $self->get_element(STYLES, '//office:styles'); | |||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 760 | { | ||||||||||||||||||||||||||||||||||
| 761 | 0 | alert "Default style context not available"; | |||||||||||||||||||||||||||||||||
| 762 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||
| 764 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | my $ds = $style->make_default or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 766 | 0 | my $old = $self->get_style($family); | |||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | $old->delete() if $old; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 768 | 0 | return $context->insert_element($ds); | |||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||
| 771 | sub insert_style | ||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_style: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 773 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 774 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 775 | 0 | my $class = ref $style; | |||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | if ($class) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 777 | { | ||||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | if ($class eq 'ARRAY') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 779 | { | ||||||||||||||||||||||||||||||||||
| 780 | 0 | $style = ODF::lpOD::Style->create(@$style); | |||||||||||||||||||||||||||||||||
| 781 | 0 | $class = ref $style; | |||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | unless ($class && $style->isa('ODF::lpOD::Style')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class and $style->isa("ODF::lpOD::Style")
MC/DC0%0/2
$class and $style->isa("ODF::lpOD::Style")
$class
$style->isa("ODF::lpOD::Style")
Truth table0%0/3
A and B
A= $classB= $style->isa("ODF::lpOD::Style")
| |||||||||||||||||||||||||||||||||||
| 785 | { | ||||||||||||||||||||||||||||||||||
| 786 | 0 | alert "Missing or wrong style element"; | |||||||||||||||||||||||||||||||||
| 787 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||
| 789 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 790 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if (is_true($opt{default})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||||||||
| 793 | 0 | return $self->insert_default_style($style, $family); | |||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | if ($family =~ /^(text|paragraph|graphic|gradient|drawing page|number|currency|date)$/) | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 796 | { | ||||||||||||||||||||||||||||||||||
| 797 | 0 | return $self->insert_regular_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||
| 799 | elsif ($family =~ /(list|master|page layout)/) | ||||||||||||||||||||||||||||||||||
| 800 | { | ||||||||||||||||||||||||||||||||||
| 801 | 0 | return $self->insert_special_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||
| 803 | elsif ($family eq 'outline') | ||||||||||||||||||||||||||||||||||
| 804 | { | ||||||||||||||||||||||||||||||||||
| 805 | 0 | return $self->insert_outline_style($style); | |||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||
| 807 | elsif ($family =~ /^table/) | ||||||||||||||||||||||||||||||||||
| 808 | { | ||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | $opt{automatic} = TRUE unless exists $opt{automatic}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | $opt{part} = CONTENT unless $opt{part}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 811 | 0 | return $self->insert_special_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||
| 813 | else | ||||||||||||||||||||||||||||||||||
| 814 | { | ||||||||||||||||||||||||||||||||||
| 815 | 0 | alert "Not supported"; return undef; | |||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||
| 819 | #--- bulk style replacement by import from another document ------------------ | ||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||
| 821 | sub substitute_styles | ||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_styles: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 823 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 824 | 0 | my $from = shift; | |||||||||||||||||||||||||||||||||
| 825 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 826 | ( | ||||||||||||||||||||||||||||||||||
| 827 | common => TRUE, | ||||||||||||||||||||||||||||||||||
| 828 | master => TRUE, | ||||||||||||||||||||||||||||||||||
| 829 | automatic => TRUE, | ||||||||||||||||||||||||||||||||||
| 830 | fonts => TRUE, | ||||||||||||||||||||||||||||||||||
| 831 | @_ | ||||||||||||||||||||||||||||||||||
| 832 | ); | ||||||||||||||||||||||||||||||||||
| 833 | 0 | my $source; | |||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | if (ref $from) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 835 | { | ||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | $source = $from if $from->isa('ODF::lpOD::Document'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||
| 838 | else | ||||||||||||||||||||||||||||||||||
| 839 | { | ||||||||||||||||||||||||||||||||||
| 840 | 0 | $source = ODF::lpOD::Document->new(template => $from); | |||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | unless ($source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 843 | { | ||||||||||||||||||||||||||||||||||
| 844 | 0 | alert "Malformed or not available source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||||||||
| 847 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 848 | 0 | foreach my $part ($self->get_part(CONTENT), $self->get_part(STYLES)) | |||||||||||||||||||||||||||||||||
| 849 | { | ||||||||||||||||||||||||||||||||||
| 850 | 0 | $count += $part->substitute_styles($source, %opt); | |||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | $source->forget unless ref $from; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 854 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||
| 857 | #--- document variable handling ---------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||
| 859 | sub get_user_variables | ||||||||||||||||||||||||||||||||||
| 860 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_variables: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 861 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 862 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | my $context = $opt{context} // $self->get_body; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{"context"} // $self->get_body
MC/DC0%0/2
$opt{"context"} // $self->get_body
$opt{"context"}
$self->get_body
Truth table0%0/3
A // B
A= $opt{"context"}B= $self->get_body
| |||||||||||||||||||||||||||||||||||
| 864 | 0 | return $context->get_elements('text:user-field-decl'); | |||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||
| 867 | sub get_simple_variables | ||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_simple_variables: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 869 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 870 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | my $context = $opt{context} // $self->get_body; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{"context"} // $self->get_body
MC/DC0%0/2
$opt{"context"} // $self->get_body
$opt{"context"}
$self->get_body
Truth table0%0/3
A // B
A= $opt{"context"}B= $self->get_body
| |||||||||||||||||||||||||||||||||||
| 872 | 0 | return $context->get_elements('text:variable-decl'); | |||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||
| 875 | sub get_variables | ||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_variables: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 877 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 878 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if (!defined $opt{class}) | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 880 | { | ||||||||||||||||||||||||||||||||||
| 881 | return ( | ||||||||||||||||||||||||||||||||||
| 882 | 0 | $self->get_user_variables(@_), | |||||||||||||||||||||||||||||||||
| 883 | $self->get_simple_variables(@_) | ||||||||||||||||||||||||||||||||||
| 884 | ); | ||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||
| 886 | elsif ($opt{class} eq 'user') | ||||||||||||||||||||||||||||||||||
| 887 | { | ||||||||||||||||||||||||||||||||||
| 888 | 0 | return $self->get_user_variables; | |||||||||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||||||||
| 890 | elsif ($opt{class} eq 'simple') | ||||||||||||||||||||||||||||||||||
| 891 | { | ||||||||||||||||||||||||||||||||||
| 892 | 0 | return $self->get_simple_variables; | |||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||
| 894 | else | ||||||||||||||||||||||||||||||||||
| 895 | { | ||||||||||||||||||||||||||||||||||
| 896 | 0 | alert "Unknown variable class $opt{class}"; | |||||||||||||||||||||||||||||||||
| 897 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||
| 901 | sub get_variable | ||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_variable: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 903 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 904 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 905 | 0 | my %opt = ( class => 'user', @_ ); | |||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | my $context = $opt{context} // $self->get_body; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{"context"} // $self->get_body
MC/DC0%0/2
$opt{"context"} // $self->get_body
$opt{"context"}
$self->get_body
Truth table0%0/3
A // B
A= $opt{"context"}B= $self->get_body
| |||||||||||||||||||||||||||||||||||
| 907 | 0 | my $tag; | |||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | if (!defined $opt{class}) | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 909 | { | ||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | return $self->get_variable($name, class => 'user') | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_variable($name, 'class', 'user') || $self->get_variable($name, 'class', 'simple')
MC/DC0%0/2
$self->get_variable($name, 'class', 'user') || $self->get_variable($name, 'class', 'simple')
$self->get_variable($name, 'class', 'user')
$self->get_variable($name, 'class', 'simple')
Truth table0%0/3
A || B
A= $self->get_variable($name, 'class', 'user')B= $self->get_variable($name, 'class', 'simple')
| |||||||||||||||||||||||||||||||||||
| 911 | || | ||||||||||||||||||||||||||||||||||
| 912 | $self->get_variable($name, class => 'simple'); | ||||||||||||||||||||||||||||||||||
| 913 | } | ||||||||||||||||||||||||||||||||||
| 914 | elsif ($opt{class} eq 'user') | ||||||||||||||||||||||||||||||||||
| 915 | { | ||||||||||||||||||||||||||||||||||
| 916 | 0 | $tag = 'text:user-field-decl'; | |||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||
| 918 | elsif ($opt{class} eq 'simple') | ||||||||||||||||||||||||||||||||||
| 919 | { | ||||||||||||||||||||||||||||||||||
| 920 | 0 | $tag = 'text:variable-decl'; | |||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||
| 922 | else | ||||||||||||||||||||||||||||||||||
| 923 | { | ||||||||||||||||||||||||||||||||||
| 924 | 0 | alert "Wrong variable class"; return undef; | |||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||
| 927 | 0 | return $context->get_element | |||||||||||||||||||||||||||||||||
| 928 | ($tag, attribute => 'name', value => $name); | ||||||||||||||||||||||||||||||||||
| 929 | } | ||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||
| 931 | sub set_variable | ||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_variable: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 933 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 934 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 935 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 936 | { | ||||||||||||||||||||||||||||||||||
| 937 | 0 | alert "Missing variable name"; return FALSE; | |||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | if ($self->get_variable($name, class => undef)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 940 | { | ||||||||||||||||||||||||||||||||||
| 941 | 0 | alert "Variable $name already exists"; return FALSE; | |||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||
| 943 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 944 | ( | ||||||||||||||||||||||||||||||||||
| 945 | name => $name, | ||||||||||||||||||||||||||||||||||
| 946 | class => 'user', | ||||||||||||||||||||||||||||||||||
| 947 | type => 'string', | ||||||||||||||||||||||||||||||||||
| 948 | @_ | ||||||||||||||||||||||||||||||||||
| 949 | ); | ||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||
| 951 | 0 | my $class = $opt{class}; | |||||||||||||||||||||||||||||||||
| 952 | 0 | my $context = $opt{context}; | |||||||||||||||||||||||||||||||||
| 953 | 0 | delete @opt{qw(class context)}; | |||||||||||||||||||||||||||||||||
| 954 | 0 | my $var; | |||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | if ($class eq 'user') | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 956 | { | ||||||||||||||||||||||||||||||||||
| 957 | 0 | $var = ODF::lpOD::UserVariable->create(%opt); | |||||||||||||||||||||||||||||||||
| 958 | } | ||||||||||||||||||||||||||||||||||
| 959 | elsif ($class eq 'simple') | ||||||||||||||||||||||||||||||||||
| 960 | { | ||||||||||||||||||||||||||||||||||
| 961 | 0 | $var = ODF::lpOD::SimpleVariable->create(%opt); | |||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||
| 963 | else | ||||||||||||||||||||||||||||||||||
| 964 | { | ||||||||||||||||||||||||||||||||||
| 965 | 0 | alert "Unsupported variable class"; | |||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | if ($var) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 968 | { | ||||||||||||||||||||||||||||||||||
| 969 | 0 | my $tag = $var->context_tag; | |||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | $context //= $self->get_body->set_first_child($tag); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$context //= $self->get_body->set_first_child($tag)
MC/DC0%0/2
$context //= $self->get_body->set_first_child($tag)
$context
$self->get_body->set_first_child($tag)
Truth table0%0/3
A //= B
A= $contextB= $self->get_body->set_first_child($tag)
| |||||||||||||||||||||||||||||||||||
| 971 | 0 | ▶ | if ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 972 | { | ||||||||||||||||||||||||||||||||||
| 973 | 0 | $context->append_element($var); | |||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||
| 975 | else | ||||||||||||||||||||||||||||||||||
| 976 | { | ||||||||||||||||||||||||||||||||||
| 977 | 0 | alert "Unknown object insertion context"; | |||||||||||||||||||||||||||||||||
| 978 | 0 | $var->delete; $var = undef; | |||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||
| 981 | 0 | return $var; | |||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||
| 984 | #--- table of content handling ----------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||
| 986 | sub get_tocs | ||||||||||||||||||||||||||||||||||
| 987 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tocs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 988 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 989 | 0 | return $self->get_part(CONTENT)->get_tocs(@_); | |||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||
| 992 | sub get_toc | ||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_toc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 994 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 995 | 0 | return $self->get_part(CONTENT)->get_toc(@_); | |||||||||||||||||||||||||||||||||
| 996 | } | ||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||
| 998 | #--- named range handling ---------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||
| 1000 | sub get_named_range | ||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_named_range: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1003 | 0 | return $self->get_part(CONTENT)->get_named_range(@_); | |||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||
| 1006 | sub set_named_range | ||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_named_range: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1008 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1009 | 0 | return $self->get_part(CONTENT)->set_named_range(@_); | |||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||
| 1012 | #--- font declaration -------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||
| 1014 | sub set_font_declaration | ||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_font_declaration: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1016 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1017 | return ( | ||||||||||||||||||||||||||||||||||
| 1018 | 0 | $self->get_part(CONTENT)->set_font_declaration(@_), | |||||||||||||||||||||||||||||||||
| 1019 | $self->get_part(STYLES)->set_font_declaration(@_) | ||||||||||||||||||||||||||||||||||
| 1020 | ); | ||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||
| 1023 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1024 | package ODF::lpOD::Container; | ||||||||||||||||||||||||||||||||||
| 1025 | 2 | our $VERSION = '1.004'; | |||||||||||||||||||||||||||||||||
| 1026 | 2 | ▶ | use constant PACKAGE_DATE => '2012-02-19T19:08:31'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1027 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1028 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1029 | 2 | ▶ | use Archive::Zip 1.30 qw ( :DEFAULT :CONSTANTS :ERROR_CODES ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1030 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||
| 1032 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1033 | 2 | *forget = *DESTROY; | |||||||||||||||||||||||||||||||||
| 1034 | 2 | *get_parts = *parts; | |||||||||||||||||||||||||||||||||
| 1035 | 2 | *add_part = *add_file; | |||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||
| 1038 | #=== parameters ============================================================== | ||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||
| 1040 | 2 | our %ODF_PARTS = | |||||||||||||||||||||||||||||||||
| 1041 | ( | ||||||||||||||||||||||||||||||||||
| 1042 | content => CONTENT, | ||||||||||||||||||||||||||||||||||
| 1043 | styles => STYLES, | ||||||||||||||||||||||||||||||||||
| 1044 | meta => META, | ||||||||||||||||||||||||||||||||||
| 1045 | manifest => MANIFEST, | ||||||||||||||||||||||||||||||||||
| 1046 | settings => SETTINGS, | ||||||||||||||||||||||||||||||||||
| 1047 | mimetype => MIMETYPE | ||||||||||||||||||||||||||||||||||
| 1048 | ); | ||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||
| 1050 | 2 | our %PARTS_ODF = reverse %ODF_PARTS; | |||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||
| 1052 | sub translate_part_name | ||||||||||||||||||||||||||||||||||
| 1053 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
translate_part_name: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1054 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1055 | 0 | ▶ | return $ODF_PARTS{$name} ? $ODF_PARTS{$name} : $name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||
| 1058 | 2 | our %COMPRESSION = # compression rule for some parts | |||||||||||||||||||||||||||||||||
| 1059 | ( | ||||||||||||||||||||||||||||||||||
| 1060 | MIMETYPE => FALSE, | ||||||||||||||||||||||||||||||||||
| 1061 | META => FALSE, | ||||||||||||||||||||||||||||||||||
| 1062 | CONTENT => TRUE, | ||||||||||||||||||||||||||||||||||
| 1063 | STYLES => TRUE, | ||||||||||||||||||||||||||||||||||
| 1064 | MANIFEST => TRUE, | ||||||||||||||||||||||||||||||||||
| 1065 | SETTINGS => TRUE | ||||||||||||||||||||||||||||||||||
| 1066 | ); | ||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||
| 1068 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||
| 1070 | sub get_from_uri | ||||||||||||||||||||||||||||||||||
| 1071 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_from_uri: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1072 | 0 | return ODF::lpOD::Container->new(uri => shift); | |||||||||||||||||||||||||||||||||
| 1073 | } | ||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||
| 1075 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||
| 1077 | sub create_from_template | ||||||||||||||||||||||||||||||||||
| 1078 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
create_from_template: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1079 | 0 | return ODF::lpOD::Container->new(template => shift); | |||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||
| 1082 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||
| 1084 | sub create | ||||||||||||||||||||||||||||||||||
| 1085 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1086 | 0 | return ODF::lpOD::Container->new(type => shift); | |||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||
| 1089 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||
| 1091 | sub new | ||||||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 1093 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 1094 | 0 | my $self = | |||||||||||||||||||||||||||||||||
| 1095 | { | ||||||||||||||||||||||||||||||||||
| 1096 | type => undef, | ||||||||||||||||||||||||||||||||||
| 1097 | uri => undef, | ||||||||||||||||||||||||||||||||||
| 1098 | read_only => undef, | ||||||||||||||||||||||||||||||||||
| 1099 | zip => undef, | ||||||||||||||||||||||||||||||||||
| 1100 | deleted => [], | ||||||||||||||||||||||||||||||||||
| 1101 | stored => {}, | ||||||||||||||||||||||||||||||||||
| 1102 | @_ | ||||||||||||||||||||||||||||||||||
| 1103 | }; | ||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||
| 1105 | 0 | ▶ | if ($self->{type}) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 1106 | { | ||||||||||||||||||||||||||||||||||
| 1107 | $self->{uri} = ODF::lpOD::Common::template($self->{type}) | ||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1109 | 0 | $self->{read_only} = TRUE; | |||||||||||||||||||||||||||||||||
| 1110 | 0 | $self->{create} = TRUE; | |||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||
| 1112 | elsif ($self->{template}) | ||||||||||||||||||||||||||||||||||
| 1113 | { | ||||||||||||||||||||||||||||||||||
| 1114 | 0 | $self->{uri} = $self->{template}; | |||||||||||||||||||||||||||||||||
| 1115 | 0 | $self->{read_only} = TRUE; | |||||||||||||||||||||||||||||||||
| 1116 | 0 | $self->{create} = FALSE; | |||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||
| 1118 | else | ||||||||||||||||||||||||||||||||||
| 1119 | { | ||||||||||||||||||||||||||||||||||
| 1120 | 0 | $self->{create} = FALSE; | |||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||
| 1123 | 0 | my $source = $self->{uri}; | |||||||||||||||||||||||||||||||||
| 1124 | my $zip = defined $self->{zip} ? | ||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | $self->{zip} : Archive::Zip->new; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||
| 1127 | 0 | ▶ | if (UNIVERSAL::isa($source, 'IO::File')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1128 | { | ||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | if ($zip->readFromFileHandle($source) != AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1130 | { | ||||||||||||||||||||||||||||||||||
| 1131 | 0 | alert("Handle read error"); | |||||||||||||||||||||||||||||||||
| 1132 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||||||||
| 1135 | else | ||||||||||||||||||||||||||||||||||
| 1136 | { | ||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | unless (-r -f -e $source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1138 | { | ||||||||||||||||||||||||||||||||||
| 1139 | 0 | alert("Missing source"); | |||||||||||||||||||||||||||||||||
| 1140 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||
| 1142 | 0 | ▶ | if ($zip->read($source) != AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1143 | { | ||||||||||||||||||||||||||||||||||
| 1144 | 0 | alert("File read error"); | |||||||||||||||||||||||||||||||||
| 1145 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||
| 1149 | 0 | $self->{zip} = $zip; | |||||||||||||||||||||||||||||||||
| 1150 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 1151 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||||
| 1154 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||||||||
| 1156 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 1157 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1158 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1159 | 0 | undef $self->{zip}; | |||||||||||||||||||||||||||||||||
| 1160 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||
| 1163 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||
| 1165 | sub get_mimetype | ||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_mimetype: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1167 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1168 | 0 | return $self->get_part(MIMETYPE); | |||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||
| 1171 | sub set_mimetype | ||||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_mimetype: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1173 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1174 | 0 | return $self->set_part( | |||||||||||||||||||||||||||||||||
| 1175 | MIMETYPE, shift, compress => FALSE, string => TRUE | ||||||||||||||||||||||||||||||||||
| 1176 | ); | ||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||
| 1179 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||
| 1181 | sub parts | ||||||||||||||||||||||||||||||||||
| 1182 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
parts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1183 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1184 | 0 | return $self->{zip}->memberNames; | |||||||||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||
| 1187 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||
| 1189 | sub contains | ||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
contains: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1191 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | my $part_name = shift or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | return (grep $_ eq $part_name, $self->parts) ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1194 | } | ||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||
| 1196 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||
| 1198 | sub raw_set_part | ||||||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
raw_set_part: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 1200 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1201 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||||||||
| 1203 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||
| 1204 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1205 | ( | ||||||||||||||||||||||||||||||||||
| 1206 | string => TRUE, | ||||||||||||||||||||||||||||||||||
| 1207 | compress => undef, | ||||||||||||||||||||||||||||||||||
| 1208 | compression_method => COMPRESSION_DEFLATED, | ||||||||||||||||||||||||||||||||||
| 1209 | compression_level => COMPRESSION_LEVEL_BEST_COMPRESSION, | ||||||||||||||||||||||||||||||||||
| 1210 | @_ | ||||||||||||||||||||||||||||||||||
| 1211 | ); | ||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||
| 1213 | 0 | ▶ | my $compress = $opt{compress} // $COMPRESSION{$part_name} // FALSE; | ||||||||||||||||||||||||||||||||
|
Condition0%0/5
($opt{"compress"} // $ODF::lpOD::Container::COMPRESSION{$part_name}) // 0
$opt{"compress"} // $ODF::lpOD::Container::COMPRESSION{$part_name}
MC/DC0%0/2
($opt{"compress"} // $ODF::lpOD::Container::COMPRESSION{$part_name}) // 0
$opt{"compress"}
$ODF::lpOD::Container::COMPRESSION{$part_name}
Truth table0%0/3
A // B
A= $opt{"compress"}B= $ODF::lpOD::Container::COMPRESSION{$part_name}
| |||||||||||||||||||||||||||||||||||
| 1214 | 0 | my $zip = $self->{zip}; | |||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | my $buffer = is_true($opt{string}) ? $data : load_file($data, ':raw'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1216 | 0 | my $p = $zip->addString($buffer, $part_name); | |||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||
| 1218 | 0 | ▶ | if ($p) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1219 | { | ||||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | if (is_true($compress)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1221 | { | ||||||||||||||||||||||||||||||||||
| 1222 | 0 | $p->desiredCompressionMethod($opt{compression_method}); | |||||||||||||||||||||||||||||||||
| 1223 | 0 | $p->desiredCompressionLevel($opt{compression_level}); | |||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||
| 1225 | else | ||||||||||||||||||||||||||||||||||
| 1226 | { | ||||||||||||||||||||||||||||||||||
| 1227 | 0 | $p->desiredCompressionMethod(COMPRESSION_STORED); | |||||||||||||||||||||||||||||||||
| 1228 | } | ||||||||||||||||||||||||||||||||||
| 1229 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1230 | } | ||||||||||||||||||||||||||||||||||
| 1231 | else | ||||||||||||||||||||||||||||||||||
| 1232 | { | ||||||||||||||||||||||||||||||||||
| 1233 | 0 | alert("Data storage error"); | |||||||||||||||||||||||||||||||||
| 1234 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1235 | } | ||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||
| 1238 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||
| 1240 | sub raw_del_part | ||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
raw_del_part: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1242 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1243 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1244 | 0 | ▶ | return FALSE unless $self->contains($part_name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||
| 1246 | 0 | my $status = $self->{zip}->removeMember($part_name); | |||||||||||||||||||||||||||||||||
| 1247 | 0 | ▶ | unless ($status) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1248 | { | ||||||||||||||||||||||||||||||||||
| 1249 | 0 | alert("$part_name removal failed"); | |||||||||||||||||||||||||||||||||
| 1250 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||
| 1252 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||
| 1255 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||
| 1257 | sub set_part | ||||||||||||||||||||||||||||||||||
| 1258 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_part: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1259 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | my $part_name = translate_part_name(shift) or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1261 | 0 | ▶ | my $data = shift // ""; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 1262 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1263 | ( | ||||||||||||||||||||||||||||||||||
| 1264 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 1265 | compress => FALSE, | ||||||||||||||||||||||||||||||||||
| 1266 | @_ | ||||||||||||||||||||||||||||||||||
| 1267 | ); | ||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||
| 1269 | 0 | $self->{stored}{$part_name}{data} = $data; | |||||||||||||||||||||||||||||||||
| 1270 | 0 | $self->{stored}{$part_name}{string} = $opt{string}; | |||||||||||||||||||||||||||||||||
| 1271 | 0 | $self->{stored}{$part_name}{compress} = $opt{compress}; | |||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||
| 1273 | 0 | $self->del_part($part_name); | |||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||
| 1275 | 0 | return $part_name; | |||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||
| 1278 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||
| 1280 | sub add_file | ||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
add_file: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1283 | 0 | ▶ | my $path = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1284 | 0 | my $destination = shift; | |||||||||||||||||||||||||||||||||
| 1285 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1286 | ( | ||||||||||||||||||||||||||||||||||
| 1287 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 1288 | @_ | ||||||||||||||||||||||||||||||||||
| 1289 | ); | ||||||||||||||||||||||||||||||||||
| 1290 | 0 | ▶ | unless ($destination) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1291 | { | ||||||||||||||||||||||||||||||||||
| 1292 | 0 | my $mimetype = file_type($path); | |||||||||||||||||||||||||||||||||
| 1293 | 0 | my $filename = file_parse($path); | |||||||||||||||||||||||||||||||||
| 1294 | 0 | ▶ | if ($mimetype && $mimetype =~ /^image/) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mimetype and $mimetype =~ /^image/
MC/DC0%0/2
$mimetype and $mimetype =~ /^image/
$mimetype
$mimetype =~ /^image/
Truth table0%0/3
A and B
A= $mimetypeB= $mimetype =~ /^image/
| |||||||||||||||||||||||||||||||||||
| 1295 | { | ||||||||||||||||||||||||||||||||||
| 1296 | 0 | $destination = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 1297 | 0 | $opt{compress} = FALSE; | |||||||||||||||||||||||||||||||||
| 1298 | } | ||||||||||||||||||||||||||||||||||
| 1299 | else | ||||||||||||||||||||||||||||||||||
| 1300 | { | ||||||||||||||||||||||||||||||||||
| 1301 | 0 | $destination = $filename; | |||||||||||||||||||||||||||||||||
| 1302 | 0 | $opt{compress} = TRUE; | |||||||||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||
| 1305 | 0 | return $self->set_part($destination, $path, %opt); | |||||||||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||
| 1308 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||
| 1310 | sub get_stored_part | ||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_stored_part: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1312 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1313 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1314 | 0 | return $self->{stored}{$part_name}; | |||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||
| 1317 | sub get_part | ||||||||||||||||||||||||||||||||||
| 1318 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_part: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1319 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1320 | 0 | my $part_name = translate_part_name(shift); | |||||||||||||||||||||||||||||||||
| 1321 | 0 | ▶ | unless ($part_name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1322 | { | ||||||||||||||||||||||||||||||||||
| 1323 | 0 | alert "Missing part name"; | |||||||||||||||||||||||||||||||||
| 1324 | 0 | return FALSE | |||||||||||||||||||||||||||||||||
| 1325 | } | ||||||||||||||||||||||||||||||||||
| 1326 | 0 | ▶ | unless ($self->contains($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1327 | { | ||||||||||||||||||||||||||||||||||
| 1328 | 0 | alert("Unknown part $part_name"); | |||||||||||||||||||||||||||||||||
| 1329 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1330 | } | ||||||||||||||||||||||||||||||||||
| 1331 | 0 | my ($result, $status) = $self->{'zip'}->contents($part_name); | |||||||||||||||||||||||||||||||||
| 1332 | 0 | ▶ | return $status == AZ_OK ? $result : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1333 | } | ||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||
| 1335 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||
| 1337 | sub del_part | ||||||||||||||||||||||||||||||||||
| 1338 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
del_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1339 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1340 | 0 | ▶ | my $part_name = translate_part_name(shift) or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1341 | 0 | push @{$self->{deleted}}, $part_name; | |||||||||||||||||||||||||||||||||
| 1342 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||
| 1345 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||
| 1347 | sub save | ||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 1349 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1350 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1351 | ( | ||||||||||||||||||||||||||||||||||
| 1352 | target => undef, | ||||||||||||||||||||||||||||||||||
| 1353 | packaging => 'zip', | ||||||||||||||||||||||||||||||||||
| 1354 | @_ | ||||||||||||||||||||||||||||||||||
| 1355 | ); | ||||||||||||||||||||||||||||||||||
| 1356 | 0 | ▶ | if (is_true($self->{read_only})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1357 | { | ||||||||||||||||||||||||||||||||||
| 1358 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opt{"target"} and $opt{"target"} ne $self->{"uri"}
MC/DC0%0/2
defined $opt{"target"} and $opt{"target"} ne $self->{"uri"}
defined $opt{"target"}
$opt{"target"} ne $self->{"uri"}
Truth table0%0/3
A and B
A= defined $opt{"target"}B= $opt{"target"} ne $self->{"uri"}
| |||||||||||||||||||||||||||||||||||
| 1359 | (defined $opt{target}) && | ||||||||||||||||||||||||||||||||||
| 1360 | $opt{target} ne $self->{uri} | ||||||||||||||||||||||||||||||||||
| 1361 | ) | ||||||||||||||||||||||||||||||||||
| 1362 | { | ||||||||||||||||||||||||||||||||||
| 1363 | 0 | alert("Read-only container"); | |||||||||||||||||||||||||||||||||
| 1364 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 1365 | } | ||||||||||||||||||||||||||||||||||
| 1366 | } | ||||||||||||||||||||||||||||||||||
| 1367 | 0 | my $target = $opt{target}; | |||||||||||||||||||||||||||||||||
| 1368 | 0 | my $packaging = $opt{packaging}; | |||||||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||||||||
| 1370 | 0 | $self->raw_del_part($_) for @{$self->{deleted}}; | |||||||||||||||||||||||||||||||||
| 1371 | |||||||||||||||||||||||||||||||||||
| 1372 | 0 | foreach my $part_name (keys %{$self->{stored}}) | |||||||||||||||||||||||||||||||||
| 1373 | { | ||||||||||||||||||||||||||||||||||
| 1374 | 0 | my $data = $self->{stored}{$part_name}{data}; | |||||||||||||||||||||||||||||||||
| 1375 | 0 | my $compress = $self->{stored}{$part_name}{compress}; | |||||||||||||||||||||||||||||||||
| 1376 | 0 | my $string = $self->{stored}{$part_name}{string}; | |||||||||||||||||||||||||||||||||
| 1377 | 0 | $self->raw_del_part($part_name); | |||||||||||||||||||||||||||||||||
| 1378 | 0 | $self->raw_set_part | |||||||||||||||||||||||||||||||||
| 1379 | ( | ||||||||||||||||||||||||||||||||||
| 1380 | $part_name, $data, | ||||||||||||||||||||||||||||||||||
| 1381 | compress => $compress, | ||||||||||||||||||||||||||||||||||
| 1382 | string => $string | ||||||||||||||||||||||||||||||||||
| 1383 | ); | ||||||||||||||||||||||||||||||||||
| 1384 | } | ||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||
| 1386 | 0 | my $status = undef; | |||||||||||||||||||||||||||||||||
| 1387 | 0 | ▶ | unless (defined $target) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 1388 | { | ||||||||||||||||||||||||||||||||||
| 1389 | 0 | $status = $self->{zip}->overwrite(); | |||||||||||||||||||||||||||||||||
| 1390 | } | ||||||||||||||||||||||||||||||||||
| 1391 | elsif (UNIVERSAL::isa($target, 'IO::File')) | ||||||||||||||||||||||||||||||||||
| 1392 | { | ||||||||||||||||||||||||||||||||||
| 1393 | 0 | $status = $self->{zip}->writeToFileHandle($target); | |||||||||||||||||||||||||||||||||
| 1394 | } | ||||||||||||||||||||||||||||||||||
| 1395 | else | ||||||||||||||||||||||||||||||||||
| 1396 | { | ||||||||||||||||||||||||||||||||||
| 1397 | 0 | $status = $self->{zip}->writeToFileNamed($target); | |||||||||||||||||||||||||||||||||
| 1398 | } | ||||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||
| 1400 | 0 | ▶ | unless ($status == AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1401 | { | ||||||||||||||||||||||||||||||||||
| 1402 | 0 | alert("Zip I/O error"); | |||||||||||||||||||||||||||||||||
| 1403 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||
| 1406 | 0 | $self->{deleted} = []; | |||||||||||||||||||||||||||||||||
| 1407 | 0 | $self->{stored} = {}; | |||||||||||||||||||||||||||||||||
| 1408 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1409 | } | ||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||
| 1411 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1412 | package ODF::lpOD::XMLPart; | ||||||||||||||||||||||||||||||||||
| 1413 | 2 | our $VERSION = '1.007'; | |||||||||||||||||||||||||||||||||
| 1414 | 2 | ▶ | use constant PACKAGE_DATE => '2012-05-15T08:36:28'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1415 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1416 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||
| 1418 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1419 | 2 | *forget = *DESTROY; | |||||||||||||||||||||||||||||||||
| 1420 | 2 | *body = *get_body; | |||||||||||||||||||||||||||||||||
| 1421 | 2 | *get_container = *container; | |||||||||||||||||||||||||||||||||
| 1422 | 2 | *get_document = *document; | |||||||||||||||||||||||||||||||||
| 1423 | 2 | *root = *get_root; | |||||||||||||||||||||||||||||||||
| 1424 | 2 | *get_element_list = *get_elements; | |||||||||||||||||||||||||||||||||
| 1425 | 2 | *export = *serialize; | |||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||
| 1428 | sub class_of | ||||||||||||||||||||||||||||||||||
| 1429 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
class_of: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $part = shift; | |||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | return ref $part if ref $part; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1432 | 0 | ▶ | if ($part eq CONTENT) { return 'ODF::lpOD::Content' } | ||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||
| 1433 | 0 | elsif ($part eq STYLES) { return 'ODF::lpOD::Styles' } | |||||||||||||||||||||||||||||||||
| 1434 | 0 | elsif ($part eq META) { return 'ODF::lpOD::Meta' } | |||||||||||||||||||||||||||||||||
| 1435 | 0 | elsif ($part eq SETTINGS) { return 'ODF::lpOD::Settings' } | |||||||||||||||||||||||||||||||||
| 1436 | 0 | elsif ($part eq MANIFEST) { return 'ODF::lpOD::Manifest' } | |||||||||||||||||||||||||||||||||
| 1437 | 0 | else { return undef } | |||||||||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||
| 1440 | 2 | our %CLASS = | |||||||||||||||||||||||||||||||||
| 1441 | ( | ||||||||||||||||||||||||||||||||||
| 1442 | content => 'ODF::lpOD::Content', | ||||||||||||||||||||||||||||||||||
| 1443 | styles => 'ODF::lpOD::Styles', | ||||||||||||||||||||||||||||||||||
| 1444 | meta => 'ODF::lpOD::Meta', | ||||||||||||||||||||||||||||||||||
| 1445 | manifest => 'ODF::lpOD::Manifest', | ||||||||||||||||||||||||||||||||||
| 1446 | settings => 'ODF::lpOD::Settings' | ||||||||||||||||||||||||||||||||||
| 1447 | ); | ||||||||||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||||||||
| 1449 | 0 | ▶ | sub pre_load {} | ||||||||||||||||||||||||||||||||
|
Subroutine
pre_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1450 | sub post_load | ||||||||||||||||||||||||||||||||||
| 1451 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1452 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1453 | 0 | $self->get_root->set_classes; | |||||||||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||
| 1456 | #=== exported part =========================================================== | ||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||
| 1458 | sub get | ||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1460 | 0 | my $container = shift; | |||||||||||||||||||||||||||||||||
| 1461 | 0 | ▶ | unless (ref $container && $container->isa('ODF::lpOD::Container')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $container and $container->isa("ODF::lpOD::Container")
MC/DC0%0/2
ref $container and $container->isa("ODF::lpOD::Container")
ref $container
$container->isa("ODF::lpOD::Container")
Truth table0%0/3
A and B
A= ref $containerB= $container->isa("ODF::lpOD::Container")
| |||||||||||||||||||||||||||||||||||
| 1462 | { | ||||||||||||||||||||||||||||||||||
| 1463 | 0 | alert "Missing or not valid container"; | |||||||||||||||||||||||||||||||||
| 1464 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1465 | } | ||||||||||||||||||||||||||||||||||
| 1466 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1467 | 0 | ▶ | unless (class_of($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1468 | { | ||||||||||||||||||||||||||||||||||
| 1469 | 0 | alert "Missing or unknown document part"; | |||||||||||||||||||||||||||||||||
| 1470 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1471 | } | ||||||||||||||||||||||||||||||||||
| 1472 | 0 | return ODF::lpOD::XMLPart->new | |||||||||||||||||||||||||||||||||
| 1473 | ( | ||||||||||||||||||||||||||||||||||
| 1474 | part => $part_name, | ||||||||||||||||||||||||||||||||||
| 1475 | container => $container, | ||||||||||||||||||||||||||||||||||
| 1476 | @_ | ||||||||||||||||||||||||||||||||||
| 1477 | ); | ||||||||||||||||||||||||||||||||||
| 1478 | } | ||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||
| 1480 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1481 | #--- constructor and associated utilities ------------------------------------ | ||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||
| 1483 | sub new | ||||||||||||||||||||||||||||||||||
| 1484 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||
| 1485 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 1486 | 0 | my $self = | |||||||||||||||||||||||||||||||||
| 1487 | { | ||||||||||||||||||||||||||||||||||
| 1488 | container => undef, | ||||||||||||||||||||||||||||||||||
| 1489 | part => undef, | ||||||||||||||||||||||||||||||||||
| 1490 | load => TRUE, | ||||||||||||||||||||||||||||||||||
| 1491 | elt_class => 'ODF::lpOD::Element', | ||||||||||||||||||||||||||||||||||
| 1492 | twig => undef, | ||||||||||||||||||||||||||||||||||
| 1493 | context => undef, | ||||||||||||||||||||||||||||||||||
| 1494 | @_ | ||||||||||||||||||||||||||||||||||
| 1495 | }; | ||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||
| 1497 | 0 | ▶ | unless (defined $self->{update}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1498 | { | ||||||||||||||||||||||||||||||||||
| 1499 | 0 | ▶ | $self->{update} = $self->{roots} ? FALSE : TRUE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1500 | } | ||||||||||||||||||||||||||||||||||
| 1501 | 0 | my $part_class = class_of($self->{part}); | |||||||||||||||||||||||||||||||||
| 1502 | 0 | ▶ | unless ($class) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1503 | { | ||||||||||||||||||||||||||||||||||
| 1504 | 0 | alert "Unknown ODF XML part"; return FALSE; | |||||||||||||||||||||||||||||||||
| 1505 | } | ||||||||||||||||||||||||||||||||||
| 1506 | 0 | ▶ | $self->{pretty} //= ($self->{indent} // lpod->debug); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$self->{"indent"} // "ODF::lpOD::Common"->debug
MC/DC0%0/3
$self->{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$self->{"pretty"}
$self->{"indent"}
"ODF::lpOD::Common"->debug
Truth table0%0/4
A //= B // C
A= $self->{"pretty"}B= $self->{"indent"}C= "ODF::lpOD::Common"->debug
| |||||||||||||||||||||||||||||||||||
| 1507 | 0 | ▶ | $self->{pretty_print} = PRETTY_PRINT if is_true($self->{pretty}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1508 | $self->{twig} //= XML::Twig->new # twig init | ||||||||||||||||||||||||||||||||||
| 1509 | ( | ||||||||||||||||||||||||||||||||||
| 1510 | twig_handlers => $self->{handlers}, | ||||||||||||||||||||||||||||||||||
| 1511 | twig_roots => $self->{roots}, | ||||||||||||||||||||||||||||||||||
| 1512 | elt_class => $self->{elt_class}, | ||||||||||||||||||||||||||||||||||
| 1513 | pretty_print => $self->{pretty_print}, | ||||||||||||||||||||||||||||||||||
| 1514 | 0 | ▶ | output_encoding => TRUE, | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->{"twig"} //= "XML::Twig"->new("twig_handlers", $self->{"handlers"}, "twig_roots", $self->{"roots"}, "elt_class", $self->{"elt_class"}, "pretty_print", $self->{"pretty_print"}, "output_encoding", 1, "id", $ODF::lpOD::Common::LPOD_ID)
MC/DC0%0/2
$self->{"twig"} //= "XML::Twig"->new("twig_handlers", $self->{"handlers"}, "twig_roots", $self->{"roots"}, "elt_class", $self->{"elt_class"}, "pretty_print", $self->{"pretty_print"}, "output_encoding", 1, "id", $ODF::lpOD::Common::LPOD_ID)
$self->{"twig"}
"XML::Twig"->new("twig_handlers", $self->{"handlers"}, "twig_roots", $self->{"roots"}, "elt_class", $self->{"elt_class"}, "pretty_print", $self->{"pretty_print"}, "output_encoding", 1, "id", $ODF::lpOD::Common::LPOD_ID)
Truth table0%0/3
A //= B
A= $self->{"twig"}B= "XML::Twig"->new("twig_handlers", $self->{"handlers"}, "twig_roots", $self->{"roots"}, "elt_class", $self->{"elt_class"}, "pretty_print", $self->{"pretty_print"}, "output_encoding", 1, "id", $ODF::lpOD::Common::LPOD_ID)
| |||||||||||||||||||||||||||||||||||
| 1515 | id => $ODF::lpOD::Common::LPOD_ID | ||||||||||||||||||||||||||||||||||
| 1516 | ); | ||||||||||||||||||||||||||||||||||
| 1517 | 0 | $self->{twig}->set_output_encoding('UTF-8'); | |||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||
| 1519 | 0 | bless $self, $part_class; | |||||||||||||||||||||||||||||||||
| 1520 | 0 | ▶ | if ($self->{load}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1521 | { | ||||||||||||||||||||||||||||||||||
| 1522 | 0 | my $status = $self->load(); | |||||||||||||||||||||||||||||||||
| 1523 | 0 | ▶ | unless (is_true($status)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1524 | { | ||||||||||||||||||||||||||||||||||
| 1525 | 0 | alert("Part load failed"); | |||||||||||||||||||||||||||||||||
| 1526 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1527 | } | ||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||
| 1529 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||
| 1532 | sub load | ||||||||||||||||||||||||||||||||||
| 1533 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1534 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1535 | 0 | ▶ | my $xml = shift || $self->{container}->get_part($self->{part}); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'container'}->get_part($self->{'part'})
MC/DC0%0/2
shift() || $self->{'container'}->get_part($self->{'part'})
shift()
$self->{'container'}->get_part($self->{'part'})
Truth table0%0/3
A || B
A= shift()B= $self->{'container'}->get_part($self->{'part'})
| |||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||
| 1537 | 0 | ▶ | unless (defined $xml) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1538 | { | ||||||||||||||||||||||||||||||||||
| 1539 | 0 | alert("No content"); | |||||||||||||||||||||||||||||||||
| 1540 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1541 | } | ||||||||||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||||||||
| 1543 | 0 | $self->pre_load; | |||||||||||||||||||||||||||||||||
| 1544 | my $r = UNIVERSAL::isa($xml, 'IO::File') ? | ||||||||||||||||||||||||||||||||||
| 1545 | $self->{twig}->safe_parsefile($xml) : | ||||||||||||||||||||||||||||||||||
| 1546 | 0 | ▶ | $self->{twig}->safe_parse($xml); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1547 | 0 | ▶ | unless ($r) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1548 | { | ||||||||||||||||||||||||||||||||||
| 1549 | 0 | alert "No valid XML content"; | |||||||||||||||||||||||||||||||||
| 1550 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1551 | } | ||||||||||||||||||||||||||||||||||
| 1552 | 0 | $self->{context} = $self->{twig}->root; | |||||||||||||||||||||||||||||||||
| 1553 | 0 | $self->{context}->lpod_part($self); | |||||||||||||||||||||||||||||||||
| 1554 | 0 | $self->post_load; | |||||||||||||||||||||||||||||||||
| 1555 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1556 | } | ||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||
| 1558 | sub needs_update | ||||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
needs_update: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1560 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1561 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||
| 1562 | 0 | ▶ | if (!defined $arg) {} | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 1563 | 0 | elsif ($arg == TRUE) { $self->{update} = TRUE } | |||||||||||||||||||||||||||||||||
| 1564 | 0 | elsif ($arg == FALSE) { $self->{update} = FALSE } | |||||||||||||||||||||||||||||||||
| 1565 | 0 | return $self->{update}; | |||||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||
| 1568 | sub get_name | ||||||||||||||||||||||||||||||||||
| 1569 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1570 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1571 | 0 | return $self->{part}; | |||||||||||||||||||||||||||||||||
| 1572 | } | ||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||
| 1574 | #--- destructor -------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||
| 1576 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1578 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1579 | $self->{context} && | ||||||||||||||||||||||||||||||||||
| 1580 | 0 | ▶ | $self->{context}->del_att($ODF::lpOD::Common::LPOD_PART); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1581 | 0 | ▶ | $self->{context} && $self->{context}->delete; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1582 | 0 | delete $self->{context}; | |||||||||||||||||||||||||||||||||
| 1583 | 0 | ▶ | $self->{twig} && $self->{twig}->dispose; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1584 | 0 | delete $self->{twig}; | |||||||||||||||||||||||||||||||||
| 1585 | 0 | delete $self->{container}; | |||||||||||||||||||||||||||||||||
| 1586 | 0 | delete $self->{part}; | |||||||||||||||||||||||||||||||||
| 1587 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||
| 1590 | #--- basic individual node selection ----------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||
| 1592 | sub find_node | ||||||||||||||||||||||||||||||||||
| 1593 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
find_node: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1594 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1595 | 0 | my $tag = shift; | |||||||||||||||||||||||||||||||||
| 1596 | 0 | ▶ | my $context = shift || $self->{context}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->{'context'}
MC/DC0%0/2
shift() || $self->{'context'}
shift()
$self->{'context'}
Truth table0%0/3
A || B
A= shift()B= $self->{'context'}
| |||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||
| 1598 | 0 | return $context->first_descendant($tag); | |||||||||||||||||||||||||||||||||
| 1599 | } | ||||||||||||||||||||||||||||||||||
| 1600 | |||||||||||||||||||||||||||||||||||
| 1601 | #=== public part ============================================================= | ||||||||||||||||||||||||||||||||||
| 1602 | #--- general document management --------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||
| 1604 | sub get_class | ||||||||||||||||||||||||||||||||||
| 1605 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1606 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1607 | 0 | return ref $self; | |||||||||||||||||||||||||||||||||
| 1608 | } | ||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||
| 1610 | sub get_root | ||||||||||||||||||||||||||||||||||
| 1611 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_root: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1612 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1613 | 0 | return $self->{twig}->root; | |||||||||||||||||||||||||||||||||
| 1614 | } | ||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||
| 1616 | sub get_body | ||||||||||||||||||||||||||||||||||
| 1617 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1618 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1619 | 0 | my $tag = shift; | |||||||||||||||||||||||||||||||||
| 1620 | 0 | my $root = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1621 | 0 | ▶ | if ($tag) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1622 | { | ||||||||||||||||||||||||||||||||||
| 1623 | 0 | ▶ | $tag = 'office:' . $tag unless $tag =~ /:/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1624 | 0 | return $root->get_xpath(('//office:body/' . $tag), 0); | |||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||
| 1626 | 0 | my $context = $root->get_xpath('//office:body', 0); | |||||||||||||||||||||||||||||||||
| 1627 | 0 | ▶ | return $context ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1628 | $context->first_child | ||||||||||||||||||||||||||||||||||
| 1629 | (qr'office:(text|spreadsheet|presentation|drawing)') | ||||||||||||||||||||||||||||||||||
| 1630 | : | ||||||||||||||||||||||||||||||||||
| 1631 | $root->first_child | ||||||||||||||||||||||||||||||||||
| 1632 | (qr'office:(body|meta|master-styles|settings)'); | ||||||||||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||
| 1635 | sub container | ||||||||||||||||||||||||||||||||||
| 1636 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
container: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1637 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1638 | 0 | return $self->{container}; | |||||||||||||||||||||||||||||||||
| 1639 | } | ||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||
| 1641 | sub document | ||||||||||||||||||||||||||||||||||
| 1642 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
document: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1643 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1644 | 0 | return $self->{document}; | |||||||||||||||||||||||||||||||||
| 1645 | } | ||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||
| 1647 | sub serialize | ||||||||||||||||||||||||||||||||||
| 1648 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
serialize: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1649 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1650 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1651 | ( | ||||||||||||||||||||||||||||||||||
| 1652 | empty_tags => EMPTY_TAGS, | ||||||||||||||||||||||||||||||||||
| 1653 | output => undef, | ||||||||||||||||||||||||||||||||||
| 1654 | @_ | ||||||||||||||||||||||||||||||||||
| 1655 | ); | ||||||||||||||||||||||||||||||||||
| 1656 | 0 | ▶ | $opt{pretty} //= ($self->{indent} // lpod->debug); | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$opt{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$self->{"indent"} // "ODF::lpOD::Common"->debug
MC/DC0%0/3
$opt{"pretty"} //= $self->{"indent"} // "ODF::lpOD::Common"->debug
$opt{"pretty"}
$self->{"indent"}
"ODF::lpOD::Common"->debug
Truth table0%0/4
A //= B // C
A= $opt{"pretty"}B= $self->{"indent"}C= "ODF::lpOD::Common"->debug
| |||||||||||||||||||||||||||||||||||
| 1657 | 0 | ▶ | $opt{pretty_print} = PRETTY_PRINT if is_true($opt{pretty}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1658 | 0 | my $output = $opt{output}; | |||||||||||||||||||||||||||||||||
| 1659 | 0 | delete @opt{qw(pretty output indent)}; | |||||||||||||||||||||||||||||||||
| 1660 | return (defined $output) ? | ||||||||||||||||||||||||||||||||||
| 1661 | $self->{twig}->print($output, %opt) : | ||||||||||||||||||||||||||||||||||
| 1662 | 0 | ▶ | $self->{twig}->sprint(%opt); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1663 | } | ||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||
| 1665 | sub store | ||||||||||||||||||||||||||||||||||
| 1666 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1667 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1668 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1669 | { | ||||||||||||||||||||||||||||||||||
| 1670 | 0 | alert "No associated container"; | |||||||||||||||||||||||||||||||||
| 1671 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||
| 1673 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 1674 | 0 | my %storage = (); | |||||||||||||||||||||||||||||||||
| 1675 | 0 | ▶ | if ($opt{storage}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1676 | { | ||||||||||||||||||||||||||||||||||
| 1677 | 0 | %storage = %{$opt{storage}}; | |||||||||||||||||||||||||||||||||
| 1678 | 0 | delete $opt{storage}; | |||||||||||||||||||||||||||||||||
| 1679 | } | ||||||||||||||||||||||||||||||||||
| 1680 | else | ||||||||||||||||||||||||||||||||||
| 1681 | { | ||||||||||||||||||||||||||||||||||
| 1682 | 0 | %storage = (compress => TRUE, string => TRUE); | |||||||||||||||||||||||||||||||||
| 1683 | } | ||||||||||||||||||||||||||||||||||
| 1684 | return | ||||||||||||||||||||||||||||||||||
| 1685 | $self->{container}->set_part | ||||||||||||||||||||||||||||||||||
| 1686 | ( | ||||||||||||||||||||||||||||||||||
| 1687 | $self->{part}, | ||||||||||||||||||||||||||||||||||
| 1688 | 0 | $self->serialize(%opt), | |||||||||||||||||||||||||||||||||
| 1689 | %storage | ||||||||||||||||||||||||||||||||||
| 1690 | ); | ||||||||||||||||||||||||||||||||||
| 1691 | } | ||||||||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||||||||
| 1693 | #--- general element management ---------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1694 | |||||||||||||||||||||||||||||||||||
| 1695 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 1696 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1697 | 0 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||||||||
| 1698 | 0 | return $self->{context}->get_xpath($xpath); | |||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||
| 1701 | sub get_element | ||||||||||||||||||||||||||||||||||
| 1702 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1703 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1704 | 0 | my $xpath = shift; | |||||||||||||||||||||||||||||||||
| 1705 | 0 | ▶ | my $offset = shift || 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 1706 | 0 | return $self->{context}->get_xpath($xpath, $offset); | |||||||||||||||||||||||||||||||||
| 1707 | } | ||||||||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||||||||
| 1709 | sub append_element | ||||||||||||||||||||||||||||||||||
| 1710 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
append_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1711 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1712 | 0 | my $context = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1713 | 0 | return $context->append_element(@_); | |||||||||||||||||||||||||||||||||
| 1714 | } | ||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||
| 1716 | sub insert_element | ||||||||||||||||||||||||||||||||||
| 1717 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1718 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1719 | 0 | my $context = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1720 | 0 | return $context->insert_element(@_); | |||||||||||||||||||||||||||||||||
| 1721 | } | ||||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||||
| 1723 | sub delete_element | ||||||||||||||||||||||||||||||||||
| 1724 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
delete_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1725 | 0 | my ($self, $element) = @_; | |||||||||||||||||||||||||||||||||
| 1726 | 0 | return $element->delete; | |||||||||||||||||||||||||||||||||
| 1727 | } | ||||||||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||||||||
| 1729 | #--- tracked change handling ------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||
| 1731 | sub get_tracked_changes_root | ||||||||||||||||||||||||||||||||||
| 1732 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tracked_changes_root: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1733 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1734 | 0 | ▶ | unless ($self->{tracked_changes}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1735 | { | ||||||||||||||||||||||||||||||||||
| 1736 | $self->{tracked_changes} = | ||||||||||||||||||||||||||||||||||
| 1737 | 0 | $self->find_node('text:tracked-changes'); | |||||||||||||||||||||||||||||||||
| 1738 | } | ||||||||||||||||||||||||||||||||||
| 1739 | 0 | return $self->{tracked_changes}; | |||||||||||||||||||||||||||||||||
| 1740 | } | ||||||||||||||||||||||||||||||||||
| 1741 | |||||||||||||||||||||||||||||||||||
| 1742 | sub get_changes | ||||||||||||||||||||||||||||||||||
| 1743 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_changes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1744 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1745 | 0 | my $context = $self->get_tracked_changes_root; | |||||||||||||||||||||||||||||||||
| 1746 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1747 | { | ||||||||||||||||||||||||||||||||||
| 1748 | 0 | alert "Not valid tracked change retrieval context"; | |||||||||||||||||||||||||||||||||
| 1749 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1750 | } | ||||||||||||||||||||||||||||||||||
| 1751 | 0 | return $context->get_changes(@_); | |||||||||||||||||||||||||||||||||
| 1752 | } | ||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||
| 1754 | sub get_change | ||||||||||||||||||||||||||||||||||
| 1755 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_change: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1756 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1757 | 0 | my $context = $self->get_tracked_changes_root; | |||||||||||||||||||||||||||||||||
| 1758 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1759 | { | ||||||||||||||||||||||||||||||||||
| 1760 | 0 | alert "Not valid tracked change retrieval context"; | |||||||||||||||||||||||||||||||||
| 1761 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1762 | } | ||||||||||||||||||||||||||||||||||
| 1763 | 0 | return $context->get_change(shift); | |||||||||||||||||||||||||||||||||
| 1764 | } | ||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||
| 1766 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1767 | package ODF::lpOD::StyleContainer; | ||||||||||||||||||||||||||||||||||
| 1768 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1769 | 2 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||||||||
| 1770 | 2 | ▶ | use constant PACKAGE_DATE => '2011-05-29T16:05:40'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1771 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1772 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||
| 1774 | sub get_font_declarations | ||||||||||||||||||||||||||||||||||
| 1775 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_font_declarations: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1776 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1777 | 0 | return $self->get_elements | |||||||||||||||||||||||||||||||||
| 1778 | ('//office:font-face-decls/style:font-face'); | ||||||||||||||||||||||||||||||||||
| 1779 | } | ||||||||||||||||||||||||||||||||||
| 1780 | |||||||||||||||||||||||||||||||||||
| 1781 | sub get_font_declaration | ||||||||||||||||||||||||||||||||||
| 1782 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_font_declaration: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1783 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1784 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1785 | 0 | my $xp = '//office:font-face-decls' . | |||||||||||||||||||||||||||||||||
| 1786 | '/style:font-face[@style:name="' . | ||||||||||||||||||||||||||||||||||
| 1787 | $name . | ||||||||||||||||||||||||||||||||||
| 1788 | '"]'; | ||||||||||||||||||||||||||||||||||
| 1789 | 0 | return $self->get_element($xp); | |||||||||||||||||||||||||||||||||
| 1790 | } | ||||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||||
| 1792 | sub set_font_declaration | ||||||||||||||||||||||||||||||||||
| 1793 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_font_declaration: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1794 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1795 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1796 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1797 | { | ||||||||||||||||||||||||||||||||||
| 1798 | 0 | alert "Missing font name"; return undef; | |||||||||||||||||||||||||||||||||
| 1799 | } | ||||||||||||||||||||||||||||||||||
| 1800 | 0 | my %opt = process_options(@_); | |||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | $opt{family} ||= $name; | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opt{"family"} ||= $name
MC/DC0%0/2
$opt{"family"} ||= $name
$opt{"family"}
$name
Truth table0%0/3
A ||= B
A= $opt{"family"}B= $name
| |||||||||||||||||||||||||||||||||||
| 1802 | 0 | my $fd = $self->get_font_declaration($name); | |||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | $fd->delete if $fd; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1804 | 0 | return $self | |||||||||||||||||||||||||||||||||
| 1805 | ->get_root | ||||||||||||||||||||||||||||||||||
| 1806 | ->set_child('office:font-face-decls') | ||||||||||||||||||||||||||||||||||
| 1807 | ->append_element | ||||||||||||||||||||||||||||||||||
| 1808 | (ODF::lpOD::FontDeclaration->create($name, %opt)); | ||||||||||||||||||||||||||||||||||
| 1809 | } | ||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||
| 1811 | sub substitute_context | ||||||||||||||||||||||||||||||||||
| 1812 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_context: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1813 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1814 | 0 | my $doc = shift; | |||||||||||||||||||||||||||||||||
| 1815 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||
| 1817 | 0 | my $part = $self->get_name; | |||||||||||||||||||||||||||||||||
| 1818 | 0 | ▶ | my $origin = $doc->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1819 | or return undef; | ||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | my $destination = $self->get_element($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1821 | or return undef; | ||||||||||||||||||||||||||||||||||
| 1822 | 0 | return $destination->substitute_children($origin); | |||||||||||||||||||||||||||||||||
| 1823 | } | ||||||||||||||||||||||||||||||||||
| 1824 | |||||||||||||||||||||||||||||||||||
| 1825 | sub substitute_styles | ||||||||||||||||||||||||||||||||||
| 1826 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_styles: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||
| 1827 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1828 | 0 | my $from = shift; | |||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||
| 1830 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1831 | ( | ||||||||||||||||||||||||||||||||||
| 1832 | common => TRUE, | ||||||||||||||||||||||||||||||||||
| 1833 | master => TRUE, | ||||||||||||||||||||||||||||||||||
| 1834 | automatic => TRUE, | ||||||||||||||||||||||||||||||||||
| 1835 | fonts => TRUE, | ||||||||||||||||||||||||||||||||||
| 1836 | @_ | ||||||||||||||||||||||||||||||||||
| 1837 | ); | ||||||||||||||||||||||||||||||||||
| 1838 | 0 | my $part = $self->get_name; | |||||||||||||||||||||||||||||||||
| 1839 | 0 | ▶ | if ($part ne STYLES) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1840 | { | ||||||||||||||||||||||||||||||||||
| 1841 | 0 | delete @opt{qw(common master)}; | |||||||||||||||||||||||||||||||||
| 1842 | } | ||||||||||||||||||||||||||||||||||
| 1843 | 0 | my $source; | |||||||||||||||||||||||||||||||||
| 1844 | 0 | ▶ | if (ref $from) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1845 | { | ||||||||||||||||||||||||||||||||||
| 1846 | 0 | ▶ | $source = $from if $from->isa('ODF::lpOD::Document'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1847 | } | ||||||||||||||||||||||||||||||||||
| 1848 | else | ||||||||||||||||||||||||||||||||||
| 1849 | { | ||||||||||||||||||||||||||||||||||
| 1850 | 0 | $source = ODF::lpOD::Document->new(template => $from); | |||||||||||||||||||||||||||||||||
| 1851 | } | ||||||||||||||||||||||||||||||||||
| 1852 | 0 | ▶ | unless ($source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1853 | { | ||||||||||||||||||||||||||||||||||
| 1854 | 0 | alert "Malformed or not available source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||
| 1857 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||
| 1859 | 0 | ▶ | if (is_true($opt{automatic})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1860 | { | ||||||||||||||||||||||||||||||||||
| 1861 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1862 | ($source, '//office:automatic-styles'); | ||||||||||||||||||||||||||||||||||
| 1863 | } | ||||||||||||||||||||||||||||||||||
| 1864 | 0 | ▶ | if (is_true($opt{common})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1865 | { | ||||||||||||||||||||||||||||||||||
| 1866 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1867 | ($source, '//office:styles'); | ||||||||||||||||||||||||||||||||||
| 1868 | } | ||||||||||||||||||||||||||||||||||
| 1869 | 0 | ▶ | if (is_true($opt{master})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1870 | { | ||||||||||||||||||||||||||||||||||
| 1871 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1872 | ($source, '//office:master-styles'); | ||||||||||||||||||||||||||||||||||
| 1873 | } | ||||||||||||||||||||||||||||||||||
| 1874 | 0 | ▶ | if (is_true($opt{fonts})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1875 | { | ||||||||||||||||||||||||||||||||||
| 1876 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1877 | ($source, '//office:font-face-decls'); | ||||||||||||||||||||||||||||||||||
| 1878 | } | ||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||
| 1880 | 0 | ▶ | $source->forget unless ref $from; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1881 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 1882 | } | ||||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||||
| 1884 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1885 | package ODF::lpOD::Content; | ||||||||||||||||||||||||||||||||||
| 1886 | 2 | ▶ | use base 'ODF::lpOD::StyleContainer'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1887 | 2 | our $VERSION = '1.003'; | |||||||||||||||||||||||||||||||||
| 1888 | 2 | ▶ | use constant PACKAGE_DATE => '2012-03-29T08:25:40'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1889 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1890 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||
| 1892 | sub get_tocs | ||||||||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tocs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1894 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1895 | 0 | my $context = $self->get_body; | |||||||||||||||||||||||||||||||||
| 1896 | 0 | return $context->get_elements('text:table-of-content'); | |||||||||||||||||||||||||||||||||
| 1897 | } | ||||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||||
| 1899 | sub get_toc | ||||||||||||||||||||||||||||||||||
| 1900 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_toc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1901 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1902 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1903 | 0 | my $context = $self->get_body; | |||||||||||||||||||||||||||||||||
| 1904 | 0 | return $context->get_element_by_name('text:table-of-content', $name); | |||||||||||||||||||||||||||||||||
| 1905 | } | ||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||
| 1907 | sub get_named_range | ||||||||||||||||||||||||||||||||||
| 1908 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_named_range: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1909 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1910 | 0 | my $context = $self->get_body('spreadsheet'); | |||||||||||||||||||||||||||||||||
| 1911 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1912 | { | ||||||||||||||||||||||||||||||||||
| 1913 | 0 | alert "Not in spreadsheet context"; return undef; | |||||||||||||||||||||||||||||||||
| 1914 | } | ||||||||||||||||||||||||||||||||||
| 1915 | 0 | return $context->get_element_by_name('table:named-range', @_); | |||||||||||||||||||||||||||||||||
| 1916 | } | ||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||
| 1918 | sub set_named_range | ||||||||||||||||||||||||||||||||||
| 1919 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_named_range: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1920 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1921 | 0 | my $body = $self->get_body('spreadsheet'); | |||||||||||||||||||||||||||||||||
| 1922 | 0 | ▶ | unless ($body) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1923 | { | ||||||||||||||||||||||||||||||||||
| 1924 | 0 | alert "Not in spreadsheet context"; return undef; | |||||||||||||||||||||||||||||||||
| 1925 | } | ||||||||||||||||||||||||||||||||||
| 1926 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1927 | 0 | my $old = $self->get_named_range($name); | |||||||||||||||||||||||||||||||||
| 1928 | 0 | ▶ | if ($old) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1929 | { | ||||||||||||||||||||||||||||||||||
| 1930 | 0 | alert "Named range $name already exists"; return undef; | |||||||||||||||||||||||||||||||||
| 1931 | } | ||||||||||||||||||||||||||||||||||
| 1932 | 0 | my $context = $body->set_last_child('table:named-expressions'); | |||||||||||||||||||||||||||||||||
| 1933 | 0 | my $nr = ODF::lpOD::NamedRange->create($name, @_); | |||||||||||||||||||||||||||||||||
| 1934 | 0 | $context->append_element($nr); | |||||||||||||||||||||||||||||||||
| 1935 | 0 | return $nr; | |||||||||||||||||||||||||||||||||
| 1936 | } | ||||||||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||||||||
| 1938 | sub get_headings | ||||||||||||||||||||||||||||||||||
| 1939 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_headings: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1940 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1941 | 0 | return $self->get_body->get_headings(@_); | |||||||||||||||||||||||||||||||||
| 1942 | } | ||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||
| 1944 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1945 | package ODF::lpOD::Styles; | ||||||||||||||||||||||||||||||||||
| 1946 | 2 | ▶ | use base 'ODF::lpOD::StyleContainer'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1947 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 1948 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:51:47'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1949 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1950 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1951 | package ODF::lpOD::Meta; | ||||||||||||||||||||||||||||||||||
| 1952 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1953 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 1954 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:51:58'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1955 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1956 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||
| 1958 | 2 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1959 | 2 | *get_element_list = *get_elements; | |||||||||||||||||||||||||||||||||
| 1960 | } | ||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||
| 1962 | 0 | ▶ | sub post_load {} | ||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||
| 1964 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||
| 1966 | 2 | our %META = | |||||||||||||||||||||||||||||||||
| 1967 | ( | ||||||||||||||||||||||||||||||||||
| 1968 | creation_date => 'meta:creation-date', | ||||||||||||||||||||||||||||||||||
| 1969 | creator => 'dc:creator', | ||||||||||||||||||||||||||||||||||
| 1970 | description => 'dc:description', | ||||||||||||||||||||||||||||||||||
| 1971 | editing_cycles => 'meta:editing-cycles', | ||||||||||||||||||||||||||||||||||
| 1972 | editing_duration => 'meta:editing-duration', | ||||||||||||||||||||||||||||||||||
| 1973 | generator => 'meta:generator', | ||||||||||||||||||||||||||||||||||
| 1974 | initial_creator => 'meta:initial-creator', | ||||||||||||||||||||||||||||||||||
| 1975 | language => 'dc:language', | ||||||||||||||||||||||||||||||||||
| 1976 | modification_date => 'dc:date', | ||||||||||||||||||||||||||||||||||
| 1977 | printed_by => 'meta:printed-by', | ||||||||||||||||||||||||||||||||||
| 1978 | print_date => 'meta:print-date', | ||||||||||||||||||||||||||||||||||
| 1979 | subject => 'dc:subject', | ||||||||||||||||||||||||||||||||||
| 1980 | title => 'dc:title' | ||||||||||||||||||||||||||||||||||
| 1981 | ); | ||||||||||||||||||||||||||||||||||
| 1982 | |||||||||||||||||||||||||||||||||||
| 1983 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||||
| 1985 | sub get_body | ||||||||||||||||||||||||||||||||||
| 1986 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1987 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1988 | 0 | ▶ | unless ($self->{body}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1989 | { | ||||||||||||||||||||||||||||||||||
| 1990 | 0 | $self->{body} = $self->SUPER::get_element('//office:meta'); | |||||||||||||||||||||||||||||||||
| 1991 | } | ||||||||||||||||||||||||||||||||||
| 1992 | 0 | return $self->{body}; | |||||||||||||||||||||||||||||||||
| 1993 | } | ||||||||||||||||||||||||||||||||||
| 1994 | |||||||||||||||||||||||||||||||||||
| 1995 | sub get_element | ||||||||||||||||||||||||||||||||||
| 1996 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1997 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 1998 | 0 | return $self->get_body->get_element(@_); | |||||||||||||||||||||||||||||||||
| 1999 | } | ||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||
| 2001 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 2002 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2003 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2004 | 0 | return $self->get_body->get_element_list(@_); | |||||||||||||||||||||||||||||||||
| 2005 | } | ||||||||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||||||||
| 2007 | sub append_element | ||||||||||||||||||||||||||||||||||
| 2008 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
append_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2009 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2010 | 0 | return $self->get_body->append_element(@_); | |||||||||||||||||||||||||||||||||
| 2011 | } | ||||||||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||||||||
| 2013 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||||||||
| 2015 | sub get_statistics | ||||||||||||||||||||||||||||||||||
| 2016 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_statistics: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2017 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2018 | 0 | my $stat = $self->get_element('meta:document-statistic'); | |||||||||||||||||||||||||||||||||
| 2019 | 0 | ▶ | return $stat ? $stat->get_attributes() : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2020 | } | ||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||
| 2022 | sub set_statistics | ||||||||||||||||||||||||||||||||||
| 2023 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_statistics: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2024 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2025 | 0 | ▶ | my $stat = $self->get_element('meta:document-statistic') || | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_element('meta:document-statistic') || $self->append_element('meta:document-statistic')
MC/DC0%0/2
$self->get_element('meta:document-statistic') || $self->append_element('meta:document-statistic')
$self->get_element('meta:document-statistic')
$self->append_element('meta:document-statistic')
Truth table0%0/3
A || B
A= $self->get_element('meta:document-statistic')B= $self->append_element('meta:document-statistic')
| |||||||||||||||||||||||||||||||||||
| 2026 | $self->append_element('meta:document-statistic'); | ||||||||||||||||||||||||||||||||||
| 2027 | 0 | return $stat->set_attributes(@_); | |||||||||||||||||||||||||||||||||
| 2028 | } | ||||||||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||||||||
| 2030 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||||
| 2032 | sub get_keyword_list | ||||||||||||||||||||||||||||||||||
| 2033 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_keyword_list: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2034 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2035 | 0 | my $expr = shift; | |||||||||||||||||||||||||||||||||
| 2036 | 0 | return $self->get_element_list | |||||||||||||||||||||||||||||||||
| 2037 | ('meta:keyword', content => $expr); | ||||||||||||||||||||||||||||||||||
| 2038 | } | ||||||||||||||||||||||||||||||||||
| 2039 | |||||||||||||||||||||||||||||||||||
| 2040 | sub get_keywords | ||||||||||||||||||||||||||||||||||
| 2041 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_keywords: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2042 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2043 | 0 | my @kwl = (); | |||||||||||||||||||||||||||||||||
| 2044 | 0 | for ($self->get_keyword_list(@_)) | |||||||||||||||||||||||||||||||||
| 2045 | { | ||||||||||||||||||||||||||||||||||
| 2046 | 0 | push @kwl, $_->get_text; | |||||||||||||||||||||||||||||||||
| 2047 | } | ||||||||||||||||||||||||||||||||||
| 2048 | 0 | ▶ | return wantarray ? @kwl : join (', ', @kwl); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2049 | } | ||||||||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||||||||
| 2051 | sub set_keyword | ||||||||||||||||||||||||||||||||||
| 2052 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_keyword: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 2053 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2054 | 0 | ▶ | my $kw = shift // return undef; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // (return undef)
MC/DC0%0/1
shift() // (return undef)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 2055 | 0 | for ($self->get_keyword_list) | |||||||||||||||||||||||||||||||||
| 2056 | { | ||||||||||||||||||||||||||||||||||
| 2057 | 0 | ▶ | return FALSE if $_->get_text() eq $kw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2058 | } | ||||||||||||||||||||||||||||||||||
| 2059 | 0 | my $e = $self->append_element('meta:keyword'); | |||||||||||||||||||||||||||||||||
| 2060 | 0 | $e->set_text($kw); | |||||||||||||||||||||||||||||||||
| 2061 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2062 | } | ||||||||||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||||||||
| 2064 | sub set_keywords | ||||||||||||||||||||||||||||||||||
| 2065 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_keywords: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2066 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2067 | 0 | my $input = join(',', @_); | |||||||||||||||||||||||||||||||||
| 2068 | 0 | foreach my $kw (split(',', $input)) | |||||||||||||||||||||||||||||||||
| 2069 | { | ||||||||||||||||||||||||||||||||||
| 2070 | 0 | $kw =~ s/^ *//; $kw =~ s/ *$//; | |||||||||||||||||||||||||||||||||
| 2071 | 0 | $self->set_keyword($kw); | |||||||||||||||||||||||||||||||||
| 2072 | } | ||||||||||||||||||||||||||||||||||
| 2073 | 0 | return $self->get_keywords; | |||||||||||||||||||||||||||||||||
| 2074 | } | ||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||
| 2076 | sub check_keyword | ||||||||||||||||||||||||||||||||||
| 2077 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
check_keyword: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2078 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2079 | 0 | ▶ | my $expr = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||
| 2081 | 0 | return scalar $self->get_keyword_list($expr); | |||||||||||||||||||||||||||||||||
| 2082 | } | ||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||
| 2084 | sub remove_keyword | ||||||||||||||||||||||||||||||||||
| 2085 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
remove_keyword: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2086 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2087 | 0 | ▶ | my $expr = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2088 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 2089 | 0 | for ($self->get_keyword_list($expr)) | |||||||||||||||||||||||||||||||||
| 2090 | { | ||||||||||||||||||||||||||||||||||
| 2091 | 0 | $_->delete; $count++; | |||||||||||||||||||||||||||||||||
| 2092 | } | ||||||||||||||||||||||||||||||||||
| 2093 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 2094 | } | ||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||
| 2096 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||
| 2098 | sub get_user_field | ||||||||||||||||||||||||||||||||||
| 2099 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_field: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 2100 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2101 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2102 | 0 | ▶ | my $e = ref $name ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2103 | $name | ||||||||||||||||||||||||||||||||||
| 2104 | : | ||||||||||||||||||||||||||||||||||
| 2105 | $self->get_element | ||||||||||||||||||||||||||||||||||
| 2106 | ( | ||||||||||||||||||||||||||||||||||
| 2107 | 'meta:user-defined', | ||||||||||||||||||||||||||||||||||
| 2108 | attribute => 'name', | ||||||||||||||||||||||||||||||||||
| 2109 | value => $name | ||||||||||||||||||||||||||||||||||
| 2110 | ); | ||||||||||||||||||||||||||||||||||
| 2111 | 0 | ▶ | return undef unless $e; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2112 | return wantarray ? | ||||||||||||||||||||||||||||||||||
| 2113 | ( | ||||||||||||||||||||||||||||||||||
| 2114 | 0 | ▶ | $e->get_text(), | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 2115 | $e->get_attribute('value type') || 'string' | ||||||||||||||||||||||||||||||||||
| 2116 | ) | ||||||||||||||||||||||||||||||||||
| 2117 | : | ||||||||||||||||||||||||||||||||||
| 2118 | $e->get_text; | ||||||||||||||||||||||||||||||||||
| 2119 | } | ||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||
| 2121 | sub set_user_field | ||||||||||||||||||||||||||||||||||
| 2122 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_user_field: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 2123 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2124 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 2125 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 2126 | 0 | ▶ | my $type = shift || 'string'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'string'
MC/DC0%0/1
shift() || 'string'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 2127 | 0 | ▶ | unless (is_odf_datatype($type)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2128 | { | ||||||||||||||||||||||||||||||||||
| 2129 | 0 | alert "Wrong data type $type"; | |||||||||||||||||||||||||||||||||
| 2130 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 2131 | } | ||||||||||||||||||||||||||||||||||
| 2132 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2133 | { | ||||||||||||||||||||||||||||||||||
| 2134 | 0 | alert "Missing user field name"; | |||||||||||||||||||||||||||||||||
| 2135 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 2136 | } | ||||||||||||||||||||||||||||||||||
| 2137 | 0 | $value = check_odf_value($value, $type); | |||||||||||||||||||||||||||||||||
| 2138 | 0 | ▶ | my $e = $self->get_element | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_element("meta:user-defined", "attribute", "name", "value", $name) // $self->append_element("meta:user-defined")
MC/DC0%0/2
$self->get_element("meta:user-defined", "attribute", "name", "value", $name) // $self->append_element("meta:user-defined")
$self->get_element("meta:user-defined", "attribute", "name", "value", $name)
$self->append_element("meta:user-defined")
Truth table0%0/3
A // B
A= $self->get_element("meta:user-defined", "attribute", "name", "value", $name)B= $self->append_element("meta:user-defined")
| |||||||||||||||||||||||||||||||||||
| 2139 | ( | ||||||||||||||||||||||||||||||||||
| 2140 | 'meta:user-defined', | ||||||||||||||||||||||||||||||||||
| 2141 | attribute => 'name', | ||||||||||||||||||||||||||||||||||
| 2142 | value => $name | ||||||||||||||||||||||||||||||||||
| 2143 | ) | ||||||||||||||||||||||||||||||||||
| 2144 | // | ||||||||||||||||||||||||||||||||||
| 2145 | $self->append_element('meta:user-defined'); | ||||||||||||||||||||||||||||||||||
| 2146 | 0 | $e->set_attribute('name' => $name); | |||||||||||||||||||||||||||||||||
| 2147 | 0 | $e->set_attribute('value type' => $type); | |||||||||||||||||||||||||||||||||
| 2148 | 0 | $e->set_text($value); | |||||||||||||||||||||||||||||||||
| 2149 | return wantarray ? | ||||||||||||||||||||||||||||||||||
| 2150 | 0 | ▶ | ($e->get_text(), $e->get_attribute('value type')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2151 | : | ||||||||||||||||||||||||||||||||||
| 2152 | $e->get_text; | ||||||||||||||||||||||||||||||||||
| 2153 | } | ||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||
| 2155 | sub get_user_fields | ||||||||||||||||||||||||||||||||||
| 2156 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_fields: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 2157 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2158 | 0 | my @result = (); | |||||||||||||||||||||||||||||||||
| 2159 | 0 | foreach my $e ($self->get_element_list('meta:user-defined')) | |||||||||||||||||||||||||||||||||
| 2160 | { | ||||||||||||||||||||||||||||||||||
| 2161 | 0 | my $f; | |||||||||||||||||||||||||||||||||
| 2162 | 0 | $f->{name} = $e->get_attribute('name'); | |||||||||||||||||||||||||||||||||
| 2163 | 0 | ▶ | $f->{type} = $e->get_attribute('value type') // 'string'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$e->get_attribute("value type") // "string"
MC/DC0%0/1
$e->get_attribute("value type") // "string"
$e->get_attribute("value type")
Truth table0%0/2
A
A= $e->get_attribute("value type")
| |||||||||||||||||||||||||||||||||||
| 2164 | 0 | ▶ | $f->{value} = $e->get_text() // ""; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$e->get_text // ""
MC/DC0%0/1
$e->get_text // ""
$e->get_text
Truth table0%0/2
A
A= $e->get_text
| |||||||||||||||||||||||||||||||||||
| 2165 | 0 | push @result, $f; | |||||||||||||||||||||||||||||||||
| 2166 | } | ||||||||||||||||||||||||||||||||||
| 2167 | 0 | return @result; | |||||||||||||||||||||||||||||||||
| 2168 | } | ||||||||||||||||||||||||||||||||||
| 2169 | |||||||||||||||||||||||||||||||||||
| 2170 | sub set_user_fields | ||||||||||||||||||||||||||||||||||
| 2171 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_user_fields: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2172 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2173 | 0 | foreach my $f (@_) | |||||||||||||||||||||||||||||||||
| 2174 | { | ||||||||||||||||||||||||||||||||||
| 2175 | 0 | $self->set_user_field($f->{name}, $f->{value}, $f->{type}); | |||||||||||||||||||||||||||||||||
| 2176 | } | ||||||||||||||||||||||||||||||||||
| 2177 | 0 | return $self->get_user_fields; | |||||||||||||||||||||||||||||||||
| 2178 | } | ||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||
| 2180 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2181 | |||||||||||||||||||||||||||||||||||
| 2182 | 2 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||
| 2183 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||||
| 2184 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||
| 2185 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2186 | 0 | $AUTOLOAD =~ /.*:(.*)/; | |||||||||||||||||||||||||||||||||
| 2187 | 0 | my $method = $1; | |||||||||||||||||||||||||||||||||
| 2188 | 0 | $method =~ /^([gs]et)_(.*)/; | |||||||||||||||||||||||||||||||||
| 2189 | 0 | my $action = $1; | |||||||||||||||||||||||||||||||||
| 2190 | 0 | my $object = $META{$2}; | |||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||
| 2192 | 0 | ▶ | unless ($action && $object) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$action and $object
MC/DC0%0/2
$action and $object
$action
$object
Truth table0%0/3
A and B
A= $actionB= $object
| |||||||||||||||||||||||||||||||||||
| 2193 | { | ||||||||||||||||||||||||||||||||||
| 2194 | 0 | alert "Unsupported method $method"; | |||||||||||||||||||||||||||||||||
| 2195 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 2196 | } | ||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||
| 2198 | 0 | my $e = $self->get_element($object); | |||||||||||||||||||||||||||||||||
| 2199 | 0 | ▶ | if (!defined $action) | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 2200 | { | ||||||||||||||||||||||||||||||||||
| 2201 | 0 | alert "Unsupported action"; | |||||||||||||||||||||||||||||||||
| 2202 | } | ||||||||||||||||||||||||||||||||||
| 2203 | elsif ($action eq 'get') | ||||||||||||||||||||||||||||||||||
| 2204 | { | ||||||||||||||||||||||||||||||||||
| 2205 | 0 | ▶ | return $e ? $e->get_text() : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2206 | } | ||||||||||||||||||||||||||||||||||
| 2207 | elsif ($action eq 'set') | ||||||||||||||||||||||||||||||||||
| 2208 | { | ||||||||||||||||||||||||||||||||||
| 2209 | 0 | ▶ | unless ($e) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2210 | { | ||||||||||||||||||||||||||||||||||
| 2211 | 0 | my $body = $self->get_body; | |||||||||||||||||||||||||||||||||
| 2212 | 0 | $e = $body->append_element($object); | |||||||||||||||||||||||||||||||||
| 2213 | } | ||||||||||||||||||||||||||||||||||
| 2214 | 0 | my $v = shift; | |||||||||||||||||||||||||||||||||
| 2215 | 0 | ▶ | if ($object =~ /date$/) | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 2216 | { | ||||||||||||||||||||||||||||||||||
| 2217 | 0 | ▶ | unless ($v) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2218 | { | ||||||||||||||||||||||||||||||||||
| 2219 | 0 | $v = iso_date; | |||||||||||||||||||||||||||||||||
| 2220 | } | ||||||||||||||||||||||||||||||||||
| 2221 | else | ||||||||||||||||||||||||||||||||||
| 2222 | { | ||||||||||||||||||||||||||||||||||
| 2223 | 0 | $v = check_odf_value($v, 'date'); | |||||||||||||||||||||||||||||||||
| 2224 | } | ||||||||||||||||||||||||||||||||||
| 2225 | } | ||||||||||||||||||||||||||||||||||
| 2226 | elsif ($object =~ /creator$/) | ||||||||||||||||||||||||||||||||||
| 2227 | { | ||||||||||||||||||||||||||||||||||
| 2228 | 0 | ▶ | $v = | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
scalar getlogin || scalar getpwuid $< || $<
scalar getlogin or scalar getpwuid $<
MC/DC0%0/2
scalar getlogin || scalar getpwuid $< || $<
scalar getlogin
$<
Truth table0%0/3
A || B
A= scalar getloginB= $<
| |||||||||||||||||||||||||||||||||||
| 2229 | $v = (scalar getlogin()) || | ||||||||||||||||||||||||||||||||||
| 2230 | (scalar getpwuid($<)) || | ||||||||||||||||||||||||||||||||||
| 2231 | $< | ||||||||||||||||||||||||||||||||||
| 2232 | unless $v; | ||||||||||||||||||||||||||||||||||
| 2233 | } | ||||||||||||||||||||||||||||||||||
| 2234 | elsif ($object =~ /generator$/) | ||||||||||||||||||||||||||||||||||
| 2235 | { | ||||||||||||||||||||||||||||||||||
| 2236 | 0 | ▶ | $v = $0 || $$ unless $v; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$0 || $$
MC/DC0%0/2
$0 || $$
$0
$$
Truth table0%0/3
A || B
A= $0B= $$
| |||||||||||||||||||||||||||||||||||
| 2237 | } | ||||||||||||||||||||||||||||||||||
| 2238 | elsif ($object =~ /cycles$/) | ||||||||||||||||||||||||||||||||||
| 2239 | { | ||||||||||||||||||||||||||||||||||
| 2240 | 0 | ▶ | unless ($v) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2241 | { | ||||||||||||||||||||||||||||||||||
| 2242 | 0 | ▶ | $v = $e->get_text() || 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$e->get_text || 0
MC/DC0%0/1
$e->get_text || 0
$e->get_text
Truth table0%0/2
A
A= $e->get_text
| |||||||||||||||||||||||||||||||||||
| 2243 | 0 | $v++; | |||||||||||||||||||||||||||||||||
| 2244 | } | ||||||||||||||||||||||||||||||||||
| 2245 | } | ||||||||||||||||||||||||||||||||||
| 2246 | 0 | return $e->set_text($v); | |||||||||||||||||||||||||||||||||
| 2247 | } | ||||||||||||||||||||||||||||||||||
| 2248 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 2249 | } | ||||||||||||||||||||||||||||||||||
| 2250 | |||||||||||||||||||||||||||||||||||
| 2251 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2252 | |||||||||||||||||||||||||||||||||||
| 2253 | sub store | ||||||||||||||||||||||||||||||||||
| 2254 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2255 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2256 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 2257 | ( | ||||||||||||||||||||||||||||||||||
| 2258 | storage => { compress => FALSE, string => TRUE }, | ||||||||||||||||||||||||||||||||||
| 2259 | @_ | ||||||||||||||||||||||||||||||||||
| 2260 | ); | ||||||||||||||||||||||||||||||||||
| 2261 | 0 | return $self->SUPER::store(%opt); | |||||||||||||||||||||||||||||||||
| 2262 | } | ||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||
| 2264 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2265 | package ODF::lpOD::Settings; | ||||||||||||||||||||||||||||||||||
| 2266 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2267 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 2268 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:52:14'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2269 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2270 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||
| 2272 | 0 | ▶ | sub post_load {} | ||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||
| 2274 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2275 | package ODF::lpOD::Manifest; | ||||||||||||||||||||||||||||||||||
| 2276 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2277 | 2 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||||||||
| 2278 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-30T08:34:26'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2279 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2280 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||
| 2282 | 0 | ▶ | sub post_load {} | ||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||
| 2284 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2285 | |||||||||||||||||||||||||||||||||||
| 2286 | sub get_entries | ||||||||||||||||||||||||||||||||||
| 2287 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_entries: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 2288 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2289 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 2290 | my @all_entries = $self->{context}->get_element_list | ||||||||||||||||||||||||||||||||||
| 2291 | 0 | ('manifest:file-entry'); | |||||||||||||||||||||||||||||||||
| 2292 | 0 | ▶ | unless (defined $opt{type}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2293 | { | ||||||||||||||||||||||||||||||||||
| 2294 | 0 | return @all_entries; | |||||||||||||||||||||||||||||||||
| 2295 | } | ||||||||||||||||||||||||||||||||||
| 2296 | 0 | my @selected_entries = (); | |||||||||||||||||||||||||||||||||
| 2297 | 0 | ENTRY: foreach my $e (@all_entries) | |||||||||||||||||||||||||||||||||
| 2298 | { | ||||||||||||||||||||||||||||||||||
| 2299 | 0 | my $type = $e->get_attribute('media type'); | |||||||||||||||||||||||||||||||||
| 2300 | 0 | ▶ | next ENTRY unless defined $type; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2301 | 0 | ▶ | if ($opt{type} eq "") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2302 | { | ||||||||||||||||||||||||||||||||||
| 2303 | 0 | ▶ | push @selected_entries, $e if $type eq ""; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2304 | 0 | next ENTRY; | |||||||||||||||||||||||||||||||||
| 2305 | } | ||||||||||||||||||||||||||||||||||
| 2306 | 0 | ▶ | push @selected_entries, $e if $type =~ /$opt{type}/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2307 | } | ||||||||||||||||||||||||||||||||||
| 2308 | 0 | return @selected_entries; | |||||||||||||||||||||||||||||||||
| 2309 | } | ||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||
| 2311 | sub get_entry | ||||||||||||||||||||||||||||||||||
| 2312 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_entry: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2313 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2314 | return $self->{context}->get_element( | ||||||||||||||||||||||||||||||||||
| 2315 | 0 | 'manifest:file-entry', | |||||||||||||||||||||||||||||||||
| 2316 | attribute => 'full path', | ||||||||||||||||||||||||||||||||||
| 2317 | value => shift | ||||||||||||||||||||||||||||||||||
| 2318 | ); | ||||||||||||||||||||||||||||||||||
| 2319 | } | ||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||
| 2321 | sub set_entry | ||||||||||||||||||||||||||||||||||
| 2322 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
set_entry: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2323 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2324 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 2325 | 0 | ▶ | unless ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2326 | { | ||||||||||||||||||||||||||||||||||
| 2327 | 0 | alert "Missing entry path"; return FALSE; | |||||||||||||||||||||||||||||||||
| 2328 | } | ||||||||||||||||||||||||||||||||||
| 2329 | 0 | my $e = $self->get_entry($path); | |||||||||||||||||||||||||||||||||
| 2330 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 2331 | 0 | ▶ | unless ($e) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2332 | { | ||||||||||||||||||||||||||||||||||
| 2333 | 0 | $e = ODF::lpOD::Element->create('manifest:file-entry'); | |||||||||||||||||||||||||||||||||
| 2334 | 0 | $e->set_attribute('full path' => $path); | |||||||||||||||||||||||||||||||||
| 2335 | 0 | $e->paste_last_child($self->{context}); | |||||||||||||||||||||||||||||||||
| 2336 | } | ||||||||||||||||||||||||||||||||||
| 2337 | 0 | $e->set_type($opt{type}); | |||||||||||||||||||||||||||||||||
| 2338 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2339 | } | ||||||||||||||||||||||||||||||||||
| 2340 | |||||||||||||||||||||||||||||||||||
| 2341 | sub del_entry | ||||||||||||||||||||||||||||||||||
| 2342 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||
|
Subroutine
del_entry: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2343 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 2344 | 0 | my $e = $self->get_entry(@_); | |||||||||||||||||||||||||||||||||
| 2345 | 0 | ▶ | $e->delete() if $e; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2346 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2347 | } | ||||||||||||||||||||||||||||||||||
| 2348 | |||||||||||||||||||||||||||||||||||
| 2349 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2350 | 2 | 1; | |||||||||||||||||||||||||||||||||