include/oox/export/chartexport.hxx | 45 - oox/source/export/chartexport.cxx | 1264 ++++++++++++--------------------- oox/source/token/namespaces-strict.txt | 2 oox/source/token/namespaces.txt | 2 oox/source/token/tokens.txt | 5 5 files changed, 477 insertions(+), 841 deletions(-)
New commits: commit 1dcf2786330b0c8ee1a60ae3a1ab8e3123377c5c Author: Kurt Nordback <[email protected]> AuthorDate: Thu Jan 22 12:25:57 2026 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Tue Jan 27 04:55:42 2026 +0100 Revert "tdf#165742 Step 4.1: Establish a narrow export path for chartex" This reverts commit 12e869449f83f070e0f260c6ade72c36b3c7c894. Change-Id: I247dffc6dc1ee2c89cedf3a0038464cb739d215f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197905 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 1da778fe4808..15944e44dbe6 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -169,27 +169,21 @@ private: OUString parseFormula( const OUString& rRange ); void InitPlotArea(); - void ExportContent_(bool bIsChartex); + void ExportContent_(); void exportChartSpace( const css::uno::Reference< css::chart::XChartDocument >& rChartDoc, - bool bIncludeTable, - bool bIsChartex); + bool bIncludeTable ); void exportChart( const css::uno::Reference< - css::chart::XChartDocument >& rChartDoc, - bool bIsChartex); + css::chart::XChartDocument >& rChartDoc ); void exportExternalData( const css::uno::Reference< - css::chart::XChartDocument >& rChartDoc, - bool bIsChartex); + css::chart::XChartDocument >& rChartDoc ); void exportLegend( const css::uno::Reference< - css::chart::XChartDocument >& rChartDoc, - bool bIsChartex); + css::chart::XChartDocument >& rChartDoc ); void exportTitle( const css::uno::Reference< css::drawing::XShape >& xShape, - bool bIsChartex, const css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >& xFormattedSubTitle = css::uno::Sequence< css::uno::Reference< css::chart2::XFormattedString > >() ); void exportPlotArea( const css::uno::Reference< - css::chart::XChartDocument >& rChartDoc, - bool bIsChartex); + css::chart::XChartDocument >& rChartDoc ); void exportAdditionalShapes( const css::uno::Reference<css::chart::XChartDocument >& rChartDoc ); void exportFill( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportSolidFill(const css::uno::Reference<css::beans::XPropertySet>& xPropSet); @@ -202,7 +196,6 @@ private: void exportBarChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); void exportBubbleChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); void exportDoughnutChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); - void exportFunnelChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); void exportLineChart( const css::uno::Reference< css::chart2::XChartType >& xChartType ); void exportOfPieChart( const css::uno::Reference< css::chart2::XChartType >& xChartType, const char* s_subtype, double nSplitPos ); @@ -218,9 +211,7 @@ private: void exportAllSeries(const css::uno::Reference<css::chart2::XChartType>& xChartType, bool& rPrimaryAxes); void exportSeries(const css::uno::Reference< css::chart2::XChartType >& xChartType, - const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, - bool& rPrimaryAxes, - bool bIsChartex); + const css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes); void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& xChartType); void exportCandleStickSeries( @@ -233,14 +224,12 @@ private: const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_cat ); void exportSeriesValues( const css::uno::Reference< css::chart2::data::XDataSequence >& xValueSeq, sal_Int32 nValueType = XML_val ); - void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet, - bool bIsChartex); + void exportShapeProps( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); void exportDataPoints( const css::uno::Reference< css::beans::XPropertySet >& xSeriesProperties, sal_Int32 nSeriesLength, sal_Int32 eChartType ); void exportDataLabels( const css::uno::Reference<css::chart2::XDataSeries>& xSeries, sal_Int32 nSeriesLength, - sal_Int32 eChartType, DataLabelsRange& rDLblsRange, - bool bIsChartex); + sal_Int32 eChartType, DataLabelsRange& rDLblsRange ); void exportGrouping( bool isBar = false ); void exportTrendlines( const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); void exportMarker( const css::uno::Reference< css::beans::XPropertySet >& xPropSet ); @@ -252,9 +241,8 @@ private: void exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning); - void exportAxes( bool bIsChartex ); - void exportAxis(const AxisIdPair& rAxisIdPair, - bool bIsChartex); + void exportAxes( ); + void exportAxis(const AxisIdPair& rAxisIdPair); void _exportAxis( const css::uno::Reference< css::beans::XPropertySet >& xAxisProp, const css::uno::Reference< css::drawing::XShape >& xAxisTitle, @@ -262,14 +250,10 @@ private: const css::uno::Reference< css::beans::XPropertySet >& xMinorGrid, sal_Int32 nAxisType, const char* sAxisPos, - const AxisIdPair& rAxisIdPair, - bool bIsChartex); + const AxisIdPair& rAxisIdPair ); void exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes = false); void exportView3D(); bool isDeep3dChart(); - // Determine if (at least one) chart exported is from the 2014 chartex - // schema. If not, all are from the 2006 chart schema. - bool isChartexNotChartNS() const; void exportMissingValueTreatment(const css::uno::Reference<css::beans::XPropertySet>& xPropSet); @@ -277,8 +261,7 @@ private: void writeLabelProperties( const css::uno::Reference<css::beans::XPropertySet>& xPropSet, const LabelPlacementParam& rLabelParam, - sal_Int32 nLabelIndex, DataLabelsRange& rDLblsRange, - bool bIsChartex); + sal_Int32 nLabelIndex, DataLabelsRange& rDLblsRange); public: @@ -290,7 +273,7 @@ public: const css::uno::Reference< css::frame::XModel >& getModel() const { return mxChartModel; } OOX_DLLPUBLIC void WriteChartObj( const css::uno::Reference< css::drawing::XShape >& xShape, sal_Int32 nID, sal_Int32 nChartCount ); - void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet, bool bIsChartex); + void exportTextProps(const css::uno::Reference< css::beans::XPropertySet >& xPropSet); OOX_DLLPUBLIC void ExportContent(); void InitRangeSegmentationProperties( diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index e1cac13f5af3..39769f3a376b 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -470,8 +470,6 @@ constexpr auto constChartTypeMap = frozen::make_unordered_map<std::u16string_vie { u"com.sun.star.chart2.CandleStickChartType", chart::TYPEID_STOCK }, { u"com.sun.star.chart.BubbleDiagram", chart::TYPEID_BUBBLE }, { u"com.sun.star.chart2.BubbleChartType", chart::TYPEID_BUBBLE }, - { u"com.sun.star.chart.FunnelDiagram", chart::TYPEID_FUNNEL }, - { u"com.sun.star.chart2.FunnelChartType", chart::TYPEID_FUNNEL }, }); } // end anonymous namespace @@ -774,25 +772,6 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI { FSHelperPtr pFS = GetFS(); - Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); - OSL_ASSERT( xChartDoc.is() ); - if( !xChartDoc.is() ) - return; - - // We need to get the new diagram here so we can know if this is a chartex - // chart. - mxNewDiagram.set( xChartDoc->getFirstDiagram()); - - const bool bIsChartex = isChartexNotChartNS(); - - if (bIsChartex) { - // Do the AlternateContent header - mpFS->startElementNS(XML_mc, XML_AlternateContent); - mpFS->startElementNS(XML_mc, XML_Choice, - FSNS(XML_xmlns, XML_cx2), "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", - XML_Requires, "cx2"); - } - Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY ); pFS->startElementNS(mnXmlNamespace, XML_graphicFrame); @@ -821,19 +800,6 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), sRelId); } - - if (bIsChartex) { - pFS->startElement(FSNS(XML_a, XML_extLst)); - pFS->startElement(FSNS(XML_a, XML_ext), XML_uri, - "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}"); - pFS->singleElement(FSNS(XML_a16, XML_creationId), - FSNS(XML_xmlns, XML_a16), "http://schemas.microsoft.com/office/drawing/2014/main", - XML_id, "{393D7C90-AF84-3958-641C-0FEC03FE8894}"); - - pFS->endElement(FSNS(XML_a, XML_ext)); - pFS->endElement(FSNS(XML_a, XML_extLst)); - } - pFS->endElementNS(mnXmlNamespace, XML_cNvPr); pFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr); @@ -845,52 +811,46 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI // visual chart properties WriteShapeTransformation( xShape, mnXmlNamespace ); - const char *sSchemaURL = bIsChartex? - "http://schemas.microsoft.com/office/drawing/2014/chartex" : - "http://schemas.openxmlformats.org/drawingml/2006/chart"; - // writer chart object pFS->startElement(FSNS(XML_a, XML_graphic)); - pFS->startElement( FSNS( XML_a, XML_graphicData ), XML_uri, sSchemaURL ); + pFS->startElement( FSNS( XML_a, XML_graphicData ), + XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart" ); OUString sId; const char* sFullPath = nullptr; const char* sRelativePath = nullptr; - const char *sChartFnamePrefix = bIsChartex? "chartEx" : "chart"; switch( GetDocumentType() ) { case DOCUMENT_DOCX: { - sFullPath = "word/charts/"; - sRelativePath = "charts/"; + sFullPath = "word/charts/chart"; + sRelativePath = "charts/chart"; break; } case DOCUMENT_PPTX: { - sFullPath = "ppt/charts/"; - sRelativePath = "../charts/"; + sFullPath = "ppt/charts/chart"; + sRelativePath = "../charts/chart"; break; } case DOCUMENT_XLSX: { - sFullPath = "xl/charts/"; - sRelativePath = "../charts/"; + sFullPath = "xl/charts/chart"; + sRelativePath = "../charts/chart"; break; } default: { - sFullPath = "charts/"; - sRelativePath = "charts/"; + sFullPath = "charts/chart"; + sRelativePath = "charts/chart"; break; } } OUString sFullStream = OUStringBuffer() .appendAscii(sFullPath) - .appendAscii(sChartFnamePrefix) .append(OUString::number(nChartCount) + ".xml") .makeStringAndClear(); OUString sRelativeStream = OUStringBuffer() .appendAscii(sRelativePath) - .appendAscii(sChartFnamePrefix) .append(OUString::number(nChartCount) + ".xml" ) .makeStringAndClear(); FSHelperPtr pChart = CreateOutputStream( @@ -902,77 +862,15 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI &sId ); XmlFilterBase* pFB = GetFB(); - - if (bIsChartex) { - // There's no dmlChartex namespace, but using that to avoid hard-coding - // the URL here - pFS->singleElement( FSNS( XML_cx, XML_chart ), - FSNS(XML_xmlns, XML_cx), pFB->getNamespaceURL(OOX_NS(dmlChartex)), - FSNS(XML_xmlns, XML_r), pFB->getNamespaceURL(OOX_NS(officeRel)), - FSNS(XML_r, XML_id), sId ); - } else { - pFS->singleElement( FSNS( XML_c, XML_chart ), - FSNS(XML_xmlns, XML_c), pFB->getNamespaceURL(OOX_NS(dmlChart)), - FSNS(XML_xmlns, XML_r), pFB->getNamespaceURL(OOX_NS(officeRel)), - FSNS(XML_r, XML_id), sId ); - } + pFS->singleElement( FSNS( XML_c, XML_chart ), + FSNS(XML_xmlns, XML_c), pFB->getNamespaceURL(OOX_NS(dmlChart)), + FSNS(XML_xmlns, XML_r), pFB->getNamespaceURL(OOX_NS(officeRel)), + FSNS(XML_r, XML_id), sId ); pFS->endElement( FSNS( XML_a, XML_graphicData ) ); pFS->endElement( FSNS( XML_a, XML_graphic ) ); pFS->endElementNS( mnXmlNamespace, XML_graphicFrame ); - if (bIsChartex) { - // Do the AlternateContent fallback path - pFS->endElementNS(XML_mc, XML_Choice); - pFS->startElementNS(XML_mc, XML_Fallback); - // TODO: export bitmap shape as fallback - - pFS->startElementNS(XML_xdr, XML_sp, XML_macro, "", XML_textlink, ""); - pFS->startElementNS(XML_xdr, XML_nvSpPr); - pFS->singleElementNS(XML_xdr, XML_cNvPr, XML_id, "0", XML_name, ""); - pFS->startElementNS(XML_xdr, XML_cNvSpPr); - pFS->singleElementNS(XML_a, XML_spLocks, XML_noTextEdit, "1"); - pFS->endElementNS(XML_xdr, XML_cNvSpPr); - pFS->endElementNS(XML_xdr, XML_nvSpPr); - pFS->startElementNS(XML_xdr, XML_spPr); - pFS->startElementNS(XML_a, XML_xfrm); - pFS->singleElementNS(XML_a, XML_off, XML_x, "6600825", XML_y, "2533650"); - pFS->singleElementNS(XML_a, XML_ext, XML_cx, "4572000", XML_cy, "2743200"); - pFS->endElementNS(XML_a, XML_xfrm); - pFS->startElementNS(XML_a, XML_prstGeom, XML_prst, "rect"); - pFS->singleElementNS(XML_a, XML_avLst); - pFS->endElementNS(XML_a, XML_prstGeom); - pFS->startElementNS(XML_a, XML_solidFill); - pFS->singleElementNS(XML_a, XML_prstClr, XML_val, "white"); - pFS->endElementNS(XML_a, XML_solidFill); - pFS->startElementNS(XML_a, XML_ln, XML_w, "1"); - pFS->startElementNS(XML_a, XML_solidFill); - pFS->singleElementNS(XML_a, XML_prstClr, XML_val, "green"); - pFS->endElementNS(XML_a, XML_solidFill); - pFS->endElementNS(XML_a, XML_ln); - pFS->endElementNS(XML_xdr, XML_spPr); - pFS->startElementNS(XML_xdr, XML_txBody); - pFS->singleElementNS(XML_a, XML_bodyPr, XML_vertOverflow, "clip", XML_horzOverflow, "clip"); - pFS->singleElementNS(XML_a, XML_lstStyle); - pFS->startElementNS(XML_a, XML_p); - pFS->startElementNS(XML_a, XML_r); - pFS->singleElementNS(XML_a, XML_rPr, XML_sz, "1100"); - pFS->startElementNS(XML_a, XML_t); - - const std::string_view sErrTxt("This chart isn't available in your version of Excel. " - "Editing this shape or saving this workbook into a different file format will permanently break the chart."); - pFS->writeEscaped( sErrTxt ); - - pFS->endElementNS(XML_a, XML_t); - pFS->endElementNS(XML_a, XML_r); - pFS->endElementNS(XML_a, XML_p); - pFS->endElementNS(XML_xdr, XML_txBody); - pFS->endElementNS(XML_xdr, XML_sp); - - pFS->endElementNS(XML_mc, XML_Fallback); - pFS->endElementNS(XML_mc, XML_AlternateContent); - } - SetFS( pChart ); ExportContent(); SetFS( pFS ); @@ -1006,12 +904,11 @@ void ChartExport::ExportContent() if( !xChartDoc.is() ) return; InitRangeSegmentationProperties( xChartDoc ); - - const bool bIsChartex = isChartexNotChartNS(); - ExportContent_( bIsChartex ); + // TODO: export chart + ExportContent_( ); } -void ChartExport::ExportContent_( bool bIsChartex ) +void ChartExport::ExportContent_() { Reference< css::chart::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); if( xChartDoc.is()) @@ -1031,7 +928,7 @@ void ChartExport::ExportContent_( bool bIsChartex ) bIncludeTable = false; } } - exportChartSpace( xChartDoc, bIncludeTable, bIsChartex ); + exportChartSpace( xChartDoc, bIncludeTable ); } else { @@ -1040,16 +937,12 @@ void ChartExport::ExportContent_( bool bIsChartex ) } void ChartExport::exportChartSpace( const Reference< css::chart::XChartDocument >& xChartDoc, - bool bIncludeTable, - bool bIsChartex) + bool bIncludeTable ) { FSHelperPtr pFS = GetFS(); XmlFilterBase* pFB = GetFB(); - - const sal_Int32 nChartNS = bIsChartex ? XML_cx : XML_c; - - pFS->startElement( FSNS( nChartNS, XML_chartSpace ), - FSNS( XML_xmlns, nChartNS ), pFB->getNamespaceURL(OOX_NS(dmlChart)), + pFS->startElement( FSNS( XML_c, XML_chartSpace ), + FSNS( XML_xmlns, XML_c ), pFB->getNamespaceURL(OOX_NS(dmlChart)), FSNS( XML_xmlns, XML_a ), pFB->getNamespaceURL(OOX_NS(dml)), FSNS( XML_xmlns, XML_r ), pFB->getNamespaceURL(OOX_NS(officeRel))); @@ -1063,19 +956,12 @@ void ChartExport::exportChartSpace( const Reference< css::chart::XChartDocument } // TODO: get the correct editing language - if (bIsChartex) { - // chartData - pFS->startElement(FSNS(XML_cx, XML_chartData)); - exportExternalData(xChartDoc, true); - pFS->endElement(FSNS(XML_cx, XML_chartData)); - } else { - pFS->singleElement(FSNS(XML_c, XML_lang), XML_val, "en-US"); + pFS->singleElement(FSNS(XML_c, XML_lang), XML_val, "en-US"); - pFS->singleElement(FSNS(XML_c, XML_roundedCorners), XML_val, "0"); - } + pFS->singleElement(FSNS(XML_c, XML_roundedCorners), XML_val, "0"); //XML_chart - exportChart(xChartDoc, bIsChartex); + exportChart(xChartDoc); // TODO: printSettings // TODO: style @@ -1083,26 +969,19 @@ void ChartExport::exportChartSpace( const Reference< css::chart::XChartDocument // TODO: shape properties Reference< XPropertySet > xPropSet = xChartDoc->getArea(); if( xPropSet.is() ) - exportShapeProps( xPropSet, bIsChartex ); + exportShapeProps( xPropSet ); - // TODO for chartex - if (!bIsChartex) { - //XML_externalData - exportExternalData(xChartDoc, false); - } + //XML_externalData + exportExternalData(xChartDoc); // export additional shapes in chart - if (!bIsChartex) { - exportAdditionalShapes(xChartDoc); - } + exportAdditionalShapes(xChartDoc); - pFS->endElement( FSNS( nChartNS, XML_chartSpace ) ); + pFS->endElement( FSNS( XML_c, XML_chartSpace ) ); } -void ChartExport::exportExternalData( const Reference< css::chart::XChartDocument >& xChartDoc, - bool bIsChartex) +void ChartExport::exportExternalData( const Reference< css::chart::XChartDocument >& xChartDoc ) { - if (bIsChartex) return; // TODO!! // Embedded external data is grab bagged for docx file hence adding export part of // external data for docx files only. if(!mbLinkToExternalData || GetDocumentType() != DOCUMENT_DOCX) @@ -1150,8 +1029,6 @@ void ChartExport::exportExternalData( const Reference< css::chart::XChartDocumen void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDocument >& xChartDoc ) { - // Not used in chartex - Reference< beans::XPropertySet > xDocPropSet(xChartDoc, uno::UNO_QUERY); if (!xDocPropSet.is()) return; @@ -1254,14 +1131,12 @@ void ChartExport::exportAdditionalShapes( const Reference< css::chart::XChartDoc } } -void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xChartDoc, - bool bIsChartex) +void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xChartDoc ) { Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY ); mxDiagram.set( xChartDoc->getDiagram() ); - if( xNewDoc.is()) { + if( xNewDoc.is()) mxNewDiagram.set( xNewDoc->getFirstDiagram()); - } // get Properties of ChartDocument bool bHasMainTitle = false; @@ -1293,79 +1168,70 @@ void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xC // chart element FSHelperPtr pFS = GetFS(); - - const sal_Int32 nChartNS = bIsChartex ? XML_cx : XML_c; - pFS->startElement(FSNS(nChartNS, XML_chart)); + pFS->startElement(FSNS(XML_c, XML_chart)); // titles - const char * const sTitleDelVal = "1"; if( bHasMainTitle ) { - exportTitle( xChartDoc->getTitle(), bIsChartex, xFormattedSubTitle); - if (!bIsChartex) { - pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); - } + exportTitle( xChartDoc->getTitle(), xFormattedSubTitle); + pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); } else if( xFormattedSubTitle.hasElements() ) { - exportTitle( xChartDoc->getSubTitle(), bIsChartex ); - if (!bIsChartex) { - pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); - } + exportTitle( xChartDoc->getSubTitle() ); + pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "0"); } - else if (!bIsChartex) { - pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, sTitleDelVal); + else + { + pFS->singleElement(FSNS(XML_c, XML_autoTitleDeleted), XML_val, "1"); } InitPlotArea( ); if( mbIs3DChart ) { - if (!bIsChartex) { - exportView3D(); + exportView3D(); - // floor - Reference< beans::XPropertySet > xFloor = mxNewDiagram->getFloor(); - if( xFloor.is() ) - { - pFS->startElement(FSNS(XML_c, XML_floor)); - exportShapeProps( xFloor, false ); - pFS->endElement( FSNS( XML_c, XML_floor ) ); - } + // floor + Reference< beans::XPropertySet > xFloor = mxNewDiagram->getFloor(); + if( xFloor.is() ) + { + pFS->startElement(FSNS(XML_c, XML_floor)); + exportShapeProps( xFloor ); + pFS->endElement( FSNS( XML_c, XML_floor ) ); + } - // LibreOffice doesn't distinguish between sideWall and backWall (both are using the same color). - // It is controlled by the same Wall property. - Reference< beans::XPropertySet > xWall = mxNewDiagram->getWall(); - if( xWall.is() ) - { - // sideWall - pFS->startElement(FSNS(XML_c, XML_sideWall)); - exportShapeProps( xWall, false ); - pFS->endElement( FSNS( XML_c, XML_sideWall ) ); - - // backWall - pFS->startElement(FSNS(XML_c, XML_backWall)); - exportShapeProps( xWall, false ); - pFS->endElement( FSNS( XML_c, XML_backWall ) ); - } + // LibreOffice doesn't distinguish between sideWall and backWall (both are using the same color). + // It is controlled by the same Wall property. + Reference< beans::XPropertySet > xWall = mxNewDiagram->getWall(); + if( xWall.is() ) + { + // sideWall + pFS->startElement(FSNS(XML_c, XML_sideWall)); + exportShapeProps( xWall ); + pFS->endElement( FSNS( XML_c, XML_sideWall ) ); + + // backWall + pFS->startElement(FSNS(XML_c, XML_backWall)); + exportShapeProps( xWall ); + pFS->endElement( FSNS( XML_c, XML_backWall ) ); } + } // plot area - exportPlotArea( xChartDoc, bIsChartex ); + exportPlotArea( xChartDoc ); // legend if( bHasLegend ) - exportLegend( xChartDoc, bIsChartex ); + exportLegend( xChartDoc ); - if (!bIsChartex) { - uno::Reference<beans::XPropertySet> xDiagramPropSet(xChartDoc->getDiagram(), uno::UNO_QUERY); - uno::Any aPlotVisOnly = xDiagramPropSet->getPropertyValue(u"IncludeHiddenCells"_ustr); - bool bIncludeHiddenCells = false; - aPlotVisOnly >>= bIncludeHiddenCells; - pFS->singleElement(FSNS(XML_c, XML_plotVisOnly), XML_val, ToPsz10(!bIncludeHiddenCells)); + uno::Reference<beans::XPropertySet> xDiagramPropSet(xChartDoc->getDiagram(), uno::UNO_QUERY); + uno::Any aPlotVisOnly = xDiagramPropSet->getPropertyValue(u"IncludeHiddenCells"_ustr); + bool bIncludeHiddenCells = false; + aPlotVisOnly >>= bIncludeHiddenCells; + pFS->singleElement(FSNS(XML_c, XML_plotVisOnly), XML_val, ToPsz10(!bIncludeHiddenCells)); - exportMissingValueTreatment(Reference<beans::XPropertySet>(mxDiagram, uno::UNO_QUERY)); - } + exportMissingValueTreatment(Reference<beans::XPropertySet>(mxDiagram, uno::UNO_QUERY)); - pFS->endElement( FSNS( nChartNS, XML_chart ) ); + pFS->endElement( FSNS( XML_c, XML_chart ) ); } void ChartExport::exportMissingValueTreatment(const uno::Reference<beans::XPropertySet>& xPropSet) @@ -1399,18 +1265,14 @@ void ChartExport::exportMissingValueTreatment(const uno::Reference<beans::XPrope pFS->singleElement(FSNS(XML_c, XML_dispBlanksAs), XML_val, pVal); } -void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& xChartDoc, - bool bIsChartex) +void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& xChartDoc ) { FSHelperPtr pFS = GetFS(); + pFS->startElement(FSNS(XML_c, XML_legend)); Reference< beans::XPropertySet > xProp( xChartDoc->getLegend(), uno::UNO_QUERY ); if( xProp.is() ) { - if (!bIsChartex) { - pFS->startElement(FSNS(XML_c, XML_legend)); - } - // position css::chart::ChartLegendPosition aLegendPos = css::chart::ChartLegendPosition_NONE; try @@ -1444,162 +1306,148 @@ void ChartExport::exportLegend( const Reference< css::chart::XChartDocument >& x break; } - if (!bIsChartex) { - if( strPos != nullptr ) - { - pFS->singleElement(FSNS(XML_c, XML_legendPos), XML_val, strPos); - } + if( strPos != nullptr ) + { + pFS->singleElement(FSNS(XML_c, XML_legendPos), XML_val, strPos); + } - // legendEntry - Reference<chart2::XCoordinateSystemContainer> xCooSysContainer(mxNewDiagram, UNO_QUERY_THROW); - const Sequence<Reference<chart2::XCoordinateSystem>> xCooSysSequence(xCooSysContainer->getCoordinateSystems()); + // legendEntry + Reference<chart2::XCoordinateSystemContainer> xCooSysContainer(mxNewDiagram, UNO_QUERY_THROW); + const Sequence<Reference<chart2::XCoordinateSystem>> xCooSysSequence(xCooSysContainer->getCoordinateSystems()); - sal_Int32 nIndex = 0; - bool bShowLegendEntry; - for (const auto& rCooSys : xCooSysSequence) - { - PropertySet aCooSysProp(rCooSys); - bool bSwapXAndY = aCooSysProp.getBoolProperty(PROP_SwapXAndYAxis); + sal_Int32 nIndex = 0; + bool bShowLegendEntry; + for (const auto& rCooSys : xCooSysSequence) + { + PropertySet aCooSysProp(rCooSys); + bool bSwapXAndY = aCooSysProp.getBoolProperty(PROP_SwapXAndYAxis); + + Reference<chart2::XChartTypeContainer> xChartTypeContainer(rCooSys, UNO_QUERY_THROW); + const Sequence<Reference<chart2::XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes()); + if (!xChartTypeSequence.hasElements()) + continue; - Reference<chart2::XChartTypeContainer> xChartTypeContainer(rCooSys, UNO_QUERY_THROW); - const Sequence<Reference<chart2::XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes()); - if (!xChartTypeSequence.hasElements()) + for (const auto& rCT : xChartTypeSequence) + { + Reference<chart2::XDataSeriesContainer> xDSCont(rCT, UNO_QUERY); + if (!xDSCont.is()) continue; - for (const auto& rCT : xChartTypeSequence) + OUString aChartType(rCT->getChartType()); + bool bIsPie = lcl_getChartType(aChartType) == chart::TYPEID_PIE; + if (bIsPie) { - Reference<chart2::XDataSeriesContainer> xDSCont(rCT, UNO_QUERY); - if (!xDSCont.is()) - continue; - - OUString aChartType(rCT->getChartType()); - bool bIsPie = lcl_getChartType(aChartType) == chart::TYPEID_PIE; - if (bIsPie) - { - PropertySet xChartTypeProp(rCT); - bIsPie = !xChartTypeProp.getBoolProperty(PROP_UseRings); - } - const Sequence<Reference<chart2::XDataSeries>> aDataSeriesSeq = xDSCont->getDataSeries(); - if (bSwapXAndY) - nIndex += aDataSeriesSeq.getLength() - 1; - for (const auto& rDataSeries : aDataSeriesSeq) + PropertySet xChartTypeProp(rCT); + bIsPie = !xChartTypeProp.getBoolProperty(PROP_UseRings); + } + const Sequence<Reference<chart2::XDataSeries>> aDataSeriesSeq = xDSCont->getDataSeries(); + if (bSwapXAndY) + nIndex += aDataSeriesSeq.getLength() - 1; + for (const auto& rDataSeries : aDataSeriesSeq) + { + PropertySet aSeriesProp(rDataSeries); + bool bVaryColorsByPoint = aSeriesProp.getBoolProperty(PROP_VaryColorsByPoint); + if (bVaryColorsByPoint || bIsPie) { - PropertySet aSeriesProp(rDataSeries); - bool bVaryColorsByPoint = aSeriesProp.getBoolProperty(PROP_VaryColorsByPoint); - if (bVaryColorsByPoint || bIsPie) + Sequence<sal_Int32> deletedLegendEntriesSeq; + aSeriesProp.getProperty(deletedLegendEntriesSeq, PROP_DeletedLegendEntries); + for (const auto& deletedLegendEntry : deletedLegendEntriesSeq) { - Sequence<sal_Int32> deletedLegendEntriesSeq; - aSeriesProp.getProperty(deletedLegendEntriesSeq, PROP_DeletedLegendEntries); - for (const auto& deletedLegendEntry : std::as_const(deletedLegendEntriesSeq)) - { - pFS->startElement(FSNS(XML_c, XML_legendEntry)); - pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, - OString::number(nIndex + deletedLegendEntry)); - pFS->singleElement(FSNS(XML_c, XML_delete), XML_val, "1"); - pFS->endElement(FSNS(XML_c, XML_legendEntry)); - } - Reference<chart2::data::XDataSource> xDSrc(rDataSeries, UNO_QUERY); - if (!xDSrc.is()) - continue; + pFS->startElement(FSNS(XML_c, XML_legendEntry)); + pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, + OString::number(nIndex + deletedLegendEntry)); + pFS->singleElement(FSNS(XML_c, XML_delete), XML_val, "1"); + pFS->endElement(FSNS(XML_c, XML_legendEntry)); + } + Reference<chart2::data::XDataSource> xDSrc(rDataSeries, UNO_QUERY); + if (!xDSrc.is()) + continue; - const Sequence<Reference<chart2::data::XLabeledDataSequence>> aDataSeqs = xDSrc->getDataSequences(); - for (const auto& rDataSeq : aDataSeqs) - { - Reference<chart2::data::XDataSequence> xValues = rDataSeq->getValues(); - if (!xValues.is()) - continue; + const Sequence<Reference<chart2::data::XLabeledDataSequence>> aDataSeqs = xDSrc->getDataSequences(); + for (const auto& rDataSeq : aDataSeqs) + { + Reference<chart2::data::XDataSequence> xValues = rDataSeq->getValues(); + if (!xValues.is()) + continue; - sal_Int32 nDataSeqSize = xValues->getData().getLength(); - nIndex += nDataSeqSize; - } + sal_Int32 nDataSeqSize = xValues->getData().getLength(); + nIndex += nDataSeqSize; } - else + } + else + { + bShowLegendEntry = aSeriesProp.getBoolProperty(PROP_ShowLegendEntry); + if (!bShowLegendEntry) { - bShowLegendEntry = aSeriesProp.getBoolProperty(PROP_ShowLegendEntry); - if (!bShowLegendEntry) - { - pFS->startElement(FSNS(XML_c, XML_legendEntry)); - pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, - OString::number(nIndex)); - pFS->singleElement(FSNS(XML_c, XML_delete), XML_val, "1"); - pFS->endElement(FSNS(XML_c, XML_legendEntry)); - } - bSwapXAndY ? nIndex-- : nIndex++; + pFS->startElement(FSNS(XML_c, XML_legendEntry)); + pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, + OString::number(nIndex)); + pFS->singleElement(FSNS(XML_c, XML_delete), XML_val, "1"); + pFS->endElement(FSNS(XML_c, XML_legendEntry)); } + bSwapXAndY ? nIndex-- : nIndex++; } - if (bSwapXAndY) - nIndex += aDataSeriesSeq.getLength() + 1; } + if (bSwapXAndY) + nIndex += aDataSeriesSeq.getLength() + 1; } + } - uno::Any aRelativePos = xProp->getPropertyValue(u"RelativePosition"_ustr); - if (aRelativePos.hasValue()) - { - pFS->startElement(FSNS(XML_c, XML_layout)); - pFS->startElement(FSNS(XML_c, XML_manualLayout)); + uno::Any aRelativePos = xProp->getPropertyValue(u"RelativePosition"_ustr); + if (aRelativePos.hasValue()) + { + pFS->startElement(FSNS(XML_c, XML_layout)); + pFS->startElement(FSNS(XML_c, XML_manualLayout)); - pFS->singleElement(FSNS(XML_c, XML_xMode), XML_val, "edge"); - pFS->singleElement(FSNS(XML_c, XML_yMode), XML_val, "edge"); - chart2::RelativePosition aPos = aRelativePos.get<chart2::RelativePosition>(); + pFS->singleElement(FSNS(XML_c, XML_xMode), XML_val, "edge"); + pFS->singleElement(FSNS(XML_c, XML_yMode), XML_val, "edge"); + chart2::RelativePosition aPos = aRelativePos.get<chart2::RelativePosition>(); - const double x = aPos.Primary; - const double y = aPos.Secondary; + const double x = aPos.Primary; + const double y = aPos.Secondary; - pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(x)); - pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(y)); + pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(x)); + pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(y)); - uno::Any aRelativeSize = xProp->getPropertyValue(u"RelativeSize"_ustr); - if (aRelativeSize.hasValue()) - { - chart2::RelativeSize aSize = aRelativeSize.get<chart2::RelativeSize>(); + uno::Any aRelativeSize = xProp->getPropertyValue(u"RelativeSize"_ustr); + if (aRelativeSize.hasValue()) + { + chart2::RelativeSize aSize = aRelativeSize.get<chart2::RelativeSize>(); - const double w = aSize.Primary; - const double h = aSize.Secondary; + const double w = aSize.Primary; + const double h = aSize.Secondary; - pFS->singleElement(FSNS(XML_c, XML_w), XML_val, OString::number(w)); + pFS->singleElement(FSNS(XML_c, XML_w), XML_val, OString::number(w)); - pFS->singleElement(FSNS(XML_c, XML_h), XML_val, OString::number(h)); - } + pFS->singleElement(FSNS(XML_c, XML_h), XML_val, OString::number(h)); + } - SAL_WARN_IF(aPos.Anchor != css::drawing::Alignment_TOP_LEFT, "oox", "unsupported anchor position"); + SAL_WARN_IF(aPos.Anchor != css::drawing::Alignment_TOP_LEFT, "oox", "unsupported anchor position"); - pFS->endElement(FSNS(XML_c, XML_manualLayout)); - pFS->endElement(FSNS(XML_c, XML_layout)); - } + pFS->endElement(FSNS(XML_c, XML_manualLayout)); + pFS->endElement(FSNS(XML_c, XML_layout)); } - const char *sOverlay = nullptr; if (strPos != nullptr) { uno::Any aOverlay = xProp->getPropertyValue(u"Overlay"_ustr); if(aOverlay.get<bool>()) - sOverlay = "1"; + pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "1"); else - sOverlay = "0"; - } - - if (bIsChartex) { - pFS->startElement(FSNS(XML_cx, XML_legend), - XML_pos, strPos ? strPos : "r", - XML_align, "ctr", // is this supported? - XML_overlay, sOverlay ? sOverlay : "0"); - } else { - pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, sOverlay); + pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "0"); } // shape properties - exportShapeProps( xProp, bIsChartex ); + exportShapeProps( xProp ); // draw-chart:txPr text properties - exportTextProps( xProp, bIsChartex ); - - if (!bIsChartex) { - pFS->endElement( FSNS( XML_c, XML_legend ) ); - } + exportTextProps( xProp ); } + + pFS->endElement( FSNS( XML_c, XML_legend ) ); } -void ChartExport::exportTitle( const Reference< XShape >& xShape, bool bIsChartex, +void ChartExport::exportTitle( const Reference< XShape >& xShape, const css::uno::Sequence< uno::Reference< css::chart2::XFormattedString > >& xFormattedSubTitle ) { Sequence< uno::Reference< chart2::XFormattedString > > xFormattedTitle; @@ -1638,26 +1486,10 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape, bool bIsCharte return; FSHelperPtr pFS = GetFS(); + pFS->startElement(FSNS(XML_c, XML_title)); - if (bIsChartex) { - pFS->startElement(FSNS(XML_cx, XML_title)); - pFS->startElement(FSNS(XML_cx, XML_tx)); - pFS->startElement(FSNS(XML_cx, XML_txData)); - pFS->startElement(FSNS(XML_cx, XML_v)); - - // TODO: this is probably not right? - pFS->writeEscaped( xFormattedTitle[0]->getString() ); - - pFS->endElement(FSNS(XML_cx, XML_v)); - pFS->endElement(FSNS(XML_cx, XML_txData)); - pFS->endElement(FSNS(XML_cx, XML_tx)); - - pFS->startElement(FSNS(XML_cx, XML_txPr)); - } else { - pFS->startElement(FSNS(XML_c, XML_title)); - pFS->startElement(FSNS(XML_c, XML_tx)); - pFS->startElement(FSNS(XML_c, XML_rich)); - } + pFS->startElement(FSNS(XML_c, XML_tx)); + pFS->startElement(FSNS(XML_c, XML_rich)); // TODO: bodyPr const char* sWritingMode = nullptr; @@ -1729,70 +1561,56 @@ void ChartExport::exportTitle( const Reference< XShape >& xShape, bool bIsCharte pFS->endElement( FSNS( XML_a, XML_p ) ); - if (bIsChartex) { - pFS->endElement( FSNS( XML_cx, XML_txPr ) ); - } else { - pFS->endElement( FSNS( XML_c, XML_rich ) ); - pFS->endElement( FSNS( XML_c, XML_tx ) ); - } + pFS->endElement( FSNS( XML_c, XML_rich ) ); + pFS->endElement( FSNS( XML_c, XML_tx ) ); uno::Any aManualLayout = xPropSet->getPropertyValue(u"RelativePosition"_ustr); if (aManualLayout.hasValue()) { - if (bIsChartex) { - // TODO - } else { - pFS->startElement(FSNS(XML_c, XML_layout)); - pFS->startElement(FSNS(XML_c, XML_manualLayout)); - pFS->singleElement(FSNS(XML_c, XML_xMode), XML_val, "edge"); - pFS->singleElement(FSNS(XML_c, XML_yMode), XML_val, "edge"); - - Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); - awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); - - awt::Size aSize = xShape->getSize(); - awt::Point aPos2 = xShape->getPosition(); - // rotated shapes need special handling... - double fSin = fabs(sin(basegfx::deg2rad<100>(nRotation))); - // remove part of height from X direction, if title is rotated down - if( nRotation*0.01 > 180.0 ) - aPos2.X -= static_cast<sal_Int32>(fSin * aSize.Height + 0.5); - // remove part of width from Y direction, if title is rotated up - else if( nRotation*0.01 > 0.0 ) - aPos2.Y -= static_cast<sal_Int32>(fSin * aSize.Width + 0.5); - - double x = static_cast<double>(aPos2.X) / static_cast<double>(aPageSize.Width); - double y = static_cast<double>(aPos2.Y) / static_cast<double>(aPageSize.Height); - /* - pFS->singleElement(FSNS(XML_c, XML_wMode), XML_val, "edge"); - pFS->singleElement(FSNS(XML_c, XML_hMode), XML_val, "edge"); - */ - pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(x)); - pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(y)); - /* - pFS->singleElement(FSNS(XML_c, XML_w), XML_val, ""); - pFS->singleElement(FSNS(XML_c, XML_h), XML_val, ""); - */ - pFS->endElement(FSNS(XML_c, XML_manualLayout)); - pFS->endElement(FSNS(XML_c, XML_layout)); - } - } - - if (!bIsChartex) { - pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "0"); - } + pFS->startElement(FSNS(XML_c, XML_layout)); + pFS->startElement(FSNS(XML_c, XML_manualLayout)); + pFS->singleElement(FSNS(XML_c, XML_xMode), XML_val, "edge"); + pFS->singleElement(FSNS(XML_c, XML_yMode), XML_val, "edge"); + + Reference<embed::XVisualObject> xVisObject(mxChartModel, uno::UNO_QUERY); + awt::Size aPageSize = xVisObject->getVisualAreaSize(embed::Aspects::MSOLE_CONTENT); + + awt::Size aSize = xShape->getSize(); + awt::Point aPos2 = xShape->getPosition(); + // rotated shapes need special handling... + double fSin = fabs(sin(basegfx::deg2rad<100>(nRotation))); + // remove part of height from X direction, if title is rotated down + if( nRotation*0.01 > 180.0 ) + aPos2.X -= static_cast<sal_Int32>(fSin * aSize.Height + 0.5); + // remove part of width from Y direction, if title is rotated up + else if( nRotation*0.01 > 0.0 ) + aPos2.Y -= static_cast<sal_Int32>(fSin * aSize.Width + 0.5); + + double x = static_cast<double>(aPos2.X) / static_cast<double>(aPageSize.Width); + double y = static_cast<double>(aPos2.Y) / static_cast<double>(aPageSize.Height); + /* + pFS->singleElement(FSNS(XML_c, XML_wMode), XML_val, "edge"); + pFS->singleElement(FSNS(XML_c, XML_hMode), XML_val, "edge"); + */ + pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(x)); + pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(y)); + /* + pFS->singleElement(FSNS(XML_c, XML_w), XML_val, ""); + pFS->singleElement(FSNS(XML_c, XML_h), XML_val, ""); + */ + pFS->endElement(FSNS(XML_c, XML_manualLayout)); + pFS->endElement(FSNS(XML_c, XML_layout)); + } + + pFS->singleElement(FSNS(XML_c, XML_overlay), XML_val, "0"); // shape properties if( xPropSet.is() ) { - exportShapeProps( xPropSet, bIsChartex ); + exportShapeProps( xPropSet ); } - if (bIsChartex) { - pFS->endElement( FSNS( XML_cx, XML_title ) ); - } else { - pFS->endElement( FSNS( XML_c, XML_title ) ); - } + pFS->endElement( FSNS( XML_c, XML_title ) ); } namespace { @@ -1852,8 +1670,7 @@ namespace { } -void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& xChartDoc, - bool bIsChartex) +void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& xChartDoc) { Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( mxNewDiagram, uno::UNO_QUERY ); if( ! xBCooSysCnt.is()) @@ -1862,25 +1679,19 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& // plot-area element FSHelperPtr pFS = GetFS(); + pFS->startElement(FSNS(XML_c, XML_plotArea)); - if (bIsChartex) { - pFS->startElement(FSNS(XML_cx, XML_plotArea)); - pFS->startElement(FSNS(XML_cx, XML_plotAreaRegion)); - } else { - pFS->startElement(FSNS(XML_c, XML_plotArea)); - - Reference<beans::XPropertySet> xWall(mxNewDiagram, uno::UNO_QUERY); - if( xWall.is() ) + Reference<beans::XPropertySet> xWall(mxNewDiagram, uno::UNO_QUERY); + if( xWall.is() ) + { + uno::Any aAny = xWall->getPropertyValue(u"RelativePosition"_ustr); + if (aAny.hasValue()) { - uno::Any aAny = xWall->getPropertyValue(u"RelativePosition"_ustr); - if (aAny.hasValue()) - { - chart2::RelativePosition aPos = aAny.get<chart2::RelativePosition>(); - aAny = xWall->getPropertyValue(u"RelativeSize"_ustr); - chart2::RelativeSize aSize = aAny.get<chart2::RelativeSize>(); - uno::Reference< css::chart::XDiagramPositioning > xDiagramPositioning( xChartDoc->getDiagram(), uno::UNO_QUERY ); - exportManualLayout(aPos, aSize, xDiagramPositioning->isExcludingDiagramPositioning() ); - } + chart2::RelativePosition aPos = aAny.get<chart2::RelativePosition>(); + aAny = xWall->getPropertyValue(u"RelativeSize"_ustr); + chart2::RelativeSize aSize = aAny.get<chart2::RelativeSize>(); + uno::Reference< css::chart::XDiagramPositioning > xDiagramPositioning( xChartDoc->getDiagram(), uno::UNO_QUERY ); + exportManualLayout(aPos, aSize, xDiagramPositioning->isExcludingDiagramPositioning() ); } } @@ -1891,8 +1702,6 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& // tdf#123647 Save empty chart as empty bar chart. if (!aCooSysSeq.hasElements()) { - assert(!bIsChartex); - pFS->startElement(FSNS(XML_c, XML_barChart)); pFS->singleElement(FSNS(XML_c, XML_barDir), XML_val, "col"); pFS->singleElement(FSNS(XML_c, XML_grouping), XML_val, "clustered"); @@ -1941,11 +1750,6 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& exportBubbleChart( xChartType ); break; } - case chart::TYPEID_FUNNEL: - { - exportFunnelChart( xChartType ); - break; - } case chart::TYPEID_DOUGHNUT: // doesn't currently happen case chart::TYPEID_OFPIE: // doesn't currently happen case chart::TYPEID_PIE: @@ -2021,12 +1825,10 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& } } //Axis Data - exportAxes( bIsChartex ); + exportAxes( ); - if (!bIsChartex) { // not supported in chartex? - // Data Table - exportDataTable(); - } + // Data Table + exportDataTable(); // shape properties /* @@ -2053,16 +1855,11 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& { xWallPropSet->setPropertyValue( u"LineStyle"_ustr, uno::Any(drawing::LineStyle_NONE) ); } - exportShapeProps( xWallPropSet, bIsChartex ); + exportShapeProps( xWallPropSet ); } } - if (bIsChartex) { - pFS->endElement( FSNS( XML_cx, XML_plotAreaRegion ) ); - pFS->endElement( FSNS( XML_cx, XML_plotArea ) ); - } else { - pFS->endElement( FSNS( XML_c, XML_plotArea ) ); - } + pFS->endElement( FSNS( XML_c, XML_plotArea ) ); } @@ -2070,7 +1867,6 @@ void ChartExport::exportManualLayout(const css::chart2::RelativePosition& rPos, const css::chart2::RelativeSize& rSize, const bool bIsExcludingDiagramPositioning) { - // 2006 chart schema only FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, XML_layout)); pFS->startElement(FSNS(XML_c, XML_manualLayout)); @@ -2347,7 +2143,6 @@ void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet void ChartExport::exportDataTable( ) { - // Not supported in chartex 2014 schema auto xDataTable = mxNewDiagram->getDataTable(); if (!xDataTable.is()) return; @@ -2380,8 +2175,8 @@ void ChartExport::exportDataTable( ) if (bShowKeys) pFS->singleElement(FSNS(XML_c, XML_showKeys), XML_val, "1"); - exportShapeProps(aPropSet, false); - exportTextProps(aPropSet, false); + exportShapeProps(aPropSet); + exportTextProps(aPropSet); pFS->endElement(FSNS(XML_c, XML_dTable)); } @@ -2405,8 +2200,7 @@ void ChartExport::exportAreaChart( const Reference< chart2::XChartType >& xChart exportGrouping(); bool bPrimaryAxes = true; if (splitDataSeries.hasElements()) - exportSeries(xChartType, splitDataSeries, bPrimaryAxes, false); - + exportSeries(xChartType, splitDataSeries, bPrimaryAxes); exportAxesId(bPrimaryAxes); pFS->endElement(FSNS(XML_c, nTypeId)); @@ -2444,7 +2238,7 @@ void ChartExport::exportBarChart(const Reference< chart2::XChartType >& xChartTy bool bPrimaryAxes = true; if (splitDataSeries.hasElements()) - exportSeries(xChartType, splitDataSeries, bPrimaryAxes, false); + exportSeries(xChartType, splitDataSeries, bPrimaryAxes); Reference< XPropertySet > xTypeProp(xChartType, uno::UNO_QUERY); @@ -2533,7 +2327,7 @@ void ChartExport::exportBubbleChart( const Reference< chart2::XChartType >& xCha bool bPrimaryAxes = true; if (splitDataSeries.hasElements()) - exportSeries(xChartType, splitDataSeries, bPrimaryAxes, false); + exportSeries(xChartType, splitDataSeries, bPrimaryAxes); exportAxesId(bPrimaryAxes); @@ -2541,29 +2335,6 @@ void ChartExport::exportBubbleChart( const Reference< chart2::XChartType >& xCha } } -void ChartExport::exportFunnelChart( const Reference< chart2::XChartType >& xChartType ) -{ - FSHelperPtr pFS = GetFS(); - const std::vector<Sequence<Reference<chart2::XDataSeries> > > aSplitDataSeries = splitDataSeriesByAxis(xChartType); - for (const auto& splitDataSeries : aSplitDataSeries) - { - if (!splitDataSeries.hasElements()) - continue; - - pFS->startElement(FSNS(XML_cx, XML_series), XML_layoutId, "funnel"); - - //exportVaryColors(xChartType); - - bool bPrimaryAxes = false; - exportSeries(xChartType, splitDataSeries, bPrimaryAxes, true); - - // TODO: in chartex, axis is an element of cx:plotArea - //exportAxesId(bPrimaryAxes); - - pFS->endElement(FSNS(XML_cx, XML_series)); - } -} - void ChartExport::exportDoughnutChart( const Reference< chart2::XChartType >& xChartType ) { FSHelperPtr pFS = GetFS(); @@ -2661,7 +2432,7 @@ void ChartExport::exportLineChart( const Reference< chart2::XChartType >& xChart // TODO: show marker symbol in series? bool bPrimaryAxes = true; if (splitDataSeries.hasElements()) - exportSeries(xChartType, splitDataSeries, bPrimaryAxes, false); + exportSeries(xChartType, splitDataSeries, bPrimaryAxes); // show marker? sal_Int32 nSymbolType = css::chart::ChartSymbolType::NONE; @@ -2751,7 +2522,7 @@ void ChartExport::exportScatterChartSeries( const Reference< chart2::XChartType // FIXME: should export xVal and yVal bool bPrimaryAxes = true; if (pSeries) - exportSeries(xChartType, *pSeries, bPrimaryAxes, false); + exportSeries(xChartType, *pSeries, bPrimaryAxes); exportAxesId(bPrimaryAxes); pFS->endElement( FSNS( XML_c, XML_scatterChart ) ); @@ -2820,7 +2591,7 @@ void ChartExport::exportHiLowLines() return; pFS->startElement(FSNS(XML_c, XML_hiLowLines)); - exportShapeProps( xStockPropSet, false ); + exportShapeProps( xStockPropSet ); pFS->endElement( FSNS( XML_c, XML_hiLowLines ) ); } @@ -2848,7 +2619,7 @@ void ChartExport::exportUpDownBars( const Reference< chart2::XChartType >& xChar // so no need to call the exportShapeProps() for LineChart if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType") { - exportShapeProps(xChartPropSet, false); + exportShapeProps(xChartPropSet); } pFS->endElement( FSNS( XML_c, XML_upBars ) ); } @@ -2858,7 +2629,7 @@ void ChartExport::exportUpDownBars( const Reference< chart2::XChartType >& xChar pFS->startElement(FSNS(XML_c, XML_downBars)); if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType") { - exportShapeProps(xChartPropSet, false); + exportShapeProps(xChartPropSet); } pFS->endElement( FSNS( XML_c, XML_downBars ) ); } @@ -2888,7 +2659,7 @@ void ChartExport::exportAllSeries(const Reference<chart2::XChartType>& xChartTyp // export dataseries for current chart-type Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries()); - exportSeries(xChartType, aSeriesSeq, rPrimaryAxes, false); + exportSeries(xChartType, aSeriesSeq, rPrimaryAxes); } void ChartExport::exportVaryColors(const Reference<chart2::XChartType>& xChartType) @@ -2910,9 +2681,7 @@ void ChartExport::exportVaryColors(const Reference<chart2::XChartType>& xChartTy } void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType, - const Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, - bool& rPrimaryAxes, - bool bIsChartex) + const Sequence<Reference<chart2::XDataSeries> >& rSeriesSeq, bool& rPrimaryAxes ) { OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel(); OUString aChartType( xChartType->getChartType()); @@ -2961,158 +2730,154 @@ void ChartExport::exportSeries( const Reference<chart2::XChartType>& xChartType, { FSHelperPtr pFS = GetFS(); - if (!bIsChartex) { - pFS->startElement(FSNS(XML_c, XML_ser)); + pFS->startElement(FSNS(XML_c, XML_ser)); - // TODO: idx and order - pFS->singleElement( FSNS( XML_c, XML_idx ), - XML_val, OString::number(mnSeriesCount) ); - pFS->singleElement( FSNS( XML_c, XML_order ), - XML_val, OString::number(mnSeriesCount++) ); + // TODO: idx and order + pFS->singleElement( FSNS( XML_c, XML_idx ), + XML_val, OString::number(mnSeriesCount) ); + pFS->singleElement( FSNS( XML_c, XML_order ), + XML_val, OString::number(mnSeriesCount++) ); - // export label - if( xLabelSeq.is() ) - exportSeriesText( xLabelSeq ); + // export label + if( xLabelSeq.is() ) + exportSeriesText( xLabelSeq ); + + Reference<XPropertySet> xPropSet(xDataSeries, UNO_QUERY_THROW); + if( GetProperty( xPropSet, u"AttachedAxisIndex"_ustr) ) + { + sal_Int32 nLocalAttachedAxis = 0; + mAny >>= nLocalAttachedAxis; + rPrimaryAxes = isPrimaryAxes(nLocalAttachedAxis); + } - Reference<XPropertySet> xPropSet(xDataSeries, UNO_QUERY_THROW); - if( GetProperty( xPropSet, u"AttachedAxisIndex"_ustr) ) + // export shape properties + Reference< XPropertySet > xOldPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet( + rSeries, getModel() ); + if( xOldPropSet.is() ) + { + exportShapeProps( xOldPropSet ); + } + + switch( eChartType ) + { + case chart::TYPEID_BUBBLE: + case chart::TYPEID_HORBAR: + case chart::TYPEID_BAR: { - sal_Int32 nLocalAttachedAxis = 0; - mAny >>= nLocalAttachedAxis; - rPrimaryAxes = isPrimaryAxes(nLocalAttachedAxis); + pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), XML_val, "0"); } - - // export shape properties - Reference< XPropertySet > xOldPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet( - rSeries, getModel() ); - if( xOldPropSet.is() ) + break; + case chart::TYPEID_LINE: { - exportShapeProps( xOldPropSet, false ); + exportMarker(xOldPropSet); + break; } - - switch( eChartType ) + case chart::TYPEID_PIE: + case chart::TYPEID_DOUGHNUT: { - case chart::TYPEID_BUBBLE: - case chart::TYPEID_HORBAR: - case chart::TYPEID_BAR: + if( xOldPropSet.is() && GetProperty( xOldPropSet, u"SegmentOffset"_ustr) ) { - pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), XML_val, "0"); + sal_Int32 nOffset = 0; + mAny >>= nOffset; + pFS->singleElement( FSNS( XML_c, XML_explosion ), + XML_val, OString::number( nOffset ) ); } break; - case chart::TYPEID_LINE: - { - exportMarker(xOldPropSet); - break; - } - case chart::TYPEID_PIE: - case chart::TYPEID_DOUGHNUT: - { - if( xOldPropSet.is() && GetProperty( xOldPropSet, u"SegmentOffset"_ustr) ) - { - sal_Int32 nOffset = 0; - mAny >>= nOffset; - pFS->singleElement( FSNS( XML_c, XML_explosion ), - XML_val, OString::number( nOffset ) ); - } - break; - } - case chart::TYPEID_SCATTER: - { - exportMarker(xOldPropSet); - break; - } - case chart::TYPEID_RADARLINE: - { - exportMarker(xOldPropSet); - break; - } } - - // export data points - exportDataPoints( uno::Reference< beans::XPropertySet >( rSeries, uno::UNO_QUERY ), nSeriesLength, eChartType ); + case chart::TYPEID_SCATTER: + { + exportMarker(xOldPropSet); + break; + } + case chart::TYPEID_RADARLINE: + { + exportMarker(xOldPropSet); + break; + } } + // export data points + exportDataPoints( uno::Reference< beans::XPropertySet >( rSeries, uno::UNO_QUERY ), nSeriesLength, eChartType ); + DataLabelsRange aDLblsRange; // export data labels - exportDataLabels(rSeries, nSeriesLength, eChartType, aDLblsRange, bIsChartex); + exportDataLabels(rSeries, nSeriesLength, eChartType, aDLblsRange); - if (!bIsChartex) { - exportTrendlines( rSeries ); + exportTrendlines( rSeries ); - if( eChartType != chart::TYPEID_PIE && - eChartType != chart::TYPEID_RADARLINE ) + if( eChartType != chart::TYPEID_PIE && + eChartType != chart::TYPEID_RADARLINE ) + { + //export error bars here + Reference< XPropertySet > xSeriesPropSet( xSource, uno::UNO_QUERY ); + Reference< XPropertySet > xErrorBarYProps; + xSeriesPropSet->getPropertyValue(u"ErrorBarY"_ustr) >>= xErrorBarYProps; + if(xErrorBarYProps.is()) + exportErrorBar(xErrorBarYProps, true); + if (eChartType != chart::TYPEID_BAR && + eChartType != chart::TYPEID_HORBAR) { - //export error bars here - Reference< XPropertySet > xSeriesPropSet( xSource, uno::UNO_QUERY ); - Reference< XPropertySet > xErrorBarYProps; - xSeriesPropSet->getPropertyValue(u"ErrorBarY"_ustr) >>= xErrorBarYProps; - if(xErrorBarYProps.is()) - exportErrorBar(xErrorBarYProps, true); - if (eChartType != chart::TYPEID_BAR && - eChartType != chart::TYPEID_HORBAR) - { - Reference< XPropertySet > xErrorBarXProps; - xSeriesPropSet->getPropertyValue(u"ErrorBarX"_ustr) >>= xErrorBarXProps; - if(xErrorBarXProps.is()) - exportErrorBar(xErrorBarXProps, false); - } + Reference< XPropertySet > xErrorBarXProps; + xSeriesPropSet->getPropertyValue(u"ErrorBarX"_ustr) >>= xErrorBarXProps; + if(xErrorBarXProps.is()) + exportErrorBar(xErrorBarXProps, false); } + } - // export categories - if( eChartType != chart::TYPEID_SCATTER && eChartType != chart::TYPEID_BUBBLE && mxCategoriesValues.is() ) - exportSeriesCategory( mxCategoriesValues ); + // export categories + if( eChartType != chart::TYPEID_SCATTER && eChartType != chart::TYPEID_BUBBLE && mxCategoriesValues.is() ) + exportSeriesCategory( mxCategoriesValues ); - if( (eChartType == chart::TYPEID_SCATTER) - || (eChartType == chart::TYPEID_BUBBLE) ) + if( (eChartType == chart::TYPEID_SCATTER) + || (eChartType == chart::TYPEID_BUBBLE) ) + { + // export xVal + Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, u"values-x"_ustr ) ); + if( xSequence.is() ) { - // export xVal - Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, u"values-x"_ustr ) ); - if( xSequence.is() ) - { - Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); - if( xValues.is() ) - exportSeriesValues( xValues, XML_xVal ); - } - else if( mxCategoriesValues.is() ) - exportSeriesCategory( mxCategoriesValues, XML_xVal ); + Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); + if( xValues.is() ) + exportSeriesValues( xValues, XML_xVal ); } + else if( mxCategoriesValues.is() ) + exportSeriesCategory( mxCategoriesValues, XML_xVal ); + } - if( eChartType == chart::TYPEID_BUBBLE ) + if( eChartType == chart::TYPEID_BUBBLE ) + { + // export yVal + Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, u"values-y"_ustr ) ); + if( xSequence.is() ) { - // export yVal - Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, u"values-y"_ustr ) ); - if( xSequence.is() ) - { - Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); - if( xValues.is() ) - exportSeriesValues( xValues, XML_yVal ); - } + Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); + if( xValues.is() ) + exportSeriesValues( xValues, XML_yVal ); } + } - // export values - if( xValuesSeq.is() ) - { - sal_Int32 nYValueType = XML_val; - if( eChartType == chart::TYPEID_SCATTER ) - nYValueType = XML_yVal; - else if( eChartType == chart::TYPEID_BUBBLE ) - nYValueType = XML_bubbleSize; - exportSeriesValues( xValuesSeq, nYValueType ); - } + // export values + if( xValuesSeq.is() ) + { + sal_Int32 nYValueType = XML_val; + if( eChartType == chart::TYPEID_SCATTER ) + nYValueType = XML_yVal; + else if( eChartType == chart::TYPEID_BUBBLE ) + nYValueType = XML_bubbleSize; + exportSeriesValues( xValuesSeq, nYValueType ); + } - if( eChartType == chart::TYPEID_SCATTER - || eChartType == chart::TYPEID_LINE ) - exportSmooth(); + if( eChartType == chart::TYPEID_SCATTER + || eChartType == chart::TYPEID_LINE ) + exportSmooth(); - // tdf103988: "corrupted" files with Bubble chart opening in MSO - if( eChartType == chart::TYPEID_BUBBLE ) - pFS->singleElement(FSNS(XML_c, XML_bubble3D), XML_val, "0"); + // tdf103988: "corrupted" files with Bubble chart opening in MSO + if( eChartType == chart::TYPEID_BUBBLE ) + pFS->singleElement(FSNS(XML_c, XML_bubble3D), XML_val, "0"); - if (!aDLblsRange.empty()) - writeDataLabelsRange(pFS, GetFB(), aDLblsRange); + if (!aDLblsRange.empty()) + writeDataLabelsRange(pFS, GetFB(), aDLblsRange); - pFS->endElement( FSNS( XML_c, XML_ser ) ); - } + pFS->endElement( FSNS( XML_c, XML_ser ) ); } } } @@ -3356,26 +3121,21 @@ void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequen pFS->endElement( FSNS( XML_c, nValueType ) ); } -void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet, - bool bIsChartex) +void ChartExport::exportShapeProps( const Reference< XPropertySet >& xPropSet ) { - sal_Int32 nChartNS = bIsChartex ? XML_cx : XML_c; FSHelperPtr pFS = GetFS(); - pFS->startElement(FSNS(nChartNS, XML_spPr)); + pFS->startElement(FSNS(XML_c, XML_spPr)); exportFill( xPropSet ); WriteOutline( xPropSet, getModel() ); - pFS->endElement( FSNS( nChartNS, XML_spPr ) ); + pFS->endElement( FSNS( XML_c, XML_spPr ) ); } -void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet, - bool bIsChartex) +void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet) { FSHelperPtr pFS = GetFS(); - - const sal_Int32 nChartNS = bIsChartex ? XML_cx : XML_c; - pFS->startElement(FSNS(nChartNS, XML_txPr)); + pFS->startElement(FSNS(XML_c, XML_txPr)); sal_Int32 nRotation = 0; const char* textWordWrap = nullptr; @@ -3439,7 +3199,7 @@ void ChartExport::exportTextProps(const Reference<XPropertySet>& xPropSet, pFS->endElement(FSNS(XML_a, XML_pPr)); pFS->endElement(FSNS(XML_a, XML_p)); - pFS->endElement(FSNS(nChartNS, XML_txPr)); + pFS->endElement(FSNS(XML_c, XML_txPr)); } void ChartExport::InitPlotArea( ) @@ -3468,7 +3228,7 @@ void ChartExport::InitPlotArea( ) } } -void ChartExport::exportAxes( bool bIsChartex ) +void ChartExport::exportAxes( ) { sal_Int32 nSize = maAxes.size(); // let's export the axis types in the right order @@ -3477,7 +3237,7 @@ void ChartExport::exportAxes( bool bIsChartex ) for ( sal_Int32 nIdx = 0; nIdx < nSize; nIdx++ ) { if (nSortIdx == maAxes[nIdx].nAxisType) - exportAxis( maAxes[nIdx], bIsChartex ); + exportAxis( maAxes[nIdx] ); } } } @@ -3509,7 +3269,7 @@ sal_Int32 getRealXAxisType(sal_Int32 nAxisType) } -void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair, bool bIsChartex) +void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair) { // get some properties from document first bool bHasXAxisTitle = false, @@ -3649,8 +3409,7 @@ void ChartExport::exportAxis(const AxisIdPair& rAxisIdPair, bool bIsChartex) } } - _exportAxis(xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, - sAxPos, rAxisIdPair, bIsChartex); + _exportAxis(xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, rAxisIdPair); } void ChartExport::_exportAxis( @@ -3660,12 +3419,8 @@ void ChartExport::_exportAxis( const Reference< XPropertySet >& xMinorGrid, sal_Int32 nAxisType, const char* sAxisPos, - const AxisIdPair& rAxisIdPair, - bool bIsChartex) + const AxisIdPair& rAxisIdPair ) { - // TODO for chartex - if (bIsChartex) return; - FSHelperPtr pFS = GetFS(); pFS->startElement(FSNS(XML_c, nAxisType)); pFS->singleElement(FSNS(XML_c, XML_axId), XML_val, OString::number(rAxisIdPair.nAxisId)); @@ -3734,7 +3489,7 @@ void ChartExport::_exportAxis( if( xMajorGrid.is()) { pFS->startElement(FSNS(XML_c, XML_majorGridlines)); - exportShapeProps( xMajorGrid, bIsChartex ); + exportShapeProps( xMajorGrid ); pFS->endElement( FSNS( XML_c, XML_majorGridlines ) ); } @@ -3742,13 +3497,13 @@ void ChartExport::_exportAxis( if( xMinorGrid.is()) { pFS->startElement(FSNS(XML_c, XML_minorGridlines)); - exportShapeProps( xMinorGrid, bIsChartex ); + exportShapeProps( xMinorGrid ); pFS->endElement( FSNS( XML_c, XML_minorGridlines ) ); } // title if( xAxisTitle.is() ) - exportTitle( xAxisTitle, bIsChartex ); + exportTitle( xAxisTitle ); bool bLinkedNumFmt = true; if (GetProperty(xAxisProp, u"LinkNumberFormatToSource"_ustr)) @@ -3834,9 +3589,9 @@ void ChartExport::_exportAxis( pFS->singleElement(FSNS(XML_c, XML_tickLblPos), XML_val, sTickLblPos); // shape properties - exportShapeProps( xAxisProp, bIsChartex ); + exportShapeProps( xAxisProp ); - exportTextProps(xAxisProp, bIsChartex); + exportTextProps(xAxisProp); pFS->singleElement(FSNS(XML_c, XML_crossAx), XML_val, OString::number(rAxisIdPair.nCrossAx)); @@ -4166,16 +3921,13 @@ void writeCustomLabel( const FSHelperPtr& pFS, ChartExport* pChartExport, void ChartExport::writeLabelProperties( const uno::Reference<beans::XPropertySet>& xPropSet, const LabelPlacementParam& rLabelParam, - sal_Int32 nLabelIndex, DataLabelsRange& rDLblsRange, - bool bIsChartex) + sal_Int32 nLabelIndex, DataLabelsRange& rDLblsRange ) { if (!xPropSet.is()) return; FSHelperPtr pFS = GetFS(); - const sal_Int32 nChartNS = bIsChartex ? XML_cx : XML_c; - chart2::DataPointLabel aLabel; Sequence<Reference<chart2::XDataPointCustomLabelField>> aCustomLabelFields; sal_Int32 nLabelBorderWidth = 0; @@ -4205,18 +3957,13 @@ void ChartExport::writeLabelProperties( OUString aNumberFormatString = getNumberFormatCode(nKey); - if (bIsChartex) { - pFS->singleElement(FSNS(XML_cx, XML_numFmt), XML_formatCode, aNumberFormatString, - XML_sourceLinked, ToPsz10(bLinkedNumFmt)); - } else { - pFS->singleElement(FSNS(XML_c, XML_numFmt), XML_formatCode, aNumberFormatString, - XML_sourceLinked, ToPsz10(bLinkedNumFmt)); - } + pFS->singleElement(FSNS(XML_c, XML_numFmt), XML_formatCode, aNumberFormatString, + XML_sourceLinked, ToPsz10(bLinkedNumFmt)); } if (nLabelBorderWidth > 0 || nLabelFillColor != -1) { - pFS->startElement(FSNS(nChartNS, XML_spPr)); + pFS->startElement(FSNS(XML_c, XML_spPr)); if (nLabelFillColor != -1) { @@ -4244,65 +3991,60 @@ void ChartExport::writeLabelProperties( pFS->endElement(FSNS(XML_a, XML_ln)); } - pFS->endElement(FSNS(nChartNS, XML_spPr)); + pFS->endElement(FSNS(XML_c, XML_spPr)); } - exportTextProps(xPropSet, bIsChartex); // c:txPr + exportTextProps(xPropSet); // c:txPr - if (!bIsChartex) { - // In chartex label position is an attribute of cx:dataLabel - if (rLabelParam.mbExport) + if (rLabelParam.mbExport) + { + sal_Int32 nLabelPlacement = rLabelParam.meDefault; + if (xPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement) { - sal_Int32 nLabelPlacement = rLabelParam.meDefault; - if (xPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement) + if (!rLabelParam.maAllowedValues.count(nLabelPlacement)) { - if (!rLabelParam.maAllowedValues.count(nLabelPlacement)) - { - SAL_WARN("oox", "this label placement not allowed in OOXML for current chart type: " - + OString::number(nLabelPlacement)); - nLabelPlacement = rLabelParam.meDefault; - } - pFS->singleElement(FSNS(XML_c, XML_dLblPos), XML_val, toOOXMLPlacement(nLabelPlacement)); + SAL_WARN("oox", "this label placement not allowed in OOXML for current chart type: " + + OString::number(nLabelPlacement)); + nLabelPlacement = rLabelParam.meDefault; } + pFS->singleElement(FSNS(XML_c, XML_dLblPos), XML_val, toOOXMLPlacement(nLabelPlacement)); } - - pFS->singleElement(FSNS(XML_c, XML_showLegendKey), XML_val, ToPsz10(aLabel.ShowLegendSymbol)); - pFS->singleElement(FSNS(XML_c, XML_showVal), XML_val, ToPsz10(aLabel.ShowNumber)); - pFS->singleElement(FSNS(XML_c, XML_showCatName), XML_val, ToPsz10(aLabel.ShowCategoryName)); - pFS->singleElement(FSNS(XML_c, XML_showSerName), XML_val, ToPsz10(aLabel.ShowSeriesName)); - pFS->singleElement(FSNS(XML_c, XML_showPercent), XML_val, ToPsz10(aLabel.ShowNumberInPercent)); } + pFS->singleElement(FSNS(XML_c, XML_showLegendKey), XML_val, ToPsz10(aLabel.ShowLegendSymbol)); + pFS->singleElement(FSNS(XML_c, XML_showVal), XML_val, ToPsz10(aLabel.ShowNumber)); + pFS->singleElement(FSNS(XML_c, XML_showCatName), XML_val, ToPsz10(aLabel.ShowCategoryName)); + pFS->singleElement(FSNS(XML_c, XML_showSerName), XML_val, ToPsz10(aLabel.ShowSeriesName)); + pFS->singleElement(FSNS(XML_c, XML_showPercent), XML_val, ToPsz10(aLabel.ShowNumberInPercent)); + // Export the text "separator" if exists uno::Any aAny = xPropSet->getPropertyValue(u"LabelSeparator"_ustr); if( aAny.hasValue() ) { OUString nLabelSeparator; aAny >>= nLabelSeparator; - pFS->startElement(FSNS(nChartNS, XML_separator)); + pFS->startElement(FSNS(XML_c, XML_separator)); pFS->writeEscaped( nLabelSeparator ); - pFS->endElement( FSNS(nChartNS, XML_separator ) ); + pFS->endElement( FSNS( XML_c, XML_separator ) ); } if (rDLblsRange.hasLabel(nLabelIndex)) { - pFS->startElement(FSNS(nChartNS, XML_extLst)); - // TODO: is the following correct for chartex? - pFS->startElement(FSNS(nChartNS, XML_ext), XML_uri, + pFS->startElement(FSNS(XML_c, XML_extLst)); + pFS->startElement(FSNS(XML_c, XML_ext), XML_uri, "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}", FSNS(XML_xmlns, XML_c15), GetFB()->getNamespaceURL(OOX_NS(c15))); pFS->singleElement(FSNS(XML_c15, XML_showDataLabelsRange), XML_val, "1"); - pFS->endElement(FSNS(nChartNS, XML_ext)); - pFS->endElement(FSNS(nChartNS, XML_extLst)); + pFS->endElement(FSNS(XML_c, XML_ext)); + pFS->endElement(FSNS(XML_c, XML_extLst)); } } void ChartExport::exportDataLabels( const uno::Reference<chart2::XDataSeries> & xSeries, sal_Int32 nSeriesLength, sal_Int32 eChartType, - DataLabelsRange& rDLblsRange, - bool bIsChartex) + DataLabelsRange& rDLblsRange) { if (!xSeries.is() || nSeriesLength <= 0) return; @@ -4312,12 +4054,7 @@ void ChartExport::exportDataLabels( return; FSHelperPtr pFS = GetFS(); - - if (bIsChartex) { - pFS->startElement(FSNS(XML_cx, XML_dataLabels)); - } else { - pFS->startElement(FSNS(XML_c, XML_dLbls)); - } + pFS->startElement(FSNS(XML_c, XML_dLbls)); uno::Sequence<sal_Int32> aAttrLabelIndices; xPropSet->getPropertyValue(u"AttributedDataPoints"_ustr) >>= aAttrLabelIndices; @@ -4372,7 +4109,6 @@ void ChartExport::exportDataLabels( aParam.meDefault = css::chart::DataLabelPlacement::OUTSIDE; } break; - // TODO: How do chartex charts handle this? default: ; } @@ -4384,97 +4120,73 @@ void ChartExport::exportDataLabels( if (!xLabelPropSet.is()) continue; - if (bIsChartex) { - if (aParam.mbExport) - { - sal_Int32 nLabelPlacement = aParam.meDefault; - if (xPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement) - { - if (!aParam.maAllowedValues.count(nLabelPlacement)) - nLabelPlacement = aParam.meDefault; - pFS->startElement(FSNS(XML_cx, XML_dataLabel), - XML_idx, OString::number(nIdx), - XML_pos, toOOXMLPlacement(nLabelPlacement)); - } - } else { - pFS->startElement(FSNS(XML_cx, XML_dataLabel), XML_idx, OString::number(nIdx)); - } - } else { - pFS->startElement(FSNS(XML_c, XML_dLbl)); - pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, OString::number(nIdx)); - - // As far as i know there can be issues with the Positions, - // if a piechart label use AVOID_OVERLAP placement (== BestFit) - // because LO and MS may calculate the bestFit positions differently. - bool bWritePosition = true; - if (eChartType == chart::TYPEID_PIE) - { - sal_Int32 nLabelPlacement = aParam.meDefault; - xLabelPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement; - if (nLabelPlacement == css::chart::DataLabelPlacement::AVOID_OVERLAP) - bWritePosition = false; - } + pFS->startElement(FSNS(XML_c, XML_dLbl)); + pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, OString::number(nIdx)); - // export custom position of data label - if (bWritePosition) + // As far as i know there can be issues with the Positions, + // if a piechart label use AVOID_OVERLAP placement (== BestFit) + // because LO and MS may calculate the bestFit positions differently. + bool bWritePosition = true; + if (eChartType == chart::TYPEID_PIE) + { + sal_Int32 nLabelPlacement = aParam.meDefault; + xLabelPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement; + if (nLabelPlacement == css::chart::DataLabelPlacement::AVOID_OVERLAP) + bWritePosition = false; + } + + // export custom position of data label + if (bWritePosition) + { + chart2::RelativePosition aCustomLabelPosition; + if( xLabelPropSet->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition ) { - chart2::RelativePosition aCustomLabelPosition; - if( xLabelPropSet->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition ) - { - pFS->startElement(FSNS(XML_c, XML_layout)); - pFS->startElement(FSNS(XML_c, XML_manualLayout)); + pFS->startElement(FSNS(XML_c, XML_layout)); + pFS->startElement(FSNS(XML_c, XML_manualLayout)); - pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(aCustomLabelPosition.Primary)); - pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(aCustomLabelPosition.Secondary)); + pFS->singleElement(FSNS(XML_c, XML_x), XML_val, OString::number(aCustomLabelPosition.Primary)); + pFS->singleElement(FSNS(XML_c, XML_y), XML_val, OString::number(aCustomLabelPosition.Secondary)); - SAL_WARN_IF(aCustomLabelPosition.Anchor != css::drawing::Alignment_TOP_LEFT, "oox", "unsupported anchor position"); + SAL_WARN_IF(aCustomLabelPosition.Anchor != css::drawing::Alignment_TOP_LEFT, "oox", "unsupported anchor position"); - pFS->endElement(FSNS(XML_c, XML_manualLayout)); - pFS->endElement(FSNS(XML_c, XML_layout)); - } + pFS->endElement(FSNS(XML_c, XML_manualLayout)); + pFS->endElement(FSNS(XML_c, XML_layout)); } } // Individual label property that overwrites the baseline. - writeLabelProperties(xLabelPropSet, aParam, nIdx, rDLblsRange, bIsChartex); + writeLabelProperties(xLabelPropSet, aParam, nIdx, rDLblsRange); pFS->endElement(FSNS(XML_c, XML_dLbl)); } // Baseline label properties for all labels. - writeLabelProperties(xPropSet, aParam, -1, rDLblsRange, bIsChartex); + writeLabelProperties(xPropSet, aParam, -1, rDLblsRange); - if (!bIsChartex) { - bool bShowLeaderLines = false; - xPropSet->getPropertyValue(u"ShowCustomLeaderLines"_ustr) >>= bShowLeaderLines; - pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, ToPsz10(bShowLeaderLines)); + bool bShowLeaderLines = false; + xPropSet->getPropertyValue(u"ShowCustomLeaderLines"_ustr) >>= bShowLeaderLines; + pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, ToPsz10(bShowLeaderLines)); - // Export LeaderLine properties - // TODO: import all kind of LeaderLine props (not just LineColor/LineWidth) - if (bShowLeaderLines) - { - pFS->startElement(FSNS(XML_c, XML_leaderLines)); - pFS->startElement(FSNS(XML_c, XML_spPr)); - WriteOutline(xPropSet, getModel()); - pFS->endElement(FSNS(XML_c, XML_spPr)); - pFS->endElement(FSNS(XML_c, XML_leaderLines)); - } - - // Export leader line - if( eChartType != chart::TYPEID_PIE ) - { - pFS->startElement(FSNS(XML_c, XML_extLst)); - pFS->startElement(FSNS(XML_c, XML_ext), XML_uri, "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}", FSNS(XML_xmlns, XML_c15), GetFB()->getNamespaceURL(OOX_NS(c15))); - pFS->singleElement(FSNS(XML_c15, XML_showLeaderLines), XML_val, ToPsz10(bShowLeaderLines)); - pFS->endElement(FSNS(XML_c, XML_ext)); - pFS->endElement(FSNS(XML_c, XML_extLst)); - } + // Export LeaderLine properties + // TODO: import all kind of LeaderLine props (not just LineColor/LineWidth) + if (bShowLeaderLines) + { + pFS->startElement(FSNS(XML_c, XML_leaderLines)); + pFS->startElement(FSNS(XML_c, XML_spPr)); + WriteOutline(xPropSet, getModel()); + pFS->endElement(FSNS(XML_c, XML_spPr)); + pFS->endElement(FSNS(XML_c, XML_leaderLines)); } - if (bIsChartex) { - pFS->endElement(FSNS(XML_cx, XML_dataLabels)); - } else { - pFS->endElement(FSNS(XML_c, XML_dLbls)); + // Export leader line + if( eChartType != chart::TYPEID_PIE ) + { + pFS->startElement(FSNS(XML_c, XML_extLst)); + pFS->startElement(FSNS(XML_c, XML_ext), XML_uri, "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}", FSNS(XML_xmlns, XML_c15), GetFB()->getNamespaceURL(OOX_NS(c15))); + pFS->singleElement(FSNS(XML_c15, XML_showLeaderLines), XML_val, ToPsz10(bShowLeaderLines)); + pFS->endElement(FSNS(XML_c, XML_ext)); + pFS->endElement(FSNS(XML_c, XML_extLst)); } + pFS->endElement(FSNS(XML_c, XML_dLbls)); } void ChartExport::exportDataPoints( @@ -4549,7 +4261,7 @@ void ChartExport::exportDataPoints( default: break; } - exportShapeProps( xPropSet, false ); + exportShapeProps( xPropSet ); pFS->endElement( FSNS( XML_c, XML_dPt ) ); } @@ -4593,7 +4305,7 @@ void ChartExport::exportDataPoints( case chart::TYPEID_HORBAR: case chart::TYPEID_BAR: pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), XML_val, "0"); - exportShapeProps(xPropSet, false); + exportShapeProps(xPropSet); break; case chart::TYPEID_LINE: @@ -4603,7 +4315,7 @@ void ChartExport::exportDataPoints( break; default: - exportShapeProps(xPropSet, false); + exportShapeProps(xPropSet); break; } @@ -4721,7 +4433,7 @@ void ChartExport::exportTrendlines( const Reference< chart2::XDataSeries >& xSer pFS->endElement( FSNS( XML_c, XML_name) ); } - exportShapeProps( xProperties, false ); + exportShapeProps( xProperties ); if( aService == "com.sun.star.chart2.LinearRegressionCurve" ) { @@ -5041,7 +4753,7 @@ void ChartExport::exportErrorBar(const Reference< XPropertySet>& xErrorBarProps, pFS->singleElement(FSNS(XML_c, XML_val), XML_val, OString::number(nVal)); } - exportShapeProps( xErrorBarProps, false ); + exportShapeProps( xErrorBarProps ); pFS->endElement( FSNS( XML_c, XML_errBars) ); } @@ -5135,56 +4847,6 @@ bool ChartExport::isDeep3dChart() return isDeep; } -bool ChartExport::isChartexNotChartNS() const -{ - Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( mxNewDiagram, uno::UNO_QUERY ); - if( ! xBCooSysCnt.is()) return false; - - // chart type - const Sequence< Reference< chart2::XCoordinateSystem > > - aCooSysSeq( xBCooSysCnt->getCoordinateSystems()); - - for( const auto& rCS : aCooSysSeq ) { - Reference< chart2::XChartTypeContainer > xCTCnt( rCS, uno::UNO_QUERY ); - if( ! xCTCnt.is()) - continue; - const Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes()); - for( const auto& rCT : aCTSeq ) { - Reference< chart2::XDataSeriesContainer > xDSCnt( rCT, uno::UNO_QUERY ); - if( ! xDSCnt.is()) - return false; - Reference< chart2::XChartType > xChartType( rCT, uno::UNO_QUERY ); - if( ! xChartType.is()) - continue; - // note: if xDSCnt.is() then also aCTSeq[nCTIdx] - OUString aChartType( xChartType->getChartType()); - sal_Int32 eChartType = lcl_getChartType( aChartType ); - switch( eChartType ) - { - case chart::TYPEID_BAR: - case chart::TYPEID_AREA: - case chart::TYPEID_LINE: - case chart::TYPEID_BUBBLE: - case chart::TYPEID_OFPIE: - case chart::TYPEID_DOUGHNUT: - case chart::TYPEID_PIE: - case chart::TYPEID_RADARLINE: - case chart::TYPEID_RADARAREA: - case chart::TYPEID_SCATTER: - case chart::TYPEID_STOCK: - case chart::TYPEID_SURFACE: - break; - case chart::TYPEID_FUNNEL: - return true; - default: - assert(false); - break; - } - } - } - return false; -} - OUString ChartExport::getNumberFormatCode(sal_Int32 nKey) const { /* XXX if this was called more than one or two times per export the two diff --git a/oox/source/token/namespaces-strict.txt b/oox/source/token/namespaces-strict.txt index a2b5f52e600a..f73e9863cc23 100644 --- a/oox/source/token/namespaces-strict.txt +++ b/oox/source/token/namespaces-strict.txt @@ -48,7 +48,6 @@ ppt http://purl.oclc.org/ooxml/presentationml/main dml http://purl.oclc.org/ooxml/drawingml/main dsp http://schemas.microsoft.com/office/drawing/2008/diagram dmlChart http://purl.oclc.org/ooxml/drawingml/chart -dmlChartex http://purl.oclc.org/ooxml/drawingml/chartex dmlChartDr http://purl.oclc.org/ooxml/drawingml/chartDrawing dmlDiagram http://purl.oclc.org/ooxml/drawingml/diagram dmlLockedCanvas http://purl.oclc.org/ooxml/drawingml/lockedCanvas @@ -98,7 +97,6 @@ xr16 http://schemas.microsoft.com/office/spreadsheetml/2017/r # MSO 2014 extensions --------------------------------------------------------- cx http://schemas.microsoft.com/office/drawing/2014/chartex -a16 http://schemas.microsoft.com/office/drawing/2014/main # extlst namespaces diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt index ce51091c1252..d4ae3bf7ebce 100644 --- a/oox/source/token/namespaces.txt +++ b/oox/source/token/namespaces.txt @@ -48,7 +48,6 @@ ppt http://schemas.openxmlformats.org/presentationml/2006/ma dml http://schemas.openxmlformats.org/drawingml/2006/main dsp http://schemas.microsoft.com/office/drawing/2008/diagram dmlChart http://schemas.openxmlformats.org/drawingml/2006/chart -dmlChartex http://schemas.microsoft.com/office/drawing/2014/chartex dmlChartDr http://schemas.openxmlformats.org/drawingml/2006/chartDrawing dmlDiagram http://schemas.openxmlformats.org/drawingml/2006/diagram dmlLockedCanvas http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas @@ -97,7 +96,6 @@ xr16 http://schemas.microsoft.com/office/spreadsheetml/2017/r # MSO 2014 extensions --------------------------------------------------------- cx http://schemas.microsoft.com/office/drawing/2014/chartex -a16 http://schemas.microsoft.com/office/drawing/2014/main # extlst namespaces diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index c561f1170f32..81644193aee7 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -421,7 +421,6 @@ YearAccessed ZX a a14 -a16 aa above aboveAverage @@ -1456,7 +1455,6 @@ crashSave crazyMaze created createdVersion -creationId creator creaturesButterfly creaturesFish @@ -1598,7 +1596,6 @@ cw cwIn cwOut cx -cx2 cxn cxnId cxnLst @@ -1663,7 +1660,6 @@ dataExtractLoad dataField dataFields dataId -dataLabel dataLabels dataModel dataModelExt @@ -5515,7 +5511,6 @@ txAndTwoObj txBlDir txBody txBox -txData txDef txDir txEffectClrLst
