Rebased ref, commits from common ancestor: commit e560a387eefbe4cf8af225350f5e28f10ea76e70 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 21 10:52:51 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:41 2022 +0900
chart2: set the char props. to the cells of a data table from model This copies the char. properties from the model to the cells of a data table, so the correct char width, font is used for text when the table is rendered. Also add margin to the text, so it looks better. Change-Id: Ib74a8136459a31d64a86dec36a6ba14d2c313cf2 diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index 3992ea84d012..c8e2adae6fbe 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -5,7 +5,6 @@ * 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> @@ -59,11 +58,70 @@ void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet) xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); } + +void copyProperty(uno::Reference<beans::XPropertySet>& xOut, + uno::Reference<beans::XPropertySet>& xIn, OUString const& sPropertyName) +{ + xOut->setPropertyValue(sPropertyName, xIn->getPropertyValue(sPropertyName)); +} } void DataTableView::setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool bLeft, bool bTop, bool bRight, bool bBottom) { + uno::Reference<beans::XPropertySet> xDataTableProperties = m_xDataTableModel.get(); + + copyProperty(xPropertySet, xDataTableProperties, "CharColor"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontFamily"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontFamilyAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontFamilyComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontCharSet"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontCharSetAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontCharSetComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontName"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontNameAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontNameComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontPitch"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontPitchAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontPitchComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontStyleName"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontStyleNameAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharFontStyleNameComplex"); + + copyProperty(xPropertySet, xDataTableProperties, "CharHeight"); + copyProperty(xPropertySet, xDataTableProperties, "CharHeightAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharHeightComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharKerning"); + copyProperty(xPropertySet, xDataTableProperties, "CharLocale"); + copyProperty(xPropertySet, xDataTableProperties, "CharLocaleAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharLocaleComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharPosture"); + copyProperty(xPropertySet, xDataTableProperties, "CharPostureAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharPostureComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharRelief"); + copyProperty(xPropertySet, xDataTableProperties, "CharShadowed"); + copyProperty(xPropertySet, xDataTableProperties, "CharStrikeout"); + copyProperty(xPropertySet, xDataTableProperties, "CharUnderline"); + copyProperty(xPropertySet, xDataTableProperties, "CharUnderlineColor"); + copyProperty(xPropertySet, xDataTableProperties, "CharUnderlineHasColor"); + copyProperty(xPropertySet, xDataTableProperties, "CharOverline"); + copyProperty(xPropertySet, xDataTableProperties, "CharOverlineColor"); + copyProperty(xPropertySet, xDataTableProperties, "CharOverlineHasColor"); + copyProperty(xPropertySet, xDataTableProperties, "CharWeight"); + copyProperty(xPropertySet, xDataTableProperties, "CharWeightAsian"); + copyProperty(xPropertySet, xDataTableProperties, "CharWeightComplex"); + copyProperty(xPropertySet, xDataTableProperties, "CharWordMode"); + + float fFontHeight = 0.0; + xDataTableProperties->getPropertyValue("CharHeight") >>= fFontHeight; + fFontHeight = o3tl::convert(fFontHeight, o3tl::Length::pt, o3tl::Length::mm100); + uno::Any aXDistanceAny(sal_Int32(std::round(fFontHeight * 0.18f))); + uno::Any aYDistanceAny(sal_Int32(std::round(fFontHeight * 0.30f))); + xPropertySet->setPropertyValue("TextLeftDistance", aXDistanceAny); + xPropertySet->setPropertyValue("TextRightDistance", aXDistanceAny); + xPropertySet->setPropertyValue("TextUpperDistance", aYDistanceAny); + xPropertySet->setPropertyValue("TextLowerDistance", aYDistanceAny); + xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF))); xPropertySet->setPropertyValue("TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_TOP)); xPropertySet->setPropertyValue("ParaAdjust", uno::Any(style::ParagraphAdjust_CENTER)); commit 40ede4a61e2653706c248771cc20da92b2245b05 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 21 10:51:55 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:41 2022 +0900 chart2: add char properties to the DataTable model Change-Id: Ie4b49f36def7d20f89695157c3b95e6ee5d16d83 diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx index 0b7fba3176e2..b57566005e83 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -95,8 +95,9 @@ private: { std::vector<beans::Property> aProperties; lcl_AddPropertiesToVector(aProperties); - chart::LinePropertiesHelper::AddPropertiesToVector(aProperties); - chart::FillProperties::AddPropertiesToVector(aProperties); + ::chart::LinePropertiesHelper::AddPropertiesToVector(aProperties); + ::chart::FillProperties::AddPropertiesToVector(aProperties); + ::chart::CharacterProperties::AddPropertiesToVector(aProperties); std::sort(aProperties.begin(), aProperties.end(), chart::PropertyNameLess()); return comphelper::containerToSequence(aProperties); @@ -214,7 +215,8 @@ sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName) uno::Sequence<OUString> SAL_CALL DataTable::getSupportedServiceNames() { return { "com.sun.star.chart2.DataTable", "com.sun.star.beans.PropertySet", - "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties" }; + "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties", + "com.sun.star.style.CharacterProperties" }; } IMPLEMENT_FORWARD_XINTERFACE2(DataTable, DataTable_Base, ::property::OPropertySet) commit eb600c8668d6b3178947fbaf1062e62a7025ff2b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 21 00:00:30 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:41 2022 +0900 oox export: add export of basic properties of a data table Change-Id: I2c8b76125fc788a9e4df164171d6cbd351bc1c4a diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 8a6d5fa7d298..988fe4413529 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -1732,6 +1732,7 @@ void ChartExport::exportPlotArea(const Reference< css::chart::XChartDocument >& } //Axis Data exportAxes( ); + // Data Table exportDataTable(); @@ -2033,35 +2034,41 @@ void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet void ChartExport::exportDataTable( ) { + auto xDataTable = mxNewDiagram->getDataTable(); + if (!xDataTable.is()) + return; + FSHelperPtr pFS = GetFS(); - Reference< beans::XPropertySet > aPropSet( mxDiagram, uno::UNO_QUERY ); + uno::Reference<beans::XPropertySet> aPropSet(xDataTable, uno::UNO_QUERY); bool bShowVBorder = false; bool bShowHBorder = false; bool bShowOutline = false; + bool bShowKeys = false; - if (GetProperty( aPropSet, "DataTableHBorder")) + if (GetProperty(aPropSet, "HBorder")) mAny >>= bShowHBorder; - if (GetProperty( aPropSet, "DataTableVBorder")) + if (GetProperty(aPropSet, "VBorder")) mAny >>= bShowVBorder; - if (GetProperty( aPropSet, "DataTableOutline")) + if (GetProperty(aPropSet, "Outline")) + mAny >>= bShowOutline; + if (GetProperty(aPropSet, "Keys")) mAny >>= bShowOutline; - - if (!(bShowVBorder || bShowHBorder || bShowOutline)) - return; pFS->startElement(FSNS(XML_c, XML_dTable)); + if (bShowHBorder) - pFS->singleElement( FSNS( XML_c, XML_showHorzBorder ), - XML_val, "1" ); + pFS->singleElement(FSNS(XML_c, XML_showHorzBorder), XML_val, "1" ); if (bShowVBorder) pFS->singleElement(FSNS(XML_c, XML_showVertBorder), XML_val, "1"); if (bShowOutline) pFS->singleElement(FSNS(XML_c, XML_showOutline), XML_val, "1"); + if (bShowKeys) + pFS->singleElement(FSNS(XML_c, XML_showKeys), XML_val, "1"); - pFS->endElement( FSNS( XML_c, XML_dTable)); - + pFS->endElement(FSNS(XML_c, XML_dTable)); } + void ChartExport::exportAreaChart( const Reference< chart2::XChartType >& xChartType ) { FSHelperPtr pFS = GetFS(); commit ba034985e3944b50a9ed6735cfeade8d650f9ad9 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 20 23:55:45 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:41 2022 +0900 chart2: apply line props. to borders when rendering a data table This sets the color, line width, line style to the borders of the table when rendering the data table. We also need the ChartModel inside DataTableView, so we can access the needed line dashes. Change-Id: Id3bef23b75e88517d6569ad87a716f178ed64343 diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 95125beed1cf..7d985051a4a7 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -243,7 +243,8 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter& rIter ) } void VAxisBase::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/, - uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/) + uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/, + rtl::Reference<::chart::ChartModel> const& /*xChartDoc*/) { } diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx index 4da1936a452b..2c4123ba951d 100644 --- a/chart2/source/view/axes/VAxisBase.hxx +++ b/chart2/source/view/axes/VAxisBase.hxx @@ -29,6 +29,7 @@ namespace chart class VSeriesPlotter; class DataTableView; +class ChartModel; class VAxisBase : public VAxisOrGridBase { @@ -63,7 +64,8 @@ public: void setExtraLinePositionAtOtherAxis( double fCrossingAt ); virtual void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, - css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier); + css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, + rtl::Reference<::chart::ChartModel> const& xChartDoc); std::shared_ptr<DataTableView> getDataTableView() { return m_pDataTableView; } diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index bb7f0090eb93..9e6c877a4bb0 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -36,6 +36,7 @@ #include <svx/unoshtxt.hxx> #include <VSeriesPlotter.hxx> #include <DataTableView.hxx> +#include <ChartModel.hxx> #include <comphelper/scopeguard.hxx> @@ -1992,11 +1993,12 @@ void VCartesianAxis::createShapes() } void VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, - Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier) + Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, + rtl::Reference<::chart::ChartModel> const& xChartDoc) { if (m_aAxisProperties.m_bDisplayDataTable) { - m_pDataTableView.reset(new DataTableView(m_aAxisProperties.m_xDataTableModel)); + m_pDataTableView.reset(new DataTableView(xChartDoc, m_aAxisProperties.m_xDataTableModel)); m_pDataTableView->initializeValues(rSeriesPlotterList); m_xNumberFormatsSupplier = xNumberFormatsSupplier; } diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index 9f396fef43b8..a9baca907bdd 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -100,7 +100,8 @@ public: }; void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, - css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier) override; + css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, + rtl::Reference<::chart::ChartModel> const& xChartDoc) 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 cd0d49188a1c..3ea42cb087a0 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -166,7 +166,7 @@ void VCartesianCoordinateSystem::createVAxisList( apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); - apVAxis->createDataTableView(rSeriesPlotterList, xNumberFormatsSupplier); + apVAxis->createDataTableView(rSeriesPlotterList, xNumberFormatsSupplier, xChartDoc); } } } diff --git a/chart2/source/view/inc/DataTableView.hxx b/chart2/source/view/inc/DataTableView.hxx index 3f4d97629035..0967768af93e 100644 --- a/chart2/source/view/inc/DataTableView.hxx +++ b/chart2/source/view/inc/DataTableView.hxx @@ -13,23 +13,32 @@ #include <svx/unodraw/SvxTableShape.hxx> #include <com/sun/star/awt/Rectangle.hpp> #include <DataTable.hxx> +#include <VLineProperties.hxx> namespace chart { class VSeriesPlotter; +class ChartModel; class DataTableView final { +private: + rtl::Reference<::chart::ChartModel> const& m_xChartModel; rtl::Reference<SvxShapeGroupAnyD> m_xTarget; rtl::Reference<SvxTableShape> m_xTableShape; rtl::Reference<DataTable> m_xDataTableModel; + VLineProperties m_aLineProperties; std::vector<OUString> m_aDataSeriesNames; std::vector<OUString> m_aXValues; std::vector<std::vector<OUString>> m_pDataSeriesValues; + void setCellDefaults(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, bool bLeft, + bool bTop, bool bRight, bool bBottom); + public: - DataTableView(rtl::Reference<DataTable> const& rDataTableModel); + DataTableView(rtl::Reference<::chart::ChartModel> const& xChartDoc, + rtl::Reference<DataTable> const& rDataTableModel); 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, diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index 92714a8a85ba..3992ea84d012 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -12,6 +12,7 @@ #include <VSeriesPlotter.hxx> #include <ShapeFactory.hxx> #include <ExplicitCategoriesProvider.hxx> +#include <ChartModel.hxx> #include <svx/svdotable.hxx> @@ -19,10 +20,14 @@ #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/table/BorderLineStyle.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/drawing/LineDash.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/util/XBroadcaster.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <o3tl/unit_conversion.hxx> @@ -30,48 +35,97 @@ using namespace css; namespace chart { -DataTableView::DataTableView(rtl::Reference<DataTable> const& rDataTableModel) - : m_xDataTableModel(rDataTableModel) +DataTableView::DataTableView(rtl::Reference<::chart::ChartModel> const& xChartModel, + rtl::Reference<DataTable> const& rDataTableModel) + : m_xChartModel(xChartModel) + , m_xDataTableModel(rDataTableModel) { + uno::Reference<beans::XPropertySet> xProp = m_xDataTableModel.get(); + m_aLineProperties.initFromPropertySet(xProp); } namespace { -void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool bLeft, bool bTop, - bool bRight, bool bBottom) +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 = o3tl::convert(0.5, o3tl::Length::pt, o3tl::Length::mm100); + aBorderLine.LineWidth = 0; aBorderLine.Color = 0x000000; - if (bLeft) - xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); - if (bTop) - xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); - if (bRight) - xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine)); - if (bBottom) - xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine)); + xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); + xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); +} } -void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet) +void DataTableView::setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool bLeft, + bool bTop, bool bRight, bool bBottom) { 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; + drawing::LineStyle eStyle = drawing::LineStyle_NONE; + m_aLineProperties.LineStyle >>= eStyle; - xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); - xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); -} + if (eStyle != drawing::LineStyle_NONE) + { + table::BorderLine2 aBorderLine; + + sal_Int32 nWidth = 0; + m_aLineProperties.Width >>= nWidth; + aBorderLine.LineWidth = o3tl::convert(nWidth, o3tl::Length::mm100, o3tl::Length::twip); + + sal_Int32 nColor = 0; + m_aLineProperties.Color >>= nColor; + aBorderLine.Color = nColor; + + aBorderLine.LineStyle = table::BorderLineStyle::SOLID; + + if (eStyle == drawing::LineStyle_DASH) + { + OUString aDashName; + m_aLineProperties.DashName >>= aDashName; + if (!aDashName.isEmpty()) + { + uno::Reference<container::XNameContainer> xDashTable( + m_xChartModel->createInstance("com.sun.star.drawing.DashTable"), + uno::UNO_QUERY); + if (xDashTable.is() && xDashTable->hasByName(aDashName)) + { + drawing::LineDash aLineDash; + xDashTable->getByName(aDashName) >>= aLineDash; + + if (aLineDash.Dots == 0 && aLineDash.Dashes == 0) + aBorderLine.LineStyle = table::BorderLineStyle::SOLID; + else if (aLineDash.Dots == 1 && aLineDash.Dashes == 0) + aBorderLine.LineStyle = table::BorderLineStyle::DOTTED; + else if (aLineDash.Dots == 0 && aLineDash.Dashes == 1) + aBorderLine.LineStyle = table::BorderLineStyle::DASHED; + else if (aLineDash.Dots == 1 && aLineDash.Dashes == 1) + aBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT; + else if (aLineDash.Dots == 2 && aLineDash.Dashes == 1) + aBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT_DOT; + else + aBorderLine.LineStyle = table::BorderLineStyle::DASHED; + } + } + } + + if (bLeft) + xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); + if (bTop) + xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); + if (bRight) + xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine)); + if (bBottom) + xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine)); + } } + void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector const& rEnd, sal_Int32 nColumnWidth) { commit c49f8d6c21b828c5e857a84c234d5f49e80c9a94 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 20 18:39:34 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:41 2022 +0900 chart2: better readable DataTable properties definition Change-Id: Ib9cadee39f58b73782e6a3268d86b688183de1fb diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx index 12e08e28b3e4..0b7fba3176e2 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -34,23 +34,21 @@ enum DataTableProperty_Keys, }; -void lcl_AddPropertiesToVector(std::vector<beans::Property>& rOutProperties) -{ - rOutProperties.emplace_back("Show", DataTableProperty_Show, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT); - rOutProperties.emplace_back( - "HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); - rOutProperties.emplace_back( - "VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); - rOutProperties.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT); - rOutProperties.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT); +void lcl_AddPropertiesToVector(std::vector<beans::Property>& rProps) +{ + auto const nBound = beans::PropertyAttribute::BOUND; + auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT; + + rProps.emplace_back("Show", DataTableProperty_Show, cppu::UnoType<bool>::get(), + nBound | nMaybeDefault); + rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(), + nBound | nMaybeDefault); + rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(), + nBound | nMaybeDefault); + rProps.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(), + nBound | nMaybeDefault); + rProps.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(), + nBound | nMaybeDefault); } struct StaticLegendDefaults_Initializer commit 3380bb03d59f1030681e9ddb259e7376c31126ec Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 20 18:20:51 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 chart2: remove setting DataTable* props. from old chart::XDialog No API change needed as the properties were not officialy part of the API in the first place. Change-Id: I8682087d13ab2e9eb1c619646b87cde59c3a8e45 diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 563982ec2af4..56a51a8d97e6 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -136,9 +136,6 @@ enum PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, PROP_DIAGRAM_AUTOMATIC_SIZE, - PROP_DIAGRAM_DATATABLEHBORDER, - PROP_DIAGRAM_DATATABLEVBORDER, - PROP_DIAGRAM_DATATABLEOUTLINE, PROP_DIAGRAM_EXTERNALDATA }; @@ -380,21 +377,7 @@ void lcl_AddPropertiesToVector( cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableHBorder", - PROP_DIAGRAM_DATATABLEHBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableVBorder", - PROP_DIAGRAM_DATATABLEVBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableOutline", - PROP_DIAGRAM_DATATABLEOUTLINE, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "ExternalData", PROP_DIAGRAM_EXTERNALDATA, cppu::UnoType<OUString>::get(), commit a88cd545badcd5ee75b9446244c4f78e7950ed84 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu May 19 21:52:15 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 chart2: use {V,H}Border, Outline Data Table props. at rendering insert DataTable class into DataTableView, so it is possible to take the properties into account when rendering. Change rendering: VBorder - draw vert. border of data table HBorder - draw horiz. border of data table Outline - draw the outline borders of a data table Change-Id: I8348d0672d9c188014d664d667abddde8ebbc7c0 diff --git a/chart2/source/view/axes/VCartesianAxis.cxx b/chart2/source/view/axes/VCartesianAxis.cxx index 4cae0cee958d..bb7f0090eb93 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1996,7 +1996,7 @@ void VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlot { if (m_aAxisProperties.m_bDisplayDataTable) { - m_pDataTableView.reset(new DataTableView); + m_pDataTableView.reset(new DataTableView(m_aAxisProperties.m_xDataTableModel)); m_pDataTableView->initializeValues(rSeriesPlotterList); m_xNumberFormatsSupplier = xNumberFormatsSupplier; } diff --git a/chart2/source/view/inc/DataTableView.hxx b/chart2/source/view/inc/DataTableView.hxx index 517de9699d9e..3f4d97629035 100644 --- a/chart2/source/view/inc/DataTableView.hxx +++ b/chart2/source/view/inc/DataTableView.hxx @@ -12,6 +12,7 @@ #include <svx/unoshape.hxx> #include <svx/unodraw/SvxTableShape.hxx> #include <com/sun/star/awt/Rectangle.hpp> +#include <DataTable.hxx> namespace chart { @@ -21,17 +22,18 @@ class DataTableView final { rtl::Reference<SvxShapeGroupAnyD> m_xTarget; rtl::Reference<SvxTableShape> m_xTableShape; + rtl::Reference<DataTable> m_xDataTableModel; std::vector<OUString> m_aDataSeriesNames; std::vector<OUString> m_aXValues; std::vector<std::vector<OUString>> m_pDataSeriesValues; public: - DataTableView(); + DataTableView(rtl::Reference<DataTable> const& rDataTableModel); 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); + sal_Int32 nColumnWidth); }; } //namespace chart diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index 7d29f0e4276d..92714a8a85ba 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -30,11 +30,15 @@ using namespace css; namespace chart { -DataTableView::DataTableView() = default; +DataTableView::DataTableView(rtl::Reference<DataTable> const& rDataTableModel) + : m_xDataTableModel(rDataTableModel) +{ +} namespace { -void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet) +void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool bLeft, bool bTop, + bool bRight, bool bBottom) { xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF))); xPropertySet->setPropertyValue("TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_TOP)); @@ -44,10 +48,14 @@ void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet) 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)); + if (bLeft) + xPropertySet->setPropertyValue("LeftBorder", uno::Any(aBorderLine)); + if (bTop) + xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine)); + if (bRight) + xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine)); + if (bBottom) + xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine)); } void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet) @@ -65,7 +73,7 @@ void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet) } } void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector const& rEnd, - sal_Int32 nColumnSize) + sal_Int32 nColumnWidth) { if (!m_xTarget.is()) return; @@ -74,7 +82,6 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV m_xTableShape = ShapeFactory::createTable(m_xTarget); uno::Reference<table::XTable> xTable; - uno::Reference<util::XBroadcaster> xBroadcaster; try { auto rDelta = rEnd - rStart; @@ -86,18 +93,31 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV return; } - if (xTable.is()) - xBroadcaster.set(xTable, uno::UNO_QUERY); + if (!xTable.is()) + return; + + uno::Reference<util::XBroadcaster> xBroadcaster(xTable, uno::UNO_QUERY); if (!xBroadcaster.is()) return; xBroadcaster->lockBroadcasts(); + + bool bHBorder = false; + bool bVBorder = false; + bool bOutline = false; + + m_xDataTableModel->getPropertyValue("HBorder") >>= bHBorder; + m_xDataTableModel->getPropertyValue("VBorder") >>= bVBorder; + m_xDataTableModel->getPropertyValue("Outline") >>= bOutline; + + sal_Int32 nColumnCount = m_aXValues.size(); uno::Reference<table::XTableColumns> xTableColumns = xTable->getColumns(); - xTableColumns->insertByIndex(0, m_aXValues.size()); + xTableColumns->insertByIndex(0, nColumnCount); + sal_Int32 nRowCount = m_aDataSeriesNames.size(); uno::Reference<table::XTableRows> xTableRows = xTable->getRows(); - xTableRows->insertByIndex(0, m_aDataSeriesNames.size()); + xTableRows->insertByIndex(0, nRowCount); { uno::Reference<table::XCell> xCell = xTable->getCellByPosition(0, 0); @@ -120,7 +140,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV if (xCellTextRange.is()) { xCellTextRange->setString(rString); - setCellDefaults(xPropertySet); + bool bLeft = bOutline || (bVBorder && nColumn > 1); + setCellDefaults(xPropertySet, bLeft, bOutline, bOutline, bOutline); } nColumn++; } @@ -133,8 +154,9 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY); if (xCellTextRange.is()) { + bool bTop = bOutline || (bHBorder && nRow > 1); xCellTextRange->setString(rSeriesName); - setCellDefaults(xPropertySet); + setCellDefaults(xPropertySet, bOutline, bTop, bOutline, bOutline); } nRow++; } @@ -151,7 +173,25 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV if (xCellTextRange.is()) { xCellTextRange->setString(rValue); - setCellDefaults(xPropertySet); + + bool bLeft = false; + bool bTop = false; + bool bRight = false; + bool bBottom = false; + + if (nColumn > 1 && bVBorder) + bLeft = true; + + if (nRow > 1 && bHBorder) + bTop = true; + + if (nRow == nRowCount && bOutline) + bBottom = true; + + if (nColumn == nColumnCount && bOutline) + bRight = true; + + setCellDefaults(xPropertySet, bLeft, bTop, bRight, bBottom); } nColumn++; } @@ -161,7 +201,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV xBroadcaster->unlockBroadcasts(); auto* pTableObject = static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject()); - pTableObject->DistributeColumns(0, pTableObject->getColumnCount() - 1, true, true); + pTableObject->DistributeColumns(0, nColumnCount - 1, true, true); uno::Reference<beans::XPropertySet> xPropertySet(xTableColumns->getByIndex(0), uno::UNO_QUERY); sal_Int32 nWidth = 0; @@ -172,7 +212,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV for (sal_Int32 i = 1; i < xTableColumns->getCount(); ++i) { xPropertySet.set(xTableColumns->getByIndex(i), uno::UNO_QUERY); - xPropertySet->setPropertyValue("Width", uno::Any(nColumnSize)); + xPropertySet->setPropertyValue("Width", uno::Any(nColumnWidth)); } } commit eb534fe36dd41aa44972fba940e203f581a4ec38 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 16 16:19:39 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 oox: support reading text and shape properties for a data table Change-Id: I740d3bd6af11457ecb54878be648ad1e22b9d4b8 diff --git a/oox/inc/drawingml/chart/datatablemodel.hxx b/oox/inc/drawingml/chart/datatablemodel.hxx index 5c7fe7901200..937dbb3c60a6 100644 --- a/oox/inc/drawingml/chart/datatablemodel.hxx +++ b/oox/inc/drawingml/chart/datatablemodel.hxx @@ -28,6 +28,9 @@ struct DataTableModel bool mbShowOutline : 1; /// Show outline bool mbShowKeys : 1; + ModelRef<Shape> mxShapeProp; /// frame formatting. + ModelRef<TextBody> mxTextProp; /// text formatting. + DataTableModel() : mbShowHBorder(false) , mbShowVBorder(false) diff --git a/oox/source/drawingml/chart/datatablecontext.cxx b/oox/source/drawingml/chart/datatablecontext.cxx index 0813a6424312..c277dae5f4d6 100644 --- a/oox/source/drawingml/chart/datatablecontext.cxx +++ b/oox/source/drawingml/chart/datatablecontext.cxx @@ -18,7 +18,8 @@ */ #include <drawingml/chart/datatablecontext.hxx> - +#include <drawingml/shapepropertiescontext.hxx> +#include <drawingml/textbodycontext.hxx> #include <drawingml/chart/plotareamodel.hxx> #include <oox/core/xmlfilterbase.hxx> #include <oox/helper/attributelist.hxx> @@ -57,6 +58,10 @@ ContextHandlerRef DataTableContext::onCreateContext(sal_Int32 nElement, case C_TOKEN(showKeys): mrModel.mbShowKeys = rAttribs.getBool(XML_val, false); break; + case C_TOKEN(spPr): + return new ShapePropertiesContext(*this, mrModel.mxShapeProp.create()); + case C_TOKEN(txPr): + return new TextBodyContext(*this, mrModel.mxTextProp.create()); } break; } diff --git a/oox/source/drawingml/chart/datatableconverter.cxx b/oox/source/drawingml/chart/datatableconverter.cxx index 3c477c5d7507..4e42b7468ebc 100644 --- a/oox/source/drawingml/chart/datatableconverter.cxx +++ b/oox/source/drawingml/chart/datatableconverter.cxx @@ -55,6 +55,9 @@ void DataTableConverter::convertFromModel(uno::Reference<chart2::XDiagram> const aPropSet.setProperty(PROP_Outline, mrModel.mbShowOutline); if (mrModel.mbShowKeys) aPropSet.setProperty(PROP_Keys, mrModel.mbShowKeys); + + getFormatter().convertFormatting(aPropSet, mrModel.mxShapeProp, mrModel.mxTextProp, + OBJECTTYPE_DATATABLE); } catch (uno::Exception&) { commit b0a200009db3d48ec663ec8a4993a45bed999be4 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 16 16:10:02 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 chart2: add DataTable to AxisProperties, take account at rendering The Diagram model has the DataTable class, but now we need to take this into account at rendering. First add the DataTable to AxisProperties, to decide if the data table should be rendered or not. Change-Id: Ia18fcffccc632e4d36011544066072ae3cdfbfc7 diff --git a/chart2/source/view/axes/VAxisProperties.cxx b/chart2/source/view/axes/VAxisProperties.cxx index 8bbcb490fa2a..d0988998c40f 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -152,8 +152,9 @@ TickmarkProperties AxisProperties::getBiggestTickmarkProperties() return aTickmarkProperties; } -AxisProperties::AxisProperties( const rtl::Reference< Axis >& xAxisModel - , ExplicitCategoriesProvider* pExplicitCategoriesProvider ) +AxisProperties::AxisProperties(rtl::Reference<::chart::Axis> const& xAxisModel, + ExplicitCategoriesProvider* pExplicitCategoriesProvider, + rtl::Reference<::chart::DataTable> const& xDataTableModel) : m_xAxisModel(xAxisModel) , m_nDimensionIndex(0) , m_bIsMainAxis(true) @@ -173,6 +174,7 @@ AxisProperties::AxisProperties( const rtl::Reference< Axis >& xAxisModel , m_bComplexCategories(false) , m_pExplicitCategoriesProvider(pExplicitCategoriesProvider) , m_bLimitSpaceForLabels(false) + , m_xDataTableModel(xDataTableModel) { } @@ -255,7 +257,9 @@ void AxisProperties::init( bool bCartesian ) if( bCartesian ) { if (m_nDimensionIndex == 0) - m_bDisplayDataTable = true; + { + m_bDisplayDataTable = m_xDataTableModel.is(); + } if( m_nDimensionIndex == 0 && m_nAxisType == AxisType::CATEGORY && m_pExplicitCategoriesProvider && m_pExplicitCategoriesProvider->hasComplexCategories() ) diff --git a/chart2/source/view/axes/VAxisProperties.hxx b/chart2/source/view/axes/VAxisProperties.hxx index 78dbb7e3718d..5742e385d687 100644 --- a/chart2/source/view/axes/VAxisProperties.hxx +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -20,6 +20,7 @@ #include "TickmarkProperties.hxx" #include <LabelAlignment.hxx> +#include <DataTable.hxx> #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> @@ -139,10 +140,13 @@ struct AxisProperties final bool m_bLimitSpaceForLabels; + rtl::Reference<::chart::DataTable> m_xDataTableModel; + //methods: - AxisProperties( const rtl::Reference< ::chart::Axis >& xAxisModel - , ExplicitCategoriesProvider* pExplicitCategoriesProvider ); + AxisProperties(rtl::Reference<::chart::Axis> const& xAxisModel, + ExplicitCategoriesProvider* pExplicitCategoriesProvider, + rtl::Reference<::chart::DataTable> const& xDataTableModel); void init(bool bCartesian=false);//init from model data (m_xAxisModel) diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx index e1a2ba5046e3..cd0d49188a1c 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -23,6 +23,8 @@ #include <BaseCoordinateSystem.hxx> #include <AxisIndexDefines.hxx> #include <Axis.hxx> +#include <DataTable.hxx> +#include <Diagram.hxx> #include <AxisHelper.hxx> #include <cppuhelper/implbase.hxx> #include <ChartModel.hxx> @@ -130,7 +132,8 @@ void VCartesianCoordinateSystem::createVAxisList( if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel )) continue; - AxisProperties aAxisProperties(xAxis,getExplicitCategoriesProvider()); + rtl::Reference<Diagram> xDiagram(xChartDoc->getFirstChartDiagram()); + AxisProperties aAxisProperties(xAxis, getExplicitCategoriesProvider(), xDiagram->getDataTableRef()); aAxisProperties.m_nDimensionIndex = nDimensionIndex; aAxisProperties.m_bSwapXAndY = bSwapXAndY; aAxisProperties.m_bIsMainAxis = (nAxisIndex==0); diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx index 3a3351a54fc3..338a1c4ab7ed 100644 --- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx +++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx @@ -24,6 +24,8 @@ #include <AxisIndexDefines.hxx> #include <Axis.hxx> #include <AxisHelper.hxx> +#include <Diagram.hxx> +#include <DataTable.hxx> #include <ChartModel.hxx> namespace chart @@ -90,7 +92,9 @@ void VPolarCoordinateSystem::createVAxisList( rtl::Reference< Axis > xAxis = getAxisByDimension(nDimensionIndex,nAxisIndex); if(!xAxis.is() || !AxisHelper::shouldAxisBeDisplayed( xAxis, m_xCooSysModel )) continue; - AxisProperties aAxisProperties(xAxis,getExplicitCategoriesProvider()); + + rtl::Reference<Diagram> xDiagram(xChartDoc->getFirstChartDiagram()); + AxisProperties aAxisProperties(xAxis,getExplicitCategoriesProvider(), xDiagram->getDataTableRef()); aAxisProperties.init(); if(aAxisProperties.m_bDisplayLabels) aAxisProperties.m_nNumberFormatKey = getNumberFormatKeyForAxis(xAxis, xChartDoc); commit f7356bc7ad6d18fc85e157fe43bde3f1e4e4fb5e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 16 15:53:59 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 oox: add data table and props. with the new UNO DataTable service Refactor filling of the old data table UNO properties to use the new service DataTable and its properties. Change-Id: Iee611c88bec6f58a50b5ae09d3acffd16e0b6dd9 diff --git a/oox/source/drawingml/chart/datatableconverter.cxx b/oox/source/drawingml/chart/datatableconverter.cxx index 802edc9464ac..3c477c5d7507 100644 --- a/oox/source/drawingml/chart/datatableconverter.cxx +++ b/oox/source/drawingml/chart/datatableconverter.cxx @@ -20,6 +20,7 @@ #include <drawingml/chart/datatableconverter.hxx> #include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XDataTable.hpp> #include <drawingml/chart/plotareamodel.hxx> #include <oox/token/properties.hxx> @@ -36,13 +37,28 @@ DataTableConverter::~DataTableConverter() = default; void DataTableConverter::convertFromModel(uno::Reference<chart2::XDiagram> const& rxDiagram) { - PropertySet aPropSet(rxDiagram); - if (mrModel.mbShowHBorder) - aPropSet.setProperty(PROP_DataTableHBorder, mrModel.mbShowHBorder); - if (mrModel.mbShowVBorder) - aPropSet.setProperty(PROP_DataTableVBorder, mrModel.mbShowVBorder); - if (mrModel.mbShowOutline) - aPropSet.setProperty(PROP_DataTableOutline, mrModel.mbShowOutline); + if (!rxDiagram.is()) + return; + + try + { + uno::Reference<chart2::XDataTable> xDataTable( + createInstance("com.sun.star.chart2.DataTable"), uno::UNO_QUERY_THROW); + rxDiagram->setDataTable(xDataTable); + + PropertySet aPropSet(xDataTable); + if (mrModel.mbShowHBorder) + aPropSet.setProperty(PROP_HBorder, mrModel.mbShowHBorder); + if (mrModel.mbShowVBorder) + aPropSet.setProperty(PROP_VBorder, mrModel.mbShowVBorder); + if (mrModel.mbShowOutline) + aPropSet.setProperty(PROP_Outline, mrModel.mbShowOutline); + if (mrModel.mbShowKeys) + aPropSet.setProperty(PROP_Keys, mrModel.mbShowKeys); + } + catch (uno::Exception&) + { + } } } // namespace oox diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx index afbb28adee03..18c0fd774feb 100644 --- a/oox/source/drawingml/chart/plotareaconverter.cxx +++ b/oox/source/drawingml/chart/plotareaconverter.cxx @@ -433,8 +433,11 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel ) nAxesSetIdx = 1 - nAxesSetIdx; } - DataTableConverter dataTableConverter (*this, mrModel.mxDataTable.getOrCreate()); - dataTableConverter.convertFromModel(xDiagram); + if (mrModel.mxDataTable) + { + DataTableConverter dataTableConverter(*this, *mrModel.mxDataTable.get()); + dataTableConverter.convertFromModel(xDiagram); + } // plot area formatting if( xDiagram.is() && !mb3dChart ) diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 8467d3683875..904ba3f35c0e 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -127,9 +127,6 @@ D3DSceneLightOn2 D3DScenePerspective D3DSceneShadeMode DDELinks -DataTableHBorder -DataTableOutline -DataTableVBorder DatabaseRanges Decoration DefaultScrollValue @@ -246,6 +243,7 @@ HasVerticalScrollBar HasXAxisTitle HasYAxisTitle HasZAxisTitle +HBorder HeaderBodyDistance HeaderHeight HeaderIsDynamicHeight @@ -293,6 +291,7 @@ IsVisible IterationCount IterationEpsilon Japanese +Keys Label LabelBorderColor LabelBorderStyle @@ -364,6 +363,7 @@ OpCodeMap Opaque Orientation OutputPosition +Outline OverlapSequence Overlay PageScale @@ -585,6 +585,7 @@ UseSelectedPage VScroll Validation Value +VBorder VaryColorsByPoint VertJustify VertJustifyMethod commit 78ab3ca4517bddcca1d816da2c16dd6a6e2b760c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 16 15:27:46 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:40 2022 +0900 [API-CHANGE] chart data table implementation Adds new service DataTable, which is reposible for the properties of a data table for a chart. Also removes the existing properties related to the data table from Diagram service, which were added prematurely in the past, without a data table actually being supported by the chart module. Also adds an implementation of the DataTable service in chart2 module. Change-Id: I0c6b32163745704c623d04baaf0ce0e208c107f5 diff --git a/chart2/Library_chartcore.mk b/chart2/Library_chartcore.mk index 3d3806e14c27..4c93c6d2c3ec 100644 --- a/chart2/Library_chartcore.mk +++ b/chart2/Library_chartcore.mk @@ -130,6 +130,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcore,\ chart2/source/model/main/DataPointProperties \ chart2/source/model/main/DataSeries \ chart2/source/model/main/DataSeriesProperties \ + chart2/source/model/main/DataTable \ chart2/source/model/main/Diagram \ chart2/source/model/main/FormattedString \ chart2/source/model/main/GridProperties \ diff --git a/chart2/source/chartcore.component b/chart2/source/chartcore.component index f58ba98ba3ac..d15c808919df 100644 --- a/chart2/source/chartcore.component +++ b/chart2/source/chartcore.component @@ -219,6 +219,13 @@ <service name="com.sun.star.drawing.LineProperties"/> <service name="com.sun.star.layout.LayoutElement"/> <service name="com.sun.star.style.CharacterProperties"/> + </implementation> + <implementation name="com.sun.star.comp.chart2.DataTable" + constructor="com_sun_star_comp_chart2_DataTable_get_implementation"> + <service name="com.sun.star.beans.PropertySet"/> + <service name="com.sun.star.chart2.DataTable"/> + <service name="com.sun.star.drawing.FillProperties"/> + <service name="com.sun.star.drawing.LineProperties"/> </implementation> <implementation name="com.sun.star.comp.chart2.PageBackground" constructor="com_sun_star_comp_chart2_PageBackground_get_implementation"> diff --git a/chart2/source/inc/DataTable.hxx b/chart2/source/inc/DataTable.hxx new file mode 100644 index 000000000000..4a41a40a1cbf --- /dev/null +++ b/chart2/source/inc/DataTable.hxx @@ -0,0 +1,89 @@ +/* -*- 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 "OPropertySet.hxx" +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/uno3.hxx> + +#include "charttoolsdllapi.hxx" +#include <com/sun/star/chart2/XDataTable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include "ModifyListenerHelper.hxx" + +namespace chart +{ +typedef cppu::WeakImplHelper<css::chart2::XDataTable, css::lang::XServiceInfo, + css::util::XCloneable, css::util::XModifyBroadcaster, + css::util::XModifyListener> + DataTable_Base; + +/** Data table implementation */ +class OOO_DLLPUBLIC_CHARTTOOLS DataTable final : public cppu::BaseMutex, + public DataTable_Base, + public ::property::OPropertySet +{ +public: + explicit DataTable(); + virtual ~DataTable() override; + + /// XServiceInfo declarations + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + /// merge XInterface implementations + DECLARE_XINTERFACE() + + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + + explicit DataTable(DataTable const& rOther); + +private: + // ____ OPropertySet ____ + virtual void GetDefaultValue(sal_Int32 nHandle, css::uno::Any& rAny) const override; + + // ____ OPropertySet ____ + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; + +public: + // ____ XPropertySet ____ + virtual css::uno::Reference<css::beans::XPropertySetInfo> + SAL_CALL getPropertySetInfo() override; + + // ____ XCloneable ____ + virtual css::uno::Reference<css::util::XCloneable> SAL_CALL createClone() override; + + // ____ XModifyBroadcaster ____ + virtual void SAL_CALL + addModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + virtual void SAL_CALL + removeModifyListener(const css::uno::Reference<css::util::XModifyListener>& aListener) override; + +private: + // ____ XModifyListener ____ + virtual void SAL_CALL modified(const css::lang::EventObject& aEvent) override; + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; + + // ____ OPropertySet ____ + virtual void firePropertyChangeEvent() override; + using OPropertySet::disposing; + + rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; +}; + +} // namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 3c0e31d8be6d..50cc2cb0dfcd 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -26,8 +26,8 @@ #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/XTitled.hpp> #include <com/sun/star/chart/X3DDefaultSetter.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include "ModifyListenerHelper.hxx" #include "charttoolsdllapi.hxx" @@ -41,6 +41,7 @@ namespace chart { class BaseCoordinateSystem; class Legend; +class DataTable; class Wall; namespace impl @@ -110,6 +111,9 @@ public: const css::uno::Reference< css::chart2::data::XDataSource >& xDataSource, const css::uno::Sequence< css::beans::PropertyValue >& aArguments ) override; + virtual css::uno::Reference<css::chart2::XDataTable> SAL_CALL getDataTable() override; + virtual void SAL_CALL setDataTable(const css::uno::Reference<css::chart2::XDataTable>& xDataTable) override; + // ____ XCoordinateSystemContainer ____ virtual void SAL_CALL addCoordinateSystem( const css::uno::Reference< css::chart2::XCoordinateSystem >& aCoordSys ) override; @@ -150,8 +154,14 @@ public: const rtl::Reference< ::chart::Legend > & getLegend2() const { return m_xLegend; } void setLegend(const rtl::Reference< ::chart::Legend > &); -private: + void setDataTable(const rtl::Reference<::chart::DataTable>& xNewDataTable); + + rtl::Reference<::chart::DataTable> const& getDataTableRef() const + { + return m_xDataTable; + }; +private: // ____ XModifyListener ____ virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; @@ -175,6 +185,7 @@ private: css::uno::Reference<css::chart2::XTitle> m_xTitle; rtl::Reference<::chart::Legend> m_xLegend; + rtl::Reference<::chart::DataTable> m_xDataTable; css::uno::Reference<css::chart2::XColorScheme> m_xColorScheme; rtl::Reference<ModifyEventForwarder> m_xModifyEventForwarder; diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx new file mode 100644 index 000000000000..12e08e28b3e4 --- /dev/null +++ b/chart2/source/model/main/DataTable.cxx @@ -0,0 +1,234 @@ +/* -*- 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 <DataTable.hxx> + +#include <LinePropertiesHelper.hxx> +#include <FillProperties.hxx> +#include <CharacterProperties.hxx> +#include <ModifyListenerHelper.hxx> +#include <PropertyHelper.hxx> +#include <cppuhelper/supportsservice.hxx> + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <algorithm> + +using namespace css; + +namespace +{ +enum +{ + DataTableProperty_Show, + DataTableProperty_HorizontalBorder, + DataTableProperty_VerticalBorder, + DataTableProperty_Outilne, + DataTableProperty_Keys, +}; + +void lcl_AddPropertiesToVector(std::vector<beans::Property>& rOutProperties) +{ + rOutProperties.emplace_back("Show", DataTableProperty_Show, cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "HBorder", DataTableProperty_HorizontalBorder, cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back( + "VBorder", DataTableProperty_VerticalBorder, cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back("Outline", DataTableProperty_Outilne, cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT); + rOutProperties.emplace_back("Keys", DataTableProperty_Keys, cppu::UnoType<bool>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT); +} + +struct StaticLegendDefaults_Initializer +{ + chart::tPropertyValueMap* operator()() + { + static chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap(aStaticDefaults); + return &aStaticDefaults; + } + +private: + static void lcl_AddDefaultsToMap(::chart::tPropertyValueMap& aMap) + { + ::chart::LinePropertiesHelper::AddDefaultsToMap(aMap); + ::chart::FillProperties::AddDefaultsToMap(aMap); + ::chart::CharacterProperties::AddDefaultsToMap(aMap); + + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Show, false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder, + false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder, + false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false); + } +}; + +struct StaticLegendDefaults + : public rtl::StaticAggregate<::chart::tPropertyValueMap, StaticLegendDefaults_Initializer> +{ +}; + +struct StaticLegendInfoHelper_Initializer +{ + cppu::OPropertyArrayHelper* operator()() + { + static cppu::OPropertyArrayHelper aPropHelper(lcl_GetPropertySequence()); + return &aPropHelper; + } + +private: + static uno::Sequence<beans::Property> lcl_GetPropertySequence() + { + std::vector<beans::Property> aProperties; + lcl_AddPropertiesToVector(aProperties); + chart::LinePropertiesHelper::AddPropertiesToVector(aProperties); + chart::FillProperties::AddPropertiesToVector(aProperties); + std::sort(aProperties.begin(), aProperties.end(), chart::PropertyNameLess()); + + return comphelper::containerToSequence(aProperties); + } +}; + +struct StaticLegendInfoHelper + : public rtl::StaticAggregate<::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer> +{ +}; + +struct StaticLegendInfo_Initializer +{ + uno::Reference<beans::XPropertySetInfo>* operator()() + { + static uno::Reference<beans::XPropertySetInfo> xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLegendInfoHelper::get())); + return &xPropertySetInfo; + } +}; + +struct StaticLegendInfo : public rtl::StaticAggregate<uno::Reference<beans::XPropertySetInfo>, + StaticLegendInfo_Initializer> +{ +}; + +} // anonymous namespace + +namespace chart +{ +DataTable::DataTable() + : ::property::OPropertySet(m_aMutex) + , m_xModifyEventForwarder(new ModifyEventForwarder()) +{ +} + +DataTable::DataTable(const DataTable& rOther) + : DataTable_Base(rOther) + , ::property::OPropertySet(rOther, m_aMutex) + , m_xModifyEventForwarder(new ModifyEventForwarder()) +{ +} + +DataTable::~DataTable() = default; + +// ____ XCloneable ____ +uno::Reference<util::XCloneable> SAL_CALL DataTable::createClone() +{ + return uno::Reference<util::XCloneable>(new DataTable(*this)); +} + +// ____ XModifyBroadcaster ____ +void SAL_CALL DataTable::addModifyListener(const uno::Reference<util::XModifyListener>& aListener) +{ + m_xModifyEventForwarder->addModifyListener(aListener); +} + +void SAL_CALL +DataTable::removeModifyListener(const uno::Reference<util::XModifyListener>& aListener) +{ + m_xModifyEventForwarder->removeModifyListener(aListener); +} + +// ____ XModifyListener ____ +void SAL_CALL DataTable::modified(const lang::EventObject& aEvent) +{ + m_xModifyEventForwarder->modified(aEvent); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL DataTable::disposing(const lang::EventObject& /* Source */) +{ + // nothing +} + +// ____ OPropertySet ____ +void DataTable::firePropertyChangeEvent() +{ + m_xModifyEventForwarder->modified(lang::EventObject(static_cast<uno::XWeak*>(this))); +} + +// ____ OPropertySet ____ +void DataTable::GetDefaultValue(sal_Int32 nHandle, uno::Any& rAny) const +{ + const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get(); + auto aFound = rStaticDefaults.find(nHandle); + if (aFound == rStaticDefaults.end()) + rAny.clear(); + else + rAny = (*aFound).second; +} + +::cppu::IPropertyArrayHelper& SAL_CALL DataTable::getInfoHelper() +{ + return *StaticLegendInfoHelper::get(); +} + +// ____ XPropertySet ____ +uno::Reference<beans::XPropertySetInfo> SAL_CALL DataTable::getPropertySetInfo() +{ + return *StaticLegendInfo::get(); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +OUString SAL_CALL DataTable::getImplementationName() +{ + return "com.sun.star.comp.chart2.DataTable"; +} + +sal_Bool SAL_CALL DataTable::supportsService(const OUString& rServiceName) +{ + return cppu::supportsService(this, rServiceName); +} + +uno::Sequence<OUString> SAL_CALL DataTable::getSupportedServiceNames() +{ + return { "com.sun.star.chart2.DataTable", "com.sun.star.beans.PropertySet", + "com.sun.star.drawing.FillProperties", "com.sun.star.drawing.LineProperties" }; +} + +IMPLEMENT_FORWARD_XINTERFACE2(DataTable, DataTable_Base, ::property::OPropertySet) +IMPLEMENT_FORWARD_XTYPEPROVIDER2(DataTable, DataTable_Base, ::property::OPropertySet) + +} // namespace chart + +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_chart2_DataTable_get_implementation( + css::uno::XComponentContext* /*pComponentContext*/, uno::Sequence<uno::Any> const& /*rAny*/) +{ + return cppu::acquire(new chart::DataTable); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index b1cfa0786f83..2225071f2768 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -32,6 +32,7 @@ #include <unonames.hxx> #include <BaseCoordinateSystem.hxx> #include <Legend.hxx> +#include <DataTable.hxx> #include <basegfx/numeric/ftools.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> @@ -160,21 +161,6 @@ void lcl_AddPropertiesToVector( PROP_DIAGRAM_3DRELATIVEHEIGHT, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::MAYBEVOID ); - rOutProperties.emplace_back( "DataTableHBorder", - PROP_DIAGRAM_DATATABLEHBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableVBorder", - PROP_DIAGRAM_DATATABLEVBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableOutline", - PROP_DIAGRAM_DATATABLEOUTLINE, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); rOutProperties.emplace_back( "ExternalData", PROP_DIAGRAM_EXTERNALDATA, cppu::UnoType<OUString>::get(), @@ -192,9 +178,6 @@ const ::chart::tPropertyValueMap& StaticDiagramDefaults() ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); - ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEHBORDER, false ); - ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEVBORDER, false ); - ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEOUTLINE, false ); ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 ); ::chart::SceneProperties::AddDefaultsToMap( aMap ); @@ -663,6 +646,36 @@ void SAL_CALL Diagram::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) co ::property::OPropertySet::getFastPropertyValue( rValue,nHandle ); } +uno::Reference<chart2::XDataTable> SAL_CALL Diagram::getDataTable() +{ + MutexGuard aGuard(m_aMutex); + return m_xDataTable; +} + +void SAL_CALL Diagram::setDataTable(const uno::Reference<chart2::XDataTable>& xDataTable) +{ + auto* pDataTable = dynamic_cast<DataTable*>(xDataTable.get()); + assert(!xDataTable || pDataTable); + setDataTable(rtl::Reference<DataTable>(pDataTable)); +} + +void Diagram::setDataTable(const rtl::Reference<DataTable>& xNewDataTable) +{ + rtl::Reference<DataTable> xOldDataTable; + { + MutexGuard aGuard(m_aMutex); + if (m_xDataTable == xNewDataTable) + return; + xOldDataTable = m_xDataTable; + m_xDataTable = xNewDataTable; + } + if (xOldDataTable.is()) + ModifyListenerHelper::removeListener(xOldDataTable, m_xModifyEventForwarder); + if (xNewDataTable.is()) + ModifyListenerHelper::addListener(xNewDataTable, m_xModifyEventForwarder); + fireModifyEvent(); +} + using impl::Diagram_Base; IMPLEMENT_FORWARD_XINTERFACE2( Diagram, Diagram_Base, ::property::OPropertySet ) diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index a9b92639a667..c43f293fca87 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -647,6 +647,7 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,com/sun/star/chart2,\ DataPoint \ DataPointProperties \ DataSeries \ + DataTable \ Diagram \ ErrorBar \ GridProperties \ @@ -2036,6 +2037,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/chart2,\ XDataPointCustomLabelField \ XDataSeries \ XDataSeriesContainer \ + XDataTable \ XDefaultSizeTransmitter \ XDiagram \ XDiagramProvider \ diff --git a/offapi/com/sun/star/chart2/DataTable.idl b/offapi/com/sun/star/chart2/DataTable.idl new file mode 100644 index 000000000000..c6288ad994c3 --- /dev/null +++ b/offapi/com/sun/star/chart2/DataTable.idl @@ -0,0 +1,53 @@ +/* -*- 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/. + */ +#ifndef com_sun_star_chart2_DataTable_idl +#define com_sun_star_chart2_DataTable_idl + +#include <com/sun/star/beans/PropertySet.idl> +#include <com/sun/star/drawing/LineProperties.idl> +#include <com/sun/star/drawing/FillProperties.idl> + +module com +{ +module sun +{ +module star +{ +module chart2 +{ + +/** Describes a data table for a Diagram. + @since LibreOffice 7.4 + */ +service DataTable +{ + service com::sun::star::beans::PropertySet; + service com::sun::star::drawing::FillProperties; + service com::sun::star::drawing::LineProperties; + + /** The interface for registering and removing data table entries. + */ + interface ::com::sun::star::chart2::XDataTable; + + /** Determines, whether the data table should be rendered by the view. + */ + [property] boolean Show; + + [optional, property] boolean HBorder; + [optional, property] boolean VBorder; + [optional, property] boolean Outline; + [optional, property] boolean Keys; + +}; + +}; }; }; }; // com::sun::star::chart2 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/chart2/Diagram.idl b/offapi/com/sun/star/chart2/Diagram.idl index 2ae557e64c71..514f116e3aef 100644 --- a/offapi/com/sun/star/chart2/Diagram.idl +++ b/offapi/com/sun/star/chart2/Diagram.idl @@ -91,12 +91,6 @@ service Diagram [optional, property] boolean RightAngledAxes; - /** Chart Datatable flags - */ - [optional, property] boolean DataTableHBorder; - [optional, property] boolean DataTableVBorder; - [optional, property] boolean DataTableOutline; - /** Perspective of 3D charts ( [0,100] ). */ [optional, property] long Perspective; diff --git a/offapi/com/sun/star/chart2/XDataTable.idl b/offapi/com/sun/star/chart2/XDataTable.idl new file mode 100644 index 000000000000..48117b8c44b3 --- /dev/null +++ b/offapi/com/sun/star/chart2/XDataTable.idl @@ -0,0 +1,35 @@ +/* -*- 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/. + */ + +#ifndef com_sun_star_chart2_XDataTable_idl +#define com_sun_star_chart2_XDataTable_idl + +#include <com/sun/star/uno/XInterface.idl> + +module com +{ +module sun +{ +module star +{ +module chart2 +{ + +/** Interface for the data table of a diagram + @since LibreOffice 7.4 + */ +interface XDataTable : ::com::sun::star::uno::XInterface +{ +}; + +}; }; }; }; // com::sun::star::chart2 + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/chart2/XDiagram.idl b/offapi/com/sun/star/chart2/XDiagram.idl index a878759be40d..b95e19cb7d34 100644 --- a/offapi/com/sun/star/chart2/XDiagram.idl +++ b/offapi/com/sun/star/chart2/XDiagram.idl @@ -91,6 +91,15 @@ interface XDiagram : ::com::sun::star::uno::XInterface */ void setDiagramData( [in] com::sun::star::chart2::data::XDataSource xDataSource, [in] sequence< com::sun::star::beans::PropertyValue > aArguments ); + + + /** returns the data table + */ + XDataTable getDataTable(); + + /** sets a new data table. + */ + void setDataTable([in] XDataTable xDataTable); }; } ; // chart2 commit 2adb00d7b3dbc8fb4a74e79608fa505e28187a3c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri May 6 16:04:47 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Sat May 21 22:38:39 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 25a0f5d35c09..9ebf532529ce 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..ecef60dd5c98 100644 --- a/chart2/source/view/inc/VCoordinateSystem.hxx +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -20,6 +20,7 @@ #include "MinimumAndMaximumSupplier.hxx" #include <ThreeDHelper.hxx> +#include <VSeriesPlotter.hxx> #include <chartview/ExplicitScaleValues.hxx> #include <com/sun/star/drawing/HomogenMatrix.hpp> #include <com/sun/star/uno/Sequence.h> @@ -30,9 +31,6 @@ #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..7d29f0e4276d --- /dev/null +++ b/chart2/source/view/main/DataTableView.cxx @@ -0,0 +1,214 @@ +/* -*- 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; + + ShapeFactory::removeSubShapes(m_xTarget); + m_xTableShape = ShapeFactory::createTable(m_xTarget); + + 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()) + return; + + 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); ... etc. - the rest is truncated