Rebased ref, commits from common ancestor:
commit 3990b0d4510db471ad29cfe4d60ba09513455cbf
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 6 16:04:47 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Mon May 9 14:17:11 2022 +0900
chart2: add initial code for rendering the Data Table
Change-Id: I07d282c0b5e8df6b843516c8bdad538862d6575e
diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk
index 2f1a1a9587f8..3d3806e14c27 100644
--- a/chart2/Library_chartcore.mk
+++ b/chart2/Library_chartcore.mk
@@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\
chart2/source/view/main/ChartView \
chart2/source/view/main/Clipping \
chart2/source/view/main/DataPointSymbolSupplier \
+ chart2/source/view/main/DataTableView \
chart2/source/view/main/DrawModelWrapper \
chart2/source/view/main/ExplicitValueProvider \
chart2/source/view/main/LabelPositionHelper \
diff --git a/chart2/source/view/axes/VAxisBase.cxx
b/chart2/source/view/axes/VAxisBase.cxx
index ace362a9b964..95125beed1cf 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -22,6 +22,7 @@
#include <ExplicitCategoriesProvider.hxx>
#include "Tickmarks.hxx"
#include <Axis.hxx>
+#include <VSeriesPlotter.hxx>
#include <com/sun/star/chart2/AxisType.hpp>
#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
@@ -183,8 +184,10 @@ bool VAxisBase::prepareShapeCreation()
//create named group shape
m_xGroupShape_Shapes = createGroupShape( m_xLogicTarget, m_nDimension==2 ?
m_aCID : "");
- if( m_aAxisProperties.m_bDisplayLabels )
+ if (m_aAxisProperties.m_bDisplayLabels)
m_xTextTarget = ShapeFactory::createGroup2D( m_xFinalTarget, m_aCID );
+ if (m_aAxisProperties.m_bDisplayDataTable)
+ m_xDataTableTarget = ShapeFactory::createGroup2D(m_xFinalTarget,
m_aCID);
return true;
}
@@ -239,6 +242,11 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter&
rIter )
}
}
+void
VAxisBase::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/,
+
uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/)
+{
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/axes/VAxisBase.hxx
b/chart2/source/view/axes/VAxisBase.hxx
index 31badb749c9d..4da1936a452b 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -27,6 +27,9 @@ namespace com::sun::star::util { class
XNumberFormatsSupplier; }
namespace chart
{
+class VSeriesPlotter;
+class DataTableView;
+
class VAxisBase : public VAxisOrGridBase
{
public:
@@ -59,6 +62,11 @@ public:
void setExtraLinePositionAtOtherAxis( double fCrossingAt );
+ virtual void
createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
css::uno::Reference<css::util::XNumberFormatsSupplier> const&
xNumberFormatsSupplier);
+
+ std::shared_ptr<DataTableView> getDataTableView() { return
m_pDataTableView; }
+
protected: //methods
static size_t getIndexOfLongestLabel( const css::uno::Sequence<OUString>&
rLabels );
void removeTextShapesFromTicks();
@@ -79,6 +87,9 @@ protected: //member
rtl::Reference< SvxShapeGroupAnyD > m_xGroupShape_Shapes;
rtl::Reference< SvxShapeGroupAnyD > m_xTextTarget;
+ rtl::Reference< SvxShapeGroupAnyD > m_xDataTableTarget;
+
+ std::shared_ptr<DataTableView> m_pDataTableView;
/**
* This typically consists of 2 TickInfo vectors (i.e. the outer vector
diff --git a/chart2/source/view/axes/VAxisProperties.cxx
b/chart2/source/view/axes/VAxisProperties.cxx
index f8f177936e1d..8bbcb490fa2a 100644
--- a/chart2/source/view/axes/VAxisProperties.cxx
+++ b/chart2/source/view/axes/VAxisProperties.cxx
@@ -163,6 +163,7 @@ AxisProperties::AxisProperties( const rtl::Reference< Axis
>& xAxisModel
, m_eTickmarkPos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS )
, m_bCrossingAxisHasReverseDirection(false)
, m_bCrossingAxisIsCategoryAxes(false)
+ , m_bDisplayDataTable(false)
, m_bDisplayLabels( true )
, m_bTryStaggeringFirst( false )
, m_nNumberFormatKey(0)
@@ -253,6 +254,9 @@ void AxisProperties::init( bool bCartesian )
if( bCartesian )
{
+ if (m_nDimensionIndex == 0)
+ m_bDisplayDataTable = true;
+
if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY
&& m_pExplicitCategoriesProvider &&
m_pExplicitCategoriesProvider->hasComplexCategories() )
m_bComplexCategories = true;
diff --git a/chart2/source/view/axes/VAxisProperties.hxx
b/chart2/source/view/axes/VAxisProperties.hxx
index 4370ccbb6e65..78dbb7e3718d 100644
--- a/chart2/source/view/axes/VAxisProperties.hxx
+++ b/chart2/source/view/axes/VAxisProperties.hxx
@@ -110,7 +110,8 @@ struct AxisProperties final
AxisLabelAlignment maLabelAlignment;
- bool m_bDisplayLabels;
+ bool m_bDisplayDataTable;
+ bool m_bDisplayLabels;
// Compatibility option: starting from LibreOffice 5.1 the rotated
// layout is preferred to staggering for axis labels.
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx
b/chart2/source/view/axes/VCartesianAxis.cxx
index 95a86fe377c2..4cae0cee958d 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -34,6 +34,8 @@
#include <tools/color.hxx>
#include <svx/unoshape.hxx>
#include <svx/unoshtxt.hxx>
+#include <VSeriesPlotter.hxx>
+#include <DataTableView.hxx>
#include <comphelper/scopeguard.hxx>
@@ -1665,11 +1667,35 @@ void VCartesianAxis::createLabels()
if( !prepareShapeCreation() )
return;
+ std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); //
throws on failure
+
+ if (m_pDataTableView && m_aAxisProperties.m_bDisplayDataTable)
+ {
+ m_pDataTableView->initializeShapes(m_xDataTableTarget);
+ basegfx::B2DVector aStart = apTickFactory2D->getXaxisStartPos();
+ basegfx::B2DVector aEnd = apTickFactory2D->getXaxisEndPos();
+
+ apTickFactory2D->updateScreenValues(m_aAllTickInfos);
+
+ sal_Int32 nDistance = -1;
+
+ std::unique_ptr<TickIter> apTickIter(createLabelTickIterator(0));
+ if (apTickIter)
+ {
+ nDistance = TickFactory2D::getTickScreenDistance(*apTickIter);
+ if (getTextLevelCount() > 1)
+ nDistance *= 2;
+ }
+
+ if (nDistance > 0)
+ m_pDataTableView->createShapes(aStart, aEnd, nDistance);
+ return;
+ }
+
//create labels
if (!m_aAxisProperties.m_bDisplayLabels)
return;
- std::unique_ptr<TickFactory2D> apTickFactory2D(createTickFactory2D()); //
throws on failure
TickFactory2D* pTickFactory2D = apTickFactory2D.get();
//get the transformed screen values for all tickmarks in aAllTickInfos
@@ -1965,6 +1991,18 @@ void VCartesianAxis::createShapes()
createLabels();
}
+void
VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier)
+{
+ if (m_aAxisProperties.m_bDisplayDataTable)
+ {
+ m_pDataTableView.reset(new DataTableView);
+ m_pDataTableView->initializeValues(rSeriesPlotterList);
+ m_xNumberFormatsSupplier = xNumberFormatsSupplier;
+ }
+}
+
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx
b/chart2/source/view/axes/VCartesianAxis.hxx
index 94e9b2ab967a..9f396fef43b8 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -99,6 +99,8 @@ public:
::basegfx::B2DVector aScreenPos;
};
+ void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList,
+
css::uno::Reference<css::util::XNumberFormatsSupplier> const&
xNumberFormatsSupplier) override;
private: //methods
/**
* Go through all tick label positions and decide which labels to display
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index 1257ff6f4e77..e1a2ba5046e3 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -98,11 +98,11 @@ void VCartesianCoordinateSystem::createGridShapes()
}
void VCartesianCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const awt::Size& rFontReferenceSize
- , const awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels
- )
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const awt::Size& rFontReferenceSize,
+ const awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
{
// note: using xChartDoc itself as XNumberFormatsSupplier would cause
// a leak from VCartesianAxis due to cyclic reference
@@ -163,6 +163,7 @@ void VCartesianCoordinateSystem::createVAxisList(
apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos,
m_eBottomPos );
apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
+ apVAxis->createDataTableView(rSeriesPlotterList,
xNumberFormatsSupplier);
}
}
}
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
index e9d684821445..4b7acf227867 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx
@@ -31,10 +31,11 @@ public:
virtual ~VCartesianCoordinateSystem() override;
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> &ChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels ) override;
+ const rtl::Reference<::chart::ChartModel> &ChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
override;
virtual void initVAxisInList() override;
virtual void updateScalesAndIncrementsOnAxes() override;
diff --git a/chart2/source/view/axes/VCoordinateSystem.cxx
b/chart2/source/view/axes/VCoordinateSystem.cxx
index 7860fd7de1c5..142d646010e2 100644
--- a/chart2/source/view/axes/VCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCoordinateSystem.cxx
@@ -322,11 +322,11 @@ sal_Int32
VCoordinateSystem::getMaximumAxisIndexByDimension( sal_Int32 nDimensio
}
void VCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & /* xChartDoc */
- , const awt::Size& /* rFontReferenceSize */
- , const awt::Rectangle& /* rMaximumSpaceForLabels */
- , bool /* bLimitSpaceForLabels */
- )
+ const rtl::Reference<::chart::ChartModel> & /* xChartDoc */,
+ const awt::Size& /* rFontReferenceSize */,
+ const awt::Rectangle& /* rMaximumSpaceForLabels */,
+ bool /* bLimitSpaceForLabels */,
+ std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/)
{
}
diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx
b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
index e287120f965e..3a3351a54fc3 100644
--- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx
@@ -66,11 +66,11 @@ uno::Sequence< sal_Int32 >
VPolarCoordinateSystem::getCoordinateSystemResolution
}
void VPolarCoordinateSystem::createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const awt::Size& rFontReferenceSize
- , const awt::Rectangle& rMaximumSpaceForLabels
- , bool //bLimitSpaceForLabels
- )
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const awt::Size& rFontReferenceSize,
+ const awt::Rectangle& rMaximumSpaceForLabels,
+ bool /*bLimitSpaceForLabels*/,
+ std::vector<std::unique_ptr<VSeriesPlotter>>&
/*rSeriesPlotterList*/)
{
// note: using xChartDoc itself as XNumberFormatsSupplier would cause
// a leak from VPolarAxis due to cyclic reference
diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.hxx
b/chart2/source/view/axes/VPolarCoordinateSystem.hxx
index 9659660a5e8c..ecfb2ce4d19d 100644
--- a/chart2/source/view/axes/VPolarCoordinateSystem.hxx
+++ b/chart2/source/view/axes/VPolarCoordinateSystem.hxx
@@ -35,10 +35,11 @@ public:
, const css::awt::Size& rPageResolution )
override;
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels ) override;
+ const rtl::Reference<::chart::ChartModel> &ChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
override;
virtual void initVAxisInList() override;
virtual void updateScalesAndIncrementsOnAxes() override;
diff --git a/chart2/source/view/inc/DataTableView.hxx
b/chart2/source/view/inc/DataTableView.hxx
new file mode 100644
index 000000000000..517de9699d9e
--- /dev/null
+++ b/chart2/source/view/inc/DataTableView.hxx
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ *
+ */
+#pragma once
+
+#include <svx/unoshape.hxx>
+#include <svx/unodraw/SvxTableShape.hxx>
+#include <com/sun/star/awt/Rectangle.hpp>
+
+namespace chart
+{
+class VSeriesPlotter;
+
+class DataTableView final
+{
+ rtl::Reference<SvxShapeGroupAnyD> m_xTarget;
+ rtl::Reference<SvxTableShape> m_xTableShape;
+
+ std::vector<OUString> m_aDataSeriesNames;
+ std::vector<OUString> m_aXValues;
+ std::vector<std::vector<OUString>> m_pDataSeriesValues;
+
+public:
+ DataTableView();
+ void initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& xTarget);
+ void initializeValues(std::vector<std::unique_ptr<VSeriesPlotter>>&
rSeriesPlotterList);
+ void createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector
const& rEnd,
+ sal_Int32 nDistance);
+};
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx
b/chart2/source/view/inc/VCoordinateSystem.hxx
index 0664a5462996..3fef60df6f72 100644
--- a/chart2/source/view/inc/VCoordinateSystem.hxx
+++ b/chart2/source/view/inc/VCoordinateSystem.hxx
@@ -25,14 +25,12 @@
#include <com/sun/star/uno/Sequence.h>
#include <rtl/ref.hxx>
#include <svx/unoshape.hxx>
+#include <DataTableView.hxx>
#include <map>
#include <memory>
#include <vector>
-namespace chart { class ExplicitCategoriesProvider; }
-namespace chart { class ScaleAutomatism; }
-namespace chart { class ChartModel; }
namespace com::sun::star::awt { struct Rectangle; }
namespace com::sun::star::awt { struct Size; }
namespace com::sun::star::beans { class XPropertySet; }
@@ -42,9 +40,11 @@ namespace com::sun::star::chart2 { class XCoordinateSystem; }
namespace com::sun::star::drawing { class XShapes; }
namespace com::sun::star::lang { class XMultiServiceFactory; }
-
namespace chart
{
+class ExplicitCategoriesProvider;
+class ScaleAutomatism;
+class ChartModel;
class Axis;
class BaseCoordinateSystem;
class VAxisBase;
@@ -116,10 +116,11 @@ public:
* Create "view" axis objects 'VAxis' from the coordinate system model.
*/
virtual void createVAxisList(
- const rtl::Reference<::chart::ChartModel> & xChartDoc
- , const css::awt::Size& rFontReferenceSize
- , const css::awt::Rectangle& rMaximumSpaceForLabels
- , bool bLimitSpaceForLabels );
+ const rtl::Reference<::chart::ChartModel> & xChartDoc,
+ const css::awt::Size& rFontReferenceSize,
+ const css::awt::Rectangle& rMaximumSpaceForLabels,
+ bool bLimitSpaceForLabels,
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList);
virtual void initVAxisInList();
virtual void updateScalesAndIncrementsOnAxes();
diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx
b/chart2/source/view/inc/VSeriesPlotter.hxx
index 90a73f1ee504..eefa602caf4d 100644
--- a/chart2/source/view/inc/VSeriesPlotter.hxx
+++ b/chart2/source/view/inc/VSeriesPlotter.hxx
@@ -234,6 +234,8 @@ public:
void setExplicitCategoriesProvider( ExplicitCategoriesProvider*
pExplicitCategoriesProvider );
+ ExplicitCategoriesProvider* getExplicitCategoriesProvider() { return
m_pExplicitCategoriesProvider; }
+
//get series names for the z axis labels
css::uno::Sequence< OUString > getSeriesNames() const;
@@ -254,6 +256,11 @@ public:
bool WantToPlotInFrontOfAxisLine();
virtual bool shouldSnapRectToUsedArea();
+ /// This method returns a text string representation of the passed numeric
+ /// value by exploiting a NumberFormatterWrapper object.
+ OUString getLabelTextForValue(VDataSeries const & rDataSeries, sal_Int32
nPointIndex,
+ double fValue, bool bAsPercentage);
+
protected:
VSeriesPlotter( const rtl::Reference< ::chart::ChartType >& xChartTypeModel
@@ -322,13 +329,6 @@ protected:
, sal_Int32 nOffset=0
, sal_Int32 nTextWidth = 0 );
- /// This method returns a text string representation of the passed numeric
- /// value by exploiting a NumberFormatterWrapper object.
- OUString getLabelTextForValue( VDataSeries const & rDataSeries
- , sal_Int32 nPointIndex
- , double fValue
- , bool bAsPercentage );
-
/** creates two T-shaped error bars in both directions (up/down or
left/right depending on the bVertical parameter)
diff --git a/chart2/source/view/main/ChartView.cxx
b/chart2/source/view/main/ChartView.cxx
index 3f96a68b2612..40b5afa15ffb 100644
--- a/chart2/source/view/main/ChartView.cxx
+++ b/chart2/source/view/main/ChartView.cxx
@@ -536,7 +536,7 @@ awt::Rectangle ChartView::impl_createDiagramAndContent(
const CreateShapeParam2D
rpVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos,
eBottomPos );
}
- rpVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize);
+ rpVCooSys->createVAxisList(&mrChartModel, rPageSize,
rParam.maRemainingSpace, rParam.mbUseFixedInnerSize, rSeriesPlotterList);
}
// - prepare list of all axis and how they are used
diff --git a/chart2/source/view/main/DataTableView.cxx
b/chart2/source/view/main/DataTableView.cxx
new file mode 100644
index 000000000000..e697fba1ce31
--- /dev/null
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -0,0 +1,217 @@
+/* -*- 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/.
+ *
+ */
+
+#include <DataTableView.hxx>
+#include <VSeriesPlotter.hxx>
+#include <ShapeFactory.hxx>
+#include <ExplicitCategoriesProvider.hxx>
+
+#include <svx/svdotable.hxx>
+
+#include <com/sun/star/table/XTable.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/util/XBroadcaster.hpp>
+
+#include <o3tl/unit_conversion.hxx>
+
+using namespace css;
+
+namespace chart
+{
+DataTableView::DataTableView() = default;
+
+namespace
+{
+void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet)
+{
+ xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF)));
+ xPropertySet->setPropertyValue("TextVerticalAdjust",
uno::Any(drawing::TextVerticalAdjust_TOP));
+ xPropertySet->setPropertyValue("ParaAdjust",
uno::Any(style::ParagraphAdjust_CENTER));
+
+ table::BorderLine2 aBorderLine;
+ aBorderLine.LineWidth = o3tl::convert(0.5, o3tl::Length::pt,
o3tl::Length::mm100);
+ aBorderLine.Color = 0x000000;
+
+ xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine));
+}
+
+void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet)
+{
+ xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF)));
+ xPropertySet->setPropertyValue("TextVerticalAdjust",
uno::Any(drawing::TextVerticalAdjust_TOP));
+ xPropertySet->setPropertyValue("ParaAdjust",
uno::Any(style::ParagraphAdjust_CENTER));
+
+ table::BorderLine2 aBorderLine;
+ aBorderLine.LineWidth = 0;
+ aBorderLine.Color = 0x000000;
+
+ xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+ xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine));
+}
+}
+void DataTableView::createShapes(basegfx::B2DVector const& rStart,
basegfx::B2DVector const& rEnd,
+ sal_Int32 nColumnSize)
+{
+ if (!m_xTarget.is())
+ return;
+
+ if (m_xTarget.is())
+ ShapeFactory::removeSubShapes(m_xTarget);
+
+ m_xTableShape = ShapeFactory::createTable(m_xTarget);
+
+ auto* pTableObject =
static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject());
+ uno::Reference<table::XTable> xTable;
+ uno::Reference<util::XBroadcaster> xBroadcaster;
+ try
+ {
+ auto rDelta = rEnd - rStart;
+ m_xTableShape->setSize({ rDelta.getX(), 0 });
+
+ m_xTableShape->getPropertyValue("Model") >>= xTable;
+ }
+ catch (const uno::Exception&)
+ {
+ return;
+ }
+
+ if (xTable.is())
+ xBroadcaster.set(xTable, uno::UNO_QUERY);
+
+ if (xBroadcaster.is())
+ {
+ xBroadcaster->lockBroadcasts();
+ uno::Reference<table::XTableColumns> xTableColumns =
xTable->getColumns();
+ xTableColumns->insertByIndex(0, m_aXValues.size());
+
+ uno::Reference<table::XTableRows> xTableRows = xTable->getRows();
+ xTableRows->insertByIndex(0, m_aDataSeriesNames.size());
+
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(0,
0);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ setTopCell(xPropertySet);
+ }
+ }
+
+ sal_Int32 nColumn;
+ sal_Int32 nRow;
+
+ nColumn = 1;
+ for (auto const& rString : m_aXValues)
+ {
+ uno::Reference<table::XCell> xCell =
xTable->getCellByPosition(nColumn, 0);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rString);
+ setCellDefaults(xPropertySet);
+ }
+ nColumn++;
+ }
+
+ nRow = 1;
+ for (auto const& rSeriesName : m_aDataSeriesNames)
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(0,
nRow);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rSeriesName);
+ setCellDefaults(xPropertySet);
+ }
+ nRow++;
+ }
+
+ nRow = 1;
+ for (auto const& rSeries : m_pDataSeriesValues)
+ {
+ nColumn = 1;
+ for (auto const& rValue : rSeries)
+ {
+ uno::Reference<table::XCell> xCell =
xTable->getCellByPosition(nColumn, nRow);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCell,
uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xCellTextRange(xCell,
uno::UNO_QUERY);
+ if (xCellTextRange.is())
+ {
+ xCellTextRange->setString(rValue);
+ setCellDefaults(xPropertySet);
+ }
+ nColumn++;
+ }
+ nRow++;
+ }
+
+ xBroadcaster->unlockBroadcasts();
+
+ pTableObject->DistributeColumns(0, pTableObject->getColumnCount() - 1,
true, true);
+
+ uno::Reference<beans::XPropertySet>
xPropSet(xTableColumns->getByIndex(0), uno::UNO_QUERY);
+ sal_Int32 nWidth = 0;
+ xPropSet->getPropertyValue("Width") >>= nWidth;
+
+ m_xTableShape->setPosition({ rStart.getX() - nWidth, rStart.getY() });
+
+ for (sal_Int32 i = 1; i < xTableColumns->getCount(); ++i)
+ {
+ xPropSet.set(xTableColumns->getByIndex(i), uno::UNO_QUERY);
+ xPropSet->setPropertyValue("Width", uno::Any(nColumnSize));
+ }
+ }
+}
+
+void DataTableView::initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>&
xTarget)
+{
+ m_xTarget = xTarget;
+}
+
+void DataTableView::initializeValues(
+ std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
+{
+ for (auto& rSeriesPlotter : rSeriesPlotterList)
+ {
+ for (auto const& rCategory :
+
rSeriesPlotter->getExplicitCategoriesProvider()->getSimpleCategories())
+ {
+ m_aXValues.push_back(rCategory);
+ }
+
+ for (auto const& rString : rSeriesPlotter->getSeriesNames())
+ {
+ m_aDataSeriesNames.push_back(rString);
+ }
+
+ for (VDataSeries* pSeries : rSeriesPlotter->getAllSeries())
+ {
+ auto& rValues = m_pDataSeriesValues.emplace_back();
+ for (int i = 0; i < pSeries->getTotalPointCount(); i++)
+ {
+ double nValue = pSeries->getYValue(i);
+
rValues.push_back(rSeriesPlotter->getLabelTextForValue(*pSeries, i, nValue,
false));
+ }
+ }
+ }
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit a3fdc3faf547b511911c6abd5f85fa99276554f2
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Sun May 8 21:48:04 2022 +0900
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Mon May 9 14:16:41 2022 +0900
chart2: prefix VDataSeries members, rename Double to m_aValues
Change-Id: I74d560fa8a9c9d1ee761b26aa1ca90798f774a7f
diff --git a/chart2/source/view/inc/VDataSeries.hxx
b/chart2/source/view/inc/VDataSeries.hxx
index f445d06092ee..29a71918b549 100644
--- a/chart2/source/view/inc/VDataSeries.hxx
+++ b/chart2/source/view/inc/VDataSeries.hxx
@@ -53,9 +53,8 @@ public:
sal_Int32 detectNumberFormatKey( sal_Int32 index ) const;
sal_Int32 getLength() const;
- css::uno::Reference<css::chart2::data::XDataSequence> Model;
-
- mutable css::uno::Sequence<double> Doubles;
+ css::uno::Reference<css::chart2::data::XDataSequence> m_xModel;
+ mutable css::uno::Sequence<double> m_aValues;
};
class VDataSeries final
diff --git a/chart2/source/view/main/VDataSeries.cxx
b/chart2/source/view/main/VDataSeries.cxx
index 311273034e10..3fb12ebca325 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -49,24 +49,24 @@ using ::com::sun::star::uno::Reference;
void VDataSequence::init( const uno::Reference< data::XDataSequence >& xModel )
{
- Model = xModel;
- Doubles = DataSequenceToDoubleSequence( xModel );
+ m_xModel = xModel;
+ m_aValues = DataSequenceToDoubleSequence( xModel );
}
bool VDataSequence::is() const
{
- return Model.is();
+ return m_xModel.is();
}
void VDataSequence::clear()
{
- Model = nullptr;
- Doubles.realloc(0);
+ m_xModel = nullptr;
+ m_aValues.realloc(0);
}
double VDataSequence::getValue( sal_Int32 index ) const
{
- if( 0<=index && index<Doubles.getLength() )
- return Doubles[index];
+ if( 0<=index && index<m_aValues.getLength() )
+ return m_aValues[index];
return std::numeric_limits<double>::quiet_NaN();
}
@@ -75,10 +75,9 @@ sal_Int32 VDataSequence::detectNumberFormatKey( sal_Int32
index ) const
sal_Int32 nNumberFormatKey = -1;
// -1 is allowed and means a key for the whole sequence
- if( -1<=index && index<Doubles.getLength() &&
- Model.is())
+ if( -1<=index && index<m_aValues.getLength() && m_xModel.is())
{
- nNumberFormatKey = Model->getNumberFormatKeyByIndex( index );
+ nNumberFormatKey = m_xModel->getNumberFormatKeyByIndex( index );
}
return nNumberFormatKey;
@@ -86,7 +85,7 @@ sal_Int32 VDataSequence::detectNumberFormatKey( sal_Int32
index ) const
sal_Int32 VDataSequence::getLength() const
{
- return Doubles.getLength();
+ return m_aValues.getLength();
}
namespace
@@ -107,10 +106,10 @@ struct lcl_LessXOfPoint
void lcl_clearIfNoValuesButTextIsContained( VDataSequence& rData, const
uno::Reference<data::XDataSequence>& xDataSequence )
{
//#i71686#, #i101968#, #i102428#
- sal_Int32 nCount = rData.Doubles.getLength();
+ sal_Int32 nCount = rData.m_aValues.getLength();
for( sal_Int32 i = 0; i < nCount; ++i )
{
- if( !std::isnan( rData.Doubles[i] ) )
+ if( !std::isnan( rData.m_aValues[i] ) )
return;
}
//no double value is contained
@@ -248,7 +247,7 @@ VDataSeries::~VDataSeries()
void VDataSeries::doSortByXValues()
{
- if( !(m_aValues_X.is() && m_aValues_X.Doubles.hasElements()) )
+ if( !(m_aValues_X.is() && m_aValues_X.m_aValues.hasElements()) )
return;
//prepare a vector for sorting
@@ -257,9 +256,9 @@ void VDataSeries::doSortByXValues()
for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ )
{
aTmp.push_back(
- { ((nPointIndex < m_aValues_X.Doubles.getLength()) ?
m_aValues_X.Doubles[nPointIndex]
+ { ((nPointIndex < m_aValues_X.m_aValues.getLength()) ?
m_aValues_X.m_aValues[nPointIndex]
:
std::numeric_limits<double>::quiet_NaN()),
- ((nPointIndex < m_aValues_Y.Doubles.getLength()) ?
m_aValues_Y.Doubles[nPointIndex]
+ ((nPointIndex < m_aValues_Y.m_aValues.getLength()) ?
m_aValues_Y.m_aValues[nPointIndex]
:
std::numeric_limits<double>::quiet_NaN())
}
);
@@ -269,10 +268,10 @@ void VDataSeries::doSortByXValues()
std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() );
//fill the sorted points back to the members
- m_aValues_X.Doubles.realloc( m_nPointCount );
- auto pDoublesX = m_aValues_X.Doubles.getArray();
- m_aValues_Y.Doubles.realloc( m_nPointCount );
- auto pDoublesY = m_aValues_Y.Doubles.getArray();
+ m_aValues_X.m_aValues.realloc( m_nPointCount );
+ auto pDoublesX = m_aValues_X.m_aValues.getArray();
+ m_aValues_Y.m_aValues.realloc( m_nPointCount );
+ auto pDoublesY = m_aValues_Y.m_aValues.getArray();
for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ )
{
@@ -421,10 +420,10 @@ double VDataSeries::getXValue( sal_Int32 index ) const
{
if( 0<=index && index<m_aValues_X.getLength() )
{
- fRet = m_aValues_X.Doubles[index];
+ fRet = m_aValues_X.m_aValues[index];
if(mpOldSeries && index < mpOldSeries->m_aValues_X.getLength())
{
- double nOldVal = mpOldSeries->m_aValues_X.Doubles[index];
+ double nOldVal = mpOldSeries->m_aValues_X.m_aValues[index];
fRet = nOldVal + (fRet - nOldVal) * mnPercent;
}
}
@@ -446,10 +445,10 @@ double VDataSeries::getYValue( sal_Int32 index ) const
{
if( 0<=index && index<m_aValues_Y.getLength() )
{
- fRet = m_aValues_Y.Doubles[index];
+ fRet = m_aValues_Y.m_aValues[index];
if(mpOldSeries && index < mpOldSeries->m_aValues_Y.getLength())
{
- double nOldVal = mpOldSeries->m_aValues_Y.Doubles[index];
+ double nOldVal = mpOldSeries->m_aValues_Y.m_aValues[index];
fRet = nOldVal + (fRet - nOldVal) * mnPercent;
}
}
@@ -719,12 +718,12 @@ uno::Sequence< double > const & VDataSeries::getAllX()
const
{
//init x values from category indexes
//first category (index 0) matches with real number 1.0
- m_aValues_X.Doubles.realloc( m_nPointCount );
- auto pDoubles = m_aValues_X.Doubles.getArray();
+ m_aValues_X.m_aValues.realloc( m_nPointCount );
+ auto pDoubles = m_aValues_X.m_aValues.getArray();
for(sal_Int32 nN=m_aValues_X.getLength();nN--;)
pDoubles[nN] = nN+1;
}
- return m_aValues_X.Doubles;
+ return m_aValues_X.m_aValues;
}
uno::Sequence< double > const & VDataSeries::getAllY() const
@@ -733,12 +732,12 @@ uno::Sequence< double > const & VDataSeries::getAllY()
const
{
//init y values from indexes
//first y-value (index 0) matches with real number 1.0
- m_aValues_Y.Doubles.realloc( m_nPointCount );
- auto pDoubles = m_aValues_Y.Doubles.getArray();
+ m_aValues_Y.m_aValues.realloc( m_nPointCount );
+ auto pDoubles = m_aValues_Y.m_aValues.getArray();
for(sal_Int32 nN=m_aValues_Y.getLength();nN--;)
pDoubles[nN] = nN+1;
}
- return m_aValues_Y.Doubles;
+ return m_aValues_Y.m_aValues;
}
double VDataSeries::getXMeanValue() const