summaryrefslogtreecommitdiffstats
path: root/chart2
diff options
context:
space:
mode:
authorDennis Francis <dennisfrancis.in@gmail.com>2021-09-02 14:33:55 +0530
committerDennis Francis <dennis.francis@collabora.com>2021-09-07 08:19:22 +0200
commit3798e0a383404606ec27f318e4fe239de2350fe8 (patch)
tree02ad169d2f7708469da2f4ec2b9db2ac1f0436bb /chart2
parentsc: lok: introduce LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR callback (diff)
downloadcore-3798e0a383404606ec27f318e4fe239de2350fe8.tar.gz
core-3798e0a383404606ec27f318e4fe239de2350fe8.zip
[API CHANGE] oox: fix import of chart date categories
Before this fix, date categories imported in oox's DataSourceContext were stored as formatted strings according to number format code in <c:formatCode> under the <c:cat> tree. As a result chart2 could not recognize them as dates. This causes problems like: * The axis that is linked to date categories cannot use the scaling/range-selection(min/max)/increments specs mentioned as axis properties. This results in distorted/unreadable chart renders w.r.t the date axis. * No re-formatting is attempted as per the number format provided for axis. This patch introduces a role qualifer argument to the XDataProvider interface method createDataSequenceByValueArray to support categories of date type via this method. When exporting to oox, write date categories and format code under <c:cat> <c:numRef> <c:numCache> This patch also fixes some discrepancies in date axis interval computation (auto mode) found by already existing unit tests. Conflicts: chart2/qa/extras/chart2export2.cxx chart2/source/inc/InternalDataProvider.hxx chart2/source/tools/InternalDataProvider.cxx Change-Id: Ibc53b0a56fdddba80ba452d5567ce98d80460ea7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121525 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> (cherry picked from commit f547cf17a179ebd7de5c2b4dd2d00d0027a25429) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121723 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2dump/chart2dump.cxx1
-rw-r--r--chart2/qa/extras/chart2dump/data/date-categories.pptxbin0 -> 41931 bytes
-rw-r--r--chart2/qa/extras/chart2dump/reference/axislabeltest/date-categories.txt180
-rw-r--r--chart2/qa/extras/chart2export.cxx40
-rw-r--r--chart2/qa/extras/chart2import.cxx46
-rw-r--r--chart2/qa/extras/charttest.hxx37
-rw-r--r--chart2/source/inc/InternalDataProvider.hxx6
-rw-r--r--chart2/source/tools/InternalDataProvider.cxx20
-rw-r--r--chart2/source/view/axes/ScaleAutomatism.cxx4
-rw-r--r--chart2/source/view/axes/VCoordinateSystem.cxx6
-rw-r--r--chart2/source/view/charttypes/AreaChart.cxx4
11 files changed, 308 insertions, 36 deletions
diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx
index 6ac2a0e21a49..89d47d77d884 100644
--- a/chart2/qa/extras/chart2dump/chart2dump.cxx
+++ b/chart2/qa/extras/chart2dump/chart2dump.cxx
@@ -615,6 +615,7 @@ DECLARE_DUMP_TEST(AxisLabelTest, Chart2DumpTest, false)
"formated_axis_labels.odp",
"percent_stacked_column_chart.odp",
"tdf118150.xlsx",
+ "date-categories.pptx",
};
for (const OUString& sTestFile : aTestFiles)
diff --git a/chart2/qa/extras/chart2dump/data/date-categories.pptx b/chart2/qa/extras/chart2dump/data/date-categories.pptx
new file mode 100644
index 000000000000..b9e0c69f32b7
--- /dev/null
+++ b/chart2/qa/extras/chart2dump/data/date-categories.pptx
Binary files differ
diff --git a/chart2/qa/extras/chart2dump/reference/axislabeltest/date-categories.txt b/chart2/qa/extras/chart2dump/reference/axislabeltest/date-categories.txt
new file mode 100644
index 000000000000..a9274fd7838a
--- /dev/null
+++ b/chart2/qa/extras/chart2dump/reference/axislabeltest/date-categories.txt
@@ -0,0 +1,180 @@
+/// CID/D=0:CS=0:Axis=0,0
+// nAxisLabelsCount
+22
+// xLabel->getString()
+15/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+17/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+19/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+21/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+23/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+25/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+27/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+29/Jun/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+1/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+3/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+5/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+7/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+9/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+11/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+13/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+15/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+17/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+19/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+21/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+23/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+25/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+27/Jul/21
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+/// CID/D=0:CS=0:Axis=1,0
+// nAxisLabelsCount
+7
+// xLabel->getString()
+0
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+20
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+40
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+60
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+80
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+100
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
+// xLabel->getString()
+120
+// static_cast<sal_Int32>(aLabelFontColor)
+5855577
+// fLabelFontHeight
+9
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 67d1b7dcb83c..d80e8fc6ae0d 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -186,6 +186,7 @@ public:
void testTdf138181();
void testCustomShapeText();
void testTdf143942();
+ void testDateCategoriesPPTX();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(testErrorBarXLSX);
@@ -334,6 +335,7 @@ public:
CPPUNIT_TEST(testTdf138181);
CPPUNIT_TEST(testCustomShapeText);
CPPUNIT_TEST(testTdf143942);
+ CPPUNIT_TEST(testDateCategoriesPPTX);
CPPUNIT_TEST_SUITE_END();
@@ -3140,6 +3142,44 @@ void Chart2ExportTest::testTdf143942()
}
}
+void Chart2ExportTest::testDateCategoriesPPTX()
+{
+ load("/chart2/qa/extras/data/pptx/", "bnc889755.pptx");
+ xmlDocUniquePtr pXmlDoc = parseExport("ppt/charts/chart", "Impress Office Open XML");
+ CPPUNIT_ASSERT(pXmlDoc);
+
+ constexpr size_t nCats = 16;
+ double aDates[nCats] = {
+ 41183, 41214, 41244, 41275, 41306, 41334, 41365, 41395,
+ 41426, 41456, 41487, 41518, 41548, 41579, 41609, 41640,
+ };
+
+ assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat");
+ assertXPathContent(pXmlDoc,
+ "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:numRef/"
+ "c:numCache/c:formatCode",
+ "mmm\\-yy");
+ assertXPath(
+ pXmlDoc,
+ "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:numRef/c:numCache/c:ptCount",
+ "val", OUString::number(nCats));
+
+ for (size_t i = 0; i < nCats; ++i)
+ {
+ assertXPath(
+ pXmlDoc,
+ "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:numRef/c:numCache/c:pt["
+ + OString::number(i + 1) + "]",
+ "idx", OUString::number(i));
+ assertXPathContent(
+ pXmlDoc,
+ "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:cat/c:numRef/c:numCache/c:pt["
+ + OString::number(i + 1) + "]/c:v",
+ OUString::number(aDates[i]));
+ }
+}
+
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 4b7d2fadb88b..5272e55aab93 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -29,7 +29,9 @@
#include <com/sun/star/chart2/Symbol.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
#include <com/sun/star/chart/DataLabelPlacement.hpp>
+#include <com/sun/star/chart/XDateCategories.hpp>
#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/util/NumberFormatter.hpp>
#include <iterator>
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
@@ -824,26 +826,20 @@ void Chart2ImportTest::testBnc889755()
uno::Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 5), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
- uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
- uno::Reference< chart::XChartDataArray > xChartDataArray(xDataProvider, uno::UNO_QUERY_THROW);
- uno::Sequence< OUString > aRowLabels = xChartDataArray->getRowDescriptions();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aRowLabels.getLength());
- CPPUNIT_ASSERT_EQUAL(OUString("Oct-12"), aRowLabels[0]);
- CPPUNIT_ASSERT_EQUAL(OUString("Nov-12"), aRowLabels[1]);
- CPPUNIT_ASSERT_EQUAL(OUString("Dec-12"), aRowLabels[2]);
- CPPUNIT_ASSERT_EQUAL(OUString("Jan-13"), aRowLabels[3]);
- CPPUNIT_ASSERT_EQUAL(OUString("Feb-13"), aRowLabels[4]);
- CPPUNIT_ASSERT_EQUAL(OUString("Mar-13"), aRowLabels[5]);
- CPPUNIT_ASSERT_EQUAL(OUString("Apr-13"), aRowLabels[6]);
- CPPUNIT_ASSERT_EQUAL(OUString("May-13"), aRowLabels[7]);
- CPPUNIT_ASSERT_EQUAL(OUString("Jun-13"), aRowLabels[8]);
- CPPUNIT_ASSERT_EQUAL(OUString("Jul-13"), aRowLabels[9]);
- CPPUNIT_ASSERT_EQUAL(OUString("Aug-13"), aRowLabels[10]);
- CPPUNIT_ASSERT_EQUAL(OUString("Sep-13"), aRowLabels[11]);
- CPPUNIT_ASSERT_EQUAL(OUString("Oct-13"), aRowLabels[12]);
- CPPUNIT_ASSERT_EQUAL(OUString("Nov-13"), aRowLabels[13]);
- CPPUNIT_ASSERT_EQUAL(OUString("Dec-13"), aRowLabels[14]);
- CPPUNIT_ASSERT_EQUAL(OUString("Jan-14"), aRowLabels[15]);
+ constexpr sal_Int32 nNumCategories = 16;
+ Sequence<OUString> aDateSeq = getFormattedDateCategories(xChartDoc);
+
+ CPPUNIT_ASSERT_EQUAL(nNumCategories, aDateSeq.getLength());
+
+ const OUString aExpectedDateCategories[nNumCategories] = {
+ "Oct-12", "Nov-12", "Dec-12", "Jan-13",
+ "Feb-13", "Mar-13", "Apr-13", "May-13",
+ "Jun-13", "Jul-13", "Aug-13", "Sep-13",
+ "Oct-13", "Nov-13", "Dec-13", "Jan-14",
+ };
+
+ for (size_t nIdx = 0; nIdx < nNumCategories; ++nIdx)
+ CPPUNIT_ASSERT_EQUAL(aExpectedDateCategories[nIdx], aDateSeq[nIdx]);
//tdf#139940 - the title's gradient was lost and was filled with solid blue, instead of a "blue underline".
uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
@@ -1774,7 +1770,7 @@ void Chart2ImportTest::testInternalDataProvider() {
const uno::Reference< chart2::data::XDataProvider >& rxDataProvider = xChartDoc->getDataProvider();
// Parse 42 array
- Reference<chart2::data::XDataSequence> xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;42;42;42}");
+ Reference<chart2::data::XDataSequence> xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;42;42;42}", "");
Sequence<Any> xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
@@ -1782,7 +1778,7 @@ void Chart2ImportTest::testInternalDataProvider() {
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
// Parse empty first and last
- xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}");
+ xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{\"\";42;42;\"\"}", "");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[0].getValue())));
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[1]);
@@ -1790,7 +1786,7 @@ void Chart2ImportTest::testInternalDataProvider() {
CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[3].getValue())));
// Parse empty middle
- xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}");
+ xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"\";\"\";42}", "");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT( std::isnan( *static_cast<const double*>(xSequence[1].getValue())) );
@@ -1798,7 +1794,7 @@ void Chart2ImportTest::testInternalDataProvider() {
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[3]);
// Parse mixed types, numeric only role
- xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}");
+ xDataSeq = rxDataProvider->createDataSequenceByValueArray("values-y", "{42;\"hello\";0;\"world\"}", "");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(42)), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[1]);
@@ -1806,7 +1802,7 @@ void Chart2ImportTest::testInternalDataProvider() {
CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xSequence[3]);
// Parse mixed types, mixed role
- xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}");
+ xDataSeq = rxDataProvider->createDataSequenceByValueArray("categories", "{42;\"hello\";0;\"world\"}", "");
xSequence = xDataSeq->getData();
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 1 42")), xSequence[0]);
CPPUNIT_ASSERT_EQUAL(uno::Any(OUString("Row 2 hello")), xSequence[1]);
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 5257fb0acdc4..22908f19ad5b 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -32,6 +32,7 @@
#include <rtl/math.hxx>
#include <svx/charthelper.hxx>
+#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
@@ -43,12 +44,15 @@
#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
#include <com/sun/star/chart2/data/XDataSource.hpp>
#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart2/XInternalDataProvider.hpp>
+#include <com/sun/star/chart/XDateCategories.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/NumberFormatter.hpp>
#include <unonames.hxx>
@@ -82,6 +86,7 @@ public:
uno::Reference<chart::XChartDocument> getChartDocFromDrawImpress( sal_Int32 nPage, sal_Int32 nShape );
uno::Reference<chart::XChartDocument> getChartDocFromWriter( sal_Int32 nShape );
+ Sequence< OUString > getFormattedDateCategories( const Reference<chart2::XChartDocument>& xChartDoc );
awt::Size getPageSize( const Reference< chart2::XChartDocument > & xChartDoc );
awt::Size getSize(css::uno::Reference<chart2::XDiagram> xDiagram, const awt::Size& rPageSize);
@@ -593,6 +598,38 @@ sal_Int16 getNumberFormatType( const Reference<chart2::XChartDocument>& xChartDo
return nType;
}
+Sequence< double > getDateCategories(const Reference<chart2::XChartDocument>& xChartDoc)
+{
+ CPPUNIT_ASSERT(xChartDoc->hasInternalDataProvider());
+ uno::Reference< chart2::XInternalDataProvider > xDataProvider( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW );
+ uno::Reference< chart::XDateCategories > xDateCategories( xDataProvider, uno::UNO_QUERY_THROW );
+ CPPUNIT_ASSERT(xDateCategories.is());
+ return xDateCategories->getDateCategories();
+}
+
+Sequence< OUString > ChartTest::getFormattedDateCategories( const Reference<chart2::XChartDocument>& xChartDoc )
+{
+ Reference<util::XNumberFormatsSupplier> xNFS(xChartDoc, uno::UNO_QUERY_THROW);
+ Reference< util::XNumberFormatter > xNumFormatter(
+ util::NumberFormatter::create(comphelper::getComponentContext(m_xSFactory)), uno::UNO_QUERY_THROW );
+ xNumFormatter->attachNumberFormatsSupplier(xNFS);
+
+ Reference<chart2::XAxis> xAxisX = getAxisFromDoc(xChartDoc, 0, 0, 0);
+ chart2::ScaleData aScaleData = xAxisX->getScaleData();
+ CPPUNIT_ASSERT_EQUAL(chart2::AxisType::DATE, aScaleData.AxisType);
+
+ sal_Int32 nNumFmt = getNumberFormatFromAxis(xAxisX);
+
+ Sequence<double> aDateSeq = getDateCategories(xChartDoc);
+ const sal_Int32 nNumCategories = aDateSeq.getLength();
+ Sequence<OUString> aFormattedDates(nNumCategories);
+
+ for (sal_Int32 nIdx = 0; nIdx < nNumCategories; ++nIdx)
+ aFormattedDates[nIdx] = xNumFormatter->convertNumberToString(nNumFmt, aDateSeq[nIdx]);
+
+ return aFormattedDates;
+}
+
awt::Size ChartTest::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc )
{
awt::Size aSize( 0, 0 );
diff --git a/chart2/source/inc/InternalDataProvider.hxx b/chart2/source/inc/InternalDataProvider.hxx
index 7e3291f2f582..e5bfb553dc34 100644
--- a/chart2/source/inc/InternalDataProvider.hxx
+++ b/chart2/source/inc/InternalDataProvider.hxx
@@ -112,7 +112,8 @@ public:
const OUString& aRangeRepresentation ) override;
virtual css::uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
- createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation ) override;
+ createDataSequenceByValueArray( const OUString& aRole, const OUString& aRangeRepresentation,
+ const OUString& aRoleQualifier ) override;
virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override;
@@ -183,7 +184,8 @@ private:
createDataSequenceAndAddToMap( const OUString & rRangeRepresentation );
css::uno::Reference<css::chart2::data::XDataSequence>
- createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole );
+ createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole,
+ const OUString& rRoleQualifier );
void deleteMapReferences( const OUString & rRangeRepresentation );
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx
index 415f08ac3ea9..d6b02814ab78 100644
--- a/chart2/source/tools/InternalDataProvider.cxx
+++ b/chart2/source/tools/InternalDataProvider.cxx
@@ -486,7 +486,7 @@ void InternalDataProvider::decreaseMapReferences(
Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenceAndAddToMap(
const OUString & rRangeRepresentation )
{
- Reference<chart2::data::XDataSequence> xSeq = createDataSequenceFromArray(rRangeRepresentation, OUString());
+ Reference<chart2::data::XDataSequence> xSeq = createDataSequenceFromArray(rRangeRepresentation, OUString(), OUString());
if (xSeq.is())
return xSeq;
@@ -496,7 +496,7 @@ Reference< chart2::data::XDataSequence > InternalDataProvider::createDataSequenc
}
uno::Reference<chart2::data::XDataSequence>
-InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole )
+InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, const OUString& rRole, const OUString& rRoleQualifier )
{
if (rArrayStr.indexOf('{') != 0 || rArrayStr[rArrayStr.getLength()-1] != '}')
{
@@ -623,9 +623,19 @@ InternalDataProvider::createDataSequenceFromArray( const OUString& rArrayStr, co
{
// Category labels.
+ // Store date categories as numbers.
+ bool bStoreNumeric = rRoleQualifier == "date";
+ double fValue;
for (size_t i = 0; i < aRawElems.size(); ++i)
{
- std::vector<uno::Any> aLabels(1, uno::Any(aRawElems[i]));
+ if (bStoreNumeric)
+ {
+ bool bGetDouble = bAllNumeric && !aRawElems[i].isEmpty();
+ fValue = bGetDouble ? aRawElems[i].toDouble() :
+ std::numeric_limits<double>::quiet_NaN();
+ }
+ std::vector<uno::Any> aLabels(1,
+ bStoreNumeric ? uno::Any(fValue) : uno::Any(aRawElems[i]));
m_aInternalData.setComplexRowLabel(i, aLabels);
}
@@ -834,9 +844,9 @@ Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDa
Reference<chart2::data::XDataSequence> SAL_CALL
InternalDataProvider::createDataSequenceByValueArray(
- const OUString& aRole, const OUString& aRangeRepresentation )
+ const OUString& aRole, const OUString& aRangeRepresentation, const OUString& aRoleQualifier )
{
- return createDataSequenceFromArray(aRangeRepresentation, aRole);
+ return createDataSequenceFromArray(aRangeRepresentation, aRole, aRoleQualifier);
}
Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelection()
diff --git a/chart2/source/view/axes/ScaleAutomatism.cxx b/chart2/source/view/axes/ScaleAutomatism.cxx
index 7557f9b3d95b..8b7c94b6f60e 100644
--- a/chart2/source/view/axes/ScaleAutomatism.cxx
+++ b/chart2/source/view/axes/ScaleAutomatism.cxx
@@ -656,7 +656,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis(
nDaysPerInterval = 1.0;
}
- nNumer = static_cast<sal_Int32>( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) );
+ nNumer = static_cast<sal_Int32>( rtl::math::approxFloor( nIntervalDays/nDaysPerInterval ) );
if(nNumer<=0)
nNumer=1;
if( rExplicitIncrement.MajorTimeInterval.TimeUnit == DAY )
@@ -667,7 +667,7 @@ void ScaleAutomatism::calculateExplicitIncrementAndScaleForDateTimeAxis(
{
rExplicitIncrement.MajorTimeInterval.TimeUnit = MONTH;
nDaysPerInterval = 31.0;
- nNumer = static_cast<sal_Int32>( rtl::math::approxCeil( nIntervalDays/nDaysPerInterval ) );
+ nNumer = static_cast<sal_Int32>( rtl::math::approxFloor( nIntervalDays/nDaysPerInterval ) );
if(nNumer<=0)
nNumer=1;
}
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx b/chart2/source/view/axes/VCoordinateSystem.cxx
index 1c900b392233..b8d916c375d9 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -342,7 +342,8 @@ void VCoordinateSystem::updateScalesAndIncrementsOnAxes()
void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAutomatism, sal_Int32 nDimIndex, sal_Int32 nAxisIndex )
{
- if( rScaleAutomatism.getScale().AxisType==AxisType::DATE && nDimIndex==0 )
+ bool bDateAxisX = (rScaleAutomatism.getScale().AxisType == AxisType::DATE) && (nDimIndex == 0);
+ if( bDateAxisX )
{
// This is a date X dimension. Determine proper time resolution.
sal_Int32 nTimeResolution = css::chart::TimeUnit::MONTH;
@@ -387,6 +388,9 @@ void VCoordinateSystem::prepareAutomaticAxisScaling( ScaleAutomatism& rScaleAuto
m_aMergedMinMaxSupplier.isExpandWideValuesToZero( nDimIndex ),
m_aMergedMinMaxSupplier.isExpandNarrowValuesTowardZero( nDimIndex ) );
+ if (bDateAxisX)
+ return;
+
VAxisBase* pVAxis = getVAxis(nDimIndex, nAxisIndex);
if( pVAxis )
rScaleAutomatism.setMaximumAutoMainIncrementCount( pVAxis->estimateMaximumAutoMainIncrementCount() );
diff --git a/chart2/source/view/charttypes/AreaChart.cxx b/chart2/source/view/charttypes/AreaChart.cxx
index a658a26d04a6..09e6bb504b7e 100644
--- a/chart2/source/view/charttypes/AreaChart.cxx
+++ b/chart2/source/view/charttypes/AreaChart.cxx
@@ -694,6 +694,8 @@ void AreaChart::createShapes()
uno::Reference< drawing::XShapes > xSeriesGroupShape_Shapes = getSeriesGroupShapeFrontChild(pSeries.get(), m_xSeriesTarget);
sal_Int32 nAttachedAxisIndex = pSeries->getAttachedAxisIndex();
+ double fXMin, fXMax;
+ pSeries->getMinMaxXValue(fXMin, fXMax);
PlottingPositionHelper& rPosHelper = getPlottingPositionHelper(nAttachedAxisIndex);
m_pPosHelper = &rPosHelper;
@@ -714,7 +716,7 @@ void AreaChart::createShapes()
double fLogicX = pSeries->getXValue(nIndex);
if (bDateCategory)
{
- if (std::isnan(fLogicX))
+ if (std::isnan(fLogicX) || (fLogicX < fXMin || fLogicX > fXMax))
continue;
fLogicX = DateHelper::RasterizeDateValue( fLogicX, m_aNullDate, m_nTimeResolution );