protected function writeContentPart(Chart $chart)
{
$this->xmlContent = new XMLWriter(XMLWriter::STORAGE_MEMORY);
$chartType = $chart->getPlotArea()->getType();
// Data
$this->arrayData = array();
$this->arrayTitle = array();
$this->numData = 0;
foreach ($chartType->getSeries() as $series) {
$inc = 0;
$this->arrayTitle[] = $series->getTitle();
foreach ($series->getValues() as $key => $value) {
if (!isset($this->arrayData[$inc])) {
$this->arrayData[$inc] = array();
}
if (empty($this->arrayData[$inc])) {
$this->arrayData[$inc][] = $key;
}
$this->arrayData[$inc][] = $value;
$inc++;
}
if ($inc > $this->numData) {
$this->numData = $inc;
}
}
// office:document-content
$this->xmlContent->startElement('office:document-content');
$this->xmlContent->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$this->xmlContent->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
$this->xmlContent->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
$this->xmlContent->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
$this->xmlContent->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
$this->xmlContent->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
$this->xmlContent->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$this->xmlContent->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$this->xmlContent->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$this->xmlContent->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
$this->xmlContent->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
$this->xmlContent->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
$this->xmlContent->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
$this->xmlContent->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
$this->xmlContent->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
$this->xmlContent->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
$this->xmlContent->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$this->xmlContent->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
$this->xmlContent->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
$this->xmlContent->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
$this->xmlContent->writeAttribute('xmlns:xforms', 'http://www.w3.org/2002/xforms');
$this->xmlContent->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$this->xmlContent->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->xmlContent->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
$this->xmlContent->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
$this->xmlContent->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
$this->xmlContent->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$this->xmlContent->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
$this->xmlContent->writeAttribute('xmlns:chartooo', 'http://openoffice.org/2010/chart');
$this->xmlContent->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
$this->xmlContent->writeAttribute('xmlns:calcext', 'urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0');
$this->xmlContent->writeAttribute('xmlns:loext', 'urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0');
$this->xmlContent->writeAttribute('xmlns:field', 'urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0');
$this->xmlContent->writeAttribute('xmlns:formx', 'urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0');
$this->xmlContent->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
$this->xmlContent->writeAttribute('office:version', '1.2');
// office:automatic-styles
$this->xmlContent->startElement('office:automatic-styles');
// Chart
$this->writeChartStyle($chart);
// Axis
$this->writeAxisStyle($chart);
// Series
$this->numSeries = 0;
foreach ($chartType->getSeries() as $series) {
$this->writeSeriesStyle($chart, $series);
$this->numSeries++;
}
// Floor
$this->writeFloorStyle();
// Legend
$this->writeLegendStyle($chart);
// PlotArea
$this->writePlotAreaStyle($chart);
// Title
$this->writeTitleStyle($chart->getTitle());
// Wall
$this->writeWallStyle($chart);
// > office:automatic-styles
$this->xmlContent->endElement();
// office:body
$this->xmlContent->startElement('office:body');
// office:chart
$this->xmlContent->startElement('office:chart');
// office:chart
$this->xmlContent->startElement('chart:chart');
$this->xmlContent->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getWidth()), 3) . 'cm');
$this->xmlContent->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getHeight()), 3) . 'cm');
$this->xmlContent->writeAttribute('xlink:href', '.');
$this->xmlContent->writeAttribute('xlink:type', 'simple');
$this->xmlContent->writeAttribute('chart:style-name', 'styleChart');
$this->xmlContent->writeAttributeIf($chartType instanceof Area, 'chart:class', 'chart:area');
$this->xmlContent->writeAttributeIf($chartType instanceof AbstractTypeBar, 'chart:class', 'chart:bar');
$this->xmlContent->writeAttributeIf($chartType instanceof Line, 'chart:class', 'chart:line');
$this->xmlContent->writeAttributeIf($chartType instanceof AbstractTypePie, 'chart:class', 'chart:circle');
$this->xmlContent->writeAttributeIf($chartType instanceof Scatter, 'chart:class', 'chart:scatter');
//**** Title ****
$this->writeTitle($chart->getTitle());
//**** Legend ****
$this->writeLegend($chart);
//**** Plotarea ****
$this->writePlotArea($chart);
//**** Table ****
$this->writeTable();
// > chart:chart
$this->xmlContent->endElement();
// > office:chart
$this->xmlContent->endElement();
// > office:body
$this->xmlContent->endElement();
// > office:document-content
$this->xmlContent->endElement();
return $this->xmlContent->getData();
}