chart2/Library_chart2.mk | 1 chart2/inc/strings.hrc | 1 chart2/source/view/charttypes/UnsupportedChart.cxx | 117 +++++++++++++++++++++ chart2/source/view/charttypes/UnsupportedChart.hxx | 47 ++++++++ chart2/source/view/charttypes/VSeriesPlotter.cxx | 5 5 files changed, 170 insertions(+), 1 deletion(-)
New commits: commit ef9c1d57ad2ef381df9464fd6b295f20eb5a83a1 Author: Kurt Nordback <[email protected]> AuthorDate: Mon Jan 12 08:48:47 2026 -0700 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Thu Feb 12 16:11:54 2026 +0100 tdf#165742 Step 5.4: Add 'unsupported chart type' message Add clearer handling for chartex types whose rendering is not currently supported. Previously, unsupported types defaulted to being rendered as line charts, which could lead to confusion. With this commit, we instead display a message stating that the chart type is not supported, and do not attempt to render it. Note that at this time, the message is hard-coded only in English language text. In the short term it should be internationalised, though in the longer term, the intent is that all chart types will be properly rendered. Change-Id: I66eecb3368abaf228d80c21ab664a1eb2b45ae32 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197128 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/chart2/Library_chart2.mk b/chart2/Library_chart2.mk index 3cf268eeb9cb..b8d7057cdcf9 100644 --- a/chart2/Library_chart2.mk +++ b/chart2/Library_chart2.mk @@ -254,6 +254,7 @@ $(eval $(call gb_Library_add_exception_objects,chart2,\ chart2/source/view/charttypes/CategoryPositionHelper \ chart2/source/view/charttypes/NetChart \ chart2/source/view/charttypes/PieChart \ + chart2/source/view/charttypes/UnsupportedChart \ chart2/source/view/charttypes/Splines \ chart2/source/view/charttypes/VSeriesPlotter \ chart2/source/view/diagram/VDiagram \ diff --git a/chart2/inc/strings.hrc b/chart2/inc/strings.hrc index ac6afc884474..67a294527815 100644 --- a/chart2/inc/strings.hrc +++ b/chart2/inc/strings.hrc @@ -175,6 +175,7 @@ #define STR_MIN_GREATER_MAX NC_("STR_MIN_GREATER_MAX", "The minimum must be lower than the maximum. Check your input.") #define STR_INVALID_INTERVALS NC_("STR_INVALID_INTERVALS", "The major interval needs to be greater than the minor interval. Check your input.") #define STR_INVALID_TIME_UNIT NC_("STR_INVALID_TIME_UNIT", "The major and minor interval need to be greater or equal to the resolution. Check your input.") +#define STR_UNSUPPORTED_CHART_TYPE NC_("STR_UNSUPPORTED_CHART_TYPE", "One or more chart types are unsupported in this version of LibreOffice") #endif diff --git a/chart2/source/view/charttypes/UnsupportedChart.cxx b/chart2/source/view/charttypes/UnsupportedChart.cxx new file mode 100644 index 000000000000..69d4062ccb08 --- /dev/null +++ b/chart2/source/view/charttypes/UnsupportedChart.cxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <ResId.hxx> +#include <strings.hrc> + +#include "UnsupportedChart.hxx" +#include <PlottingPositionHelper.hxx> +#include <ShapeFactory.hxx> +#include <ObjectIdentifier.hxx> +#include <LabelPositionHelper.hxx> +#include <ChartType.hxx> +#include <PropertyMapper.hxx> +#include <CommonConverters.hxx> + +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> + +#include <com/sun/star/chart/DataLabelPlacement.hpp> +#include <sal/log.hxx> +#include <osl/diagnose.h> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/chart2/XFormattedString.hpp> +#include <com/sun/star/chart2/FormattedString.hpp> + +#include <limits> + +namespace chart +{ +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; + +UnsupportedChart::UnsupportedChart(const rtl::Reference<ChartType>& xChartTypeModel) + : VSeriesPlotter(xChartTypeModel, 2, false) +{ + if (!m_pMainPosHelper) + m_pMainPosHelper = new PlottingPositionHelper(); + PlotterBase::m_pPosHelper = m_pMainPosHelper; +} + +UnsupportedChart::~UnsupportedChart() { delete m_pMainPosHelper; } + +bool UnsupportedChart::isExpandIfValuesCloseToBorder(sal_Int32 /*nDimensionIndex*/) { return true; } + +bool UnsupportedChart::isSeparateStackingForDifferentSigns(sal_Int32 /*nDimensionIndex*/) +{ + return false; +} + +LegendSymbolStyle UnsupportedChart::getLegendSymbolStyle() { return LegendSymbolStyle::Circle; } + +drawing::Direction3D UnsupportedChart::getPreferredDiagramAspectRatio() const +{ + return drawing::Direction3D(-1, -1, -1); +} + +void UnsupportedChart::createShapes() +{ + rtl::Reference<SvxShapeGroup> xSeriesTarget = ShapeFactory::createGroup2D(m_xFinalTarget); + + tNameSequence aPropNames; + tAnySequence aPropValues; + + tPropertyNameValueMap aTextValueMap; + aTextValueMap[u"CharHeight"_ustr] <<= 10.0f; + aTextValueMap[u"CharHeightAsian"_ustr] <<= 10.0f; + aTextValueMap[u"CharHeightComplex"_ustr] <<= 10.0f; + aTextValueMap[u"FillColor"_ustr] <<= sal_Int32(0xFFFFFF); + aTextValueMap[u"FillStyle"_ustr] <<= drawing::FillStyle_SOLID; + aTextValueMap[u"LineColor"_ustr] <<= sal_Int32(0xFFFFFF); + aTextValueMap[u"LineStyle"_ustr] <<= drawing::LineStyle_SOLID; + aTextValueMap[u"ParaAdjust"_ustr] <<= style::ParagraphAdjust_CENTER; + aTextValueMap[u"TextHorizontalAdjust"_ustr] <<= drawing::TextHorizontalAdjust_CENTER; + aTextValueMap[u"TextVerticalAdjust"_ustr] <<= drawing::TextVerticalAdjust_CENTER; + aTextValueMap[u"ParaLeftMargin"_ustr] <<= sal_Int32(0); + aTextValueMap[u"ParaRightMargin"_ustr] <<= sal_Int32(0); + aTextValueMap[u"TextMaximumFrameWidth"_ustr] <<= sal_Int32(2 * m_aPageReferenceSize.Width / 3); + aTextValueMap[u"TextAutoGrowHeight"_ustr] <<= true; + aTextValueMap[u"TextAutoGrowWidth"_ustr] <<= true; + + PropertyMapper::getMultiPropertyListsFromValueMap(aPropNames, aPropValues, aTextValueMap); + + ::basegfx::B2DHomMatrix aM; + aM.translate(m_aPageReferenceSize.Width / 2, m_aPageReferenceSize.Height / 2); + + rtl::Reference<SvxShapeText> xTextShape + = ShapeFactory::createText(xSeriesTarget, SchResId(STR_UNSUPPORTED_CHART_TYPE), aPropNames, + aPropValues, uno::Any(B2DHomMatrixToHomogenMatrix3(aM))); +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/charttypes/UnsupportedChart.hxx b/chart2/source/view/charttypes/UnsupportedChart.hxx new file mode 100644 index 000000000000..1832f7e52af6 --- /dev/null +++ b/chart2/source/view/charttypes/UnsupportedChart.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <VSeriesPlotter.hxx> +#include <com/sun/star/drawing/Direction3D.hpp> + +namespace chart +{ +class UnsupportedChart : public VSeriesPlotter +{ + // public methods +public: + UnsupportedChart() = delete; + + UnsupportedChart(const rtl::Reference<::chart::ChartType>& xChartTypeModel); + virtual ~UnsupportedChart() override; + + virtual void createShapes() override; + + virtual css::drawing::Direction3D getPreferredDiagramAspectRatio() const override; + + // MinimumAndMaximumSupplier + virtual bool isExpandIfValuesCloseToBorder(sal_Int32 nDimensionIndex) override; + virtual bool isSeparateStackingForDifferentSigns(sal_Int32 nDimensionIndex) override; + + virtual LegendSymbolStyle getLegendSymbolStyle() override; +}; +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index 70b7ab465136..3d9d61080258 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -58,6 +58,7 @@ #include "CandleStickChart.hxx" #include "BubbleChart.hxx" #include "NetChart.hxx" +#include "UnsupportedChart.hxx" #include <unonames.hxx> #include <SpecialCharacters.hxx> @@ -2896,8 +2897,10 @@ VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( pRet = new NetChart(xChartTypeModel,nDimensionCount,false,std::make_unique<PolarPlottingPositionHelper>()); else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) pRet = new CandleStickChart(xChartTypeModel,nDimensionCount); - else + else if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_AREA) ) pRet = new AreaChart(xChartTypeModel,nDimensionCount,false,true); + else + pRet = new UnsupportedChart(xChartTypeModel); return pRet; }
