| 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 | 2 | ▶ | use experimental 'smartmatch'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 12 | # The ODF Document class definition | ||||||||||||||||||||||||||||||||||
| 13 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 14 | package ODF::lpOD::Document; | ||||||||||||||||||||||||||||||||||
| 15 | 2 | our $VERSION = '1.013'; | |||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant PACKAGE_DATE => '2014-04-30T08:27:07'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||
| 20 | BEGIN { | ||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | *forget = *DESTROY; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | 2 | *container = *get_container; | |||||||||||||||||||||||||||||||||
| 23 | 2 | *body = *get_body; | |||||||||||||||||||||||||||||||||
| 24 | 2 | *add_part = *add_file; | |||||||||||||||||||||||||||||||||
| 25 | 2 | *register_style = *insert_style; | |||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | #--- specific constructors --------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | sub get_from_uri | ||||||||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | my $resource = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_from_uri: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | unless ($resource) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||
| 35 | 0 | alert "Missing source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | 0 | return ODF::lpOD::Document->new(@_, uri => $resource); | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | sub create_from_template | ||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | my $resource = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
create_from_template: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | unless ($resource) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||
| 45 | 0 | alert "Missing template"; return FALSE; | |||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | 0 | return ODF::lpOD::Document->new(@_, template => $resource); | |||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | sub get | ||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 54 | 0 | return ODF::lpOD::Document->new(uri => shift, @_); | |||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | sub create | ||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $caller = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 60 | 0 | return ODF::lpOD::Document->new(type => shift, @_); | |||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | sub _create | ||||||||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $type = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
_create: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | unless ($type) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||||
| 68 | 0 | alert "Missing document type"; return FALSE; | |||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | 0 | return ODF::lpOD::Document->new(@_, type => $type); | |||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | #--- generic constructor & destructor ---------------------------------------- | ||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||
| 75 | sub new | ||||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 78 | 0 | my $self = { @_ }; | |||||||||||||||||||||||||||||||||
| 79 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 80 | 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"}
| |||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($self->{type}) # new document, type provided | ||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||
| 83 | my $template = ODF::lpOD::Common::template($self->{type}) | ||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 86 | (template => $template) or return undef; | ||||||||||||||||||||||||||||||||||
| 87 | 0 | my $meta = $self->get_part(META); | |||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($meta) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||
| 90 | 0 | my $d = iso_date; | |||||||||||||||||||||||||||||||||
| 91 | 0 | $meta->set_creation_date($d); | |||||||||||||||||||||||||||||||||
| 92 | 0 | $meta->set_modification_date($d); | |||||||||||||||||||||||||||||||||
| 93 | 0 | $meta->set_editing_duration('PT00H00M00S'); | |||||||||||||||||||||||||||||||||
| 94 | 0 | $meta->set_generator("ODF::lpOD $ODF::lpOD::VERSION"); | |||||||||||||||||||||||||||||||||
| 95 | 0 | $meta->set_initial_creator(); | |||||||||||||||||||||||||||||||||
| 96 | 0 | $meta->set_creator(); | |||||||||||||||||||||||||||||||||
| 97 | 0 | $meta->set_editing_cycles(1); | |||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||
| 100 | elsif ($self->{template}) | ||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||
| 102 | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||||
| 103 | (template => $self->{template}) | ||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||
| 106 | elsif ($self->{uri}) # existing document, path provided | ||||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||||
| 108 | $self->{container} = ODF::lpOD::Container->new | ||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | (uri => $self->{uri}) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | 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
| |||||||||||||||||||||||||||||||||||
| 112 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach my $part_name ($self->loaded_xmlparts) | |||||||||||||||||||||||||||||||||
| 119 | { | ||||||||||||||||||||||||||||||||||
| 120 | 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}
| |||||||||||||||||||||||||||||||||||
| 121 | 0 | $self->{$part_name}->forget; | |||||||||||||||||||||||||||||||||
| 122 | 0 | delete $self->{$part_name}; | |||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||
| 124 | 0 | delete $self->{xmlparts}; | |||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | $self->{container} && $self->{container}->DESTROY; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 126 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | #--- XML part detection ------------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | sub is_xmlpart | ||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $name = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
is_xmlpart: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return ODF::lpOD::XMLPart::class_of($name) ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | #--- document part accessors ------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | sub get_container | ||||||||||||||||||||||||||||||||||
| 140 | { | ||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_container: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 142 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 143 | 0 | my $container = $self->{container}; | |||||||||||||||||||||||||||||||||
| 144 | 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"})
| |||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||
| 146 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||
| 148 | 0 | return $container; | |||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | sub contains | ||||||||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
contains: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 155 | 0 | return $container->contains(@_); | |||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | sub parts | ||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
parts: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 162 | 0 | return $container->parts; | |||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | sub get_stored_part | ||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_stored_part: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $container = $self->get_container or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 169 | 0 | return $container->get_stored_part(@_); | |||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | sub get_xmlpart | ||||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_xmlpart: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 176 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $part_name = shift or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | unless ($self->{$part_name}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||
| 182 | my $xmlpart = ODF::lpOD::XMLPart->new | ||||||||||||||||||||||||||||||||||
| 183 | ( | ||||||||||||||||||||||||||||||||||
| 184 | container => $container, | ||||||||||||||||||||||||||||||||||
| 185 | part => $part_name, | ||||||||||||||||||||||||||||||||||
| 186 | pretty => $self->{pretty}, | ||||||||||||||||||||||||||||||||||
| 187 | @_ | ||||||||||||||||||||||||||||||||||
| 188 | 0 | ); | |||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | unless ($xmlpart) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 190 | { | ||||||||||||||||||||||||||||||||||
| 191 | 0 | alert "Unavailable part"; return FALSE; | |||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||
| 193 | 0 | $self->{$part_name} = $xmlpart; | |||||||||||||||||||||||||||||||||
| 194 | 0 | $self->{$part_name}->{document} = $self; | |||||||||||||||||||||||||||||||||
| 195 | 0 | push @{$self->{xmlparts}}, $part_name; | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | 0 | return $self->{$part_name}; | |||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | sub loaded_xmlparts | ||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
loaded_xmlparts: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | return undef unless $self->{xmlparts}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return wantarray ? @{$self->{xmlparts}} : $self->{xmlparts}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | sub get_body | ||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 210 | 0 | return $self->content->get_body(@_); | |||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||
| 213 | sub get_part | ||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_part: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 217 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 218 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if (is_xmlpart($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||
| 221 | 0 | return $self->get_xmlpart($part_name, @_); | |||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||
| 223 | else | ||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||
| 225 | 0 | return $container->get_part($part_name, @_); | |||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | sub content | ||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
content: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 232 | 0 | return $self->get_xmlpart(CONTENT, @_); | |||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | sub meta | ||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
meta: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 238 | 0 | return $self->get_xmlpart(META, @_); | |||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | sub styles | ||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
styles: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 244 | 0 | return $self->get_xmlpart(STYLES, @_); | |||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||
| 247 | sub manifest | ||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
manifest: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 250 | 0 | return $self->get_xmlpart(MANIFEST, @_); | |||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||
| 253 | sub get_parts | ||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_parts: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 257 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 258 | 0 | return $container->get_parts; | |||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||
| 261 | sub set_part | ||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_part: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||
| 266 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 267 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||
| 269 | 0 | return $self->{container}->set_part(@_); | |||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | sub del_part | ||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
del_part: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||
| 277 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 278 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||
| 280 | 0 | return $self->{container}->del_part(@_); | |||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | sub add_file | ||||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
add_file: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||
| 288 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 289 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||
| 291 | 0 | my $source = shift; | |||||||||||||||||||||||||||||||||
| 292 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 293 | 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'}
| |||||||||||||||||||||||||||||||||||
| 294 | 0 | delete @opt{qw(path part)}; | |||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | unless ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||
| 297 | 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/
| |||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||
| 299 | 0 | my $filename = file_parse($source); | |||||||||||||||||||||||||||||||||
| 300 | 0 | $path = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | 0 | $path = $self->{container}->add_file($source, $path, %opt); | |||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||
| 306 | 0 | my $manifest = $self->get_part(MANIFEST); | |||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($manifest) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||||
| 309 | 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)
| |||||||||||||||||||||||||||||||||||
| 310 | 0 | $manifest->set_entry($path, type => $type); | |||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||
| 313 | 0 | return $path; | |||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | sub add_image_file | ||||||||||||||||||||||||||||||||||
| 317 | { | ||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
add_image_file: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | my $source = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 321 | { | ||||||||||||||||||||||||||||||||||
| 322 | 0 | alert "No available ODF container"; | |||||||||||||||||||||||||||||||||
| 323 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||
| 325 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 326 | 0 | my ($filename, $sourcepath, $suffix) = file_parse($source); | |||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | unless ($filename) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||
| 329 | 0 | alert "No valid file name in $source"; | |||||||||||||||||||||||||||||||||
| 330 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||
| 332 | 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)
| |||||||||||||||||||||||||||||||||||
| 333 | 0 | my $path = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | $suffix //= 'unknown'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$suffix //= "unknown"
MC/DC0%0/1
$suffix //= "unknown"
$suffix
Truth table0%0/2
A
A= $suffix
| |||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | 0 | my ($link, $size); | |||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if (wantarray) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 338 | { | ||||||||||||||||||||||||||||||||||
| 339 | 0 | my $buffer = load_file($source, ':raw'); | |||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | unless ($buffer) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||
| 342 | 0 | alert "Resource $source not available"; | |||||||||||||||||||||||||||||||||
| 343 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||
| 345 | 0 | $size = image_size(\$buffer); | |||||||||||||||||||||||||||||||||
| 346 | 0 | $link = $self->add_file | |||||||||||||||||||||||||||||||||
| 347 | ( | ||||||||||||||||||||||||||||||||||
| 348 | $buffer, | ||||||||||||||||||||||||||||||||||
| 349 | string => TRUE, | ||||||||||||||||||||||||||||||||||
| 350 | path => $path, | ||||||||||||||||||||||||||||||||||
| 351 | type => $type, | ||||||||||||||||||||||||||||||||||
| 352 | @_ | ||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||
| 354 | 0 | return ($link, $size); | |||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||
| 356 | else | ||||||||||||||||||||||||||||||||||
| 357 | { | ||||||||||||||||||||||||||||||||||
| 358 | 0 | $link = $self->add_file | |||||||||||||||||||||||||||||||||
| 359 | ( | ||||||||||||||||||||||||||||||||||
| 360 | $source, | ||||||||||||||||||||||||||||||||||
| 361 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 362 | path => $path, | ||||||||||||||||||||||||||||||||||
| 363 | type => $type, | ||||||||||||||||||||||||||||||||||
| 364 | @_ | ||||||||||||||||||||||||||||||||||
| 365 | ); | ||||||||||||||||||||||||||||||||||
| 366 | 0 | return $link; | |||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | sub get_mimetype | ||||||||||||||||||||||||||||||||||
| 371 | { | ||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_mimetype: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | unless ($self->{mimetype}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||
| 375 | 0 | $self->{mimetype} = $self->{container}->get_mimetype; | |||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||
| 377 | 0 | return $self->{mimetype}; | |||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||
| 380 | sub set_mimetype | ||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_mimetype: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 384 | { | ||||||||||||||||||||||||||||||||||
| 385 | 0 | alert "No available container"; | |||||||||||||||||||||||||||||||||
| 386 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||
| 388 | 0 | return $self->{container}->set_mimetype(shift); | |||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||
| 391 | sub get_type | ||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_type: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | my $mt = $self->get_mimetype or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 395 | 0 | $mt =~ s/.*opendocument\.//; | |||||||||||||||||||||||||||||||||
| 396 | 0 | return $mt; | |||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||
| 399 | sub save | ||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | my $container = $self->get_container(warning => TRUE) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 403 | or return FALSE; | ||||||||||||||||||||||||||||||||||
| 404 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 405 | 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
| |||||||||||||||||||||||||||||||||||
| 406 | 0 | my $pretty = $opt{pretty}; | |||||||||||||||||||||||||||||||||
| 407 | 0 | delete @opt{qw(pretty indent)}; | |||||||||||||||||||||||||||||||||
| 408 | 0 | foreach my $part_name ($self->loaded_xmlparts) | |||||||||||||||||||||||||||||||||
| 409 | { | ||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | next unless $part_name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | my $part = $self->{$part_name} or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | $part->store(pretty => $pretty) if is_true($part->{update}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||
| 414 | 0 | return $container->save(%opt); | |||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||
| 417 | #--- required insertion context retrieval ------------------------------------ | ||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||
| 419 | sub get_required_context | ||||||||||||||||||||||||||||||||||
| 420 | { | ||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_required_context: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 422 | 0 | my $elt = shift; | |||||||||||||||||||||||||||||||||
| 423 | 0 | my ($part_name, $path) = $elt->context_path; | |||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | if ($part_name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | $path ||= '/'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
$path ||= "/"
MC/DC0%0/1
$path ||= "/"
$path
Truth table0%0/2
A
A= $path
| |||||||||||||||||||||||||||||||||||
| 427 | 0 | return $self->get_element($part_name, $path); | |||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||
| 429 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||
| 432 | #--- context import & replacement -------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||
| 434 | sub substitute_context | ||||||||||||||||||||||||||||||||||
| 435 | { | ||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_context: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 437 | 0 | my $doc = shift; | |||||||||||||||||||||||||||||||||
| 438 | 0 | my $part = shift; | |||||||||||||||||||||||||||||||||
| 439 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | my $origin = $doc->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 441 | or return undef; | ||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | my $destination = $self->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 443 | or return undef; | ||||||||||||||||||||||||||||||||||
| 444 | 0 | return $destination->substitute_children($origin); | |||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||
| 447 | #--- direct element retrieval ------------------------------------------------ | ||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||
| 449 | sub get_element | ||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 452 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 453 | 0 | my $part = $self->get_part($part_name); | |||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | unless ($part) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||
| 456 | 0 | alert "Unknown or not available document part"; | |||||||||||||||||||||||||||||||||
| 457 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||
| 459 | 0 | return $part->get_element(@_); | |||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 465 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 466 | 0 | my $part = $self->get_part($part_name); | |||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | unless ($part) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 468 | { | ||||||||||||||||||||||||||||||||||
| 469 | 0 | alert "Unknown or not available document part"; | |||||||||||||||||||||||||||||||||
| 470 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||
| 472 | 0 | return $part->get_elements(@_); | |||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||
| 475 | sub get_headings | ||||||||||||||||||||||||||||||||||
| 476 | { | ||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_headings: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 478 | 0 | return $self->get_part(CONTENT)->get_headings(@_); | |||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||
| 481 | sub get_changes | ||||||||||||||||||||||||||||||||||
| 482 | { | ||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_changes: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $part = $self->get_part(CONTENT) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 485 | 0 | return $part->get_changes(@_); | |||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||
| 488 | sub get_change | ||||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_change: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | my $part = $self->get_part(CONTENT) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 492 | 0 | return $part->get_change(@_); | |||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||
| 495 | #--- style handling ---------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||
| 497 | sub get_default_style | ||||||||||||||||||||||||||||||||||
| 498 | { | ||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_default_style: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 500 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 501 | 0 | $family =~ s/ /-/g; | |||||||||||||||||||||||||||||||||
| 502 | 0 | my $xp = '//style:default-style[@style:family="' . | |||||||||||||||||||||||||||||||||
| 503 | $family . '"]'; | ||||||||||||||||||||||||||||||||||
| 504 | 0 | return $self->get_element(STYLES, $xp); | |||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||
| 507 | sub get_outline_style | ||||||||||||||||||||||||||||||||||
| 508 | { | ||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_outline_style: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 510 | 0 | my $xp = '//text:outline-style'; | |||||||||||||||||||||||||||||||||
| 511 | 0 | return $self->get_element(STYLES, $xp); | |||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | sub get_style | ||||||||||||||||||||||||||||||||||
| 515 | { | ||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_style: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 517 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | unless ($family) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 519 | { | ||||||||||||||||||||||||||||||||||
| 520 | 0 | alert "Missing style family"; return undef; | |||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||
| 522 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 523 | 0 | $family =~ s/ /-/g; | |||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 525 | { | ||||||||||||||||||||||||||||||||||
| 526 | 0 | given ($family) | |||||||||||||||||||||||||||||||||
| 527 | { | ||||||||||||||||||||||||||||||||||
| 528 | when ('outline') | ||||||||||||||||||||||||||||||||||
| 529 | 0 | { | |||||||||||||||||||||||||||||||||
| 530 | 0 | return $self->get_outline_style; | |||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||
| 532 | default | ||||||||||||||||||||||||||||||||||
| 533 | 0 | { | |||||||||||||||||||||||||||||||||
| 534 | 0 | return $self->get_default_style($family); | |||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||
| 538 | 0 | my $style; my $xp; | |||||||||||||||||||||||||||||||||
| 539 | 0 | my $f = $family; $f =~ s/[ _]/-/g; | |||||||||||||||||||||||||||||||||
| 540 | 0 | given ($family) | |||||||||||||||||||||||||||||||||
| 541 | { | ||||||||||||||||||||||||||||||||||
| 542 | when ('list') | ||||||||||||||||||||||||||||||||||
| 543 | 0 | { | |||||||||||||||||||||||||||||||||
| 544 | 0 | $xp = '//text:list-style[@style:name="' . | |||||||||||||||||||||||||||||||||
| 545 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||
| 547 | when (/(master|page-layout)/) | ||||||||||||||||||||||||||||||||||
| 548 | 0 | { | |||||||||||||||||||||||||||||||||
| 549 | 0 | $xp = '//style:' . $f . '[@style:name="' . | |||||||||||||||||||||||||||||||||
| 550 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||
| 552 | when ('data') | ||||||||||||||||||||||||||||||||||
| 553 | 0 | { | |||||||||||||||||||||||||||||||||
| 554 | 0 | my $n = shift; | |||||||||||||||||||||||||||||||||
| 555 | 0 | $xp = '//number:' . $name . '-style' . | |||||||||||||||||||||||||||||||||
| 556 | '[@style:name="' . $n . '"]'; | ||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||
| 558 | when ('gradient') | ||||||||||||||||||||||||||||||||||
| 559 | 0 | { | |||||||||||||||||||||||||||||||||
| 560 | 0 | $xp = '//draw:gradient[@draw:name="' . | |||||||||||||||||||||||||||||||||
| 561 | $name . '"]'; | ||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||
| 563 | default | ||||||||||||||||||||||||||||||||||
| 564 | 0 | { | |||||||||||||||||||||||||||||||||
| 565 | 0 | $xp = '//style:style[@style:name="' . | |||||||||||||||||||||||||||||||||
| 566 | $name . | ||||||||||||||||||||||||||||||||||
| 567 | '"][@style:family="' . | ||||||||||||||||||||||||||||||||||
| 568 | $f . | ||||||||||||||||||||||||||||||||||
| 569 | '"]'; | ||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||
| 572 | return | ||||||||||||||||||||||||||||||||||
| 573 | 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)
| |||||||||||||||||||||||||||||||||||
| 574 | // | ||||||||||||||||||||||||||||||||||
| 575 | $self->get_element(CONTENT, $xp); | ||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||
| 578 | sub get_styles | ||||||||||||||||||||||||||||||||||
| 579 | { | ||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_styles: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 581 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | unless ($family) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||||
| 584 | 0 | alert "Missing style family"; return undef; | |||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | if (ODF::lpOD::DataStyle->is_numeric_family($family)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||
| 588 | 0 | return $self->get_data_styles($family, @_); | |||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||
| 590 | 0 | my $xp; | |||||||||||||||||||||||||||||||||
| 591 | 0 | my $f = $family; $f =~ s/[ _]/-/g; | |||||||||||||||||||||||||||||||||
| 592 | 0 | given ($family) | |||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||
| 594 | when('list') | ||||||||||||||||||||||||||||||||||
| 595 | 0 | { | |||||||||||||||||||||||||||||||||
| 596 | 0 | $xp = '//text:list-style'; | |||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||
| 598 | when (/(master|page layout)/) | ||||||||||||||||||||||||||||||||||
| 599 | 0 | { | |||||||||||||||||||||||||||||||||
| 600 | 0 | $xp = '//style:' . $f; | |||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||
| 602 | when ('gradient') | ||||||||||||||||||||||||||||||||||
| 603 | 0 | { | |||||||||||||||||||||||||||||||||
| 604 | 0 | $xp = '//draw:gradient'; | |||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||
| 606 | default | ||||||||||||||||||||||||||||||||||
| 607 | 0 | { | |||||||||||||||||||||||||||||||||
| 608 | 0 | $xp = '//style:style[@style:family="' . $f . '"]'; | |||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||
| 612 | return ( | ||||||||||||||||||||||||||||||||||
| 613 | 0 | $self->get_elements(STYLES, $xp), | |||||||||||||||||||||||||||||||||
| 614 | $self->get_elements(CONTENT, $xp) | ||||||||||||||||||||||||||||||||||
| 615 | ); | ||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||
| 618 | sub get_data_styles | ||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_data_styles: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 621 | 0 | my $family = shift; | |||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | my $filter = $family ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 623 | 'number:' . $family . '-style' : | ||||||||||||||||||||||||||||||||||
| 624 | qr'number:.*-style'; | ||||||||||||||||||||||||||||||||||
| 625 | 0 | my @ns = (); | |||||||||||||||||||||||||||||||||
| 626 | 0 | foreach my $part (STYLES, CONTENT) | |||||||||||||||||||||||||||||||||
| 627 | { | ||||||||||||||||||||||||||||||||||
| 628 | 0 | my $r = $self->get_part($part)->get_root; | |||||||||||||||||||||||||||||||||
| 629 | push @ns, $_->get_descendants($filter) | ||||||||||||||||||||||||||||||||||
| 630 | 0 | for $r->get_elements(qr'office:(automatic-|)styles'); | |||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||
| 632 | 0 | return @ns; | |||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||
| 635 | sub get_data_style | ||||||||||||||||||||||||||||||||||
| 636 | { | ||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_data_style: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 638 | 0 | my ($family, $name) = @_; | |||||||||||||||||||||||||||||||||
| 639 | 0 | my $xp = "//number:$family-style"; | |||||||||||||||||||||||||||||||||
| 640 | 0 | $xp .= '[@style:name="' . $name . '"]'; | |||||||||||||||||||||||||||||||||
| 641 | 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)
| |||||||||||||||||||||||||||||||||||
| 642 | // | ||||||||||||||||||||||||||||||||||
| 643 | $self->get_element(CONTENT, $xp); | ||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||
| 646 | sub check_stylename | ||||||||||||||||||||||||||||||||||
| 647 | { | ||||||||||||||||||||||||||||||||||
| 648 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
check_stylename: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 649 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 650 | 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
| |||||||||||||||||||||||||||||||||||
| 651 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 652 | 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
| |||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||
| 654 | 0 | alert "Missing style name and/or family"; | |||||||||||||||||||||||||||||||||
| 655 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | if ($self->get_style($family, $name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 658 | { | ||||||||||||||||||||||||||||||||||
| 659 | 0 | alert "Non unique style"; | |||||||||||||||||||||||||||||||||
| 660 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||
| 662 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||
| 665 | sub select_style_context | ||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
select_style_context: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 668 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 669 | 0 | my $context = $self->get_required_context($style); | |||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | return $context if $context; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 671 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 672 | 0 | my $xp; | |||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | my $part_name = is_true($opt{default}) ? STYLES : $opt{part}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 674 | 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"})
| |||||||||||||||||||||||||||||||||||
| 675 | { | ||||||||||||||||||||||||||||||||||
| 676 | 0 | $part_name = STYLES; delete $opt{automatic}; | |||||||||||||||||||||||||||||||||
| 677 | 0 | $xp = '//office:styles'; | |||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||
| 679 | else | ||||||||||||||||||||||||||||||||||
| 680 | { | ||||||||||||||||||||||||||||||||||
| 681 | 0 | $part_name = $opt{part}; | |||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if (is_true($opt{automatic})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 683 | { | ||||||||||||||||||||||||||||||||||
| 684 | 0 | $xp = '//office:automatic-styles'; | |||||||||||||||||||||||||||||||||
| 685 | 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
| |||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||
| 687 | else | ||||||||||||||||||||||||||||||||||
| 688 | { | ||||||||||||||||||||||||||||||||||
| 689 | 0 | given ($part_name) | |||||||||||||||||||||||||||||||||
| 690 | { | ||||||||||||||||||||||||||||||||||
| 691 | when (undef) | ||||||||||||||||||||||||||||||||||
| 692 | 0 | { | |||||||||||||||||||||||||||||||||
| 693 | 0 | $part_name = STYLES; | |||||||||||||||||||||||||||||||||
| 694 | 0 | ▶ | $xp = is_true($opt{automatic}) ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 695 | '//office:automatic-styles' : | ||||||||||||||||||||||||||||||||||
| 696 | '//office:styles'; | ||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||
| 698 | when (STYLES) | ||||||||||||||||||||||||||||||||||
| 699 | 0 | { | |||||||||||||||||||||||||||||||||
| 700 | 0 | ▶ | $xp = is_true($opt{automatic}) ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 701 | '//office:automatic-styles' : | ||||||||||||||||||||||||||||||||||
| 702 | '//office:styles'; | ||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||
| 704 | when (CONTENT) | ||||||||||||||||||||||||||||||||||
| 705 | 0 | { | |||||||||||||||||||||||||||||||||
| 706 | 0 | $xp = '//office:automatic-styles'; | |||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||
| 711 | 0 | $context = $self->get_element($part_name, $xp); | |||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 713 | { | ||||||||||||||||||||||||||||||||||
| 714 | 0 | alert "Wrong document structure; style insertion failure"; | |||||||||||||||||||||||||||||||||
| 715 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||
| 717 | 0 | return $context; | |||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||
| 720 | sub insert_regular_style | ||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_regular_style: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 723 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 724 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | my $context = $self->select_style_context($style, %opt) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 726 | or return undef; | ||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | if (is_true($opt{default})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 728 | { | ||||||||||||||||||||||||||||||||||
| 729 | 0 | $style->check_tag('style:default-style'); | |||||||||||||||||||||||||||||||||
| 730 | 0 | $style->set_name(undef); | |||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||
| 732 | else | ||||||||||||||||||||||||||||||||||
| 733 | { | ||||||||||||||||||||||||||||||||||
| 734 | 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
| |||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | return undef unless $self->check_stylename($style, $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 736 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 737 | 0 | $style->set_name($name); | |||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||
| 739 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||
| 742 | sub insert_special_style | ||||||||||||||||||||||||||||||||||
| 743 | { | ||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_special_style: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 745 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 746 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | my $context = $self->select_style_context($style, %opt) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 748 | or return undef; | ||||||||||||||||||||||||||||||||||
| 749 | 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
| |||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | return undef unless $self->check_stylename($style, $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 751 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 752 | 0 | $style->set_name($name); | |||||||||||||||||||||||||||||||||
| 753 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||
| 756 | sub insert_outline_style | ||||||||||||||||||||||||||||||||||
| 757 | { | ||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_outline_style: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 759 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | my $context = $self->select_style_context($style) or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | my $old = $self->get_style('outline'); $old && $old->delete; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 762 | 0 | $style->set_name(undef); | |||||||||||||||||||||||||||||||||
| 763 | 0 | $style->check_tag($style->required_tag); | |||||||||||||||||||||||||||||||||
| 764 | 0 | return $context->insert_element($style); | |||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||
| 767 | sub insert_default_style | ||||||||||||||||||||||||||||||||||
| 768 | { | ||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_default_style: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 770 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 771 | 0 | my $context = $self->get_element(STYLES, '//office:styles'); | |||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 773 | { | ||||||||||||||||||||||||||||||||||
| 774 | 0 | alert "Default style context not available"; | |||||||||||||||||||||||||||||||||
| 775 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 776 | } | ||||||||||||||||||||||||||||||||||
| 777 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 778 | 0 | ▶ | my $ds = $style->make_default or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 779 | 0 | my $old = $self->get_style($family); | |||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | $old->delete() if $old; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 781 | 0 | return $context->insert_element($ds); | |||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||
| 784 | sub insert_style | ||||||||||||||||||||||||||||||||||
| 785 | { | ||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_style: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 787 | 0 | my $style = shift; | |||||||||||||||||||||||||||||||||
| 788 | 0 | my $class = ref $style; | |||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | if ($class) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 790 | { | ||||||||||||||||||||||||||||||||||
| 791 | 0 | ▶ | if ($class eq 'ARRAY') | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||||||||
| 793 | 0 | $style = ODF::lpOD::Style->create(@$style); | |||||||||||||||||||||||||||||||||
| 794 | 0 | $class = ref $style; | |||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||
| 797 | 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")
| |||||||||||||||||||||||||||||||||||
| 798 | { | ||||||||||||||||||||||||||||||||||
| 799 | 0 | alert "Missing or wrong style element"; | |||||||||||||||||||||||||||||||||
| 800 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||
| 802 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 803 | 0 | my $family = $style->get_family; | |||||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | if (is_true($opt{default})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 805 | { | ||||||||||||||||||||||||||||||||||
| 806 | 0 | return $self->insert_default_style($style, $family); | |||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||
| 808 | 0 | given ($family) | |||||||||||||||||||||||||||||||||
| 809 | { | ||||||||||||||||||||||||||||||||||
| 810 | when ([ | ||||||||||||||||||||||||||||||||||
| 811 | 'text', 'paragraph', 'graphic', 'gradient', | ||||||||||||||||||||||||||||||||||
| 812 | 'drawing page', 'number', 'currency', 'date' | ||||||||||||||||||||||||||||||||||
| 813 | ]) | ||||||||||||||||||||||||||||||||||
| 814 | 0 | { | |||||||||||||||||||||||||||||||||
| 815 | 0 | return $self->insert_regular_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||
| 817 | when (/(list|master|page layout)/) | ||||||||||||||||||||||||||||||||||
| 818 | 0 | { | |||||||||||||||||||||||||||||||||
| 819 | 0 | return $self->insert_special_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||
| 821 | when ('outline') | ||||||||||||||||||||||||||||||||||
| 822 | 0 | { | |||||||||||||||||||||||||||||||||
| 823 | 0 | return $self->insert_outline_style($style); | |||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||
| 825 | when (/^table/) | ||||||||||||||||||||||||||||||||||
| 826 | 0 | { | |||||||||||||||||||||||||||||||||
| 827 | 0 | ▶ | $opt{automatic} = TRUE unless exists $opt{automatic}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | $opt{part} = CONTENT unless $opt{part}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 829 | 0 | return $self->insert_special_style($style, %opt); | |||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||
| 831 | default | ||||||||||||||||||||||||||||||||||
| 832 | 0 | { | |||||||||||||||||||||||||||||||||
| 833 | 0 | alert "Not supported"; return undef; | |||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||
| 838 | #--- bulk style replacement by import from another document ------------------ | ||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||
| 840 | sub substitute_styles | ||||||||||||||||||||||||||||||||||
| 841 | { | ||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_styles: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 843 | 0 | my $from = shift; | |||||||||||||||||||||||||||||||||
| 844 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 845 | ( | ||||||||||||||||||||||||||||||||||
| 846 | common => TRUE, | ||||||||||||||||||||||||||||||||||
| 847 | master => TRUE, | ||||||||||||||||||||||||||||||||||
| 848 | automatic => TRUE, | ||||||||||||||||||||||||||||||||||
| 849 | fonts => TRUE, | ||||||||||||||||||||||||||||||||||
| 850 | @_ | ||||||||||||||||||||||||||||||||||
| 851 | ); | ||||||||||||||||||||||||||||||||||
| 852 | 0 | my $source; | |||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if (ref $from) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 854 | { | ||||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | $source = $from if $from->isa('ODF::lpOD::Document'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||
| 857 | else | ||||||||||||||||||||||||||||||||||
| 858 | { | ||||||||||||||||||||||||||||||||||
| 859 | 0 | $source = ODF::lpOD::Document->new(template => $from); | |||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | unless ($source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 862 | { | ||||||||||||||||||||||||||||||||||
| 863 | 0 | alert "Malformed or not available source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||
| 866 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 867 | 0 | foreach my $part ($self->get_part(CONTENT), $self->get_part(STYLES)) | |||||||||||||||||||||||||||||||||
| 868 | { | ||||||||||||||||||||||||||||||||||
| 869 | 0 | $count += $part->substitute_styles($source, %opt); | |||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||
| 872 | 0 | ▶ | $source->forget unless ref $from; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 873 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||
| 876 | #--- document variable handling ---------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||
| 878 | sub get_user_variables | ||||||||||||||||||||||||||||||||||
| 879 | { | ||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_variables: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 881 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 882 | 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
| |||||||||||||||||||||||||||||||||||
| 883 | 0 | return $context->get_elements('text:user-field-decl'); | |||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||
| 886 | sub get_simple_variables | ||||||||||||||||||||||||||||||||||
| 887 | { | ||||||||||||||||||||||||||||||||||
| 888 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_simple_variables: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 889 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 890 | 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
| |||||||||||||||||||||||||||||||||||
| 891 | 0 | return $context->get_elements('text:variable-decl'); | |||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||
| 894 | sub get_variables | ||||||||||||||||||||||||||||||||||
| 895 | { | ||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_variables: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 897 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 898 | 0 | given ($opt{class}) | |||||||||||||||||||||||||||||||||
| 899 | { | ||||||||||||||||||||||||||||||||||
| 900 | when (undef) | ||||||||||||||||||||||||||||||||||
| 901 | 0 | { | |||||||||||||||||||||||||||||||||
| 902 | return ( | ||||||||||||||||||||||||||||||||||
| 903 | 0 | $self->get_user_variables(@_), | |||||||||||||||||||||||||||||||||
| 904 | $self->get_simple_variables(@_) | ||||||||||||||||||||||||||||||||||
| 905 | ); | ||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||
| 907 | when ('user') | ||||||||||||||||||||||||||||||||||
| 908 | 0 | { | |||||||||||||||||||||||||||||||||
| 909 | 0 | return $self->get_user_variables; | |||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||
| 911 | when ('simple') | ||||||||||||||||||||||||||||||||||
| 912 | 0 | { | |||||||||||||||||||||||||||||||||
| 913 | 0 | return $self->get_simple_variables; | |||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||
| 915 | default | ||||||||||||||||||||||||||||||||||
| 916 | 0 | { | |||||||||||||||||||||||||||||||||
| 917 | 0 | alert "Unknown variable class $opt{class}"; | |||||||||||||||||||||||||||||||||
| 918 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 919 | } | ||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||
| 923 | sub get_variable | ||||||||||||||||||||||||||||||||||
| 924 | { | ||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_variable: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 926 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 927 | 0 | my %opt = ( class => 'user', @_ ); | |||||||||||||||||||||||||||||||||
| 928 | 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
| |||||||||||||||||||||||||||||||||||
| 929 | 0 | my $tag; | |||||||||||||||||||||||||||||||||
| 930 | 0 | given ($opt{class}) | |||||||||||||||||||||||||||||||||
| 931 | { | ||||||||||||||||||||||||||||||||||
| 932 | when (undef) | ||||||||||||||||||||||||||||||||||
| 933 | 0 | { | |||||||||||||||||||||||||||||||||
| 934 | 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')
| |||||||||||||||||||||||||||||||||||
| 935 | || | ||||||||||||||||||||||||||||||||||
| 936 | $self->get_variable($name, class => 'simple'); | ||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||
| 938 | when ('user') | ||||||||||||||||||||||||||||||||||
| 939 | 0 | { | |||||||||||||||||||||||||||||||||
| 940 | 0 | $tag = 'text:user-field-decl'; | |||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||
| 942 | when ('simple') | ||||||||||||||||||||||||||||||||||
| 943 | 0 | { | |||||||||||||||||||||||||||||||||
| 944 | 0 | $tag = 'text:variable-decl'; | |||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||
| 946 | default | ||||||||||||||||||||||||||||||||||
| 947 | 0 | { | |||||||||||||||||||||||||||||||||
| 948 | 0 | alert "Wrong variable class"; return undef; | |||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||
| 952 | 0 | return $context->get_element | |||||||||||||||||||||||||||||||||
| 953 | ($tag, attribute => 'name', value => $name); | ||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||
| 956 | sub set_variable | ||||||||||||||||||||||||||||||||||
| 957 | { | ||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_variable: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 959 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 961 | { | ||||||||||||||||||||||||||||||||||
| 962 | 0 | alert "Missing variable name"; return FALSE; | |||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | if ($self->get_variable($name, class => undef)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||||
| 966 | 0 | alert "Variable $name already exists"; return FALSE; | |||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||
| 968 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 969 | ( | ||||||||||||||||||||||||||||||||||
| 970 | name => $name, | ||||||||||||||||||||||||||||||||||
| 971 | class => 'user', | ||||||||||||||||||||||||||||||||||
| 972 | type => 'string', | ||||||||||||||||||||||||||||||||||
| 973 | @_ | ||||||||||||||||||||||||||||||||||
| 974 | ); | ||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||
| 976 | 0 | my $class = $opt{class}; | |||||||||||||||||||||||||||||||||
| 977 | 0 | my $context = $opt{context}; | |||||||||||||||||||||||||||||||||
| 978 | 0 | delete @opt{qw(class context)}; | |||||||||||||||||||||||||||||||||
| 979 | 0 | my $var; | |||||||||||||||||||||||||||||||||
| 980 | 0 | given ($class) | |||||||||||||||||||||||||||||||||
| 981 | { | ||||||||||||||||||||||||||||||||||
| 982 | when ('user') | ||||||||||||||||||||||||||||||||||
| 983 | 0 | { | |||||||||||||||||||||||||||||||||
| 984 | 0 | $var = ODF::lpOD::UserVariable->create(%opt); | |||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||
| 986 | when ('simple') | ||||||||||||||||||||||||||||||||||
| 987 | 0 | { | |||||||||||||||||||||||||||||||||
| 988 | 0 | $var = ODF::lpOD::SimpleVariable->create(%opt); | |||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||
| 990 | default | ||||||||||||||||||||||||||||||||||
| 991 | 0 | { | |||||||||||||||||||||||||||||||||
| 992 | 0 | alert "Unsupported variable class"; | |||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||
| 995 | 0 | ▶ | if ($var) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 996 | { | ||||||||||||||||||||||||||||||||||
| 997 | 0 | my $tag = $var->context_tag; | |||||||||||||||||||||||||||||||||
| 998 | 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)
| |||||||||||||||||||||||||||||||||||
| 999 | 0 | ▶ | if ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1000 | { | ||||||||||||||||||||||||||||||||||
| 1001 | 0 | $context->append_element($var); | |||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||
| 1003 | else | ||||||||||||||||||||||||||||||||||
| 1004 | { | ||||||||||||||||||||||||||||||||||
| 1005 | 0 | alert "Unknown object insertion context"; | |||||||||||||||||||||||||||||||||
| 1006 | 0 | $var->delete; $var = undef; | |||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||||||||
| 1009 | 0 | return $var; | |||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||
| 1012 | #--- table of content handling ----------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||
| 1014 | sub get_tocs | ||||||||||||||||||||||||||||||||||
| 1015 | { | ||||||||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tocs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1017 | 0 | return $self->get_part(CONTENT)->get_tocs(@_); | |||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||
| 1020 | sub get_toc | ||||||||||||||||||||||||||||||||||
| 1021 | { | ||||||||||||||||||||||||||||||||||
| 1022 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_toc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1023 | 0 | return $self->get_part(CONTENT)->get_toc(@_); | |||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||
| 1026 | #--- named range handling ---------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||
| 1028 | sub get_named_range | ||||||||||||||||||||||||||||||||||
| 1029 | { | ||||||||||||||||||||||||||||||||||
| 1030 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_named_range: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1031 | 0 | return $self->get_part(CONTENT)->get_named_range(@_); | |||||||||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||
| 1034 | sub set_named_range | ||||||||||||||||||||||||||||||||||
| 1035 | { | ||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_named_range: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1037 | 0 | return $self->get_part(CONTENT)->set_named_range(@_); | |||||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||
| 1040 | #--- font declaration -------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||
| 1042 | sub set_font_declaration | ||||||||||||||||||||||||||||||||||
| 1043 | { | ||||||||||||||||||||||||||||||||||
| 1044 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_font_declaration: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 1045 | return ( | ||||||||||||||||||||||||||||||||||
| 1046 | 0 | $self->get_part(CONTENT)->set_font_declaration(@_), | |||||||||||||||||||||||||||||||||
| 1047 | $self->get_part(STYLES)->set_font_declaration(@_) | ||||||||||||||||||||||||||||||||||
| 1048 | ); | ||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||
| 1051 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1052 | package ODF::lpOD::Container; | ||||||||||||||||||||||||||||||||||
| 1053 | 2 | our $VERSION = '1.004'; | |||||||||||||||||||||||||||||||||
| 1054 | 2 | ▶ | use constant PACKAGE_DATE => '2012-02-19T19:08:31'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1055 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1056 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1057 | 2 | ▶ | use Archive::Zip 1.30 qw ( :DEFAULT :CONSTANTS :ERROR_CODES ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1058 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||
| 1060 | BEGIN { | ||||||||||||||||||||||||||||||||||
| 1061 | 2 | ▶ | *forget = *DESTROY; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1062 | 2 | *get_parts = *parts; | |||||||||||||||||||||||||||||||||
| 1063 | 2 | *add_part = *add_file; | |||||||||||||||||||||||||||||||||
| 1064 | } | ||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||
| 1066 | #=== parameters ============================================================== | ||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||
| 1068 | 2 | our %ODF_PARTS = | |||||||||||||||||||||||||||||||||
| 1069 | ( | ||||||||||||||||||||||||||||||||||
| 1070 | content => CONTENT, | ||||||||||||||||||||||||||||||||||
| 1071 | styles => STYLES, | ||||||||||||||||||||||||||||||||||
| 1072 | meta => META, | ||||||||||||||||||||||||||||||||||
| 1073 | manifest => MANIFEST, | ||||||||||||||||||||||||||||||||||
| 1074 | settings => SETTINGS, | ||||||||||||||||||||||||||||||||||
| 1075 | mimetype => MIMETYPE | ||||||||||||||||||||||||||||||||||
| 1076 | ); | ||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||
| 1078 | 2 | our %PARTS_ODF = reverse %ODF_PARTS; | |||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||
| 1080 | sub translate_part_name | ||||||||||||||||||||||||||||||||||
| 1081 | { | ||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Subroutine
translate_part_name: not called CC=3 SCAR=24.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1083 | 0 | ▶ | return $ODF_PARTS{$name} ? $ODF_PARTS{$name} : $name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||
| 1086 | 2 | our %COMPRESSION = # compression rule for some parts | |||||||||||||||||||||||||||||||||
| 1087 | ( | ||||||||||||||||||||||||||||||||||
| 1088 | MIMETYPE => FALSE, | ||||||||||||||||||||||||||||||||||
| 1089 | META => FALSE, | ||||||||||||||||||||||||||||||||||
| 1090 | CONTENT => TRUE, | ||||||||||||||||||||||||||||||||||
| 1091 | STYLES => TRUE, | ||||||||||||||||||||||||||||||||||
| 1092 | MANIFEST => TRUE, | ||||||||||||||||||||||||||||||||||
| 1093 | SETTINGS => TRUE | ||||||||||||||||||||||||||||||||||
| 1094 | ); | ||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||
| 1096 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||
| 1098 | sub get_from_uri | ||||||||||||||||||||||||||||||||||
| 1099 | { | ||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | return ODF::lpOD::Container->new(uri => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
get_from_uri: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||
| 1103 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||
| 1105 | sub create_from_template | ||||||||||||||||||||||||||||||||||
| 1106 | { | ||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | return ODF::lpOD::Container->new(template => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
create_from_template: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||||||||
| 1110 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||
| 1112 | sub create | ||||||||||||||||||||||||||||||||||
| 1113 | { | ||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | return ODF::lpOD::Container->new(type => shift); | ||||||||||||||||||||||||||||||||
|
Subroutine
create: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||
| 1117 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||
| 1119 | sub new | ||||||||||||||||||||||||||||||||||
| 1120 | { | ||||||||||||||||||||||||||||||||||
| 1121 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 1122 | 0 | my $self = | |||||||||||||||||||||||||||||||||
| 1123 | { | ||||||||||||||||||||||||||||||||||
| 1124 | type => undef, | ||||||||||||||||||||||||||||||||||
| 1125 | uri => undef, | ||||||||||||||||||||||||||||||||||
| 1126 | read_only => undef, | ||||||||||||||||||||||||||||||||||
| 1127 | zip => undef, | ||||||||||||||||||||||||||||||||||
| 1128 | deleted => [], | ||||||||||||||||||||||||||||||||||
| 1129 | stored => {}, | ||||||||||||||||||||||||||||||||||
| 1130 | @_ | ||||||||||||||||||||||||||||||||||
| 1131 | }; | ||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | if ($self->{type}) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 1134 | { | ||||||||||||||||||||||||||||||||||
| 1135 | $self->{uri} = ODF::lpOD::Common::template($self->{type}) | ||||||||||||||||||||||||||||||||||
| 1136 | 0 | ▶ | or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1137 | 0 | $self->{read_only} = TRUE; | |||||||||||||||||||||||||||||||||
| 1138 | 0 | $self->{create} = TRUE; | |||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||
| 1140 | elsif ($self->{template}) | ||||||||||||||||||||||||||||||||||
| 1141 | { | ||||||||||||||||||||||||||||||||||
| 1142 | 0 | $self->{uri} = $self->{template}; | |||||||||||||||||||||||||||||||||
| 1143 | 0 | $self->{read_only} = TRUE; | |||||||||||||||||||||||||||||||||
| 1144 | 0 | $self->{create} = FALSE; | |||||||||||||||||||||||||||||||||
| 1145 | } | ||||||||||||||||||||||||||||||||||
| 1146 | else | ||||||||||||||||||||||||||||||||||
| 1147 | { | ||||||||||||||||||||||||||||||||||
| 1148 | 0 | $self->{create} = FALSE; | |||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||
| 1151 | 0 | my $source = $self->{uri}; | |||||||||||||||||||||||||||||||||
| 1152 | my $zip = defined $self->{zip} ? | ||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | $self->{zip} : Archive::Zip->new; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | if (UNIVERSAL::isa($source, 'IO::File')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1156 | { | ||||||||||||||||||||||||||||||||||
| 1157 | 0 | ▶ | if ($zip->readFromFileHandle($source) != AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1158 | { | ||||||||||||||||||||||||||||||||||
| 1159 | 0 | alert("Handle read error"); | |||||||||||||||||||||||||||||||||
| 1160 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||
| 1162 | } | ||||||||||||||||||||||||||||||||||
| 1163 | else | ||||||||||||||||||||||||||||||||||
| 1164 | { | ||||||||||||||||||||||||||||||||||
| 1165 | 0 | ▶ | unless (-r -f -e $source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1166 | { | ||||||||||||||||||||||||||||||||||
| 1167 | 0 | alert("Missing source"); | |||||||||||||||||||||||||||||||||
| 1168 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | if ($zip->read($source) != AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1171 | { | ||||||||||||||||||||||||||||||||||
| 1172 | 0 | alert("File read error"); | |||||||||||||||||||||||||||||||||
| 1173 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||
| 1177 | 0 | $self->{zip} = $zip; | |||||||||||||||||||||||||||||||||
| 1178 | 0 | bless $self, $class; | |||||||||||||||||||||||||||||||||
| 1179 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 1180 | } | ||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||
| 1182 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||
| 1184 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 1185 | { | ||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1187 | 0 | undef $self->{zip}; | |||||||||||||||||||||||||||||||||
| 1188 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||
| 1191 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||
| 1193 | sub get_mimetype | ||||||||||||||||||||||||||||||||||
| 1194 | { | ||||||||||||||||||||||||||||||||||
| 1195 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_mimetype: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1196 | 0 | return $self->get_part(MIMETYPE); | |||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||
| 1199 | sub set_mimetype | ||||||||||||||||||||||||||||||||||
| 1200 | { | ||||||||||||||||||||||||||||||||||
| 1201 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_mimetype: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1202 | 0 | return $self->set_part( | |||||||||||||||||||||||||||||||||
| 1203 | MIMETYPE, shift, compress => FALSE, string => TRUE | ||||||||||||||||||||||||||||||||||
| 1204 | ); | ||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||
| 1207 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||
| 1209 | sub parts | ||||||||||||||||||||||||||||||||||
| 1210 | { | ||||||||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
parts: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1212 | 0 | return $self->{zip}->memberNames; | |||||||||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||
| 1215 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||
| 1217 | sub contains | ||||||||||||||||||||||||||||||||||
| 1218 | { | ||||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
contains: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1220 | 0 | ▶ | my $part_name = shift or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | return (grep $_ eq $part_name, $self->parts) ? TRUE : FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||
| 1224 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||
| 1226 | sub raw_set_part | ||||||||||||||||||||||||||||||||||
| 1227 | { | ||||||||||||||||||||||||||||||||||
| 1228 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
raw_set_part: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 1229 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||
| 1231 | 0 | my $data = shift; | |||||||||||||||||||||||||||||||||
| 1232 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1233 | ( | ||||||||||||||||||||||||||||||||||
| 1234 | string => TRUE, | ||||||||||||||||||||||||||||||||||
| 1235 | compress => undef, | ||||||||||||||||||||||||||||||||||
| 1236 | compression_method => COMPRESSION_DEFLATED, | ||||||||||||||||||||||||||||||||||
| 1237 | compression_level => COMPRESSION_LEVEL_BEST_COMPRESSION, | ||||||||||||||||||||||||||||||||||
| 1238 | @_ | ||||||||||||||||||||||||||||||||||
| 1239 | ); | ||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||
| 1241 | 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}
| |||||||||||||||||||||||||||||||||||
| 1242 | 0 | my $zip = $self->{zip}; | |||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | my $buffer = is_true($opt{string}) ? $data : load_file($data, ':raw'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1244 | 0 | my $p = $zip->addString($buffer, $part_name); | |||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||
| 1246 | 0 | ▶ | if ($p) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1247 | { | ||||||||||||||||||||||||||||||||||
| 1248 | 0 | ▶ | if (is_true($compress)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1249 | { | ||||||||||||||||||||||||||||||||||
| 1250 | 0 | $p->desiredCompressionMethod($opt{compression_method}); | |||||||||||||||||||||||||||||||||
| 1251 | 0 | $p->desiredCompressionLevel($opt{compression_level}); | |||||||||||||||||||||||||||||||||
| 1252 | } | ||||||||||||||||||||||||||||||||||
| 1253 | else | ||||||||||||||||||||||||||||||||||
| 1254 | { | ||||||||||||||||||||||||||||||||||
| 1255 | 0 | $p->desiredCompressionMethod(COMPRESSION_STORED); | |||||||||||||||||||||||||||||||||
| 1256 | } | ||||||||||||||||||||||||||||||||||
| 1257 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||
| 1259 | else | ||||||||||||||||||||||||||||||||||
| 1260 | { | ||||||||||||||||||||||||||||||||||
| 1261 | 0 | alert("Data storage error"); | |||||||||||||||||||||||||||||||||
| 1262 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||
| 1265 | |||||||||||||||||||||||||||||||||||
| 1266 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1267 | |||||||||||||||||||||||||||||||||||
| 1268 | sub raw_del_part | ||||||||||||||||||||||||||||||||||
| 1269 | { | ||||||||||||||||||||||||||||||||||
| 1270 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
raw_del_part: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1271 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1272 | 0 | ▶ | return FALSE unless $self->contains($part_name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||
| 1274 | 0 | my $status = $self->{zip}->removeMember($part_name); | |||||||||||||||||||||||||||||||||
| 1275 | 0 | ▶ | unless ($status) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1276 | { | ||||||||||||||||||||||||||||||||||
| 1277 | 0 | alert("$part_name removal failed"); | |||||||||||||||||||||||||||||||||
| 1278 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||||||||
| 1280 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1281 | } | ||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||
| 1283 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||
| 1285 | sub set_part | ||||||||||||||||||||||||||||||||||
| 1286 | { | ||||||||||||||||||||||||||||||||||
| 1287 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_part: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1288 | 0 | ▶ | my $part_name = translate_part_name(shift) or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1289 | 0 | ▶ | my $data = shift // ""; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 1290 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1291 | ( | ||||||||||||||||||||||||||||||||||
| 1292 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 1293 | compress => FALSE, | ||||||||||||||||||||||||||||||||||
| 1294 | @_ | ||||||||||||||||||||||||||||||||||
| 1295 | ); | ||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||
| 1297 | 0 | $self->{stored}{$part_name}{data} = $data; | |||||||||||||||||||||||||||||||||
| 1298 | 0 | $self->{stored}{$part_name}{string} = $opt{string}; | |||||||||||||||||||||||||||||||||
| 1299 | 0 | $self->{stored}{$part_name}{compress} = $opt{compress}; | |||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||
| 1301 | 0 | $self->del_part($part_name); | |||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||
| 1303 | 0 | return $part_name; | |||||||||||||||||||||||||||||||||
| 1304 | } | ||||||||||||||||||||||||||||||||||
| 1305 | |||||||||||||||||||||||||||||||||||
| 1306 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1307 | |||||||||||||||||||||||||||||||||||
| 1308 | sub add_file | ||||||||||||||||||||||||||||||||||
| 1309 | { | ||||||||||||||||||||||||||||||||||
| 1310 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
add_file: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1311 | 0 | ▶ | my $path = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1312 | 0 | my $destination = shift; | |||||||||||||||||||||||||||||||||
| 1313 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1314 | ( | ||||||||||||||||||||||||||||||||||
| 1315 | string => FALSE, | ||||||||||||||||||||||||||||||||||
| 1316 | @_ | ||||||||||||||||||||||||||||||||||
| 1317 | ); | ||||||||||||||||||||||||||||||||||
| 1318 | 0 | ▶ | unless ($destination) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1319 | { | ||||||||||||||||||||||||||||||||||
| 1320 | 0 | my $mimetype = file_type($path); | |||||||||||||||||||||||||||||||||
| 1321 | 0 | my $filename = file_parse($path); | |||||||||||||||||||||||||||||||||
| 1322 | 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/
| |||||||||||||||||||||||||||||||||||
| 1323 | { | ||||||||||||||||||||||||||||||||||
| 1324 | 0 | $destination = 'Pictures/' . $filename; | |||||||||||||||||||||||||||||||||
| 1325 | 0 | $opt{compress} = FALSE; | |||||||||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||||||||
| 1327 | else | ||||||||||||||||||||||||||||||||||
| 1328 | { | ||||||||||||||||||||||||||||||||||
| 1329 | 0 | $destination = $filename; | |||||||||||||||||||||||||||||||||
| 1330 | 0 | $opt{compress} = TRUE; | |||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||
| 1332 | } | ||||||||||||||||||||||||||||||||||
| 1333 | 0 | return $self->set_part($destination, $path, %opt); | |||||||||||||||||||||||||||||||||
| 1334 | } | ||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||
| 1336 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||
| 1338 | sub get_stored_part | ||||||||||||||||||||||||||||||||||
| 1339 | { | ||||||||||||||||||||||||||||||||||
| 1340 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_stored_part: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1341 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1342 | 0 | return $self->{stored}{$part_name}; | |||||||||||||||||||||||||||||||||
| 1343 | } | ||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||
| 1345 | sub get_part | ||||||||||||||||||||||||||||||||||
| 1346 | { | ||||||||||||||||||||||||||||||||||
| 1347 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_part: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1348 | 0 | my $part_name = translate_part_name(shift); | |||||||||||||||||||||||||||||||||
| 1349 | 0 | ▶ | unless ($part_name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1350 | { | ||||||||||||||||||||||||||||||||||
| 1351 | 0 | alert "Missing part name"; | |||||||||||||||||||||||||||||||||
| 1352 | 0 | return FALSE | |||||||||||||||||||||||||||||||||
| 1353 | } | ||||||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | unless ($self->contains($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1355 | { | ||||||||||||||||||||||||||||||||||
| 1356 | 0 | alert("Unknown part $part_name"); | |||||||||||||||||||||||||||||||||
| 1357 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1358 | } | ||||||||||||||||||||||||||||||||||
| 1359 | 0 | my ($result, $status) = $self->{'zip'}->contents($part_name); | |||||||||||||||||||||||||||||||||
| 1360 | 0 | ▶ | return $status == AZ_OK ? $result : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1361 | } | ||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||
| 1363 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||
| 1365 | sub del_part | ||||||||||||||||||||||||||||||||||
| 1366 | { | ||||||||||||||||||||||||||||||||||
| 1367 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
del_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | my $part_name = translate_part_name(shift) or return FALSE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1369 | 0 | push @{$self->{deleted}}, $part_name; | |||||||||||||||||||||||||||||||||
| 1370 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1371 | } | ||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||
| 1373 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||
| 1375 | sub save | ||||||||||||||||||||||||||||||||||
| 1376 | { | ||||||||||||||||||||||||||||||||||
| 1377 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||
| 1378 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1379 | ( | ||||||||||||||||||||||||||||||||||
| 1380 | target => undef, | ||||||||||||||||||||||||||||||||||
| 1381 | packaging => 'zip', | ||||||||||||||||||||||||||||||||||
| 1382 | @_ | ||||||||||||||||||||||||||||||||||
| 1383 | ); | ||||||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | if (is_true($self->{read_only})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1385 | { | ||||||||||||||||||||||||||||||||||
| 1386 | 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"}
| |||||||||||||||||||||||||||||||||||
| 1387 | (defined $opt{target}) && | ||||||||||||||||||||||||||||||||||
| 1388 | $opt{target} ne $self->{uri} | ||||||||||||||||||||||||||||||||||
| 1389 | ) | ||||||||||||||||||||||||||||||||||
| 1390 | { | ||||||||||||||||||||||||||||||||||
| 1391 | 0 | alert("Read-only container"); | |||||||||||||||||||||||||||||||||
| 1392 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||
| 1394 | } | ||||||||||||||||||||||||||||||||||
| 1395 | 0 | my $target = $opt{target}; | |||||||||||||||||||||||||||||||||
| 1396 | 0 | my $packaging = $opt{packaging}; | |||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||
| 1398 | 0 | $self->raw_del_part($_) for @{$self->{deleted}}; | |||||||||||||||||||||||||||||||||
| 1399 | |||||||||||||||||||||||||||||||||||
| 1400 | 0 | foreach my $part_name (keys %{$self->{stored}}) | |||||||||||||||||||||||||||||||||
| 1401 | { | ||||||||||||||||||||||||||||||||||
| 1402 | 0 | my $data = $self->{stored}{$part_name}{data}; | |||||||||||||||||||||||||||||||||
| 1403 | 0 | my $compress = $self->{stored}{$part_name}{compress}; | |||||||||||||||||||||||||||||||||
| 1404 | 0 | my $string = $self->{stored}{$part_name}{string}; | |||||||||||||||||||||||||||||||||
| 1405 | 0 | $self->raw_del_part($part_name); | |||||||||||||||||||||||||||||||||
| 1406 | 0 | $self->raw_set_part | |||||||||||||||||||||||||||||||||
| 1407 | ( | ||||||||||||||||||||||||||||||||||
| 1408 | $part_name, $data, | ||||||||||||||||||||||||||||||||||
| 1409 | compress => $compress, | ||||||||||||||||||||||||||||||||||
| 1410 | string => $string | ||||||||||||||||||||||||||||||||||
| 1411 | ); | ||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||
| 1414 | 0 | my $status = undef; | |||||||||||||||||||||||||||||||||
| 1415 | 0 | ▶ | unless (defined $target) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 1416 | { | ||||||||||||||||||||||||||||||||||
| 1417 | 0 | $status = $self->{zip}->overwrite(); | |||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||
| 1419 | elsif (UNIVERSAL::isa($target, 'IO::File')) | ||||||||||||||||||||||||||||||||||
| 1420 | { | ||||||||||||||||||||||||||||||||||
| 1421 | 0 | $status = $self->{zip}->writeToFileHandle($target); | |||||||||||||||||||||||||||||||||
| 1422 | } | ||||||||||||||||||||||||||||||||||
| 1423 | else | ||||||||||||||||||||||||||||||||||
| 1424 | { | ||||||||||||||||||||||||||||||||||
| 1425 | 0 | $status = $self->{zip}->writeToFileNamed($target); | |||||||||||||||||||||||||||||||||
| 1426 | } | ||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||
| 1428 | 0 | ▶ | unless ($status == AZ_OK) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1429 | { | ||||||||||||||||||||||||||||||||||
| 1430 | 0 | alert("Zip I/O error"); | |||||||||||||||||||||||||||||||||
| 1431 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1432 | } | ||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||
| 1434 | 0 | $self->{deleted} = []; | |||||||||||||||||||||||||||||||||
| 1435 | 0 | $self->{stored} = {}; | |||||||||||||||||||||||||||||||||
| 1436 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1437 | } | ||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||
| 1439 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1440 | package ODF::lpOD::XMLPart; | ||||||||||||||||||||||||||||||||||
| 1441 | 2 | our $VERSION = '1.007'; | |||||||||||||||||||||||||||||||||
| 1442 | 2 | ▶ | use constant PACKAGE_DATE => '2012-05-15T08:36:28'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1443 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1444 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||
| 1446 | BEGIN { | ||||||||||||||||||||||||||||||||||
| 1447 | 2 | ▶ | *forget = *DESTROY; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1448 | 2 | *body = *get_body; | |||||||||||||||||||||||||||||||||
| 1449 | 2 | *get_container = *container; | |||||||||||||||||||||||||||||||||
| 1450 | 2 | *get_document = *document; | |||||||||||||||||||||||||||||||||
| 1451 | 2 | *root = *get_root; | |||||||||||||||||||||||||||||||||
| 1452 | 2 | *get_element_list = *get_elements; | |||||||||||||||||||||||||||||||||
| 1453 | 2 | *export = *serialize; | |||||||||||||||||||||||||||||||||
| 1454 | } | ||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||
| 1456 | sub class_of | ||||||||||||||||||||||||||||||||||
| 1457 | { | ||||||||||||||||||||||||||||||||||
| 1458 | 0 | ▶ | my $part = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
class_of: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | return ref $part if ref $part; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1460 | 0 | given($part) | |||||||||||||||||||||||||||||||||
| 1461 | { | ||||||||||||||||||||||||||||||||||
| 1462 | 0 | when (CONTENT) { return 'ODF::lpOD::Content' } | |||||||||||||||||||||||||||||||||
| 1463 | 0 | when (STYLES) { return 'ODF::lpOD::Styles' } | |||||||||||||||||||||||||||||||||
| 1464 | 0 | when (META) { return 'ODF::lpOD::Meta' } | |||||||||||||||||||||||||||||||||
| 1465 | 0 | when (SETTINGS) { return 'ODF::lpOD::Settings' } | |||||||||||||||||||||||||||||||||
| 1466 | 0 | when (MANIFEST) { return 'ODF::lpOD::Manifest' } | |||||||||||||||||||||||||||||||||
| 1467 | 0 | default { return undef } | |||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||
| 1470 | |||||||||||||||||||||||||||||||||||
| 1471 | 2 | our %CLASS = | |||||||||||||||||||||||||||||||||
| 1472 | ( | ||||||||||||||||||||||||||||||||||
| 1473 | content => 'ODF::lpOD::Content', | ||||||||||||||||||||||||||||||||||
| 1474 | styles => 'ODF::lpOD::Styles', | ||||||||||||||||||||||||||||||||||
| 1475 | meta => 'ODF::lpOD::Meta', | ||||||||||||||||||||||||||||||||||
| 1476 | manifest => 'ODF::lpOD::Manifest', | ||||||||||||||||||||||||||||||||||
| 1477 | settings => 'ODF::lpOD::Settings' | ||||||||||||||||||||||||||||||||||
| 1478 | ); | ||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||
| 1480 | ▶ | sub pre_load {} | |||||||||||||||||||||||||||||||||
|
Subroutine
pre_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1481 | sub post_load | ||||||||||||||||||||||||||||||||||
| 1482 | { | ||||||||||||||||||||||||||||||||||
| 1483 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1484 | 0 | $self->get_root->set_classes; | |||||||||||||||||||||||||||||||||
| 1485 | } | ||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||
| 1487 | #=== exported part =========================================================== | ||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||
| 1489 | sub get | ||||||||||||||||||||||||||||||||||
| 1490 | { | ||||||||||||||||||||||||||||||||||
| 1491 | 0 | ▶ | my $container = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1492 | 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")
| |||||||||||||||||||||||||||||||||||
| 1493 | { | ||||||||||||||||||||||||||||||||||
| 1494 | 0 | alert "Missing or not valid container"; | |||||||||||||||||||||||||||||||||
| 1495 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||
| 1497 | 0 | my $part_name = shift; | |||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | unless (class_of($part_name)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1499 | { | ||||||||||||||||||||||||||||||||||
| 1500 | 0 | alert "Missing or unknown document part"; | |||||||||||||||||||||||||||||||||
| 1501 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1502 | } | ||||||||||||||||||||||||||||||||||
| 1503 | 0 | return ODF::lpOD::XMLPart->new | |||||||||||||||||||||||||||||||||
| 1504 | ( | ||||||||||||||||||||||||||||||||||
| 1505 | part => $part_name, | ||||||||||||||||||||||||||||||||||
| 1506 | container => $container, | ||||||||||||||||||||||||||||||||||
| 1507 | @_ | ||||||||||||||||||||||||||||||||||
| 1508 | ); | ||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||
| 1511 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1512 | #--- constructor and associated utilities ------------------------------------ | ||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||
| 1514 | sub new | ||||||||||||||||||||||||||||||||||
| 1515 | { | ||||||||||||||||||||||||||||||||||
| 1516 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||
| 1517 | 0 | my $self = | |||||||||||||||||||||||||||||||||
| 1518 | { | ||||||||||||||||||||||||||||||||||
| 1519 | container => undef, | ||||||||||||||||||||||||||||||||||
| 1520 | part => undef, | ||||||||||||||||||||||||||||||||||
| 1521 | load => TRUE, | ||||||||||||||||||||||||||||||||||
| 1522 | elt_class => 'ODF::lpOD::Element', | ||||||||||||||||||||||||||||||||||
| 1523 | twig => undef, | ||||||||||||||||||||||||||||||||||
| 1524 | context => undef, | ||||||||||||||||||||||||||||||||||
| 1525 | @_ | ||||||||||||||||||||||||||||||||||
| 1526 | }; | ||||||||||||||||||||||||||||||||||
| 1527 | |||||||||||||||||||||||||||||||||||
| 1528 | 0 | ▶ | unless (defined $self->{update}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1529 | { | ||||||||||||||||||||||||||||||||||
| 1530 | 0 | ▶ | $self->{update} = $self->{roots} ? FALSE : TRUE; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||
| 1532 | 0 | my $part_class = class_of($self->{part}); | |||||||||||||||||||||||||||||||||
| 1533 | 0 | ▶ | unless ($class) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1534 | { | ||||||||||||||||||||||||||||||||||
| 1535 | 0 | alert "Unknown ODF XML part"; return FALSE; | |||||||||||||||||||||||||||||||||
| 1536 | } | ||||||||||||||||||||||||||||||||||
| 1537 | 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
| |||||||||||||||||||||||||||||||||||
| 1538 | 0 | ▶ | $self->{pretty_print} = PRETTY_PRINT if is_true($self->{pretty}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1539 | $self->{twig} //= XML::Twig->new # twig init | ||||||||||||||||||||||||||||||||||
| 1540 | ( | ||||||||||||||||||||||||||||||||||
| 1541 | twig_handlers => $self->{handlers}, | ||||||||||||||||||||||||||||||||||
| 1542 | twig_roots => $self->{roots}, | ||||||||||||||||||||||||||||||||||
| 1543 | elt_class => $self->{elt_class}, | ||||||||||||||||||||||||||||||||||
| 1544 | pretty_print => $self->{pretty_print}, | ||||||||||||||||||||||||||||||||||
| 1545 | 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)
| |||||||||||||||||||||||||||||||||||
| 1546 | id => $ODF::lpOD::Common::LPOD_ID | ||||||||||||||||||||||||||||||||||
| 1547 | ); | ||||||||||||||||||||||||||||||||||
| 1548 | 0 | $self->{twig}->set_output_encoding('UTF-8'); | |||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||
| 1550 | 0 | bless $self, $part_class; | |||||||||||||||||||||||||||||||||
| 1551 | 0 | ▶ | if ($self->{load}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1552 | { | ||||||||||||||||||||||||||||||||||
| 1553 | 0 | my $status = $self->load(); | |||||||||||||||||||||||||||||||||
| 1554 | 0 | ▶ | unless (is_true($status)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1555 | { | ||||||||||||||||||||||||||||||||||
| 1556 | 0 | alert("Part load failed"); | |||||||||||||||||||||||||||||||||
| 1557 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1558 | } | ||||||||||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||||||||
| 1560 | 0 | return $self; | |||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||
| 1563 | sub load | ||||||||||||||||||||||||||||||||||
| 1564 | { | ||||||||||||||||||||||||||||||||||
| 1565 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1566 | 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'})
| |||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||
| 1568 | 0 | ▶ | unless (defined $xml) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1569 | { | ||||||||||||||||||||||||||||||||||
| 1570 | 0 | alert("No content"); | |||||||||||||||||||||||||||||||||
| 1571 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1572 | } | ||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||
| 1574 | 0 | $self->pre_load; | |||||||||||||||||||||||||||||||||
| 1575 | my $r = UNIVERSAL::isa($xml, 'IO::File') ? | ||||||||||||||||||||||||||||||||||
| 1576 | $self->{twig}->safe_parsefile($xml) : | ||||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | $self->{twig}->safe_parse($xml); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1578 | 0 | ▶ | unless ($r) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1579 | { | ||||||||||||||||||||||||||||||||||
| 1580 | 0 | alert "No valid XML content"; | |||||||||||||||||||||||||||||||||
| 1581 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1582 | } | ||||||||||||||||||||||||||||||||||
| 1583 | 0 | $self->{context} = $self->{twig}->root; | |||||||||||||||||||||||||||||||||
| 1584 | 0 | $self->{context}->lpod_part($self); | |||||||||||||||||||||||||||||||||
| 1585 | 0 | $self->post_load; | |||||||||||||||||||||||||||||||||
| 1586 | 0 | return TRUE; | |||||||||||||||||||||||||||||||||
| 1587 | } | ||||||||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||||||||
| 1589 | sub needs_update | ||||||||||||||||||||||||||||||||||
| 1590 | { | ||||||||||||||||||||||||||||||||||
| 1591 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
needs_update: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1592 | 0 | my $arg = shift; | |||||||||||||||||||||||||||||||||
| 1593 | 0 | given ($arg) | |||||||||||||||||||||||||||||||||
| 1594 | { | ||||||||||||||||||||||||||||||||||
| 1595 | 0 | when (undef) {} | |||||||||||||||||||||||||||||||||
| 1596 | 0 | when (TRUE) { $self->{update} = TRUE } | |||||||||||||||||||||||||||||||||
| 1597 | 0 | when (FALSE) { $self->{update} = FALSE } | |||||||||||||||||||||||||||||||||
| 1598 | } | ||||||||||||||||||||||||||||||||||
| 1599 | 0 | return $self->{update}; | |||||||||||||||||||||||||||||||||
| 1600 | } | ||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||
| 1602 | sub get_name | ||||||||||||||||||||||||||||||||||
| 1603 | { | ||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1605 | 0 | return $self->{part}; | |||||||||||||||||||||||||||||||||
| 1606 | } | ||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||
| 1608 | #--- destructor -------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||
| 1610 | sub DESTROY | ||||||||||||||||||||||||||||||||||
| 1611 | { | ||||||||||||||||||||||||||||||||||
| 1612 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1613 | $self->{context} && | ||||||||||||||||||||||||||||||||||
| 1614 | 0 | ▶ | $self->{context}->del_att($ODF::lpOD::Common::LPOD_PART); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | $self->{context} && $self->{context}->delete; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1616 | 0 | delete $self->{context}; | |||||||||||||||||||||||||||||||||
| 1617 | 0 | ▶ | $self->{twig} && $self->{twig}->dispose; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1618 | 0 | delete $self->{twig}; | |||||||||||||||||||||||||||||||||
| 1619 | 0 | delete $self->{container}; | |||||||||||||||||||||||||||||||||
| 1620 | 0 | delete $self->{part}; | |||||||||||||||||||||||||||||||||
| 1621 | 0 | $self = {}; | |||||||||||||||||||||||||||||||||
| 1622 | } | ||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||
| 1624 | #--- basic individual node selection ----------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||
| 1626 | sub find_node | ||||||||||||||||||||||||||||||||||
| 1627 | { | ||||||||||||||||||||||||||||||||||
| 1628 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
find_node: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1629 | 0 | my $tag = shift; | |||||||||||||||||||||||||||||||||
| 1630 | 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'}
| |||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||
| 1632 | 0 | return $context->first_descendant($tag); | |||||||||||||||||||||||||||||||||
| 1633 | } | ||||||||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||||||||
| 1635 | #=== public part ============================================================= | ||||||||||||||||||||||||||||||||||
| 1636 | #--- general document management --------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1637 | |||||||||||||||||||||||||||||||||||
| 1638 | sub get_class | ||||||||||||||||||||||||||||||||||
| 1639 | { | ||||||||||||||||||||||||||||||||||
| 1640 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1641 | 0 | return ref $self; | |||||||||||||||||||||||||||||||||
| 1642 | } | ||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||
| 1644 | sub get_root | ||||||||||||||||||||||||||||||||||
| 1645 | { | ||||||||||||||||||||||||||||||||||
| 1646 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_root: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1647 | 0 | return $self->{twig}->root; | |||||||||||||||||||||||||||||||||
| 1648 | } | ||||||||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||||||||
| 1650 | sub get_body | ||||||||||||||||||||||||||||||||||
| 1651 | { | ||||||||||||||||||||||||||||||||||
| 1652 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1653 | 0 | my $tag = shift; | |||||||||||||||||||||||||||||||||
| 1654 | 0 | my $root = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1655 | 0 | ▶ | if ($tag) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1656 | { | ||||||||||||||||||||||||||||||||||
| 1657 | 0 | ▶ | $tag = 'office:' . $tag unless $tag =~ /:/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1658 | 0 | return $root->get_xpath(('//office:body/' . $tag), 0); | |||||||||||||||||||||||||||||||||
| 1659 | } | ||||||||||||||||||||||||||||||||||
| 1660 | 0 | my $context = $root->get_xpath('//office:body', 0); | |||||||||||||||||||||||||||||||||
| 1661 | 0 | ▶ | return $context ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1662 | $context->first_child | ||||||||||||||||||||||||||||||||||
| 1663 | (qr'office:(text|spreadsheet|presentation|drawing)') | ||||||||||||||||||||||||||||||||||
| 1664 | : | ||||||||||||||||||||||||||||||||||
| 1665 | $root->first_child | ||||||||||||||||||||||||||||||||||
| 1666 | (qr'office:(body|meta|master-styles|settings)'); | ||||||||||||||||||||||||||||||||||
| 1667 | } | ||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||
| 1669 | sub container | ||||||||||||||||||||||||||||||||||
| 1670 | { | ||||||||||||||||||||||||||||||||||
| 1671 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
container: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1672 | 0 | return $self->{container}; | |||||||||||||||||||||||||||||||||
| 1673 | } | ||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||
| 1675 | sub document | ||||||||||||||||||||||||||||||||||
| 1676 | { | ||||||||||||||||||||||||||||||||||
| 1677 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
document: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1678 | 0 | return $self->{document}; | |||||||||||||||||||||||||||||||||
| 1679 | } | ||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||
| 1681 | sub serialize | ||||||||||||||||||||||||||||||||||
| 1682 | { | ||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
serialize: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||
| 1684 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1685 | ( | ||||||||||||||||||||||||||||||||||
| 1686 | empty_tags => EMPTY_TAGS, | ||||||||||||||||||||||||||||||||||
| 1687 | output => undef, | ||||||||||||||||||||||||||||||||||
| 1688 | @_ | ||||||||||||||||||||||||||||||||||
| 1689 | ); | ||||||||||||||||||||||||||||||||||
| 1690 | 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
| |||||||||||||||||||||||||||||||||||
| 1691 | 0 | ▶ | $opt{pretty_print} = PRETTY_PRINT if is_true($opt{pretty}); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1692 | 0 | my $output = $opt{output}; | |||||||||||||||||||||||||||||||||
| 1693 | 0 | delete @opt{qw(pretty output indent)}; | |||||||||||||||||||||||||||||||||
| 1694 | return (defined $output) ? | ||||||||||||||||||||||||||||||||||
| 1695 | $self->{twig}->print($output, %opt) : | ||||||||||||||||||||||||||||||||||
| 1696 | 0 | ▶ | $self->{twig}->sprint(%opt); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1697 | } | ||||||||||||||||||||||||||||||||||
| 1698 | |||||||||||||||||||||||||||||||||||
| 1699 | sub store | ||||||||||||||||||||||||||||||||||
| 1700 | { | ||||||||||||||||||||||||||||||||||
| 1701 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1702 | 0 | ▶ | unless ($self->{container}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1703 | { | ||||||||||||||||||||||||||||||||||
| 1704 | 0 | alert "No associated container"; | |||||||||||||||||||||||||||||||||
| 1705 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1706 | } | ||||||||||||||||||||||||||||||||||
| 1707 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 1708 | 0 | my %storage = (); | |||||||||||||||||||||||||||||||||
| 1709 | 0 | ▶ | if ($opt{storage}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1710 | { | ||||||||||||||||||||||||||||||||||
| 1711 | 0 | %storage = %{$opt{storage}}; | |||||||||||||||||||||||||||||||||
| 1712 | 0 | delete $opt{storage}; | |||||||||||||||||||||||||||||||||
| 1713 | } | ||||||||||||||||||||||||||||||||||
| 1714 | else | ||||||||||||||||||||||||||||||||||
| 1715 | { | ||||||||||||||||||||||||||||||||||
| 1716 | 0 | %storage = (compress => TRUE, string => TRUE); | |||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||
| 1718 | return | ||||||||||||||||||||||||||||||||||
| 1719 | $self->{container}->set_part | ||||||||||||||||||||||||||||||||||
| 1720 | ( | ||||||||||||||||||||||||||||||||||
| 1721 | $self->{part}, | ||||||||||||||||||||||||||||||||||
| 1722 | 0 | $self->serialize(%opt), | |||||||||||||||||||||||||||||||||
| 1723 | %storage | ||||||||||||||||||||||||||||||||||
| 1724 | ); | ||||||||||||||||||||||||||||||||||
| 1725 | } | ||||||||||||||||||||||||||||||||||
| 1726 | |||||||||||||||||||||||||||||||||||
| 1727 | #--- general element management ---------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1728 | |||||||||||||||||||||||||||||||||||
| 1729 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 1730 | { | ||||||||||||||||||||||||||||||||||
| 1731 | 0 | ▶ | my ($self, $xpath) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1732 | 0 | return $self->{context}->get_xpath($xpath); | |||||||||||||||||||||||||||||||||
| 1733 | } | ||||||||||||||||||||||||||||||||||
| 1734 | |||||||||||||||||||||||||||||||||||
| 1735 | sub get_element | ||||||||||||||||||||||||||||||||||
| 1736 | { | ||||||||||||||||||||||||||||||||||
| 1737 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1738 | 0 | my $xpath = shift; | |||||||||||||||||||||||||||||||||
| 1739 | 0 | ▶ | my $offset = shift || 0; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 1740 | 0 | return $self->{context}->get_xpath($xpath, $offset); | |||||||||||||||||||||||||||||||||
| 1741 | } | ||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||
| 1743 | sub append_element | ||||||||||||||||||||||||||||||||||
| 1744 | { | ||||||||||||||||||||||||||||||||||
| 1745 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
append_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1746 | 0 | my $context = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1747 | 0 | return $context->append_element(@_); | |||||||||||||||||||||||||||||||||
| 1748 | } | ||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||
| 1750 | sub insert_element | ||||||||||||||||||||||||||||||||||
| 1751 | { | ||||||||||||||||||||||||||||||||||
| 1752 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
insert_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1753 | 0 | my $context = $self->get_root; | |||||||||||||||||||||||||||||||||
| 1754 | 0 | return $context->insert_element(@_); | |||||||||||||||||||||||||||||||||
| 1755 | } | ||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||
| 1757 | sub delete_element | ||||||||||||||||||||||||||||||||||
| 1758 | { | ||||||||||||||||||||||||||||||||||
| 1759 | 0 | ▶ | my ($self, $element) = @_; | ||||||||||||||||||||||||||||||||
|
Subroutine
delete_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1760 | 0 | return $element->delete; | |||||||||||||||||||||||||||||||||
| 1761 | } | ||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||
| 1763 | #--- tracked change handling ------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||
| 1765 | sub get_tracked_changes_root | ||||||||||||||||||||||||||||||||||
| 1766 | { | ||||||||||||||||||||||||||||||||||
| 1767 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tracked_changes_root: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1768 | 0 | ▶ | unless ($self->{tracked_changes}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1769 | { | ||||||||||||||||||||||||||||||||||
| 1770 | $self->{tracked_changes} = | ||||||||||||||||||||||||||||||||||
| 1771 | 0 | $self->find_node('text:tracked-changes'); | |||||||||||||||||||||||||||||||||
| 1772 | } | ||||||||||||||||||||||||||||||||||
| 1773 | 0 | return $self->{tracked_changes}; | |||||||||||||||||||||||||||||||||
| 1774 | } | ||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||
| 1776 | sub get_changes | ||||||||||||||||||||||||||||||||||
| 1777 | { | ||||||||||||||||||||||||||||||||||
| 1778 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_changes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1779 | 0 | my $context = $self->get_tracked_changes_root; | |||||||||||||||||||||||||||||||||
| 1780 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1781 | { | ||||||||||||||||||||||||||||||||||
| 1782 | 0 | alert "Not valid tracked change retrieval context"; | |||||||||||||||||||||||||||||||||
| 1783 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1784 | } | ||||||||||||||||||||||||||||||||||
| 1785 | 0 | return $context->get_changes(@_); | |||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||
| 1788 | sub get_change | ||||||||||||||||||||||||||||||||||
| 1789 | { | ||||||||||||||||||||||||||||||||||
| 1790 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_change: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1791 | 0 | my $context = $self->get_tracked_changes_root; | |||||||||||||||||||||||||||||||||
| 1792 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1793 | { | ||||||||||||||||||||||||||||||||||
| 1794 | 0 | alert "Not valid tracked change retrieval context"; | |||||||||||||||||||||||||||||||||
| 1795 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 1796 | } | ||||||||||||||||||||||||||||||||||
| 1797 | 0 | return $context->get_change(shift); | |||||||||||||||||||||||||||||||||
| 1798 | } | ||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||
| 1800 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1801 | package ODF::lpOD::StyleContainer; | ||||||||||||||||||||||||||||||||||
| 1802 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1803 | 2 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||||||||
| 1804 | 2 | ▶ | use constant PACKAGE_DATE => '2011-05-29T16:05:40'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1805 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1806 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||
| 1808 | sub get_font_declarations | ||||||||||||||||||||||||||||||||||
| 1809 | { | ||||||||||||||||||||||||||||||||||
| 1810 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_font_declarations: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1811 | 0 | return $self->get_elements | |||||||||||||||||||||||||||||||||
| 1812 | ('//office:font-face-decls/style:font-face'); | ||||||||||||||||||||||||||||||||||
| 1813 | } | ||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||
| 1815 | sub get_font_declaration | ||||||||||||||||||||||||||||||||||
| 1816 | { | ||||||||||||||||||||||||||||||||||
| 1817 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_font_declaration: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1818 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1819 | 0 | my $xp = '//office:font-face-decls' . | |||||||||||||||||||||||||||||||||
| 1820 | '/style:font-face[@style:name="' . | ||||||||||||||||||||||||||||||||||
| 1821 | $name . | ||||||||||||||||||||||||||||||||||
| 1822 | '"]'; | ||||||||||||||||||||||||||||||||||
| 1823 | 0 | return $self->get_element($xp); | |||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||||
| 1826 | sub set_font_declaration | ||||||||||||||||||||||||||||||||||
| 1827 | { | ||||||||||||||||||||||||||||||||||
| 1828 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_font_declaration: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 1829 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1830 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1831 | { | ||||||||||||||||||||||||||||||||||
| 1832 | 0 | alert "Missing font name"; return undef; | |||||||||||||||||||||||||||||||||
| 1833 | } | ||||||||||||||||||||||||||||||||||
| 1834 | 0 | my %opt = process_options(@_); | |||||||||||||||||||||||||||||||||
| 1835 | 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
| |||||||||||||||||||||||||||||||||||
| 1836 | 0 | my $fd = $self->get_font_declaration($name); | |||||||||||||||||||||||||||||||||
| 1837 | 0 | ▶ | $fd->delete if $fd; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1838 | 0 | return $self | |||||||||||||||||||||||||||||||||
| 1839 | ->get_root | ||||||||||||||||||||||||||||||||||
| 1840 | ->set_child('office:font-face-decls') | ||||||||||||||||||||||||||||||||||
| 1841 | ->append_element | ||||||||||||||||||||||||||||||||||
| 1842 | (ODF::lpOD::FontDeclaration->create($name, %opt)); | ||||||||||||||||||||||||||||||||||
| 1843 | } | ||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||
| 1845 | sub substitute_context | ||||||||||||||||||||||||||||||||||
| 1846 | { | ||||||||||||||||||||||||||||||||||
| 1847 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_context: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1848 | 0 | my $doc = shift; | |||||||||||||||||||||||||||||||||
| 1849 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 1850 | |||||||||||||||||||||||||||||||||||
| 1851 | 0 | my $part = $self->get_name; | |||||||||||||||||||||||||||||||||
| 1852 | 0 | ▶ | my $origin = $doc->get_element($part, $path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1853 | or return undef; | ||||||||||||||||||||||||||||||||||
| 1854 | 0 | ▶ | my $destination = $self->get_element($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1855 | or return undef; | ||||||||||||||||||||||||||||||||||
| 1856 | 0 | return $destination->substitute_children($origin); | |||||||||||||||||||||||||||||||||
| 1857 | } | ||||||||||||||||||||||||||||||||||
| 1858 | |||||||||||||||||||||||||||||||||||
| 1859 | sub substitute_styles | ||||||||||||||||||||||||||||||||||
| 1860 | { | ||||||||||||||||||||||||||||||||||
| 1861 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
substitute_styles: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||
| 1862 | 0 | my $from = shift; | |||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||
| 1864 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 1865 | ( | ||||||||||||||||||||||||||||||||||
| 1866 | common => TRUE, | ||||||||||||||||||||||||||||||||||
| 1867 | master => TRUE, | ||||||||||||||||||||||||||||||||||
| 1868 | automatic => TRUE, | ||||||||||||||||||||||||||||||||||
| 1869 | fonts => TRUE, | ||||||||||||||||||||||||||||||||||
| 1870 | @_ | ||||||||||||||||||||||||||||||||||
| 1871 | ); | ||||||||||||||||||||||||||||||||||
| 1872 | 0 | my $part = $self->get_name; | |||||||||||||||||||||||||||||||||
| 1873 | 0 | ▶ | if ($part ne STYLES) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1874 | { | ||||||||||||||||||||||||||||||||||
| 1875 | 0 | delete @opt{qw(common master)}; | |||||||||||||||||||||||||||||||||
| 1876 | } | ||||||||||||||||||||||||||||||||||
| 1877 | 0 | my $source; | |||||||||||||||||||||||||||||||||
| 1878 | 0 | ▶ | if (ref $from) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1879 | { | ||||||||||||||||||||||||||||||||||
| 1880 | 0 | ▶ | $source = $from if $from->isa('ODF::lpOD::Document'); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1881 | } | ||||||||||||||||||||||||||||||||||
| 1882 | else | ||||||||||||||||||||||||||||||||||
| 1883 | { | ||||||||||||||||||||||||||||||||||
| 1884 | 0 | $source = ODF::lpOD::Document->new(template => $from); | |||||||||||||||||||||||||||||||||
| 1885 | } | ||||||||||||||||||||||||||||||||||
| 1886 | 0 | ▶ | unless ($source) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1887 | { | ||||||||||||||||||||||||||||||||||
| 1888 | 0 | alert "Malformed or not available source"; return FALSE; | |||||||||||||||||||||||||||||||||
| 1889 | } | ||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||
| 1891 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | if (is_true($opt{automatic})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1894 | { | ||||||||||||||||||||||||||||||||||
| 1895 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1896 | ($source, '//office:automatic-styles'); | ||||||||||||||||||||||||||||||||||
| 1897 | } | ||||||||||||||||||||||||||||||||||
| 1898 | 0 | ▶ | if (is_true($opt{common})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1899 | { | ||||||||||||||||||||||||||||||||||
| 1900 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1901 | ($source, '//office:styles'); | ||||||||||||||||||||||||||||||||||
| 1902 | } | ||||||||||||||||||||||||||||||||||
| 1903 | 0 | ▶ | if (is_true($opt{master})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1904 | { | ||||||||||||||||||||||||||||||||||
| 1905 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1906 | ($source, '//office:master-styles'); | ||||||||||||||||||||||||||||||||||
| 1907 | } | ||||||||||||||||||||||||||||||||||
| 1908 | 0 | ▶ | if (is_true($opt{fonts})) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1909 | { | ||||||||||||||||||||||||||||||||||
| 1910 | 0 | $count += $self->substitute_context | |||||||||||||||||||||||||||||||||
| 1911 | ($source, '//office:font-face-decls'); | ||||||||||||||||||||||||||||||||||
| 1912 | } | ||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||
| 1914 | 0 | ▶ | $source->forget unless ref $from; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1915 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 1916 | } | ||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||
| 1918 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1919 | package ODF::lpOD::Content; | ||||||||||||||||||||||||||||||||||
| 1920 | 2 | ▶ | use base 'ODF::lpOD::StyleContainer'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1921 | 2 | our $VERSION = '1.003'; | |||||||||||||||||||||||||||||||||
| 1922 | 2 | ▶ | use constant PACKAGE_DATE => '2012-03-29T08:25:40'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1923 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1924 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||
| 1926 | sub get_tocs | ||||||||||||||||||||||||||||||||||
| 1927 | { | ||||||||||||||||||||||||||||||||||
| 1928 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tocs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1929 | 0 | my $context = $self->get_body; | |||||||||||||||||||||||||||||||||
| 1930 | 0 | return $context->get_elements('text:table-of-content'); | |||||||||||||||||||||||||||||||||
| 1931 | } | ||||||||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||||||||
| 1933 | sub get_toc | ||||||||||||||||||||||||||||||||||
| 1934 | { | ||||||||||||||||||||||||||||||||||
| 1935 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_toc: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1936 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1937 | 0 | my $context = $self->get_body; | |||||||||||||||||||||||||||||||||
| 1938 | 0 | return $context->get_element_by_name('text:table-of-content', $name); | |||||||||||||||||||||||||||||||||
| 1939 | } | ||||||||||||||||||||||||||||||||||
| 1940 | |||||||||||||||||||||||||||||||||||
| 1941 | sub get_named_range | ||||||||||||||||||||||||||||||||||
| 1942 | { | ||||||||||||||||||||||||||||||||||
| 1943 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_named_range: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 1944 | 0 | my $context = $self->get_body('spreadsheet'); | |||||||||||||||||||||||||||||||||
| 1945 | 0 | ▶ | unless ($context) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1946 | { | ||||||||||||||||||||||||||||||||||
| 1947 | 0 | alert "Not in spreadsheet context"; return undef; | |||||||||||||||||||||||||||||||||
| 1948 | } | ||||||||||||||||||||||||||||||||||
| 1949 | 0 | return $context->get_element_by_name('table:named-range', @_); | |||||||||||||||||||||||||||||||||
| 1950 | } | ||||||||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||||||||
| 1952 | sub set_named_range | ||||||||||||||||||||||||||||||||||
| 1953 | { | ||||||||||||||||||||||||||||||||||
| 1954 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_named_range: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 1955 | 0 | my $body = $self->get_body('spreadsheet'); | |||||||||||||||||||||||||||||||||
| 1956 | 0 | ▶ | unless ($body) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1957 | { | ||||||||||||||||||||||||||||||||||
| 1958 | 0 | alert "Not in spreadsheet context"; return undef; | |||||||||||||||||||||||||||||||||
| 1959 | } | ||||||||||||||||||||||||||||||||||
| 1960 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 1961 | 0 | my $old = $self->get_named_range($name); | |||||||||||||||||||||||||||||||||
| 1962 | 0 | ▶ | if ($old) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1963 | { | ||||||||||||||||||||||||||||||||||
| 1964 | 0 | alert "Named range $name already exists"; return undef; | |||||||||||||||||||||||||||||||||
| 1965 | } | ||||||||||||||||||||||||||||||||||
| 1966 | 0 | my $context = $body->set_last_child('table:named-expressions'); | |||||||||||||||||||||||||||||||||
| 1967 | 0 | my $nr = ODF::lpOD::NamedRange->create($name, @_); | |||||||||||||||||||||||||||||||||
| 1968 | 0 | $context->append_element($nr); | |||||||||||||||||||||||||||||||||
| 1969 | 0 | return $nr; | |||||||||||||||||||||||||||||||||
| 1970 | } | ||||||||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||||||||
| 1972 | sub get_headings | ||||||||||||||||||||||||||||||||||
| 1973 | { | ||||||||||||||||||||||||||||||||||
| 1974 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_headings: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 1975 | 0 | return $self->get_body->get_headings(@_); | |||||||||||||||||||||||||||||||||
| 1976 | } | ||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||
| 1978 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1979 | package ODF::lpOD::Styles; | ||||||||||||||||||||||||||||||||||
| 1980 | 2 | ▶ | use base 'ODF::lpOD::StyleContainer'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1981 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 1982 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:51:47'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1983 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1984 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 1985 | package ODF::lpOD::Meta; | ||||||||||||||||||||||||||||||||||
| 1986 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1987 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 1988 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:51:58'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1989 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1990 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||||||||
| 1992 | BEGIN { | ||||||||||||||||||||||||||||||||||
| 1993 | 2 | ▶ | *get_element_list = *get_elements; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1994 | } | ||||||||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||||||||
| 1996 | ▶ | sub post_load {} | |||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 1997 | |||||||||||||||||||||||||||||||||||
| 1998 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||||||||
| 2000 | 2 | our %META = | |||||||||||||||||||||||||||||||||
| 2001 | ( | ||||||||||||||||||||||||||||||||||
| 2002 | creation_date => 'meta:creation-date', | ||||||||||||||||||||||||||||||||||
| 2003 | creator => 'dc:creator', | ||||||||||||||||||||||||||||||||||
| 2004 | description => 'dc:description', | ||||||||||||||||||||||||||||||||||
| 2005 | editing_cycles => 'meta:editing-cycles', | ||||||||||||||||||||||||||||||||||
| 2006 | editing_duration => 'meta:editing-duration', | ||||||||||||||||||||||||||||||||||
| 2007 | generator => 'meta:generator', | ||||||||||||||||||||||||||||||||||
| 2008 | initial_creator => 'meta:initial-creator', | ||||||||||||||||||||||||||||||||||
| 2009 | language => 'dc:language', | ||||||||||||||||||||||||||||||||||
| 2010 | modification_date => 'dc:date', | ||||||||||||||||||||||||||||||||||
| 2011 | printed_by => 'meta:printed-by', | ||||||||||||||||||||||||||||||||||
| 2012 | print_date => 'meta:print-date', | ||||||||||||||||||||||||||||||||||
| 2013 | subject => 'dc:subject', | ||||||||||||||||||||||||||||||||||
| 2014 | title => 'dc:title' | ||||||||||||||||||||||||||||||||||
| 2015 | ); | ||||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||||
| 2017 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||||||||
| 2019 | sub get_body | ||||||||||||||||||||||||||||||||||
| 2020 | { | ||||||||||||||||||||||||||||||||||
| 2021 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_body: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2022 | 0 | ▶ | unless ($self->{body}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2023 | { | ||||||||||||||||||||||||||||||||||
| 2024 | 0 | $self->{body} = $self->SUPER::get_element('//office:meta'); | |||||||||||||||||||||||||||||||||
| 2025 | } | ||||||||||||||||||||||||||||||||||
| 2026 | 0 | return $self->{body}; | |||||||||||||||||||||||||||||||||
| 2027 | } | ||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||
| 2029 | sub get_element | ||||||||||||||||||||||||||||||||||
| 2030 | { | ||||||||||||||||||||||||||||||||||
| 2031 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2032 | 0 | return $self->get_body->get_element(@_); | |||||||||||||||||||||||||||||||||
| 2033 | } | ||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||
| 2035 | sub get_elements | ||||||||||||||||||||||||||||||||||
| 2036 | { | ||||||||||||||||||||||||||||||||||
| 2037 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_elements: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2038 | 0 | return $self->get_body->get_element_list(@_); | |||||||||||||||||||||||||||||||||
| 2039 | } | ||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||
| 2041 | sub append_element | ||||||||||||||||||||||||||||||||||
| 2042 | { | ||||||||||||||||||||||||||||||||||
| 2043 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
append_element: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2044 | 0 | return $self->get_body->append_element(@_); | |||||||||||||||||||||||||||||||||
| 2045 | } | ||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||
| 2047 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||
| 2049 | sub get_statistics | ||||||||||||||||||||||||||||||||||
| 2050 | { | ||||||||||||||||||||||||||||||||||
| 2051 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_statistics: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2052 | 0 | my $stat = $self->get_element('meta:document-statistic'); | |||||||||||||||||||||||||||||||||
| 2053 | 0 | ▶ | return $stat ? $stat->get_attributes() : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2054 | } | ||||||||||||||||||||||||||||||||||
| 2055 | |||||||||||||||||||||||||||||||||||
| 2056 | sub set_statistics | ||||||||||||||||||||||||||||||||||
| 2057 | { | ||||||||||||||||||||||||||||||||||
| 2058 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_statistics: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2059 | 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')
| |||||||||||||||||||||||||||||||||||
| 2060 | $self->append_element('meta:document-statistic'); | ||||||||||||||||||||||||||||||||||
| 2061 | 0 | return $stat->set_attributes(@_); | |||||||||||||||||||||||||||||||||
| 2062 | } | ||||||||||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||||||||
| 2064 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||
| 2066 | sub get_keyword_list | ||||||||||||||||||||||||||||||||||
| 2067 | { | ||||||||||||||||||||||||||||||||||
| 2068 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_keyword_list: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2069 | 0 | my $expr = shift; | |||||||||||||||||||||||||||||||||
| 2070 | 0 | return $self->get_element_list | |||||||||||||||||||||||||||||||||
| 2071 | ('meta:keyword', content => $expr); | ||||||||||||||||||||||||||||||||||
| 2072 | } | ||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||
| 2074 | sub get_keywords | ||||||||||||||||||||||||||||||||||
| 2075 | { | ||||||||||||||||||||||||||||||||||
| 2076 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_keywords: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2077 | 0 | my @kwl = (); | |||||||||||||||||||||||||||||||||
| 2078 | 0 | for ($self->get_keyword_list(@_)) | |||||||||||||||||||||||||||||||||
| 2079 | { | ||||||||||||||||||||||||||||||||||
| 2080 | 0 | push @kwl, $_->get_text; | |||||||||||||||||||||||||||||||||
| 2081 | } | ||||||||||||||||||||||||||||||||||
| 2082 | 0 | ▶ | return wantarray ? @kwl : join (', ', @kwl); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2083 | } | ||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||
| 2085 | sub set_keyword | ||||||||||||||||||||||||||||||||||
| 2086 | { | ||||||||||||||||||||||||||||||||||
| 2087 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_keyword: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 2088 | 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()
| |||||||||||||||||||||||||||||||||||
| 2089 | 0 | for ($self->get_keyword_list) | |||||||||||||||||||||||||||||||||
| 2090 | { | ||||||||||||||||||||||||||||||||||
| 2091 | 0 | ▶ | return FALSE if $_->get_text() eq $kw; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2092 | } | ||||||||||||||||||||||||||||||||||
| 2093 | 0 | my $e = $self->append_element('meta:keyword'); | |||||||||||||||||||||||||||||||||
| 2094 | 0 | $e->set_text($kw); | |||||||||||||||||||||||||||||||||
| 2095 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2096 | } | ||||||||||||||||||||||||||||||||||
| 2097 | |||||||||||||||||||||||||||||||||||
| 2098 | sub set_keywords | ||||||||||||||||||||||||||||||||||
| 2099 | { | ||||||||||||||||||||||||||||||||||
| 2100 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_keywords: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2101 | 0 | my $input = join(',', @_); | |||||||||||||||||||||||||||||||||
| 2102 | 0 | foreach my $kw (split(',', $input)) | |||||||||||||||||||||||||||||||||
| 2103 | { | ||||||||||||||||||||||||||||||||||
| 2104 | 0 | $kw =~ s/^ *//; $kw =~ s/ *$//; | |||||||||||||||||||||||||||||||||
| 2105 | 0 | $self->set_keyword($kw); | |||||||||||||||||||||||||||||||||
| 2106 | } | ||||||||||||||||||||||||||||||||||
| 2107 | 0 | return $self->get_keywords; | |||||||||||||||||||||||||||||||||
| 2108 | } | ||||||||||||||||||||||||||||||||||
| 2109 | |||||||||||||||||||||||||||||||||||
| 2110 | sub check_keyword | ||||||||||||||||||||||||||||||||||
| 2111 | { | ||||||||||||||||||||||||||||||||||
| 2112 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
check_keyword: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2113 | 0 | ▶ | my $expr = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||||||||
| 2115 | 0 | return scalar $self->get_keyword_list($expr); | |||||||||||||||||||||||||||||||||
| 2116 | } | ||||||||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||||||||
| 2118 | sub remove_keyword | ||||||||||||||||||||||||||||||||||
| 2119 | { | ||||||||||||||||||||||||||||||||||
| 2120 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
remove_keyword: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2121 | 0 | ▶ | my $expr = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2122 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||
| 2123 | 0 | for ($self->get_keyword_list($expr)) | |||||||||||||||||||||||||||||||||
| 2124 | { | ||||||||||||||||||||||||||||||||||
| 2125 | 0 | $_->delete; $count++; | |||||||||||||||||||||||||||||||||
| 2126 | } | ||||||||||||||||||||||||||||||||||
| 2127 | 0 | return $count; | |||||||||||||||||||||||||||||||||
| 2128 | } | ||||||||||||||||||||||||||||||||||
| 2129 | |||||||||||||||||||||||||||||||||||
| 2130 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2131 | |||||||||||||||||||||||||||||||||||
| 2132 | sub get_user_field | ||||||||||||||||||||||||||||||||||
| 2133 | { | ||||||||||||||||||||||||||||||||||
| 2134 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_field: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 2135 | 0 | ▶ | my $name = shift or return undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2136 | 0 | ▶ | my $e = ref $name ? | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2137 | $name | ||||||||||||||||||||||||||||||||||
| 2138 | : | ||||||||||||||||||||||||||||||||||
| 2139 | $self->get_element | ||||||||||||||||||||||||||||||||||
| 2140 | ( | ||||||||||||||||||||||||||||||||||
| 2141 | 'meta:user-defined', | ||||||||||||||||||||||||||||||||||
| 2142 | attribute => 'name', | ||||||||||||||||||||||||||||||||||
| 2143 | value => $name | ||||||||||||||||||||||||||||||||||
| 2144 | ); | ||||||||||||||||||||||||||||||||||
| 2145 | 0 | ▶ | return undef unless $e; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2146 | return wantarray ? | ||||||||||||||||||||||||||||||||||
| 2147 | ( | ||||||||||||||||||||||||||||||||||
| 2148 | 0 | ▶ | $e->get_text(), | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 2149 | $e->get_attribute('value type') || 'string' | ||||||||||||||||||||||||||||||||||
| 2150 | ) | ||||||||||||||||||||||||||||||||||
| 2151 | : | ||||||||||||||||||||||||||||||||||
| 2152 | $e->get_text; | ||||||||||||||||||||||||||||||||||
| 2153 | } | ||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||
| 2155 | sub set_user_field | ||||||||||||||||||||||||||||||||||
| 2156 | { | ||||||||||||||||||||||||||||||||||
| 2157 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_user_field: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||
| 2158 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||
| 2159 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||
| 2160 | 0 | ▶ | my $type = shift || 'string'; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 'string'
MC/DC0%0/1
shift() || 'string'
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 2161 | 0 | ▶ | unless (is_odf_datatype($type)) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2162 | { | ||||||||||||||||||||||||||||||||||
| 2163 | 0 | alert "Wrong data type $type"; | |||||||||||||||||||||||||||||||||
| 2164 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||||||||
| 2166 | 0 | ▶ | unless ($name) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2167 | { | ||||||||||||||||||||||||||||||||||
| 2168 | 0 | alert "Missing user field name"; | |||||||||||||||||||||||||||||||||
| 2169 | 0 | return FALSE; | |||||||||||||||||||||||||||||||||
| 2170 | } | ||||||||||||||||||||||||||||||||||
| 2171 | 0 | $value = check_odf_value($value, $type); | |||||||||||||||||||||||||||||||||
| 2172 | 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")
| |||||||||||||||||||||||||||||||||||
| 2173 | ( | ||||||||||||||||||||||||||||||||||
| 2174 | 'meta:user-defined', | ||||||||||||||||||||||||||||||||||
| 2175 | attribute => 'name', | ||||||||||||||||||||||||||||||||||
| 2176 | value => $name | ||||||||||||||||||||||||||||||||||
| 2177 | ) | ||||||||||||||||||||||||||||||||||
| 2178 | // | ||||||||||||||||||||||||||||||||||
| 2179 | $self->append_element('meta:user-defined'); | ||||||||||||||||||||||||||||||||||
| 2180 | 0 | $e->set_attribute('name' => $name); | |||||||||||||||||||||||||||||||||
| 2181 | 0 | $e->set_attribute('value type' => $type); | |||||||||||||||||||||||||||||||||
| 2182 | 0 | $e->set_text($value); | |||||||||||||||||||||||||||||||||
| 2183 | return wantarray ? | ||||||||||||||||||||||||||||||||||
| 2184 | 0 | ▶ | ($e->get_text(), $e->get_attribute('value type')) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2185 | : | ||||||||||||||||||||||||||||||||||
| 2186 | $e->get_text; | ||||||||||||||||||||||||||||||||||
| 2187 | } | ||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||
| 2189 | sub get_user_fields | ||||||||||||||||||||||||||||||||||
| 2190 | { | ||||||||||||||||||||||||||||||||||
| 2191 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_user_fields: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 2192 | 0 | my @result = (); | |||||||||||||||||||||||||||||||||
| 2193 | 0 | foreach my $e ($self->get_element_list('meta:user-defined')) | |||||||||||||||||||||||||||||||||
| 2194 | { | ||||||||||||||||||||||||||||||||||
| 2195 | 0 | my $f; | |||||||||||||||||||||||||||||||||
| 2196 | 0 | $f->{name} = $e->get_attribute('name'); | |||||||||||||||||||||||||||||||||
| 2197 | 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")
| |||||||||||||||||||||||||||||||||||
| 2198 | 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
| |||||||||||||||||||||||||||||||||||
| 2199 | 0 | push @result, $f; | |||||||||||||||||||||||||||||||||
| 2200 | } | ||||||||||||||||||||||||||||||||||
| 2201 | 0 | return @result; | |||||||||||||||||||||||||||||||||
| 2202 | } | ||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||
| 2204 | sub set_user_fields | ||||||||||||||||||||||||||||||||||
| 2205 | { | ||||||||||||||||||||||||||||||||||
| 2206 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_user_fields: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2207 | 0 | foreach my $f (@_) | |||||||||||||||||||||||||||||||||
| 2208 | { | ||||||||||||||||||||||||||||||||||
| 2209 | 0 | $self->set_user_field($f->{name}, $f->{value}, $f->{type}); | |||||||||||||||||||||||||||||||||
| 2210 | } | ||||||||||||||||||||||||||||||||||
| 2211 | 0 | return $self->get_user_fields; | |||||||||||||||||||||||||||||||||
| 2212 | } | ||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||
| 2214 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||
| 2216 | 2 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||
| 2217 | sub AUTOLOAD | ||||||||||||||||||||||||||||||||||
| 2218 | { | ||||||||||||||||||||||||||||||||||
| 2219 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||
| 2220 | 0 | $AUTOLOAD =~ /.*:(.*)/; | |||||||||||||||||||||||||||||||||
| 2221 | 0 | my $method = $1; | |||||||||||||||||||||||||||||||||
| 2222 | 0 | $method =~ /^([gs]et)_(.*)/; | |||||||||||||||||||||||||||||||||
| 2223 | 0 | my $action = $1; | |||||||||||||||||||||||||||||||||
| 2224 | 0 | my $object = $META{$2}; | |||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||
| 2226 | 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
| |||||||||||||||||||||||||||||||||||
| 2227 | { | ||||||||||||||||||||||||||||||||||
| 2228 | 0 | alert "Unsupported method $method"; | |||||||||||||||||||||||||||||||||
| 2229 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 2230 | } | ||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||
| 2232 | 0 | my $e = $self->get_element($object); | |||||||||||||||||||||||||||||||||
| 2233 | 0 | given ($action) | |||||||||||||||||||||||||||||||||
| 2234 | { | ||||||||||||||||||||||||||||||||||
| 2235 | when (undef) | ||||||||||||||||||||||||||||||||||
| 2236 | 0 | { | |||||||||||||||||||||||||||||||||
| 2237 | 0 | alert "Unsupported action"; | |||||||||||||||||||||||||||||||||
| 2238 | } | ||||||||||||||||||||||||||||||||||
| 2239 | when ('get') | ||||||||||||||||||||||||||||||||||
| 2240 | 0 | { | |||||||||||||||||||||||||||||||||
| 2241 | 0 | ▶ | return $e ? $e->get_text() : undef; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2242 | } | ||||||||||||||||||||||||||||||||||
| 2243 | when ('set') | ||||||||||||||||||||||||||||||||||
| 2244 | 0 | { | |||||||||||||||||||||||||||||||||
| 2245 | 0 | ▶ | unless ($e) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2246 | { | ||||||||||||||||||||||||||||||||||
| 2247 | 0 | my $body = $self->get_body; | |||||||||||||||||||||||||||||||||
| 2248 | 0 | $e = $body->append_element($object); | |||||||||||||||||||||||||||||||||
| 2249 | } | ||||||||||||||||||||||||||||||||||
| 2250 | 0 | my $v = shift; | |||||||||||||||||||||||||||||||||
| 2251 | 0 | ▶ | if ($object =~ /date$/) | ||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||
| 2252 | { | ||||||||||||||||||||||||||||||||||
| 2253 | 0 | ▶ | unless ($v) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2254 | { | ||||||||||||||||||||||||||||||||||
| 2255 | 0 | $v = iso_date; | |||||||||||||||||||||||||||||||||
| 2256 | } | ||||||||||||||||||||||||||||||||||
| 2257 | else | ||||||||||||||||||||||||||||||||||
| 2258 | { | ||||||||||||||||||||||||||||||||||
| 2259 | 0 | $v = check_odf_value($v, 'date'); | |||||||||||||||||||||||||||||||||
| 2260 | } | ||||||||||||||||||||||||||||||||||
| 2261 | } | ||||||||||||||||||||||||||||||||||
| 2262 | elsif ($object =~ /creator$/) | ||||||||||||||||||||||||||||||||||
| 2263 | { | ||||||||||||||||||||||||||||||||||
| 2264 | 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= $<
| |||||||||||||||||||||||||||||||||||
| 2265 | $v = (scalar getlogin()) || | ||||||||||||||||||||||||||||||||||
| 2266 | (scalar getpwuid($<)) || | ||||||||||||||||||||||||||||||||||
| 2267 | $< | ||||||||||||||||||||||||||||||||||
| 2268 | unless $v; | ||||||||||||||||||||||||||||||||||
| 2269 | } | ||||||||||||||||||||||||||||||||||
| 2270 | elsif ($object =~ /generator$/) | ||||||||||||||||||||||||||||||||||
| 2271 | { | ||||||||||||||||||||||||||||||||||
| 2272 | 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= $$
| |||||||||||||||||||||||||||||||||||
| 2273 | } | ||||||||||||||||||||||||||||||||||
| 2274 | elsif ($object =~ /cycles$/) | ||||||||||||||||||||||||||||||||||
| 2275 | { | ||||||||||||||||||||||||||||||||||
| 2276 | 0 | ▶ | unless ($v) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2277 | { | ||||||||||||||||||||||||||||||||||
| 2278 | 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
| |||||||||||||||||||||||||||||||||||
| 2279 | 0 | $v++; | |||||||||||||||||||||||||||||||||
| 2280 | } | ||||||||||||||||||||||||||||||||||
| 2281 | } | ||||||||||||||||||||||||||||||||||
| 2282 | 0 | return $e->set_text($v); | |||||||||||||||||||||||||||||||||
| 2283 | } | ||||||||||||||||||||||||||||||||||
| 2284 | } | ||||||||||||||||||||||||||||||||||
| 2285 | 0 | return undef; | |||||||||||||||||||||||||||||||||
| 2286 | } | ||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||
| 2288 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||
| 2290 | sub store | ||||||||||||||||||||||||||||||||||
| 2291 | { | ||||||||||||||||||||||||||||||||||
| 2292 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2293 | 0 | my %opt = | |||||||||||||||||||||||||||||||||
| 2294 | ( | ||||||||||||||||||||||||||||||||||
| 2295 | storage => { compress => FALSE, string => TRUE }, | ||||||||||||||||||||||||||||||||||
| 2296 | @_ | ||||||||||||||||||||||||||||||||||
| 2297 | ); | ||||||||||||||||||||||||||||||||||
| 2298 | 0 | return $self->SUPER::store(%opt); | |||||||||||||||||||||||||||||||||
| 2299 | } | ||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||
| 2301 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2302 | package ODF::lpOD::Settings; | ||||||||||||||||||||||||||||||||||
| 2303 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2304 | 2 | our $VERSION = '1.000'; | |||||||||||||||||||||||||||||||||
| 2305 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-24T13:52:14'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2306 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2307 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||||||||
| 2309 | ▶ | sub post_load {} | |||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||
| 2311 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2312 | package ODF::lpOD::Manifest; | ||||||||||||||||||||||||||||||||||
| 2313 | 2 | ▶ | use base 'ODF::lpOD::XMLPart'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2314 | 2 | our $VERSION = '1.001'; | |||||||||||||||||||||||||||||||||
| 2315 | 2 | ▶ | use constant PACKAGE_DATE => '2010-12-30T08:34:26'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2316 | 2 | ▶ | use ODF::lpOD::Common; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2317 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2318 | |||||||||||||||||||||||||||||||||||
| 2319 | ▶ | sub post_load {} | |||||||||||||||||||||||||||||||||
|
Subroutine
post_load: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||
| 2321 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||||||||
| 2323 | sub get_entries | ||||||||||||||||||||||||||||||||||
| 2324 | { | ||||||||||||||||||||||||||||||||||
| 2325 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_entries: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||
| 2326 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 2327 | my @all_entries = $self->{context}->get_element_list | ||||||||||||||||||||||||||||||||||
| 2328 | 0 | ('manifest:file-entry'); | |||||||||||||||||||||||||||||||||
| 2329 | 0 | ▶ | unless (defined $opt{type}) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2330 | { | ||||||||||||||||||||||||||||||||||
| 2331 | 0 | return @all_entries; | |||||||||||||||||||||||||||||||||
| 2332 | } | ||||||||||||||||||||||||||||||||||
| 2333 | 0 | my @selected_entries = (); | |||||||||||||||||||||||||||||||||
| 2334 | 0 | ENTRY: foreach my $e (@all_entries) | |||||||||||||||||||||||||||||||||
| 2335 | { | ||||||||||||||||||||||||||||||||||
| 2336 | 0 | my $type = $e->get_attribute('media type'); | |||||||||||||||||||||||||||||||||
| 2337 | 0 | ▶ | next ENTRY unless defined $type; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2338 | 0 | ▶ | if ($opt{type} eq "") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2339 | { | ||||||||||||||||||||||||||||||||||
| 2340 | 0 | ▶ | push @selected_entries, $e if $type eq ""; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2341 | 0 | next ENTRY; | |||||||||||||||||||||||||||||||||
| 2342 | } | ||||||||||||||||||||||||||||||||||
| 2343 | 0 | ▶ | push @selected_entries, $e if $type =~ /$opt{type}/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2344 | } | ||||||||||||||||||||||||||||||||||
| 2345 | 0 | return @selected_entries; | |||||||||||||||||||||||||||||||||
| 2346 | } | ||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||
| 2348 | sub get_entry | ||||||||||||||||||||||||||||||||||
| 2349 | { | ||||||||||||||||||||||||||||||||||
| 2350 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
get_entry: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 2351 | return $self->{context}->get_element( | ||||||||||||||||||||||||||||||||||
| 2352 | 0 | 'manifest:file-entry', | |||||||||||||||||||||||||||||||||
| 2353 | attribute => 'full path', | ||||||||||||||||||||||||||||||||||
| 2354 | value => shift | ||||||||||||||||||||||||||||||||||
| 2355 | ); | ||||||||||||||||||||||||||||||||||
| 2356 | } | ||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||
| 2358 | sub set_entry | ||||||||||||||||||||||||||||||||||
| 2359 | { | ||||||||||||||||||||||||||||||||||
| 2360 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
set_entry: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 2361 | 0 | my $path = shift; | |||||||||||||||||||||||||||||||||
| 2362 | 0 | ▶ | unless ($path) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2363 | { | ||||||||||||||||||||||||||||||||||
| 2364 | 0 | alert "Missing entry path"; return FALSE; | |||||||||||||||||||||||||||||||||
| 2365 | } | ||||||||||||||||||||||||||||||||||
| 2366 | 0 | my $e = $self->get_entry($path); | |||||||||||||||||||||||||||||||||
| 2367 | 0 | my %opt = @_; | |||||||||||||||||||||||||||||||||
| 2368 | 0 | ▶ | unless ($e) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2369 | { | ||||||||||||||||||||||||||||||||||
| 2370 | 0 | $e = ODF::lpOD::Element->create('manifest:file-entry'); | |||||||||||||||||||||||||||||||||
| 2371 | 0 | $e->set_attribute('full path' => $path); | |||||||||||||||||||||||||||||||||
| 2372 | 0 | $e->paste_last_child($self->{context}); | |||||||||||||||||||||||||||||||||
| 2373 | } | ||||||||||||||||||||||||||||||||||
| 2374 | 0 | $e->set_type($opt{type}); | |||||||||||||||||||||||||||||||||
| 2375 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2376 | } | ||||||||||||||||||||||||||||||||||
| 2377 | |||||||||||||||||||||||||||||||||||
| 2378 | sub del_entry | ||||||||||||||||||||||||||||||||||
| 2379 | { | ||||||||||||||||||||||||||||||||||
| 2380 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||
|
Subroutine
del_entry: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 2381 | 0 | my $e = $self->get_entry(@_); | |||||||||||||||||||||||||||||||||
| 2382 | 0 | ▶ | $e->delete() if $e; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 2383 | 0 | return $e; | |||||||||||||||||||||||||||||||||
| 2384 | } | ||||||||||||||||||||||||||||||||||
| 2385 | |||||||||||||||||||||||||||||||||||
| 2386 | #============================================================================= | ||||||||||||||||||||||||||||||||||
| 2387 | 2 | 1; | |||||||||||||||||||||||||||||||||