| 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 | use 5.010_001; | ||
| 9 | use strict; | ||
| 10 | #============================================================================= | ||
| 11 | # Structured containers : Sections, lists, draw pages, frames, shapes... | ||
| 12 | #----------------------------------------------------------------------------- | ||
| 13 | package ODF::lpOD::StructuredContainer; | ||
| 14 | use base 'ODF::lpOD::Element'; | ||
| 15 | our $VERSION = '1.001'; | ||
| 16 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 17 | use ODF::lpOD::Common; | ||
| 18 | #============================================================================= | ||
| 19 | package ODF::lpOD::Section; | ||
| 20 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 21 | our $VERSION = '1.003'; | ||
| 22 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 23 | use ODF::lpOD::Common; | ||
| 24 | #============================================================================= | ||
| 25 | |||
| 26 | BEGIN { | ||
| 27 | *set_hyperlink = *set_source; | ||
| 28 | *get_hyperlink = *get_source; | ||
| 29 | *set_url = *set_source; | ||
| 30 | *get_url = *get_source; | ||
| 31 | } | ||
| 32 | |||
| 33 | #----------------------------------------------------------------------------- | ||
| 34 | |||
| 35 | sub _create { ODF::lpOD::Section->create(@_) } | ||
| 36 | |||
| 37 | #----------------------------------------------------------------------------- | ||
| 38 | |||
| 39 | sub create | ||
| 40 | { | ||
| 41 | my $caller = shift; | ||
| 42 | my $name = shift; | ||
| 43 | unless ($name) | ||
| 44 | { | ||
| 45 | alert "Missing section name"; | ||
| 46 | return FALSE; | ||
| 47 | } | ||
| 48 | |||
| 49 | my %opt = | ||
| 50 | ( | ||
| 51 | style => undef, | ||
| 52 | url => undef, | ||
| 53 | display => undef, | ||
| 54 | condition => undef, | ||
| 55 | protected => undef, | ||
| 56 | key => undef, | ||
| 57 | @_ | ||
| 58 | ); | ||
| 59 | |||
| 60 | my $s = ODF::lpOD::StructuredContainer->create('text:section'); | ||
| 61 | if (defined $opt{url} or defined $opt{source}) | ||
| 62 | { | ||
| 63 | my $link = $opt{url} || $opt{source}; | ||
| 64 | $s->set_source($link); | ||
| 65 | $opt{protected} = TRUE; | ||
| 66 | } | ||
| 67 | $s->set_protected($opt{protected}); | ||
| 68 | $s->set_name($name); | ||
| 69 | $s->set_style($opt{style}); | ||
| 70 | $s->set_attribute('protection key', $opt{key}); | ||
| 71 | $s->set_display($opt{display}); | ||
| 72 | $s->set_attribute('condition', $opt{condition}); | ||
| 73 | |||
| 74 | return $s; | ||
| 75 | } | ||
| 76 | |||
| 77 | #----------------------------------------------------------------------------- | ||
| 78 | |||
| 79 | sub set_display | ||
| 80 | { | ||
| 81 | my $self = shift; | ||
| 82 | my $value = shift // 'true'; | ||
| 83 | unless ($value eq 'true' || $value eq 'none' || $value eq 'condition') | ||
| 84 | { | ||
| 85 | if ($value == TRUE) | ||
| 86 | { | ||
| 87 | $value = 'true'; | ||
| 88 | } | ||
| 89 | elsif ($value == FALSE) | ||
| 90 | { | ||
| 91 | $value = 'none'; | ||
| 92 | } | ||
| 93 | else | ||
| 94 | { | ||
| 95 | alert "Wrong display parameter"; return undef; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | $self->set_attribute('display' => $value); | ||
| 99 | } | ||
| 100 | |||
| 101 | sub get_display | ||
| 102 | { | ||
| 103 | my $self = shift; | ||
| 104 | my $value = $self->get_attribute('display'); | ||
| 105 | if (!defined $value) { return TRUE } | ||
| 106 | elsif ($value eq 'true') { return TRUE } | ||
| 107 | elsif ($value eq 'none') { return FALSE } | ||
| 108 | else { return $value } | ||
| 109 | } | ||
| 110 | |||
| 111 | sub set_source | ||
| 112 | { | ||
| 113 | my $self = shift; | ||
| 114 | my $url = shift; | ||
| 115 | my %attr = @_; | ||
| 116 | |||
| 117 | my $source = $self->insert_element('section source'); | ||
| 118 | $source->set_attribute('xlink:href', $url); | ||
| 119 | $source->set_attributes({%attr}); | ||
| 120 | $self->set_protected(TRUE); | ||
| 121 | return $source; | ||
| 122 | } | ||
| 123 | |||
| 124 | sub get_source | ||
| 125 | { | ||
| 126 | my $self = shift; | ||
| 127 | my $source = $self->get_element('section source') or return undef; | ||
| 128 | return wantarray ? | ||
| 129 | $source->get_attributes() : | ||
| 130 | $source->get_attribute('xlink:href'); | ||
| 131 | } | ||
| 132 | |||
| 133 | #============================================================================= | ||
| 134 | package ODF::lpOD::List; | ||
| 135 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 136 | our $VERSION = '1.003'; | ||
| 137 | use constant PACKAGE_DATE => '2012-05-02T09:09:28'; | ||
| 138 | use ODF::lpOD::Common; | ||
| 139 | #----------------------------------------------------------------------------- | ||
| 140 | |||
| 141 | sub _create { ODF::lpOD::List->create(@_) } | ||
| 142 | |||
| 143 | #----------------------------------------------------------------------------- | ||
| 144 | |||
| 145 | sub create | ||
| 146 | { | ||
| 147 | my $caller = shift; | ||
| 148 | my %opt = process_options(@_); | ||
| 149 | my $list = ODF::lpOD::StructuredContainer->create('text:list'); | ||
| 150 | $list->set_style($opt{style}); | ||
| 151 | $list->set_id($opt{id}); | ||
| 152 | return $list; | ||
| 153 | } | ||
| 154 | |||
| 155 | #----------------------------------------------------------------------------- | ||
| 156 | |||
| 157 | sub get_id | ||
| 158 | { | ||
| 159 | my $self = shift; | ||
| 160 | return $self->get_attribute('xml:id'); | ||
| 161 | } | ||
| 162 | |||
| 163 | sub set_id | ||
| 164 | { | ||
| 165 | my $self = shift; | ||
| 166 | return $self->set_attribute('xml:id', shift); | ||
| 167 | } | ||
| 168 | |||
| 169 | sub get_item | ||
| 170 | { | ||
| 171 | my $self = shift; | ||
| 172 | my $p = shift; | ||
| 173 | if (is_numeric($p)) | ||
| 174 | { | ||
| 175 | return $self->get_element('text:list-item', position => $p); | ||
| 176 | } | ||
| 177 | push @_, $p; | ||
| 178 | return $self->get_element('text:list-item', @_); | ||
| 179 | } | ||
| 180 | |||
| 181 | sub get_item_list | ||
| 182 | { | ||
| 183 | my $self = shift; | ||
| 184 | return $self->get_element_list('text:list-item', @_); | ||
| 185 | } | ||
| 186 | |||
| 187 | sub add_item | ||
| 188 | { | ||
| 189 | my $self = shift; | ||
| 190 | my %opt = process_options | ||
| 191 | ( | ||
| 192 | number => 1, | ||
| 193 | @_ | ||
| 194 | ); | ||
| 195 | my $ref_elt = $opt{after} || $opt{before}; | ||
| 196 | my $position = undef; | ||
| 197 | if ($ref_elt) | ||
| 198 | { | ||
| 199 | if ($opt{before} && $opt{after}) | ||
| 200 | { | ||
| 201 | alert "'before' and 'after' are mutually exclusive"; | ||
| 202 | return FALSE; | ||
| 203 | } | ||
| 204 | $position = $opt{before} ? 'before' : 'after'; | ||
| 205 | $ref_elt = $self->get_item($ref_elt) unless ref $ref_elt; | ||
| 206 | unless ( | ||
| 207 | $ref_elt->is('text:list-item') | ||
| 208 | && | ||
| 209 | $ref_elt->parent() == $self | ||
| 210 | ) | ||
| 211 | { | ||
| 212 | alert "Wrong list item $position reference"; | ||
| 213 | return FALSE; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | my $number = $opt{number}; | ||
| 217 | my $text = $opt{text}; | ||
| 218 | my $style = $opt{style}; | ||
| 219 | my $start = $opt{start_value}; | ||
| 220 | delete @opt{qw(number before after text style start_value)}; | ||
| 221 | return undef unless $number && ($number > 0); | ||
| 222 | my $elt; | ||
| 223 | if ($ref_elt) | ||
| 224 | { | ||
| 225 | $elt = $ref_elt->clone; | ||
| 226 | $elt->cut_children; | ||
| 227 | } | ||
| 228 | else | ||
| 229 | { | ||
| 230 | $elt = ODF::lpOD::Element->create('text:list-item'); | ||
| 231 | } | ||
| 232 | if (defined $text || defined $style) | ||
| 233 | { | ||
| 234 | my $p = ODF::lpOD::Paragraph->create | ||
| 235 | (text => $text, style => $style); | ||
| 236 | $p->paste_last_child($elt); | ||
| 237 | } | ||
| 238 | if ($ref_elt) | ||
| 239 | { | ||
| 240 | $elt->paste($position, $ref_elt); | ||
| 241 | } | ||
| 242 | else | ||
| 243 | { | ||
| 244 | $elt->paste_last_child($self); | ||
| 245 | } | ||
| 246 | my @items = (); | ||
| 247 | push @items, $elt; | ||
| 248 | if ($number) | ||
| 249 | { | ||
| 250 | while ($number > 1) | ||
| 251 | { | ||
| 252 | my $cp = $elt->clone; | ||
| 253 | $cp->paste_after($elt); | ||
| 254 | push @items, $cp; | ||
| 255 | $number--; | ||
| 256 | } | ||
| 257 | } | ||
| 258 | $elt->set_attribute('start value', $start) if defined $start; | ||
| 259 | return wantarray ? @items : $elt; | ||
| 260 | } | ||
| 261 | |||
| 262 | sub set_header | ||
| 263 | { | ||
| 264 | my $self = shift; | ||
| 265 | my $h = $self->get_element('text:list-header'); | ||
| 266 | $h->delete if $h; | ||
| 267 | $h = ODF::lpOD::Element->create('text:list-header'); | ||
| 268 | $h->paste_first_child($self); | ||
| 269 | while (@_) | ||
| 270 | { | ||
| 271 | my $c = shift; | ||
| 272 | my $elt = ref $c ? | ||
| 273 | $c : ODF::lpOD::Paragraph->create(text => $c); | ||
| 274 | $elt->paste_last_child($h); | ||
| 275 | } | ||
| 276 | return $h; | ||
| 277 | } | ||
| 278 | |||
| 279 | #============================================================================= | ||
| 280 | package ODF::lpOD::DrawPage; | ||
| 281 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 282 | our $VERSION = '1.004'; | ||
| 283 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 284 | use ODF::lpOD::Common; | ||
| 285 | #----------------------------------------------------------------------------- | ||
| 286 | |||
| 287 | sub _create { ODF::lpOD::DrawPage->create(@_) } | ||
| 288 | |||
| 289 | #----------------------------------------------------------------------------- | ||
| 290 | |||
| 291 | sub create | ||
| 292 | { | ||
| 293 | my $caller = shift; | ||
| 294 | my $id = shift; | ||
| 295 | unless ($id) | ||
| 296 | { | ||
| 297 | alert "Missing draw page identifier"; return FALSE; | ||
| 298 | } | ||
| 299 | my %opt = @_; | ||
| 300 | my $dp = ODF::lpOD::StructuredContainer->create('draw:page'); | ||
| 301 | $dp->set_id($id); | ||
| 302 | $dp->set_name($opt{'name'}); | ||
| 303 | $dp->set_style($opt{style}); | ||
| 304 | $dp->set_master($opt{master}); | ||
| 305 | $dp->set_layout($opt{layout} ); | ||
| 306 | return $dp; | ||
| 307 | } | ||
| 308 | |||
| 309 | #----------------------------------------------------------------------------- | ||
| 310 | |||
| 311 | sub get_master | ||
| 312 | { | ||
| 313 | my $self = shift; | ||
| 314 | return $self->get_attribute('master page name'); | ||
| 315 | } | ||
| 316 | |||
| 317 | sub set_master | ||
| 318 | { | ||
| 319 | my $self = shift; | ||
| 320 | return $self->set_attribute('master page name', shift); | ||
| 321 | } | ||
| 322 | |||
| 323 | sub get_layout | ||
| 324 | { | ||
| 325 | my $self = shift; | ||
| 326 | return $self->get_attribute | ||
| 327 | ('presentation:presentation-page-layout-name'); | ||
| 328 | } | ||
| 329 | |||
| 330 | sub set_layout | ||
| 331 | { | ||
| 332 | my $self = shift; | ||
| 333 | return $self->set_attribute | ||
| 334 | ('presentation:presentation-page-layout-name', shift); | ||
| 335 | } | ||
| 336 | |||
| 337 | sub get_title_frame | ||
| 338 | { | ||
| 339 | my $self = shift; | ||
| 340 | return $self->get_element | ||
| 341 | ( | ||
| 342 | 'draw:frame', | ||
| 343 | attribute => 'presentation:class', | ||
| 344 | value => 'title' | ||
| 345 | ); | ||
| 346 | } | ||
| 347 | |||
| 348 | sub get_title | ||
| 349 | { | ||
| 350 | my $self = shift; | ||
| 351 | my $frame = $self->get_title_frame or return undef; | ||
| 352 | my $p = $frame->get_paragraph or return undef; | ||
| 353 | return $p->get_text; | ||
| 354 | } | ||
| 355 | |||
| 356 | #============================================================================= | ||
| 357 | package ODF::lpOD::Shape; | ||
| 358 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 359 | our $VERSION = '1.003'; | ||
| 360 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 361 | use ODF::lpOD::Common; | ||
| 362 | #----------------------------------------------------------------------------- | ||
| 363 | |||
| 364 | sub _create { ODF::lpOD::Shape->create(@_) } | ||
| 365 | |||
| 366 | #----------------------------------------------------------------------------- | ||
| 367 | |||
| 368 | sub create | ||
| 369 | { | ||
| 370 | my $caller = shift; | ||
| 371 | my %opt = process_options(@_); | ||
| 372 | my $tag = $opt{tag}; $tag = 'draw:' . $tag unless $tag =~ /:/; | ||
| 373 | my $f = ODF::lpOD::StructuredContainer->create($tag); | ||
| 374 | $f->set_attribute('name' => $opt{name}); | ||
| 375 | $f->set_style($opt{style}); | ||
| 376 | $f->set_text_style($opt{text_style}); | ||
| 377 | $f->set_position($opt{position}); | ||
| 378 | if (defined $opt{page}) | ||
| 379 | { | ||
| 380 | $f->set_anchor_page($opt{page}); | ||
| 381 | } | ||
| 382 | else | ||
| 383 | { | ||
| 384 | $f->set_attribute('text:anchor-type' => $opt{anchor_type}); | ||
| 385 | } | ||
| 386 | $f->set_title($opt{title}); | ||
| 387 | $f->set_description($opt{description}); | ||
| 388 | delete @opt | ||
| 389 | {qw( | ||
| 390 | tag name style size position page | ||
| 391 | anchor_type title description | ||
| 392 | )}; | ||
| 393 | foreach my $a (keys %opt) | ||
| 394 | { | ||
| 395 | $f->set_attribute($a => $opt{$a}); | ||
| 396 | } | ||
| 397 | return $f; | ||
| 398 | } | ||
| 399 | |||
| 400 | #----------------------------------------------------------------------------- | ||
| 401 | |||
| 402 | sub input_2d | ||
| 403 | { | ||
| 404 | my $self = shift; | ||
| 405 | return input_2d_value(@_); | ||
| 406 | } | ||
| 407 | |||
| 408 | sub set_anchor_page | ||
| 409 | { | ||
| 410 | my $self = shift; | ||
| 411 | my $number = shift; | ||
| 412 | $self->set_attribute('text:anchor-page-number' => $number); | ||
| 413 | $self->set_attribute('text:anchor-type' => 'page'); | ||
| 414 | return $number; | ||
| 415 | } | ||
| 416 | |||
| 417 | sub get_anchor_page | ||
| 418 | { | ||
| 419 | my $self = shift; | ||
| 420 | return $self->get_attribute('text:anchor-page-number'); | ||
| 421 | } | ||
| 422 | |||
| 423 | sub set_title | ||
| 424 | { | ||
| 425 | my $self = shift; | ||
| 426 | my $t = $self->set_last_child('svg:title', shift); | ||
| 427 | return $t; | ||
| 428 | } | ||
| 429 | |||
| 430 | sub get_title | ||
| 431 | { | ||
| 432 | my $self = shift; | ||
| 433 | my $t = $self->get_element('svg:title') or return undef; | ||
| 434 | return $t->get_text; | ||
| 435 | } | ||
| 436 | |||
| 437 | sub set_description | ||
| 438 | { | ||
| 439 | my $self = shift; | ||
| 440 | my $t = $self->set_last_child('svg:desc', shift); | ||
| 441 | return $t; | ||
| 442 | } | ||
| 443 | |||
| 444 | sub get_description | ||
| 445 | { | ||
| 446 | my $self = shift; | ||
| 447 | my $t = $self->get_element('svg:desc') or return undef; | ||
| 448 | return $t->get_text; | ||
| 449 | } | ||
| 450 | |||
| 451 | sub set_text_style | ||
| 452 | { | ||
| 453 | my $self = shift; | ||
| 454 | return $self->set_attribute('text style name' => shift); | ||
| 455 | } | ||
| 456 | |||
| 457 | sub get_text_style | ||
| 458 | { | ||
| 459 | my $self = shift; | ||
| 460 | return $self->get_attribute('text style name'); | ||
| 461 | } | ||
| 462 | |||
| 463 | #============================================================================= | ||
| 464 | package ODF::lpOD::Area; | ||
| 465 | use base 'ODF::lpOD::Shape'; | ||
| 466 | our $VERSION = '1.002'; | ||
| 467 | use constant PACKAGE_DATE => '2011-02-19T19:54:55'; | ||
| 468 | use ODF::lpOD::Common; | ||
| 469 | #----------------------------------------------------------------------------- | ||
| 470 | |||
| 471 | sub _create { ODF::lpOD::Area->create(@_) } | ||
| 472 | |||
| 473 | #----------------------------------------------------------------------------- | ||
| 474 | |||
| 475 | sub create | ||
| 476 | { | ||
| 477 | my $caller = shift; | ||
| 478 | my %opt = @_; | ||
| 479 | my $size = $opt{size}; | ||
| 480 | delete @opt {qw(start end size)}; | ||
| 481 | my $a = ODF::lpOD::Shape->create(%opt) or return undef; | ||
| 482 | $a->set_size($size); | ||
| 483 | return $a; | ||
| 484 | } | ||
| 485 | |||
| 486 | #============================================================================= | ||
| 487 | package ODF::lpOD::Rectangle; | ||
| 488 | use base 'ODF::lpOD::Area'; | ||
| 489 | our $VERSION = '1.001'; | ||
| 490 | use constant PACKAGE_DATE => '2010-12-29T22:55:59'; | ||
| 491 | use ODF::lpOD::Common; | ||
| 492 | #----------------------------------------------------------------------------- | ||
| 493 | |||
| 494 | sub _create { ODF::lpOD::Rectangle->create(@_) } | ||
| 495 | |||
| 496 | #----------------------------------------------------------------------------- | ||
| 497 | |||
| 498 | sub create | ||
| 499 | { | ||
| 500 | my $caller = shift; | ||
| 501 | my $r = ODF::lpOD::Area->create(tag => 'rect', @_); | ||
| 502 | } | ||
| 503 | |||
| 504 | #============================================================================= | ||
| 505 | package ODF::lpOD::Ellipse; | ||
| 506 | use base 'ODF::lpOD::Area'; | ||
| 507 | our $VERSION = '1.001'; | ||
| 508 | use constant PACKAGE_DATE => '2010-12-29T22:56:09'; | ||
| 509 | use ODF::lpOD::Common; | ||
| 510 | #----------------------------------------------------------------------------- | ||
| 511 | |||
| 512 | sub _create { ODF::lpOD::Ellipse->create(@_) } | ||
| 513 | |||
| 514 | #----------------------------------------------------------------------------- | ||
| 515 | |||
| 516 | sub create | ||
| 517 | { | ||
| 518 | my $caller = shift; | ||
| 519 | return ODF::lpOD::Area->create(tag => 'ellipse', @_); | ||
| 520 | } | ||
| 521 | |||
| 522 | #============================================================================= | ||
| 523 | package ODF::lpOD::Vector; | ||
| 524 | use base 'ODF::lpOD::Shape'; | ||
| 525 | our $VERSION = '1.001'; | ||
| 526 | use constant PACKAGE_DATE => '2010-12-29T22:56:38'; | ||
| 527 | use ODF::lpOD::Common; | ||
| 528 | #----------------------------------------------------------------------------- | ||
| 529 | |||
| 530 | sub _create { ODF::lpOD::Vector->create(@_) } | ||
| 531 | |||
| 532 | #----------------------------------------------------------------------------- | ||
| 533 | |||
| 534 | sub create | ||
| 535 | { | ||
| 536 | my $caller = shift; | ||
| 537 | my %opt = @_; | ||
| 538 | my $start = $opt{start}; | ||
| 539 | my $end = $opt{end}; | ||
| 540 | delete @opt {qw(start end position size)}; | ||
| 541 | my $v = ODF::lpOD::Shape->create(%opt); | ||
| 542 | $v->set_start_position($start); | ||
| 543 | $v->set_end_position($end); | ||
| 544 | return $v; | ||
| 545 | } | ||
| 546 | |||
| 547 | #----------------------------------------------------------------------------- | ||
| 548 | |||
| 549 | sub set_start_position | ||
| 550 | { | ||
| 551 | my $self = shift; | ||
| 552 | my ($x, $y) = input_2d_value(@_); | ||
| 553 | $self->set_attribute('svg:x1' => $x); | ||
| 554 | $self->set_attribute('svg:y1' => $y); | ||
| 555 | return ($x, $y); | ||
| 556 | } | ||
| 557 | |||
| 558 | sub set_end_position | ||
| 559 | { | ||
| 560 | my $self = shift; | ||
| 561 | my ($x, $y) = input_2d_value(@_); | ||
| 562 | $self->set_attribute('svg:x2' => $x); | ||
| 563 | $self->set_attribute('svg:y2' => $y); | ||
| 564 | return ($x, $y); | ||
| 565 | } | ||
| 566 | |||
| 567 | sub get_position | ||
| 568 | { | ||
| 569 | my $self = shift; | ||
| 570 | my @p = | ||
| 571 | ( | ||
| 572 | $self->get_attribute('svg:x1'), | ||
| 573 | $self->get_attribute('svg:y1'), | ||
| 574 | $self->get_attribute('svg:x2'), | ||
| 575 | $self->get_attribute('svg:y2') | ||
| 576 | ); | ||
| 577 | return wantarray ? @p : [ @p ]; | ||
| 578 | } | ||
| 579 | |||
| 580 | sub set_position | ||
| 581 | { | ||
| 582 | my $self = shift; | ||
| 583 | my $arg = shift; | ||
| 584 | my ($x1, $y1, $x2, $y2); | ||
| 585 | if (ref $arg) | ||
| 586 | { | ||
| 587 | ($x1, $y1, $x2, $y2) = @{$arg}; | ||
| 588 | } | ||
| 589 | else | ||
| 590 | { | ||
| 591 | ($x1, $y1, $x2, $y2) = ($arg, @_); | ||
| 592 | } | ||
| 593 | $self->set_attribute('svg:x1' => $x1); | ||
| 594 | $self->set_attribute('svg:y1' => $y1); | ||
| 595 | $self->set_attribute('svg:x2' => $x2); | ||
| 596 | $self->set_attribute('svg:y2' => $y2); | ||
| 597 | return wantarray ? ($x1, $y1, $x2, $y2) : [ ($x1, $y1, $x2, $y2) ]; | ||
| 598 | } | ||
| 599 | |||
| 600 | #============================================================================= | ||
| 601 | package ODF::lpOD::Line; | ||
| 602 | use base 'ODF::lpOD::Vector'; | ||
| 603 | our $VERSION = '1.001'; | ||
| 604 | use constant PACKAGE_DATE => '2010-12-29T18:15:40'; | ||
| 605 | use ODF::lpOD::Common; | ||
| 606 | #----------------------------------------------------------------------------- | ||
| 607 | |||
| 608 | sub _create { ODF::lpOD::Line->create(@_) } | ||
| 609 | |||
| 610 | #----------------------------------------------------------------------------- | ||
| 611 | |||
| 612 | sub create | ||
| 613 | { | ||
| 614 | my $caller = shift; | ||
| 615 | return ODF::lpOD::Vector->create(tag => 'line', @_); | ||
| 616 | } | ||
| 617 | |||
| 618 | #============================================================================= | ||
| 619 | package ODF::lpOD::Connector; | ||
| 620 | use base 'ODF::lpOD::Vector'; | ||
| 621 | our $VERSION = '1.001'; | ||
| 622 | use constant PACKAGE_DATE => '2010-12-29T22:58:03'; | ||
| 623 | use ODF::lpOD::Common; | ||
| 624 | #----------------------------------------------------------------------------- | ||
| 625 | |||
| 626 | sub _create { ODF::lpOD::Connector->create(@_) } | ||
| 627 | |||
| 628 | #----------------------------------------------------------------------------- | ||
| 629 | |||
| 630 | sub create | ||
| 631 | { | ||
| 632 | my $caller = shift; | ||
| 633 | my %opt = process_options(@_); | ||
| 634 | my $cs = $opt{connected_shapes}; | ||
| 635 | my $gp = $opt{glue_points}; | ||
| 636 | my $type = $opt{type}; | ||
| 637 | delete @opt{qw(connected_shapes glue_points type)}; | ||
| 638 | my $connector = ODF::lpOD::Vector->create(tag => 'connector', %opt); | ||
| 639 | $connector->set_connected_shapes($cs); | ||
| 640 | $connector->set_glue_points($gp); | ||
| 641 | $connector->set_type($type); | ||
| 642 | return $connector; | ||
| 643 | } | ||
| 644 | |||
| 645 | #----------------------------------------------------------------------------- | ||
| 646 | |||
| 647 | sub set_connected_shapes | ||
| 648 | { | ||
| 649 | my $self = shift; | ||
| 650 | my $arg = shift; | ||
| 651 | my $ra = ref $arg or return undef; | ||
| 652 | my ($start, $end); | ||
| 653 | if ($ra eq 'ARRAY') | ||
| 654 | { | ||
| 655 | ($start, $end) = @$arg; | ||
| 656 | } | ||
| 657 | else | ||
| 658 | { | ||
| 659 | ($start, $end) = ($arg, @_); | ||
| 660 | } | ||
| 661 | $self->set_attribute('start shape' => $start); | ||
| 662 | $self->set_attribute('end shape' => $end); | ||
| 663 | return wantarray ? ($start, $end) : [ ($start, $end) ]; | ||
| 664 | } | ||
| 665 | |||
| 666 | sub get_connected_shapes | ||
| 667 | { | ||
| 668 | my $self = shift; | ||
| 669 | my $start = $self->get_attribute('start shape'); | ||
| 670 | my $end = $self->get_attribute('end shape'); | ||
| 671 | return wantarray ? ($start, $end) : [ ($start, $end) ]; | ||
| 672 | } | ||
| 673 | |||
| 674 | sub set_glue_points | ||
| 675 | { | ||
| 676 | my $self = shift; | ||
| 677 | my $arg = shift; | ||
| 678 | my ($sgp, $egp); | ||
| 679 | if (ref $arg) | ||
| 680 | { | ||
| 681 | ($sgp, $egp) = @$arg; | ||
| 682 | } | ||
| 683 | else | ||
| 684 | { | ||
| 685 | ($sgp, $egp) = ($arg, @_); | ||
| 686 | } | ||
| 687 | $self->set_attribute('start glue point' => $sgp); | ||
| 688 | $self->set_attribute('end glue point' => $egp); | ||
| 689 | return wantarray ? ($sgp, $egp) : [ ($sgp, $egp) ]; | ||
| 690 | } | ||
| 691 | |||
| 692 | sub get_glue_points | ||
| 693 | { | ||
| 694 | my $self = shift; | ||
| 695 | my $sgp = $self->get_attribute('start glue point'); | ||
| 696 | my $egp = $self->get_attribute('end glue point'); | ||
| 697 | return wantarray ? ($sgp, $egp) : [ ($sgp, $egp) ]; | ||
| 698 | } | ||
| 699 | |||
| 700 | sub set_type | ||
| 701 | { | ||
| 702 | my $self = shift; | ||
| 703 | my $type = shift or return undef; | ||
| 704 | unless ($type =~ /^(standard|lines|line|curve)$/) | ||
| 705 | { | ||
| 706 | alert "Not allowed connector type $type"; | ||
| 707 | return FALSE; | ||
| 708 | } | ||
| 709 | $self->set_attribute('type' => $type); | ||
| 710 | return $type; | ||
| 711 | } | ||
| 712 | |||
| 713 | sub get_type | ||
| 714 | { | ||
| 715 | my $self = shift; | ||
| 716 | return $self->get_attribute('type'); | ||
| 717 | } | ||
| 718 | |||
| 719 | #============================================================================= | ||
| 720 | package ODF::lpOD::Frame; | ||
| 721 | use base 'ODF::lpOD::Area'; | ||
| 722 | our $VERSION = '1.007'; | ||
| 723 | use constant PACKAGE_DATE => '2012-02-20T08:25:26'; | ||
| 724 | use ODF::lpOD::Common; | ||
| 725 | #----------------------------------------------------------------------------- | ||
| 726 | |||
| 727 | sub _create { ODF::lpOD::Frame->create(@_) } | ||
| 728 | |||
| 729 | sub _create_text | ||
| 730 | { | ||
| 731 | my $text = shift; | ||
| 732 | return ODF::lpOD::Frame->create(text => $text, @_); | ||
| 733 | } | ||
| 734 | |||
| 735 | sub _create_image | ||
| 736 | { | ||
| 737 | my $link = shift; | ||
| 738 | return ODF::lpOD::Frame->create(image => $link, @_); | ||
| 739 | } | ||
| 740 | |||
| 741 | #----------------------------------------------------------------------------- | ||
| 742 | |||
| 743 | sub create | ||
| 744 | { | ||
| 745 | my $caller = shift; | ||
| 746 | my %opt = process_options(@_); | ||
| 747 | $opt{tag} = 'frame'; | ||
| 748 | my $fr; | ||
| 749 | my $pc = $opt{class}; delete $opt{class}; | ||
| 750 | if ($opt{image}) | ||
| 751 | { | ||
| 752 | if ($opt{text}) | ||
| 753 | { | ||
| 754 | alert "image and text parameters " . | ||
| 755 | "are mutually exlusive"; | ||
| 756 | return undef; | ||
| 757 | } | ||
| 758 | my $link = $opt{image}; delete $opt{image}; | ||
| 759 | $fr = ODF::lpOD::Area->create(%opt) or return undef; | ||
| 760 | $link && $fr->set_image($link); | ||
| 761 | } | ||
| 762 | elsif ($opt{text}) | ||
| 763 | { | ||
| 764 | my $text = $opt{text}; delete $opt{text}; | ||
| 765 | $fr = ODF::lpOD::Area->create(%opt) or return undef; | ||
| 766 | $fr->set_text_box($text); | ||
| 767 | } | ||
| 768 | else | ||
| 769 | { | ||
| 770 | $fr = ODF::lpOD::Area->create(%opt); | ||
| 771 | } | ||
| 772 | $fr->set_attribute('presentation:class' => $pc) if $pc; | ||
| 773 | return $fr; | ||
| 774 | } | ||
| 775 | |||
| 776 | #----------------------------------------------------------------------------- | ||
| 777 | |||
| 778 | sub get_image | ||
| 779 | { | ||
| 780 | my $self = shift; | ||
| 781 | return $self->get_element('draw:image'); | ||
| 782 | } | ||
| 783 | |||
| 784 | sub set_image | ||
| 785 | { | ||
| 786 | my $self = shift; | ||
| 787 | my $source = shift; | ||
| 788 | my $link; | ||
| 789 | if (ref $source) | ||
| 790 | { | ||
| 791 | if ($source->is('draw:image')) | ||
| 792 | { | ||
| 793 | $source->paste_last_child($self); | ||
| 794 | return $source; | ||
| 795 | } | ||
| 796 | else | ||
| 797 | { | ||
| 798 | alert "Non-valid image element"; | ||
| 799 | return FALSE; | ||
| 800 | } | ||
| 801 | } | ||
| 802 | unless ($source) | ||
| 803 | { | ||
| 804 | alert "Missing image URL"; return FALSE; | ||
| 805 | } | ||
| 806 | my %opt = @_; | ||
| 807 | my ($w, $h) = $self->get_size; | ||
| 808 | my $sized = (defined $w && defined $h); | ||
| 809 | if (is_true($opt{load})) | ||
| 810 | { | ||
| 811 | my $doc = $self->document; | ||
| 812 | if ($doc && $doc->{container}) | ||
| 813 | { | ||
| 814 | unless ($sized || defined $opt{size}) | ||
| 815 | { | ||
| 816 | ($link, $opt{size}) = | ||
| 817 | $doc->add_image_file($source); | ||
| 818 | } | ||
| 819 | else | ||
| 820 | { | ||
| 821 | $link = $doc->add_image_file($source); | ||
| 822 | } | ||
| 823 | } | ||
| 824 | else | ||
| 825 | { | ||
| 826 | alert "Image loading not allowed out of a document"; | ||
| 827 | return FALSE; | ||
| 828 | } | ||
| 829 | } | ||
| 830 | else | ||
| 831 | { | ||
| 832 | $link = $source; | ||
| 833 | } | ||
| 834 | my $image = $self->set_first_child('draw:image'); | ||
| 835 | if (defined $opt{size}) | ||
| 836 | { | ||
| 837 | $self->set_size($opt{size}); | ||
| 838 | delete $opt{size}; | ||
| 839 | } | ||
| 840 | else | ||
| 841 | { | ||
| 842 | unless ($sized) | ||
| 843 | { | ||
| 844 | my $doc; | ||
| 845 | my $size; | ||
| 846 | $doc = $self->get_document if $source =~ /^Pictures\//; | ||
| 847 | if ($doc) | ||
| 848 | { | ||
| 849 | my $st = $doc->get_stored_part($source); | ||
| 850 | if ($st->{data}) | ||
| 851 | { | ||
| 852 | $size = is_true($st->{string}) ? | ||
| 853 | image_size(\$st->{data}) : | ||
| 854 | image_size($st->{data}); | ||
| 855 | } | ||
| 856 | else | ||
| 857 | { | ||
| 858 | $size = image_size | ||
| 859 | ($source, document => $doc); | ||
| 860 | } | ||
| 861 | } | ||
| 862 | else | ||
| 863 | { | ||
| 864 | $size = image_size($source); | ||
| 865 | } | ||
| 866 | $self->set_size($size); | ||
| 867 | } | ||
| 868 | } | ||
| 869 | $image->set_attribute('xlink:href' => $link); | ||
| 870 | foreach my $o (keys %opt) | ||
| 871 | { | ||
| 872 | my $att = ($o =~ /:/) ? $o : 'xlink:' . $o; | ||
| 873 | $image->set_attribute($att => $opt{$o}); | ||
| 874 | } | ||
| 875 | return $image; | ||
| 876 | } | ||
| 877 | |||
| 878 | #----------------------------------------------------------------------------- | ||
| 879 | |||
| 880 | sub get_text_box | ||
| 881 | { | ||
| 882 | my $self = shift; | ||
| 883 | return $self->get_element('draw:text-box'); | ||
| 884 | } | ||
| 885 | |||
| 886 | sub set_text_box | ||
| 887 | { | ||
| 888 | my $self = shift; | ||
| 889 | my $t = $self->set_first_child('draw:text-box'); | ||
| 890 | my @list = @_; | ||
| 891 | foreach my $e (@list) | ||
| 892 | { | ||
| 893 | if (ref $e) | ||
| 894 | { | ||
| 895 | $e->paste_last_child($t); | ||
| 896 | } | ||
| 897 | else | ||
| 898 | { | ||
| 899 | ODF::lpOD::Paragraph->create(text => $e) | ||
| 900 | ->paste_last_child($t); | ||
| 901 | } | ||
| 902 | } | ||
| 903 | return $t; | ||
| 904 | } | ||
| 905 | |||
| 906 | sub set_hyperlink | ||
| 907 | { | ||
| 908 | my $self = shift; | ||
| 909 | unless ($self->parent) | ||
| 910 | { | ||
| 911 | alert "Not allowed with non-attached frames"; | ||
| 912 | return FALSE; | ||
| 913 | } | ||
| 914 | my %opt = process_options(@_); | ||
| 915 | unless ($opt{url}) | ||
| 916 | { | ||
| 917 | alert("Missing URL"); return FALSE; | ||
| 918 | } | ||
| 919 | $opt{'xlink:href'} = $opt{url}; | ||
| 920 | $opt{'office:name'} = $opt{name}; | ||
| 921 | delete @opt{qw(url name)}; | ||
| 922 | return $self->set_parent('draw:a', undef, %opt); | ||
| 923 | } | ||
| 924 | |||
| 925 | sub get_hyperlink | ||
| 926 | { | ||
| 927 | my $self = shift; | ||
| 928 | my $parent = $self->parent; | ||
| 929 | return ($parent && $parent->is('draw:a')) ? $parent : undef; | ||
| 930 | } | ||
| 931 | |||
| 932 | #============================================================================= | ||
| 933 | package ODF::lpOD::Image; | ||
| 934 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 935 | our $VERSION = '1.002'; | ||
| 936 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 937 | use ODF::lpOD::Common; | ||
| 938 | #----------------------------------------------------------------------------- | ||
| 939 | |||
| 940 | sub _create { ODF::lpOD::Image->create(@_) } | ||
| 941 | |||
| 942 | #----------------------------------------------------------------------------- | ||
| 943 | |||
| 944 | sub create | ||
| 945 | { | ||
| 946 | my $caller = shift; | ||
| 947 | my %opt = @_; | ||
| 948 | my $image = ODF::lpOD::StructuredContainer->create('draw:image'); | ||
| 949 | my $uri = $opt{url} || $opt{uri}; | ||
| 950 | if ($uri) | ||
| 951 | { | ||
| 952 | $image->set_uri($uri); | ||
| 953 | } | ||
| 954 | elsif ($opt{content}) | ||
| 955 | { | ||
| 956 | $image->set_content($opt{content}); | ||
| 957 | } | ||
| 958 | else | ||
| 959 | { | ||
| 960 | alert "Missing image resource URI or content"; | ||
| 961 | return FALSE; | ||
| 962 | } | ||
| 963 | return $image; | ||
| 964 | } | ||
| 965 | |||
| 966 | #----------------------------------------------------------------------------- | ||
| 967 | |||
| 968 | sub set_uri | ||
| 969 | { | ||
| 970 | my $self = shift; | ||
| 971 | my $uri = shift; | ||
| 972 | $self->set_attribute('xlink:href' => $uri); | ||
| 973 | my $bin = $self->first_child('office:binary-data'); | ||
| 974 | $bin->delete() if $bin; | ||
| 975 | return $uri; | ||
| 976 | } | ||
| 977 | |||
| 978 | sub get_uri | ||
| 979 | { | ||
| 980 | my $self = shift; | ||
| 981 | return $self->get_attribute('xlink:href'); | ||
| 982 | } | ||
| 983 | |||
| 984 | sub set_content | ||
| 985 | { | ||
| 986 | my $self = shift; | ||
| 987 | my $bin = $self->first_child('office:binary-data'); | ||
| 988 | unless ($bin) | ||
| 989 | { | ||
| 990 | $bin = ODF::lpOD::Element->create('office:binary-data'); | ||
| 991 | $bin->paste_last_child($self); | ||
| 992 | } | ||
| 993 | my $content = shift; | ||
| 994 | $bin->_set_text($content); | ||
| 995 | $self->del_attribute('xlink:href'); | ||
| 996 | return $content; | ||
| 997 | } | ||
| 998 | |||
| 999 | sub get_content | ||
| 1000 | { | ||
| 1001 | my $self = shift; | ||
| 1002 | my $bin = $self->first_child('office:binary-data') or return undef; | ||
| 1003 | return $bin->text; | ||
| 1004 | } | ||
| 1005 | |||
| 1006 | #============================================================================= | ||
| 1007 | package ODF::lpOD::TOC; | ||
| 1008 | use base 'ODF::lpOD::StructuredContainer'; | ||
| 1009 | our $VERSION = '1.003'; | ||
| 1010 | use constant PACKAGE_DATE => '2011-11-15T19:52:49'; | ||
| 1011 | use ODF::lpOD::Common; | ||
| 1012 | #----------------------------------------------------------------------------- | ||
| 1013 | |||
| 1014 | use constant TOC_SOURCE => 'text:table-of-content-source'; | ||
| 1015 | use constant TOC_ENTRY_TEMPLATE => 'text:table-of-content-entry-template'; | ||
| 1016 | use constant TOC_TITLE_TEMPLATE => 'text:index-title-template'; | ||
| 1017 | use constant TOC_BODY => 'text:index-body'; | ||
| 1018 | |||
| 1019 | #----------------------------------------------------------------------------- | ||
| 1020 | |||
| 1021 | sub _create { ODF::lpOD::TOC->create(@_) } | ||
| 1022 | |||
| 1023 | #----------------------------------------------------------------------------- | ||
| 1024 | |||
| 1025 | sub create | ||
| 1026 | { | ||
| 1027 | my $caller = shift; | ||
| 1028 | my $name = shift; | ||
| 1029 | my %opt = process_options(@_); | ||
| 1030 | my $toc = ODF::lpOD::StructuredContainer->create | ||
| 1031 | ('text:table-of-content'); | ||
| 1032 | $toc->set_name($name); | ||
| 1033 | $toc->set_style($opt{style}); | ||
| 1034 | $toc->set_protected($opt{protected} // TRUE); | ||
| 1035 | $toc->set_outline_level($opt{outline_level} // 10); | ||
| 1036 | $toc->set_use_outline($opt{use_outline} // TRUE); | ||
| 1037 | $toc->set_use_index_marks($opt{use_index_marks} // FALSE); | ||
| 1038 | $toc->set_title($opt{title} // $name); | ||
| 1039 | return $toc; | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | #----------------------------------------------------------------------------- | ||
| 1043 | |||
| 1044 | sub get_source | ||
| 1045 | { | ||
| 1046 | my $self = shift; | ||
| 1047 | return $self->first_child(TOC_SOURCE); | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | sub set_source | ||
| 1051 | { | ||
| 1052 | my $self = shift; | ||
| 1053 | return $self->set_child(TOC_SOURCE); | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | sub get_body | ||
| 1057 | { | ||
| 1058 | my $self = shift; | ||
| 1059 | return $self->first_child(TOC_BODY); | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | sub set_body | ||
| 1063 | { | ||
| 1064 | my $self = shift; | ||
| 1065 | return $self->set_child(TOC_BODY); | ||
| 1066 | } | ||
| 1067 | |||
| 1068 | sub source_attribute | ||
| 1069 | { | ||
| 1070 | my $self = shift; | ||
| 1071 | my $attr = shift; | ||
| 1072 | my %opt = @_; | ||
| 1073 | my ($source, $val); | ||
| 1074 | if (exists $opt{value}) | ||
| 1075 | { | ||
| 1076 | $source = $self->set_source; | ||
| 1077 | $val = $opt{value}; | ||
| 1078 | $val = odf_boolean($val) if $attr =~ /^use/; | ||
| 1079 | $source->set_attribute($attr => $val); | ||
| 1080 | } | ||
| 1081 | else | ||
| 1082 | { | ||
| 1083 | $source = $self->get_source; | ||
| 1084 | $val = $source ? $source->get_attribute($attr) : undef; | ||
| 1085 | $val = TRUE if (is_true($val) && $attr =~ /^use/); | ||
| 1086 | } | ||
| 1087 | return $val; | ||
| 1088 | } | ||
| 1089 | |||
| 1090 | sub get_title | ||
| 1091 | { | ||
| 1092 | my $self = shift; | ||
| 1093 | my $title = $self->first_descendant(TOC_TITLE_TEMPLATE); | ||
| 1094 | return $title ? $title->get_text : undef; | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | sub set_title | ||
| 1098 | { | ||
| 1099 | my $self = shift; | ||
| 1100 | my $text = shift; | ||
| 1101 | my %opt = @_; | ||
| 1102 | my $source = $self->set_source; | ||
| 1103 | my $style = $opt{style}; delete $opt{style}; | ||
| 1104 | return $source->set_child | ||
| 1105 | ( | ||
| 1106 | TOC_TITLE_TEMPLATE, | ||
| 1107 | $text, | ||
| 1108 | 'style name' => $style, | ||
| 1109 | @_ | ||
| 1110 | ); | ||
| 1111 | } | ||
| 1112 | |||
| 1113 | sub get_outline_level | ||
| 1114 | { | ||
| 1115 | my $self = shift; | ||
| 1116 | return $self->source_attribute('outline level'); | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | sub set_outline_level | ||
| 1120 | { | ||
| 1121 | my $self = shift; | ||
| 1122 | my $level = shift; | ||
| 1123 | my $source = $self->set_source; | ||
| 1124 | $source->set_attribute('outline level' => $level); | ||
| 1125 | foreach my $l (1..$level) | ||
| 1126 | { | ||
| 1127 | my $t = $source->get_element | ||
| 1128 | ( | ||
| 1129 | TOC_ENTRY_TEMPLATE, | ||
| 1130 | attribute => 'outline level', | ||
| 1131 | value => $l | ||
| 1132 | ) | ||
| 1133 | // | ||
| 1134 | $source->append_element(TOC_ENTRY_TEMPLATE); | ||
| 1135 | |||
| 1136 | $t->set_attribute ('outline level' => $l); | ||
| 1137 | |||
| 1138 | $t->append_element('text:index-entry-chapter'); | ||
| 1139 | $t->append_element('text:index-entry-span') | ||
| 1140 | ->set_text(" "); | ||
| 1141 | $t->append_element('text:index-entry-text'); | ||
| 1142 | $t->append_element('text:index-entry-tab-stop') | ||
| 1143 | ->set_attributes | ||
| 1144 | ( | ||
| 1145 | 'style:type' => 'right', | ||
| 1146 | 'style:leader-char' => '.' | ||
| 1147 | ); | ||
| 1148 | $t->append_element('text:index-entry-page-number'); | ||
| 1149 | } | ||
| 1150 | return $level; | ||
| 1151 | } | ||
| 1152 | |||
| 1153 | sub get_protected | ||
| 1154 | { | ||
| 1155 | my $self = shift; | ||
| 1156 | return is_true($self->get_attribute('protected')); | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | sub set_protected | ||
| 1160 | { | ||
| 1161 | my $self = shift; | ||
| 1162 | $self->set_attribute(protected => odf_boolean(shift)); | ||
| 1163 | return $self->get_protected; | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | sub get_use_index_marks | ||
| 1167 | { | ||
| 1168 | my $self = shift; | ||
| 1169 | return $self->source_attribute('use index marks'); | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | sub set_use_index_marks | ||
| 1173 | { | ||
| 1174 | my $self = shift; | ||
| 1175 | return $self->source_attribute('use index marks', value => shift); | ||
| 1176 | } | ||
| 1177 | |||
| 1178 | sub get_use_outline | ||
| 1179 | { | ||
| 1180 | my $self = shift; | ||
| 1181 | return $self->source_attribute('use outline'); | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | sub set_use_outline | ||
| 1185 | { | ||
| 1186 | my $self = shift; | ||
| 1187 | return $self->source_attribute('use outline', value => shift); | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | #----------------------------------------------------------------------------- | ||
| 1191 | |||
| 1192 | sub get_entry_template | ||
| 1193 | { | ||
| 1194 | my $self = shift; | ||
| 1195 | my $level = shift; | ||
| 1196 | my $source = $self->get_source; | ||
| 1197 | return $source->get_element | ||
| 1198 | ( | ||
| 1199 | TOC_ENTRY_TEMPLATE, | ||
| 1200 | attribute => 'outline level', | ||
| 1201 | value => $level | ||
| 1202 | ); | ||
| 1203 | } | ||
| 1204 | |||
| 1205 | #============================================================================= | ||
| 1206 | 1; |