Complex classes like ObjectsChart often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ObjectsChart, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 23 | class ObjectsChart extends AbstractDecoratorWriter |
||
| 24 | { |
||
| 25 | /** |
||
| 26 | * @var XMLWriter |
||
| 27 | */ |
||
| 28 | protected $xmlContent; |
||
| 29 | /** |
||
| 30 | * @var mixed |
||
| 31 | */ |
||
| 32 | protected $arrayData; |
||
| 33 | /** |
||
| 34 | * @var mixed |
||
| 35 | */ |
||
| 36 | protected $arrayTitle; |
||
| 37 | /** |
||
| 38 | * @var integer |
||
| 39 | */ |
||
| 40 | protected $numData; |
||
| 41 | /** |
||
| 42 | * @var integer |
||
| 43 | */ |
||
| 44 | protected $numSeries; |
||
| 45 | /** |
||
| 46 | * @var string |
||
| 47 | */ |
||
| 48 | protected $rangeCol; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return ZipInterface |
||
| 52 | */ |
||
| 53 | 61 | public function render() |
|
| 65 | |||
| 66 | /** |
||
| 67 | * @param Chart $chart |
||
| 68 | * @return string |
||
| 69 | * @throws \Exception |
||
| 70 | */ |
||
| 71 | 24 | protected function writeContentPart(Chart $chart) |
|
| 216 | |||
| 217 | /** |
||
| 218 | * @param Chart $chart |
||
| 219 | */ |
||
| 220 | 24 | private function writeAxis(Chart $chart) |
|
| 262 | |||
| 263 | 24 | protected function writeGridline($oGridlines, $styleName, $chartClass) |
|
| 274 | |||
| 275 | /** |
||
| 276 | * @param Chart $chart |
||
| 277 | * @todo Set function in \PhpPresentation\Shape\Chart\Axis for defining width and color of the axis |
||
| 278 | */ |
||
| 279 | 24 | protected function writeAxisStyle(Chart $chart) |
|
| 367 | |||
| 368 | /** |
||
| 369 | * @param Chart\Gridlines $oGridlines |
||
| 370 | * @param string $styleName |
||
| 371 | */ |
||
| 372 | 24 | protected function writeGridlineStyle($oGridlines, $styleName) |
|
| 389 | |||
| 390 | /** |
||
| 391 | * @param Chart $chart |
||
| 392 | */ |
||
| 393 | 24 | private function writeChartStyle(Chart $chart) |
|
| 408 | |||
| 409 | 24 | private function writeFloor() |
|
| 417 | |||
| 418 | 24 | private function writeFloorStyle() |
|
| 436 | |||
| 437 | /** |
||
| 438 | * @param Chart $chart |
||
| 439 | */ |
||
| 440 | 24 | private function writeLegend(Chart $chart) |
|
| 441 | { |
||
| 442 | // chart:legend |
||
| 443 | 24 | $this->xmlContent->startElement('chart:legend'); |
|
| 444 | 24 | switch ($chart->getLegend()->getPosition()) { |
|
| 445 | 24 | case Chart\Legend::POSITION_BOTTOM: |
|
| 446 | 1 | $position = 'bottom'; |
|
| 447 | 1 | break; |
|
| 448 | 24 | case Chart\Legend::POSITION_LEFT: |
|
| 449 | 1 | $position = 'start'; |
|
| 450 | 1 | break; |
|
| 451 | 24 | case Chart\Legend::POSITION_TOP: |
|
| 452 | 1 | $position = 'top'; |
|
| 453 | 1 | break; |
|
| 454 | 24 | case Chart\Legend::POSITION_TOPRIGHT: |
|
| 455 | 1 | $position = 'top-end'; |
|
| 456 | 1 | break; |
|
| 457 | 24 | case Chart\Legend::POSITION_RIGHT: |
|
| 458 | 24 | default: |
|
| 459 | 24 | $position = 'end'; |
|
| 460 | 24 | break; |
|
| 461 | 24 | } |
|
| 462 | 24 | $this->xmlContent->writeAttribute('chart:legend-position', $position); |
|
| 463 | 24 | $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetX()), 3) . 'cm'); |
|
| 464 | 24 | $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetY()), 3) . 'cm'); |
|
| 465 | 24 | $this->xmlContent->writeAttribute('style:legend-expansion', 'high'); |
|
| 466 | 24 | $this->xmlContent->writeAttribute('chart:style-name', 'styleLegend'); |
|
| 467 | // > chart:legend |
||
| 468 | 24 | $this->xmlContent->endElement(); |
|
| 469 | 24 | } |
|
| 470 | |||
| 471 | /** |
||
| 472 | * @param Chart $chart |
||
| 473 | */ |
||
| 474 | 24 | private function writeLegendStyle(Chart $chart) |
|
| 496 | |||
| 497 | /** |
||
| 498 | * @param Chart $chart |
||
| 499 | */ |
||
| 500 | 24 | private function writePlotArea(Chart $chart) |
|
| 501 | { |
||
| 502 | 24 | $chartType = $chart->getPlotArea()->getType(); |
|
| 503 | |||
| 504 | // chart:plot-area |
||
| 505 | 24 | $this->xmlContent->startElement('chart:plot-area'); |
|
| 506 | 24 | $this->xmlContent->writeAttribute('chart:style-name', 'stylePlotArea'); |
|
| 507 | 24 | if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) { |
|
| 508 | 5 | $this->xmlContent->writeAttribute('dr3d:ambient-color', '#cccccc'); |
|
| 509 | 5 | $this->xmlContent->writeAttribute('dr3d:lighting-mode', 'true'); |
|
| 510 | 5 | } |
|
| 511 | 24 | if ($chartType instanceof Bar3D || $chartType instanceof Pie3D) { |
|
| 512 | // dr3d:light |
||
| 513 | $arrayLight = array( |
||
| 514 | 5 | array('#808080', '(0 0 1)', 'false', 'true'), |
|
| 515 | 5 | array('#666666', '(0.2 0.4 1)', 'true', 'false'), |
|
| 516 | 5 | array('#808080', '(0 0 1)', 'false', 'false'), |
|
| 517 | 5 | array('#808080', '(0 0 1)', 'false', 'false'), |
|
| 518 | 5 | array('#808080', '(0 0 1)', 'false', 'false'), |
|
| 519 | 5 | array('#808080', '(0 0 1)', 'false', 'false'), |
|
| 520 | 5 | array('#808080', '(0 0 1)', 'false', 'false'), |
|
| 521 | 5 | ); |
|
| 522 | 5 | foreach ($arrayLight as $light) { |
|
| 523 | 5 | $this->xmlContent->startElement('dr3d:light'); |
|
| 524 | 5 | $this->xmlContent->writeAttribute('dr3d:diffuse-color', $light[0]); |
|
| 525 | 5 | $this->xmlContent->writeAttribute('dr3d:direction', $light[1]); |
|
| 526 | 5 | $this->xmlContent->writeAttribute('dr3d:enabled', $light[2]); |
|
| 527 | 5 | $this->xmlContent->writeAttribute('dr3d:specular', $light[3]); |
|
| 528 | 5 | $this->xmlContent->endElement(); |
|
| 529 | 5 | } |
|
| 530 | 5 | } |
|
| 531 | |||
| 532 | //**** Axis **** |
||
| 533 | 24 | $this->writeAxis($chart); |
|
| 534 | |||
| 535 | //**** Series **** |
||
| 536 | 24 | $this->rangeCol = 'B'; |
|
| 537 | 24 | $this->numSeries = 0; |
|
| 538 | 24 | foreach ($chartType->getSeries() as $series) { |
|
| 539 | 22 | $this->writeSeries($chart, $series); |
|
| 540 | 22 | $this->rangeCol++; |
|
| 541 | 22 | $this->numSeries++; |
|
| 542 | 24 | } |
|
| 543 | |||
| 544 | //**** Wall **** |
||
| 545 | 24 | $this->writeWall(); |
|
| 546 | //**** Floor **** |
||
| 547 | 24 | $this->writeFloor(); |
|
| 548 | // > chart:plot-area |
||
| 549 | 24 | $this->xmlContent->endElement(); |
|
| 550 | 24 | } |
|
| 551 | |||
| 552 | /** |
||
| 553 | * @param Chart $chart |
||
| 554 | * @link : http://books.evc-cit.info/odbook/ch08.html#chart-plot-area-section |
||
| 555 | */ |
||
| 556 | 24 | private function writePlotAreaStyle(Chart $chart) |
|
| 557 | { |
||
| 558 | 24 | $chartType = $chart->getPlotArea()->getType(); |
|
| 559 | |||
| 560 | // style:style |
||
| 561 | 24 | $this->xmlContent->startElement('style:style'); |
|
| 562 | 24 | $this->xmlContent->writeAttribute('style:name', 'stylePlotArea'); |
|
| 563 | 24 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
| 564 | // style:text-properties |
||
| 565 | 24 | $this->xmlContent->startElement('style:chart-properties'); |
|
| 566 | 24 | if ($chartType instanceof Bar3D) { |
|
| 567 | 3 | $this->xmlContent->writeAttribute('chart:three-dimensional', 'true'); |
|
| 568 | 3 | $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true'); |
|
| 569 | 24 | } elseif ($chartType instanceof Pie3D) { |
|
| 570 | 2 | $this->xmlContent->writeAttribute('chart:three-dimensional', 'true'); |
|
| 571 | 2 | $this->xmlContent->writeAttribute('chart:right-angled-axes', 'true'); |
|
| 572 | 2 | } |
|
| 573 | 24 | if ($chartType instanceof AbstractTypeBar) { |
|
| 574 | 8 | $chartVertical = 'false'; |
|
| 575 | 8 | if ($chartType->getBarDirection() == AbstractTypeBar::DIRECTION_HORIZONTAL) { |
|
| 576 | 2 | $chartVertical = 'true'; |
|
| 577 | 2 | } |
|
| 578 | 8 | $this->xmlContent->writeAttribute('chart:vertical', $chartVertical); |
|
| 579 | 8 | if ($chartType->getBarGrouping() == Bar::GROUPING_CLUSTERED) { |
|
| 580 | 6 | $this->xmlContent->writeAttribute('chart:stacked', 'false'); |
|
| 581 | 6 | $this->xmlContent->writeAttribute('chart:overlap', '0'); |
|
| 582 | 8 | } elseif ($chartType->getBarGrouping() == Bar::GROUPING_STACKED) { |
|
| 583 | 1 | $this->xmlContent->writeAttribute('chart:stacked', 'true'); |
|
| 584 | 1 | $this->xmlContent->writeAttribute('chart:overlap', '100'); |
|
| 585 | 2 | } elseif ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) { |
|
| 586 | 1 | $this->xmlContent->writeAttribute('chart:stacked', 'true'); |
|
| 587 | 1 | $this->xmlContent->writeAttribute('chart:overlap', '100'); |
|
| 588 | 1 | $this->xmlContent->writeAttribute('chart:percentage', 'true'); |
|
| 589 | 1 | } |
|
| 590 | 8 | } |
|
| 591 | 24 | $labelFormat = 'value'; |
|
| 592 | 24 | if ($chartType instanceof AbstractTypeBar) { |
|
| 593 | 8 | if ($chartType->getBarGrouping() == Bar::GROUPING_PERCENTSTACKED) { |
|
| 594 | 1 | $labelFormat = 'percentage'; |
|
| 595 | 1 | } |
|
| 596 | 8 | } |
|
| 597 | 24 | $this->xmlContent->writeAttribute('chart:data-label-number', $labelFormat); |
|
| 598 | |||
| 599 | // > style:text-properties |
||
| 600 | 24 | $this->xmlContent->endElement(); |
|
| 601 | // > style:style |
||
| 602 | 24 | $this->xmlContent->endElement(); |
|
| 603 | 24 | } |
|
| 604 | |||
| 605 | /** |
||
| 606 | * @param Chart $chart |
||
| 607 | * @param Chart\Series $series |
||
| 608 | * @throws \Exception |
||
| 609 | */ |
||
| 610 | 22 | private function writeSeries(Chart $chart, Chart\Series $series) |
|
| 611 | { |
||
| 612 | 22 | $chartType = $chart->getPlotArea()->getType(); |
|
| 613 | |||
| 614 | 22 | $numRange = count($series->getValues()); |
|
| 615 | // chart:series |
||
| 616 | 22 | $this->xmlContent->startElement('chart:series'); |
|
| 617 | 22 | $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$'.$this->rangeCol.'$2:.$'.$this->rangeCol.'$'.($numRange+1)); |
|
| 618 | 22 | $this->xmlContent->writeAttribute('chart:label-cell-address', 'table-local.$'.$this->rangeCol.'$1'); |
|
| 619 | 22 | if ($chartType instanceof Area) { |
|
| 620 | 1 | $this->xmlContent->writeAttribute('chart:class', 'chart:area'); |
|
| 621 | 22 | } elseif ($chartType instanceof AbstractTypeBar) { |
|
| 622 | 7 | $this->xmlContent->writeAttribute('chart:class', 'chart:bar'); |
|
| 623 | 21 | } elseif ($chartType instanceof Line) { |
|
| 624 | 6 | $this->xmlContent->writeAttribute('chart:class', 'chart:line'); |
|
| 625 | 14 | } elseif ($chartType instanceof AbstractTypePie) { |
|
| 626 | 5 | $this->xmlContent->writeAttribute('chart:class', 'chart:circle'); |
|
| 627 | 8 | } elseif ($chartType instanceof Scatter) { |
|
| 628 | 3 | $this->xmlContent->writeAttribute('chart:class', 'chart:scatter'); |
|
| 629 | 3 | } |
|
| 630 | 22 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries); |
|
| 631 | 22 | if ($chartType instanceof Area || $chartType instanceof AbstractTypeBar || $chartType instanceof Line || $chartType instanceof Scatter) { |
|
| 632 | 17 | $dataPointFills = $series->getDataPointFills(); |
|
| 633 | |||
| 634 | 17 | $incRepeat = $numRange; |
|
| 635 | 17 | if (!empty($dataPointFills)) { |
|
| 636 | 4 | $inc = 0; |
|
| 637 | 4 | $incRepeat = 0; |
|
| 638 | 4 | $newFill = new Fill(); |
|
| 639 | do { |
||
| 640 | 4 | if ($series->getDataPointFill($inc)->getHashCode() != $newFill->getHashCode()) { |
|
| 641 | // chart:data-point |
||
| 642 | 4 | $this->xmlContent->startElement('chart:data-point'); |
|
| 643 | 4 | $this->xmlContent->writeAttribute('chart:repeated', $incRepeat); |
|
| 644 | // > chart:data-point |
||
| 645 | 4 | $this->xmlContent->endElement(); |
|
| 646 | 4 | $incRepeat = 0; |
|
| 647 | |||
| 648 | // chart:data-point |
||
| 649 | 4 | $this->xmlContent->startElement('chart:data-point'); |
|
| 650 | 4 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc); |
|
| 651 | // > chart:data-point |
||
| 652 | 4 | $this->xmlContent->endElement(); |
|
| 653 | 4 | } |
|
| 654 | 4 | $inc++; |
|
| 655 | 4 | $incRepeat++; |
|
| 656 | 4 | } while ($inc < $numRange); |
|
| 657 | 4 | $incRepeat--; |
|
| 658 | 4 | } |
|
| 659 | // chart:data-point |
||
| 660 | 17 | $this->xmlContent->startElement('chart:data-point'); |
|
| 661 | 17 | $this->xmlContent->writeAttribute('chart:repeated', $incRepeat); |
|
| 662 | // > chart:data-point |
||
| 663 | 17 | $this->xmlContent->endElement(); |
|
| 664 | 22 | } elseif ($chartType instanceof AbstractTypePie) { |
|
| 665 | 5 | $count = count($series->getDataPointFills()); |
|
| 666 | 5 | for ($inc = 0; $inc < $count; $inc++) { |
|
| 667 | // chart:data-point |
||
| 668 | 3 | $this->xmlContent->startElement('chart:data-point'); |
|
| 669 | 3 | $this->xmlContent->writeAttribute('chart:style-name', 'styleSeries'.$this->numSeries.'_'.$inc); |
|
| 670 | // > chart:data-point |
||
| 671 | 3 | $this->xmlContent->endElement(); |
|
| 672 | 3 | } |
|
| 673 | 5 | } |
|
| 674 | |||
| 675 | // > chart:series |
||
| 676 | 22 | $this->xmlContent->endElement(); |
|
| 677 | 22 | } |
|
| 678 | |||
| 679 | /** |
||
| 680 | * @param Chart $chart |
||
| 681 | * @param Chart\Series $series |
||
| 682 | */ |
||
| 683 | 22 | private function writeSeriesStyle(Chart $chart, Chart\Series $series) |
|
| 684 | { |
||
| 685 | 22 | $chartType = $chart->getPlotArea()->getType(); |
|
| 686 | |||
| 687 | // style:style |
||
| 688 | 22 | $this->xmlContent->startElement('style:style'); |
|
| 689 | 22 | $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries); |
|
| 690 | 22 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
| 691 | // style:chart-properties |
||
| 692 | 22 | $this->xmlContent->startElement('style:chart-properties'); |
|
| 693 | 22 | if ($series->hasShowValue()) { |
|
| 694 | 22 | if ($series->hasShowPercentage()) { |
|
| 695 | 1 | $this->xmlContent->writeAttribute('chart:data-label-number', 'value-and-percentage'); |
|
| 696 | 1 | } else { |
|
| 697 | 22 | $this->xmlContent->writeAttribute('chart:data-label-number', 'value'); |
|
| 698 | } |
||
| 699 | 22 | } else { |
|
| 700 | 1 | if ($series->hasShowPercentage()) { |
|
| 701 | 1 | $this->xmlContent->writeAttribute('chart:data-label-number', 'percentage'); |
|
| 702 | 1 | } |
|
| 703 | } |
||
| 704 | 22 | if ($series->hasShowCategoryName()) { |
|
| 705 | 1 | $this->xmlContent->writeAttribute('chart:data-label-text', 'true'); |
|
| 706 | 1 | } |
|
| 707 | 22 | $this->xmlContent->writeAttribute('chart:label-position', 'center'); |
|
| 708 | 22 | if ($chartType instanceof AbstractTypePie) { |
|
| 709 | 5 | $this->xmlContent->writeAttribute('chart:pie-offset', $chartType->getExplosion()); |
|
| 710 | 5 | } |
|
| 711 | 22 | if ($chartType instanceof Line || $chartType instanceof Scatter) { |
|
| 712 | 9 | $oMarker = $series->getMarker(); |
|
| 713 | /** |
||
| 714 | * @link : http://www.datypic.com/sc/odf/a-chart_symbol-type.html |
||
| 715 | */ |
||
| 716 | 9 | $this->xmlContent->writeAttributeIf($oMarker->getSymbol() == Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'none'); |
|
| 717 | /** |
||
| 718 | * @link : http://www.datypic.com/sc/odf/a-chart_symbol-name.html |
||
| 719 | */ |
||
| 720 | 9 | $this->xmlContent->writeAttributeIf($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE, 'chart:symbol-type', 'named-symbol'); |
|
| 721 | 9 | if ($oMarker->getSymbol() != Chart\Marker::SYMBOL_NONE) { |
|
| 722 | 2 | switch ($oMarker->getSymbol()) { |
|
| 723 | 2 | case Chart\Marker::SYMBOL_DASH: |
|
| 724 | 2 | $symbolName = 'horizontal-bar'; |
|
| 725 | 2 | break; |
|
| 726 | 2 | case Chart\Marker::SYMBOL_DOT: |
|
| 727 | 2 | $symbolName = 'circle'; |
|
| 728 | 2 | break; |
|
| 729 | 2 | case Chart\Marker::SYMBOL_TRIANGLE: |
|
| 730 | 2 | $symbolName = 'arrow-up'; |
|
| 731 | 2 | break; |
|
| 732 | 2 | default: |
|
| 733 | 2 | $symbolName = $oMarker->getSymbol(); |
|
| 734 | 2 | break; |
|
| 735 | 2 | } |
|
| 736 | 2 | $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName); |
|
| 737 | 2 | $symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', ''); |
|
| 738 | 2 | $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize.'cm'); |
|
| 739 | 2 | $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize.'cm'); |
|
| 740 | 2 | } |
|
| 741 | 9 | } |
|
| 742 | |||
| 743 | 22 | $separator = $series->getSeparator(); |
|
| 744 | 22 | if (!empty($separator)) { |
|
| 745 | // style:chart-properties/chart:label-separator |
||
| 746 | 1 | $this->xmlContent->startElement('chart:label-separator'); |
|
| 747 | 1 | if ($separator == PHP_EOL) { |
|
| 748 | $this->xmlContent->writeRaw('<text:p><text:line-break /></text:p>'); |
||
| 749 | } else { |
||
| 750 | 1 | $this->xmlContent->writeElement('text:p', $separator); |
|
| 751 | } |
||
| 752 | 1 | $this->xmlContent->endElement(); |
|
| 753 | 1 | } |
|
| 754 | |||
| 755 | // > style:chart-properties |
||
| 756 | 22 | $this->xmlContent->endElement(); |
|
| 757 | // style:graphic-properties |
||
| 758 | 22 | $this->xmlContent->startElement('style:graphic-properties'); |
|
| 759 | 22 | if ($chartType instanceof Line || $chartType instanceof Scatter) { |
|
| 760 | 9 | $outlineWidth = ''; |
|
| 761 | 9 | $outlineColor = ''; |
|
| 762 | |||
| 763 | 9 | $oOutline = $series->getOutline(); |
|
| 764 | 9 | if ($oOutline instanceof Outline) { |
|
| 765 | 2 | $outlineWidth = $oOutline->getWidth(); |
|
| 766 | 2 | if (!empty($outlineWidth)) { |
|
| 767 | 2 | $outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', ''); |
|
| 768 | 2 | } |
|
| 769 | 2 | $outlineColor = $oOutline->getFill()->getStartColor()->getRGB(); |
|
| 770 | 2 | } |
|
| 771 | 9 | if (empty($outlineWidth)) { |
|
| 772 | 9 | $outlineWidth = '0.079'; |
|
| 773 | 9 | } |
|
| 774 | 9 | if (empty($outlineColor)) { |
|
| 775 | 9 | $outlineColor = '4a7ebb'; |
|
| 776 | 9 | } |
|
| 777 | 9 | $this->xmlContent->writeAttribute('svg:stroke-width', $outlineWidth.'cm'); |
|
| 778 | 9 | $this->xmlContent->writeAttribute('svg:stroke-color', '#'.$outlineColor); |
|
| 779 | 9 | } else { |
|
| 780 | 13 | $this->xmlContent->writeAttribute('draw:stroke', 'none'); |
|
| 781 | 13 | if (!($chartType instanceof Area)) { |
|
| 782 | 12 | $this->xmlContent->writeAttribute('draw:fill', $series->getFill()->getFillType()); |
|
| 783 | 12 | } |
|
| 784 | } |
||
| 785 | 22 | $this->xmlContent->writeAttribute('draw:fill-color', '#'.$series->getFill()->getStartColor()->getRGB()); |
|
| 786 | // > style:graphic-properties |
||
| 787 | 22 | $this->xmlContent->endElement(); |
|
| 788 | // style:text-properties |
||
| 789 | 22 | $this->xmlContent->startElement('style:text-properties'); |
|
| 790 | 22 | $this->xmlContent->writeAttribute('fo:color', '#'.$series->getFont()->getColor()->getRGB()); |
|
| 791 | 22 | $this->xmlContent->writeAttribute('fo:font-family', $series->getFont()->getName()); |
|
| 792 | 22 | $this->xmlContent->writeAttribute('fo:font-size', $series->getFont()->getSize().'pt'); |
|
| 793 | // > style:text-properties |
||
| 794 | 22 | $this->xmlContent->endElement(); |
|
| 795 | |||
| 796 | // > style:style |
||
| 797 | 22 | $this->xmlContent->endElement(); |
|
| 798 | |||
| 799 | 22 | foreach ($series->getDataPointFills() as $idx => $oFill) { |
|
| 800 | // style:style |
||
| 801 | 7 | $this->xmlContent->startElement('style:style'); |
|
| 802 | 7 | $this->xmlContent->writeAttribute('style:name', 'styleSeries'.$this->numSeries.'_'.$idx); |
|
| 803 | 7 | $this->xmlContent->writeAttribute('style:family', 'chart'); |
|
| 804 | // style:graphic-properties |
||
| 805 | 7 | $this->xmlContent->startElement('style:graphic-properties'); |
|
| 806 | 7 | $this->xmlContent->writeAttribute('draw:fill', $oFill->getFillType()); |
|
| 807 | 7 | $this->xmlContent->writeAttribute('draw:fill-color', '#'.$oFill->getStartColor()->getRGB()); |
|
| 808 | // > style:graphic-properties |
||
| 809 | 7 | $this->xmlContent->endElement(); |
|
| 810 | // > style:style |
||
| 811 | 7 | $this->xmlContent->endElement(); |
|
| 812 | 22 | } |
|
| 813 | 22 | } |
|
| 814 | |||
| 815 | /** |
||
| 816 | */ |
||
| 817 | 24 | private function writeTable() |
|
| 818 | { |
||
| 819 | // table:table |
||
| 820 | 24 | $this->xmlContent->startElement('table:table'); |
|
| 821 | 24 | $this->xmlContent->writeAttribute('table:name', 'table-local'); |
|
| 822 | |||
| 823 | // table:table-header-columns |
||
| 824 | 24 | $this->xmlContent->startElement('table:table-header-columns'); |
|
| 825 | // table:table-column |
||
| 826 | 24 | $this->xmlContent->startElement('table:table-column'); |
|
| 827 | // > table:table-column |
||
| 828 | 24 | $this->xmlContent->endElement(); |
|
| 829 | // > table:table-header-columns |
||
| 830 | 24 | $this->xmlContent->endElement(); |
|
| 831 | |||
| 832 | // table:table-columns |
||
| 833 | 24 | $this->xmlContent->startElement('table:table-columns'); |
|
| 834 | // table:table-column |
||
| 835 | 24 | $this->xmlContent->startElement('table:table-column'); |
|
| 836 | 24 | if (!empty($this->arrayData)) { |
|
| 837 | 22 | $rowFirst = reset($this->arrayData); |
|
| 838 | 22 | $this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1); |
|
| 839 | 22 | } |
|
| 840 | // > table:table-column |
||
| 841 | 24 | $this->xmlContent->endElement(); |
|
| 842 | // > table:table-columns |
||
| 843 | 24 | $this->xmlContent->endElement(); |
|
| 844 | |||
| 845 | // table:table-header-rows |
||
| 846 | 24 | $this->xmlContent->startElement('table:table-header-rows'); |
|
| 847 | // table:table-row |
||
| 848 | 24 | $this->xmlContent->startElement('table:table-row'); |
|
| 849 | 24 | if (!empty($this->arrayData)) { |
|
| 850 | 22 | $rowFirst = reset($this->arrayData); |
|
| 851 | 22 | foreach ($rowFirst as $key => $cell) { |
|
| 852 | // table:table-cell |
||
| 853 | 22 | $this->xmlContent->startElement('table:table-cell'); |
|
| 854 | 22 | if (isset($this->arrayTitle[$key - 1])) { |
|
| 855 | 22 | $this->xmlContent->writeAttribute('office:value-type', 'string'); |
|
| 856 | 22 | } |
|
| 857 | // text:p |
||
| 858 | 22 | $this->xmlContent->startElement('text:p'); |
|
| 859 | 22 | if (isset($this->arrayTitle[$key - 1])) { |
|
| 860 | 22 | $this->xmlContent->text($this->arrayTitle[$key - 1]); |
|
| 861 | 22 | } |
|
| 862 | // > text:p |
||
| 863 | 22 | $this->xmlContent->endElement(); |
|
| 864 | // > table:table-cell |
||
| 865 | 22 | $this->xmlContent->endElement(); |
|
| 866 | 22 | } |
|
| 867 | 22 | } |
|
| 868 | // > table:table-row |
||
| 869 | 24 | $this->xmlContent->endElement(); |
|
| 870 | // > table:table-header-rows |
||
| 871 | 24 | $this->xmlContent->endElement(); |
|
| 872 | |||
| 873 | // table:table-rows |
||
| 874 | 24 | $this->xmlContent->startElement('table:table-rows'); |
|
| 875 | |||
| 876 | 24 | foreach ($this->arrayData as $row) { |
|
| 877 | // table:table-row |
||
| 878 | 22 | $this->xmlContent->startElement('table:table-row'); |
|
| 879 | 22 | foreach ($row as $cell) { |
|
| 880 | // table:table-cell |
||
| 881 | 22 | $this->xmlContent->startElement('table:table-cell'); |
|
| 882 | |||
| 883 | 22 | $cellNumeric = is_numeric($cell); |
|
| 884 | 22 | $this->xmlContent->writeAttributeIf(!$cellNumeric, 'office:value-type', 'string'); |
|
| 885 | 22 | $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value-type', 'float'); |
|
| 886 | 22 | $this->xmlContent->writeAttributeIf($cellNumeric, 'office:value', $cell); |
|
| 887 | // text:p |
||
| 888 | 22 | $this->xmlContent->startElement('text:p'); |
|
| 889 | 22 | $this->xmlContent->text($cell); |
|
| 890 | // > text:p |
||
| 891 | 22 | $this->xmlContent->endElement(); |
|
| 892 | // > table:table-cell |
||
| 893 | 22 | $this->xmlContent->endElement(); |
|
| 894 | 22 | } |
|
| 895 | // > table:table-row |
||
| 896 | 22 | $this->xmlContent->endElement(); |
|
| 897 | 24 | } |
|
| 898 | |||
| 899 | // > table:table-rows |
||
| 900 | 24 | $this->xmlContent->endElement(); |
|
| 901 | // > table:table |
||
| 902 | 24 | $this->xmlContent->endElement(); |
|
| 903 | 24 | } |
|
| 904 | |||
| 905 | /** |
||
| 906 | * @param Title $oTitle |
||
| 907 | */ |
||
| 908 | 24 | private function writeTitle(Title $oTitle) |
|
| 926 | |||
| 927 | /** |
||
| 928 | * @param Title $oTitle |
||
| 929 | */ |
||
| 930 | 24 | private function writeTitleStyle(Title $oTitle) |
|
| 950 | |||
| 951 | 24 | private function writeWall() |
|
| 959 | |||
| 960 | /** |
||
| 961 | * @param Chart $chart |
||
| 962 | */ |
||
| 963 | 24 | private function writeWallStyle(Chart $chart) |
|
| 964 | { |
||
| 965 | 24 | $chartType = $chart->getPlotArea()->getType(); |
|
| 988 | } |
||
| 989 |