Rebased ref, commits from common ancestor: commit 4208b0fac6111c9e5d438e2fe346e5987fcc8f4d Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jul 18 08:12:19 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 15:16:22 2022 +0200
chart2: Data table rendering of keys (legend symbols) Change-Id: Iff13b188df18fe8f9919274869774f53f2ea323b diff --git a/chart2/inc/ChartView.hxx b/chart2/inc/ChartView.hxx index 3fe2fedcf7e8..5c7e70e97900 100644 --- a/chart2/inc/ChartView.hxx +++ b/chart2/inc/ChartView.hxx @@ -104,8 +104,7 @@ private: public: ChartView() = delete; - ChartView(css::uno::Reference< css::uno::XComponentContext > xContext, - ChartModel& rModel); + ChartView(css::uno::Reference<css::uno::XComponentContext> xContext, ChartModel& rModel); virtual ~ChartView() override; @@ -185,6 +184,8 @@ public: void setViewDirty(); + css::uno::Reference<css::uno::XComponentContext> const& getComponentContext() { return m_xCC;} + /// See sfx2::XmlDump::dumpAsXml(). void dumpAsXml(xmlTextWriterPtr pWriter) const override; @@ -210,8 +211,7 @@ private: //methods private: //member ::osl::Mutex m_aMutex; - css::uno::Reference< css::uno::XComponentContext> - m_xCC; + css::uno::Reference< css::uno::XComponentContext> m_xCC; chart::ChartModel& mrChartModel; diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 814d3afd7858..30aead187dcb 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -244,7 +244,8 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter& rIter ) void VAxisBase::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/, uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/, - rtl::Reference<::chart::ChartModel> const& /*xChartDoc*/) + rtl::Reference<::chart::ChartModel> const& /*xChartDoc*/, + css::uno::Reference<css::uno::XComponentContext> const& /*rComponentContext*/) { } diff --git a/chart2/source/view/axes/VAxisBase.hxx b/chart2/source/view/axes/VAxisBase.hxx index 2c4123ba951d..4ee4f5e288ae 100644 --- a/chart2/source/view/axes/VAxisBase.hxx +++ b/chart2/source/view/axes/VAxisBase.hxx @@ -23,6 +23,7 @@ #include "Tickmarks.hxx" namespace com::sun::star::util { class XNumberFormatsSupplier; } +namespace com::sun::star::uno { class XComponentContext; } namespace chart { @@ -30,6 +31,7 @@ namespace chart class VSeriesPlotter; class DataTableView; class ChartModel; +class LegendEntryProvider; class VAxisBase : public VAxisOrGridBase { @@ -65,7 +67,8 @@ public: virtual void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, - rtl::Reference<::chart::ChartModel> const& xChartDoc); + rtl::Reference<::chart::ChartModel> const& xChartDoc, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext); 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 d7e78d5d2e85..293d1f0479a8 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1995,11 +1995,12 @@ void VCartesianAxis::createShapes() void VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, - rtl::Reference<::chart::ChartModel> const& xChartDoc) + rtl::Reference<::chart::ChartModel> const& xChartDoc, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext) { if (m_aAxisProperties.m_bDisplayDataTable) { - m_pDataTableView.reset(new DataTableView(xChartDoc, m_aAxisProperties.m_xDataTableModel)); + m_pDataTableView.reset(new DataTableView(xChartDoc, m_aAxisProperties.m_xDataTableModel, rComponentContext)); m_pDataTableView->initializeValues(rSeriesPlotterList); m_xNumberFormatsSupplier = xNumberFormatsSupplier; } diff --git a/chart2/source/view/axes/VCartesianAxis.hxx b/chart2/source/view/axes/VCartesianAxis.hxx index a9baca907bdd..132887510eff 100644 --- a/chart2/source/view/axes/VCartesianAxis.hxx +++ b/chart2/source/view/axes/VCartesianAxis.hxx @@ -23,7 +23,6 @@ namespace chart { - class VCartesianAxis : public VAxisBase { // public methods @@ -101,7 +100,8 @@ public: void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, css::uno::Reference<css::util::XNumberFormatsSupplier> const& xNumberFormatsSupplier, - rtl::Reference<::chart::ChartModel> const& xChartDoc) override; + rtl::Reference<::chart::ChartModel> const& xChartDoc, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext) 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 3ea42cb087a0..9f765223bf4d 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx @@ -104,7 +104,8 @@ void VCartesianCoordinateSystem::createVAxisList( const awt::Size& rFontReferenceSize, const awt::Rectangle& rMaximumSpaceForLabels, bool bLimitSpaceForLabels, - std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList) + std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, + uno::Reference<uno::XComponentContext> const& rComponentContext) { // note: using xChartDoc itself as XNumberFormatsSupplier would cause // a leak from VCartesianAxis due to cyclic reference @@ -166,7 +167,7 @@ void VCartesianCoordinateSystem::createVAxisList( apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, m_eBottomPos ); apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels); - apVAxis->createDataTableView(rSeriesPlotterList, xNumberFormatsSupplier, xChartDoc); + apVAxis->createDataTableView(rSeriesPlotterList, xNumberFormatsSupplier, xChartDoc, rComponentContext); } } } diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx index 4b7acf227867..968d97a21099 100644 --- a/chart2/source/view/axes/VCartesianCoordinateSystem.hxx +++ b/chart2/source/view/axes/VCartesianCoordinateSystem.hxx @@ -35,7 +35,8 @@ public: const css::awt::Size& rFontReferenceSize, const css::awt::Rectangle& rMaximumSpaceForLabels, bool bLimitSpaceForLabels, - std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList) override; + std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext) 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 1dc9aaac91e4..f8d517fd008a 100644 --- a/chart2/source/view/axes/VCoordinateSystem.cxx +++ b/chart2/source/view/axes/VCoordinateSystem.cxx @@ -327,7 +327,8 @@ void VCoordinateSystem::createVAxisList( const awt::Size& /* rFontReferenceSize */, const awt::Rectangle& /* rMaximumSpaceForLabels */, bool /* bLimitSpaceForLabels */, - std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/) + std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/, + uno::Reference<uno::XComponentContext> const& /*rComponentContext*/) { } diff --git a/chart2/source/view/axes/VPolarCoordinateSystem.cxx b/chart2/source/view/axes/VPolarCoordinateSystem.cxx index 338a1c4ab7ed..600447dd19d5 100644 --- a/chart2/source/view/axes/VPolarCoordinateSystem.cxx +++ b/chart2/source/view/axes/VPolarCoordinateSystem.cxx @@ -72,7 +72,8 @@ void VPolarCoordinateSystem::createVAxisList( const awt::Size& rFontReferenceSize, const awt::Rectangle& rMaximumSpaceForLabels, bool /*bLimitSpaceForLabels*/, - std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/) + std::vector<std::unique_ptr<VSeriesPlotter>>& /*rSeriesPlotterList*/, + css::uno::Reference<css::uno::XComponentContext> const& /*rComponentContext*/) { // 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 ecfb2ce4d19d..a2ea0220f8bc 100644 --- a/chart2/source/view/axes/VPolarCoordinateSystem.hxx +++ b/chart2/source/view/axes/VPolarCoordinateSystem.hxx @@ -39,7 +39,8 @@ public: const css::awt::Size& rFontReferenceSize, const css::awt::Rectangle& rMaximumSpaceForLabels, bool bLimitSpaceForLabels, - std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList) override; + std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext) override; virtual void initVAxisInList() override; virtual void updateScalesAndIncrementsOnAxes() override; diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx b/chart2/source/view/charttypes/VSeriesPlotter.cxx index fb93c6fd35fe..4b3295fed497 100644 --- a/chart2/source/view/charttypes/VSeriesPlotter.cxx +++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx @@ -2496,6 +2496,52 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntries( return aResult; } +std::vector<ViewLegendSymbol> VSeriesPlotter::createSymbols(const awt::Size& rEntryKeyAspectRatio + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const Reference<uno::XComponentContext>& xContext) +{ + std::vector<ViewLegendSymbol> aResult; + + if( xTarget.is() ) + { + bool bBreak = false; + bool bFirstSeries = true; + + for (std::vector<VDataSeriesGroup> const & rGroupVector : m_aZSlots) + { + for (VDataSeriesGroup const & rGroup : rGroupVector) + { + for (std::unique_ptr<VDataSeries> const & pSeries : rGroup.m_aSeriesVector) + { + if (!pSeries) + continue; + + if (!pSeries->getPropertiesOfSeries()->getPropertyValue("ShowLegendEntry").get<sal_Bool>()) + { + continue; + } + + std::vector<ViewLegendSymbol> aSeriesSymbols = createSymbolsForSeries(rEntryKeyAspectRatio, *pSeries, xTarget, xContext); + + //add series entries to the result now + + // use only the first series if VaryColorsByPoint is set for the first series + if (bFirstSeries && pSeries->isVaryColorsByPoint()) + bBreak = true; + + bFirstSeries = false; + + aResult.insert(aResult.end(), aSeriesSymbols.begin(), aSeriesSymbols.end()); + } + if (bBreak) + return aResult; + } + } + } + + return aResult; +} + namespace { bool lcl_HasVisibleLine( const uno::Reference< beans::XPropertySet >& xProps, bool& rbHasDashedLine ) @@ -2827,6 +2873,99 @@ std::vector< ViewLegendEntry > VSeriesPlotter::createLegendEntriesForSeries( return aResult; } +std::vector<ViewLegendSymbol> VSeriesPlotter::createSymbolsForSeries( + const awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const Reference<uno::XComponentContext>& xContext) +{ + std::vector<ViewLegendSymbol> aResult; + + if (!(xTarget.is() && xContext.is())) + return aResult; + + try + { + ViewLegendSymbol aEntry; + bool bVaryColorsByPoint = rSeries.isVaryColorsByPoint(); + bool bIsPie = m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE); + try + { + if (bIsPie) + { + bool bDonut = false; + if ((m_xChartTypeModel->getPropertyValue("UseRings") >>= bDonut) && bDonut) + bIsPie = false; + } + } + catch (const uno::Exception&) + { + } + + if (bVaryColorsByPoint || bIsPie) + { + Sequence< OUString > aCategoryNames; + if (m_pExplicitCategoriesProvider) + aCategoryNames = m_pExplicitCategoriesProvider->getSimpleCategories(); + Sequence<sal_Int32> deletedLegendEntries; + try + { + rSeries.getPropertiesOfSeries()->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntries; + } + catch (const uno::Exception&) + { + } + + for (sal_Int32 nIdx=0; nIdx < aCategoryNames.getLength(); ++nIdx) + { + bool deletedLegendEntry = false; + for (const auto& deletedLegendEntryIdx : std::as_const(deletedLegendEntries)) + { + if (nIdx == deletedLegendEntryIdx) + { + deletedLegendEntry = true; + break; + } + } + if (deletedLegendEntry) + continue; + + // symbol + rtl::Reference<SvxShapeGroup> xSymbolGroup(ShapeFactory::createGroup2D(xTarget)); + + // create the symbol + rtl::Reference<SvxShapeGroup> xShape = createLegendSymbolForPoint(rEntryKeyAspectRatio, rSeries, nIdx, xSymbolGroup); + + // set CID to symbol for selection + if (xShape.is()) + { + aEntry.xSymbol = xSymbolGroup; + } + } + } + else + { + // symbol + rtl::Reference<SvxShapeGroup> xSymbolGroup(ShapeFactory::createGroup2D(xTarget)); + + // create the symbol + rtl::Reference<SvxShapeGroup> xShape = createLegendSymbolForSeries(rEntryKeyAspectRatio, rSeries, xSymbolGroup ); + + // set CID to symbol for selection + if (xShape.is()) + { + aEntry.xSymbol = xSymbolGroup; + } + aResult.push_back(aEntry); + } + } + catch (const uno::Exception &) + { + DBG_UNHANDLED_EXCEPTION("chart2" ); + } + return aResult; +} + VSeriesPlotter* VSeriesPlotter::createSeriesPlotter( const rtl::Reference<ChartType>& xChartTypeModel , sal_Int32 nDimensionCount diff --git a/chart2/source/view/inc/DataTableView.hxx b/chart2/source/view/inc/DataTableView.hxx index 8a0f11bed772..3d00a9644ba3 100644 --- a/chart2/source/view/inc/DataTableView.hxx +++ b/chart2/source/view/inc/DataTableView.hxx @@ -12,6 +12,9 @@ #include <svx/unoshape.hxx> #include <svx/unodraw/SvxTableShape.hxx> #include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <DataTable.hxx> #include "VLineProperties.hxx" @@ -19,6 +22,7 @@ namespace chart { class VSeriesPlotter; class ChartModel; +class LegendEntryProvider; class DataTableView final { @@ -27,18 +31,24 @@ private: rtl::Reference<SvxShapeGroupAnyD> m_xTarget; rtl::Reference<SvxTableShape> m_xTableShape; rtl::Reference<DataTable> m_xDataTableModel; + css::uno::Reference<css::uno::XComponentContext> m_xComponentContext; VLineProperties m_aLineProperties; + std::vector<VSeriesPlotter*> m_pSeriesPlotterList; 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); + void + setCellCharAndParagraphProperties(css::uno::Reference<css::beans::XPropertySet>& xPropertySet); + + void setCellProperties(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, bool bLeft, + bool bTop, bool bRight, bool bBottom); public: DataTableView(rtl::Reference<::chart::ChartModel> const& xChartDoc, - rtl::Reference<DataTable> const& rDataTableModel); + rtl::Reference<DataTable> const& rDataTableModel, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext); 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/inc/LegendEntryProvider.hxx b/chart2/source/view/inc/LegendEntryProvider.hxx index e0133771cd27..d89447f38429 100644 --- a/chart2/source/view/inc/LegendEntryProvider.hxx +++ b/chart2/source/view/inc/LegendEntryProvider.hxx @@ -66,6 +66,15 @@ struct ViewLegendEntry css::uno::Reference< css::chart2::XFormattedString2 > > aLabel; }; + +struct ViewLegendSymbol +{ + /** The legend symbol that represents a data series or other + information contained in the legend + */ + rtl::Reference<SvxShapeGroup> xSymbol; +}; + class LegendEntryProvider { public: diff --git a/chart2/source/view/inc/VCoordinateSystem.hxx b/chart2/source/view/inc/VCoordinateSystem.hxx index 50d1cd9b2c4f..a9643bf967ad 100644 --- a/chart2/source/view/inc/VCoordinateSystem.hxx +++ b/chart2/source/view/inc/VCoordinateSystem.hxx @@ -39,6 +39,7 @@ namespace com::sun::star::chart2 { class XChartDocument; } namespace com::sun::star::chart2 { class XCoordinateSystem; } namespace com::sun::star::drawing { class XShapes; } namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class XComponentContext; } namespace chart { @@ -120,7 +121,8 @@ public: const css::awt::Size& rFontReferenceSize, const css::awt::Rectangle& rMaximumSpaceForLabels, bool bLimitSpaceForLabels, - std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList); + std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext); virtual void initVAxisInList(); virtual void updateScalesAndIncrementsOnAxes(); diff --git a/chart2/source/view/inc/VSeriesPlotter.hxx b/chart2/source/view/inc/VSeriesPlotter.hxx index 50901bf64a5a..eaf27495d0ed 100644 --- a/chart2/source/view/inc/VSeriesPlotter.hxx +++ b/chart2/source/view/inc/VSeriesPlotter.hxx @@ -216,6 +216,17 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext ); + std::vector<ViewLegendSymbol> createSymbols( + const css::awt::Size& rEntryKeyAspectRatio + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::uno::Reference<css::uno::XComponentContext>& xContext); + + std::vector<ViewLegendSymbol> createSymbolsForSeries( + const css::awt::Size& rEntryKeyAspectRatio + , const VDataSeries& rSeries + , const rtl::Reference<SvxShapeGroupAnyD>& xTarget + , const css::uno::Reference<css::uno::XComponentContext>& xContext); + std::vector<VDataSeries*> getAllSeries(); std::vector<VDataSeries const*> getAllSeries() const; diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 14ec725cadd2..282e76611081 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -536,8 +536,8 @@ awt::Rectangle ChartView::impl_createDiagramAndContent( const CreateShapeParam2D CuboidPlanePosition eBottomPos( ThreeDHelper::getAutomaticCuboidPlanePositionForStandardBottom( xDiagram ) ); rpVCooSys->set3DWallPositions( eLeftWallPos, eBackWallPos, eBottomPos ); } - - rpVCooSys->createVAxisList(&mrChartModel, rPageSize, rParam.maRemainingSpace, rParam.mbUseFixedInnerSize, rSeriesPlotterList); + rpVCooSys->createVAxisList(&mrChartModel, rPageSize, rParam.maRemainingSpace, + rParam.mbUseFixedInnerSize, rSeriesPlotterList, getComponentContext()); } // - prepare list of all axis and how they are used @@ -1376,9 +1376,12 @@ void ChartView::createShapes() if(!mxRootShape.is()) mxRootShape = ShapeFactory::getOrCreateChartRootShape( m_xDrawPage ); - SdrPage* pPage = ChartView::getSdrPage(); - if(pPage) //it is necessary to use the implementation here as the uno page does not provide a propertyset + SdrPage* pPage = getSdrPage(); + + if (pPage) //it is necessary to use the implementation here as the uno page does not provide a propertyset + { pPage->SetSize(Size(aPageSize.Width,aPageSize.Height)); + } else { OSL_FAIL("could not set page size correctly"); @@ -1910,7 +1913,7 @@ void ChartView::createShapes2D( const awt::Size& rPageSize ) } lcl_createLegend( - LegendHelper::getLegend( mrChartModel ), mxRootShape, m_xCC, + LegendHelper::getLegend( mrChartModel ), mxRootShape, getComponentContext(), aParam.maRemainingSpace, rPageSize, mrChartModel, aParam.mpSeriesPlotterContainer->getLegendEntryProviderList(), lcl_getDefaultWritingModeFromPool( m_pDrawModelWrapper ) ); diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index 64c76e5da885..981eb873669d 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/util/XBroadcaster.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <o3tl/unit_conversion.hxx> @@ -35,15 +36,6 @@ using namespace css; namespace chart { -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); - m_aLineProperties.initFromPropertySet(xProp); -} - namespace { void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet) @@ -65,10 +57,22 @@ void copyProperty(uno::Reference<beans::XPropertySet>& xOut, { xOut->setPropertyValue(sPropertyName, xIn->getPropertyValue(sPropertyName)); } +} // end anonymous namespace + +DataTableView::DataTableView( + rtl::Reference<::chart::ChartModel> const& xChartModel, + rtl::Reference<DataTable> const& rDataTableModel, + css::uno::Reference<css::uno::XComponentContext> const& rComponentContext) + : m_xChartModel(xChartModel) + , m_xDataTableModel(rDataTableModel) + , m_xComponentContext(rComponentContext) +{ + uno::Reference<beans::XPropertySet> xProp(m_xDataTableModel); + m_aLineProperties.initFromPropertySet(xProp); } -void DataTableView::setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool bLeft, - bool bTop, bool bRight, bool bBottom) +void DataTableView::setCellCharAndParagraphProperties( + uno::Reference<beans::XPropertySet>& xPropertySet) { uno::Reference<beans::XPropertySet> xDataTableProperties(m_xDataTableModel); @@ -113,19 +117,27 @@ void DataTableView::setCellDefaults(uno::Reference<beans::XPropertySet>& xProper copyProperty(xPropertySet, xDataTableProperties, "CharWeightComplex"); copyProperty(xPropertySet, xDataTableProperties, "CharWordMode"); + xPropertySet->setPropertyValue("ParaAdjust", uno::Any(style::ParagraphAdjust_CENTER)); +} + +void DataTableView::setCellProperties(css::uno::Reference<beans::XPropertySet>& xPropertySet, + bool bLeft, bool bTop, bool bRight, bool bBottom) +{ + xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF))); + + uno::Reference<beans::XPropertySet> xDataTableProperties = m_xDataTableModel.get(); 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); + sal_Int32 nXDistance = std::round(fFontHeight * 0.18f); + sal_Int32 nYDistance = std::round(fFontHeight * 0.30f); + + xPropertySet->setPropertyValue("TextLeftDistance", uno::Any(nXDistance)); + xPropertySet->setPropertyValue("TextRightDistance", uno::Any(nXDistance)); + xPropertySet->setPropertyValue("TextUpperDistance", uno::Any(nYDistance)); + xPropertySet->setPropertyValue("TextLowerDistance", uno::Any(nYDistance)); - xPropertySet->setPropertyValue("FillColor", uno::Any(Color(0xFFFFFF))); xPropertySet->setPropertyValue("TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_TOP)); - xPropertySet->setPropertyValue("ParaAdjust", uno::Any(style::ParagraphAdjust_CENTER)); drawing::LineStyle eStyle = drawing::LineStyle_NONE; m_aLineProperties.LineStyle >>= eStyle; @@ -218,13 +230,19 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV xBroadcaster->lockBroadcasts(); + auto* pTableObject = static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject()); + bool bHBorder = false; bool bVBorder = false; bool bOutline = false; + bool bKeys = false; + + std::vector<ViewLegendSymbol> aSymbols; m_xDataTableModel->getPropertyValue("HBorder") >>= bHBorder; m_xDataTableModel->getPropertyValue("VBorder") >>= bVBorder; m_xDataTableModel->getPropertyValue("Outline") >>= bOutline; + m_xDataTableModel->getPropertyValue("Keys") >>= bKeys; sal_Int32 nColumnCount = m_aXValues.size(); uno::Reference<table::XTableColumns> xTableColumns = xTable->getColumns(); @@ -256,22 +274,50 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV { xCellTextRange->setString(rString); bool bLeft = bOutline || (bVBorder && nColumn > 1); - setCellDefaults(xPropertySet, bLeft, bOutline, bOutline, bOutline); + setCellProperties(xPropertySet, bLeft, bOutline, bOutline, bOutline); + setCellCharAndParagraphProperties(xPropertySet); } nColumn++; } + if (bKeys) + { + awt::Size aMaxSymbolExtent(300, 300); + for (VSeriesPlotter* pSeriesPlotter : m_pSeriesPlotterList) + { + if (pSeriesPlotter) + { + std::vector<ViewLegendSymbol> aNewEntries = pSeriesPlotter->createSymbols( + aMaxSymbolExtent, m_xTarget, m_xComponentContext); + aSymbols.insert(aSymbols.end(), aNewEntries.begin(), aNewEntries.end()); + } + } + } + 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<beans::XPropertySet> xCellPropertySet(xCell, uno::UNO_QUERY); uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY); if (xCellTextRange.is()) { bool bTop = bOutline || (bHBorder && nRow > 1); - xCellTextRange->setString(rSeriesName); - setCellDefaults(xPropertySet, bOutline, bTop, bOutline, bOutline); + setCellProperties(xCellPropertySet, bOutline, bTop, bOutline, bOutline); + + auto xText = xCellTextRange->getText(); + xText->insertString(xText->getStart(), rSeriesName, false); + uno::Reference<container::XEnumerationAccess> xEnumAccess(xText, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xEnumeration(xEnumAccess->createEnumeration()); + uno::Reference<text::XTextRange> xParagraph(xEnumeration->nextElement(), + uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTextPropertySet(xParagraph, uno::UNO_QUERY); + + setCellCharAndParagraphProperties(xTextPropertySet); + + xCellPropertySet->setPropertyValue("ParaAdjust", uno::Any(style::ParagraphAdjust_LEFT)); + if (bKeys) + xCellPropertySet->setPropertyValue("ParaLeftMargin", uno::Any(500)); } nRow++; } @@ -306,7 +352,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV if (nColumn == nColumnCount && bOutline) bRight = true; - setCellDefaults(xPropertySet, bLeft, bTop, bRight, bBottom); + setCellProperties(xPropertySet, bLeft, bTop, bRight, bBottom); + setCellCharAndParagraphProperties(xPropertySet); } nColumn++; } @@ -315,21 +362,39 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV xBroadcaster->unlockBroadcasts(); - auto* pTableObject = static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject()); pTableObject->DistributeColumns(0, nColumnCount - 1, true, true); + pTableObject->DistributeRows(0, nRowCount - 1, true, true); uno::Reference<beans::XPropertySet> xPropertySet(xTableColumns->getByIndex(0), uno::UNO_QUERY); sal_Int32 nWidth = 0; xPropertySet->getPropertyValue("Width") >>= nWidth; - m_xTableShape->setPosition( - { basegfx::fround(rStart.getX() - nWidth), basegfx::fround(rStart.getY()) }); + sal_Int32 nTableX = basegfx::fround(rStart.getX() - nWidth); + sal_Int32 nTableY = basegfx::fround(rStart.getY()); + m_xTableShape->setPosition({ nTableX, nTableY }); for (sal_Int32 i = 1; i < xTableColumns->getCount(); ++i) { xPropertySet.set(xTableColumns->getByIndex(i), uno::UNO_QUERY); xPropertySet->setPropertyValue("Width", uno::Any(nColumnWidth)); } + + if (bKeys) + { + sal_Int32 nTotalHeight = 0; + for (sal_Int32 i = 0; i < xTableRows->getCount(); i++) + { + xPropertySet.set(xTableRows->getByIndex(i), uno::UNO_QUERY); + sal_Int32 nHeight = 0; + xPropertySet->getPropertyValue("Height") >>= nHeight; + if (i > 0) + { + aSymbols[i - 1].xSymbol->setPosition( + { nTableX + 100, nTableY + nTotalHeight + 100 }); + } + nTotalHeight += nHeight; + } + } } void DataTableView::initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& xTarget) @@ -342,6 +407,8 @@ void DataTableView::initializeValues( { for (auto& rSeriesPlotter : rSeriesPlotterList) { + m_pSeriesPlotterList.push_back(rSeriesPlotter.get()); + for (auto const& rCategory : rSeriesPlotter->getExplicitCategoriesProvider()->getSimpleCategories()) { diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 18497bcc2494..e71c8517bb3f 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -142,6 +142,8 @@ public: /** The active table has the focus or is currently edited */ const sdr::table::CellRef& getActiveCell() const; + CellRef getCell(const CellPos& rPos) const; + void setActiveCell( const sdr::table::CellPos& rPos ); void getActiveCellPos( sdr::table::CellPos& rPos ) const; sal_Int32 getColumnCount() const; diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 87f26b31704f..767a183ed2ba 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -1566,6 +1566,18 @@ void SdrTableObj::TakeTextRect( const CellPos& rPos, SdrOutliner& rOutliner, too rTextRect=tools::Rectangle(aTextPos,aTextSiz); } +CellRef SdrTableObj::getCell(const CellPos& rPos) const +{ + if (mpImpl.is()) + { + return mpImpl->getCell(rPos); + } + else + { + static CellRef xCell; + return xCell; + } +} const CellRef& SdrTableObj::getActiveCell() const { commit 7ba6bc102e0b5f0a12b22d4fb99c73da7ad7bfb7 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Aug 10 12:06:42 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:04 2022 +0200 chart2: Add undo/redo for the data table Change-Id: I6b25a7a82957705481952bc3cd181a6d0c1fce0e diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 99b3e74fffac..6fd0dd19025d 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -161,6 +161,10 @@ void ChartController::executeDispatch_InsertGrid() void ChartController::executeDispatch_OpenInsertDataTableDialog() { SolarMutexGuard aGuard; + + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_OBJECT_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); InsertDataTableDialog aDialog(GetChartFrame()); @@ -195,12 +199,14 @@ void ChartController::executeDispatch_OpenInsertDataTableDialog() // show the dialog if (aDialog.run() == RET_OK) { - auto& rDialogData = aDialog.getDataTableDialogData(); + bool bChanged = false; + auto& rDialogData = aDialog.getDataTableDialogData(); auto xDataTable = xDiagram->getDataTable(); if (!rDialogData.mbShow && xDataTable.is()) { xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + bChanged = true; } else if (rDialogData.mbShow && !xDataTable.is()) { @@ -208,6 +214,7 @@ void ChartController::executeDispatch_OpenInsertDataTableDialog() if (xNewDataTable.is()) { xDiagram->setDataTable(xNewDataTable); + bChanged = true; } } @@ -220,13 +227,20 @@ void ChartController::executeDispatch_OpenInsertDataTableDialog() xProperties->setPropertyValue("VBorder" , uno::Any(rDialogData.mbVerticalBorders)); xProperties->setPropertyValue("Outline" , uno::Any(rDialogData.mbOutline)); xProperties->setPropertyValue("Keys" , uno::Any(rDialogData.mbKeys)); + bChanged = true; } + + if (bChanged) + aUndoGuard.commit(); } } void ChartController::executeDispatch_InsertDataTable() { - SolarMutexGuard aGuard; + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_OBJECT_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); auto xDataTable = xDiagram->getDataTable(); if (!xDataTable.is()) @@ -235,18 +249,23 @@ void ChartController::executeDispatch_InsertDataTable() if (xNewDataTable.is()) { xDiagram->setDataTable(xNewDataTable); + aUndoGuard.commit(); } } } void ChartController::executeDispatch_DeleteDataTable() { - SolarMutexGuard aGuard; + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Delete, SchResId(STR_OBJECT_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); auto xDataTable = xDiagram->getDataTable(); if (xDataTable.is()) { xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + aUndoGuard.commit(); } } diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index de8244136642..cd83e5191ca0 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -260,6 +260,8 @@ Diagram::Diagram( const Diagram & rOther ) : m_xTitle.set( CloneHelper::CreateRefClone< chart2::XTitle >()( rOther.m_xTitle )); if (rOther.m_xLegend) m_xLegend = new Legend(*rOther.m_xLegend); + if (rOther.m_xDataTable) + m_xDataTable = new DataTable(*rOther.m_xDataTable); if ( m_xWall ) m_xWall->addModifyListener( m_xModifyEventForwarder ); commit 68b5f1cd395cad2d2d52fa79908e27147306be80 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Aug 10 11:58:34 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:04 2022 +0200 correct the description of NumberingRules duplicated text - "@see NumberingLevel" Change-Id: I210c392dba738e65ed22b8c66e16a6bafb1c4265 diff --git a/offapi/com/sun/star/text/NumberingRules.idl b/offapi/com/sun/star/text/NumberingRules.idl index 97286cd26523..9b12477f8f95 100644 --- a/offapi/com/sun/star/text/NumberingRules.idl +++ b/offapi/com/sun/star/text/NumberingRules.idl @@ -31,7 +31,7 @@ published service NumberingRules <p>The numbering rules are levels of property values. Each level contains equal properties.</p> - @see NumberingLevel;@see NumberingLevel; + @see NumberingLevel */ interface com::sun::star::container::XIndexReplace; commit 88233f8fc55562540bf401d9333675245b7d978b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jul 29 15:57:42 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:03 2022 +0200 xmloff: import and export for the chart data table This change adds import and export code for the the chart's data table properties to the ODF format for chart documents. The data table properties are exported to a new element "data-table", which then references a auto style with all the properties of a data table + new data table specific properties: HBorder, VBorder, Outline, Keys which are mapped to "show-horizontal-border", "show-vertical-border", "show-outline" and "show-keys" chart attributes. Also adds a test for the import and export: imports xlsx -> exports to ods -> imports ods Change-Id: Id45d9369fd619959e4d6eba7ca51c8ddce9c8f56 diff --git a/chart2/qa/extras/chart2export2.cxx b/chart2/qa/extras/chart2export2.cxx index be2902cbb15c..b9b77c0bd112 100644 --- a/chart2/qa/extras/chart2export2.cxx +++ b/chart2/qa/extras/chart2export2.cxx @@ -93,6 +93,7 @@ public: void testNameRangeXLSX(); void testTdf143942(); void testDateCategoriesPPTX(); + void testDataTableImportExport(); CPPUNIT_TEST_SUITE(Chart2ExportTest2); CPPUNIT_TEST(testSetSeriesToSecondaryAxisXLSX); @@ -158,6 +159,7 @@ public: CPPUNIT_TEST(testNameRangeXLSX); CPPUNIT_TEST(testTdf143942); CPPUNIT_TEST(testDateCategoriesPPTX); + CPPUNIT_TEST(testDataTableImportExport); CPPUNIT_TEST_SUITE_END(); }; @@ -1630,6 +1632,56 @@ void Chart2ExportTest2::testDateCategoriesPPTX() } } +void Chart2ExportTest2::testDataTableImportExport() +{ + load(u"/chart2/qa/extras/data/xlsx/", u"ChartDataTable.xlsx"); + { + uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + auto xDiagram = xChartDoc->getFirstDiagram(); + CPPUNIT_ASSERT(xDiagram.is()); + auto xDataTable = xDiagram->getDataTable(); + CPPUNIT_ASSERT(xDataTable.is()); + uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY); + CPPUNIT_ASSERT(xPropertySet.is()); + bool bHBorder; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("HBorder") >>= bHBorder); + CPPUNIT_ASSERT_EQUAL(true, bHBorder); + bool bVBorder; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("VBorder") >>= bVBorder); + CPPUNIT_ASSERT_EQUAL(true, bVBorder); + bool bOutline; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Outline") >>= bOutline); + CPPUNIT_ASSERT_EQUAL(false, bOutline); + bool bKeys; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Keys") >>= bKeys); + CPPUNIT_ASSERT_EQUAL(false, bKeys); + } + reload("calc8"); + { + uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent); + CPPUNIT_ASSERT(xChartDoc.is()); + auto xDiagram = xChartDoc->getFirstDiagram(); + CPPUNIT_ASSERT(xDiagram.is()); + auto xDataTable = xDiagram->getDataTable(); + CPPUNIT_ASSERT(xDataTable.is()); + uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY); + CPPUNIT_ASSERT(xPropertySet.is()); + bool bHBorder; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("HBorder") >>= bHBorder); + CPPUNIT_ASSERT_EQUAL(true, bHBorder); + bool bVBorder; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("VBorder") >>= bVBorder); + CPPUNIT_ASSERT_EQUAL(true, bVBorder); + bool bOutline; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Outline") >>= bOutline); + CPPUNIT_ASSERT_EQUAL(false, bOutline); + bool bKeys; + CPPUNIT_ASSERT(xPropertySet->getPropertyValue("Keys") >>= bKeys); + CPPUNIT_ASSERT_EQUAL(false, bKeys); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx b/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx new file mode 100644 index 000000000000..fff4f00aeafa Binary files /dev/null and b/chart2/qa/extras/data/xlsx/ChartDataTable.xlsx differ diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 3a13ef6ff1d4..da0e0b83c879 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -605,6 +605,7 @@ namespace xmloff::token { XML_DATA_STREAM_SOURCE, XML_DATA_STYLE, XML_DATA_STYLE_NAME, + XML_DATA_TABLE, XML_DATA_TYPE, XML_DATABASE_DISPLAY, XML_DATABASE_NAME, @@ -1747,12 +1748,16 @@ namespace xmloff::token { XML_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME, XML_SHOW_CHANGES_BY_RANGES, XML_SHOW_CHANGES_BY_RANGES_LIST, + XML_SHOW_HORIZONTAL_BORDER, + XML_SHOW_KEYS, XML_SHOW_LOGO, XML_SHOW_REJECTED_CHANGES, XML_SHOW_SHAPE, XML_SHOW_TEXT, XML_SHOW_UNIT, XML_SHOW_VALUE, + XML_SHOW_VERTICAL_BORDER, + XML_SHOW_OUTLINE, XML_SHOWS, XML_SIDE_BY_SIDE, XML_SILVER, @@ -3421,7 +3426,7 @@ namespace xmloff::token { XML_RFC_LANGUAGE_TAG, XML_RFC_LANGUAGE_TAG_ASIAN, XML_RFC_LANGUAGE_TAG_COMPLEX, - // Chart data table properties + // (Obsolete) Chart data table properties XML_DATA_TABLE_SHOW_HORZ_BORDER, XML_DATA_TABLE_SHOW_VERT_BORDER, XML_DATA_TABLE_SHOW_OUTLINE, diff --git a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng index c524533fd178..fe5c94a45ee4 100644 --- a/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng +++ b/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng @@ -2,34 +2,34 @@ <!-- Open Document Format for Office Applications (OpenDocument) Version 1.3 OASIS Standard, In progress - Relax-NG Schema + Relax-NG Schema Source: https://tools.oasis-open.org/version-control/svn/office/ Copyright (c) OASIS Open 2002-2015. All Rights Reserved. - All capitalized terms in the following text have the meanings assigned to them - in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The - full Policy may be found at the OASIS website. - - This document and translations of it may be copied and furnished to others, and - derivative works that comment on or otherwise explain it or assist in its - implementation may be prepared, copied, published, and distributed, in whole or - in part, without restriction of any kind, provided that the above copyright - notice and this section are included on all such copies and derivative works. - However, this document itself may not be modified in any way, including by - removing the copyright notice or references to OASIS, except as needed for the - purpose of developing any document or deliverable produced by an OASIS - Technical Committee (in which case the rules applicable to copyrights, as set - forth in the OASIS IPR Policy, must be followed) or as required to translate it - into languages other than English. - - The limited permissions granted above are perpetual and will not be revoked by - OASIS or its successors or assigns. - - This document and the information contained herein is provided on an "AS IS" - basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT - LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT - INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR - FITNESS FOR A PARTICULAR PURPOSE. + All capitalized terms in the following text have the meanings assigned to them + in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The + full Policy may be found at the OASIS website. + + This document and translations of it may be copied and furnished to others, and + derivative works that comment on or otherwise explain it or assist in its + implementation may be prepared, copied, published, and distributed, in whole or + in part, without restriction of any kind, provided that the above copyright + notice and this section are included on all such copies and derivative works. + However, this document itself may not be modified in any way, including by + removing the copyright notice or references to OASIS, except as needed for the + purpose of developing any document or deliverable produced by an OASIS + Technical Committee (in which case the rules applicable to copyrights, as set + forth in the OASIS IPR Policy, must be followed) or as required to translate it + into languages other than English. + + The limited permissions granted above are perpetual and will not be revoked by + OASIS or its successors or assigns. + + This document and the information contained herein is provided on an "AS IS" + basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT + LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT + INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR + FITNESS FOR A PARTICULAR PURPOSE. --> <rng:grammar xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:db="urn:oasis:names:tc:opendocument:xmlns:database:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns:script="urn:oa sis:names:tc:opendocument:xmlns:script:1.0" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" @@ -1323,6 +1323,36 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. </rng:choice> </rng:define> + <rng:define name="chart-chart"> + <rng:element name="chart:chart"> + <rng:ref name="chart-chart-attlist"/> + <rng:optional> + <rng:ref name="chart-title"/> + </rng:optional> + <rng:optional> + <rng:ref name="chart-subtitle"/> + </rng:optional> + <rng:optional> + <rng:ref name="chart-footer"/> + </rng:optional> + <rng:optional> + <rng:ref name="chart-legend"/> + </rng:optional> + <!-- Chart Data Table - TODO no proposal --> + <rng:optional> + <rng:ref name="chart-data-table"/> + </rng:optional> + <rng:ref name="chart-plot-area"/> + <rng:zeroOrMore> + <rng:ref name="shape"/> + </rng:zeroOrMore> + <!-- https://issues.oasis-open.org/browse/OFFICE-2123 --> + <rng:optional> + <rng:ref name="table-table"/> + </rng:optional> + </rng:element> + </rng:define> + <rng:define name="chart-axis"> <rng:element name="chart:axis"> <rng:ref name="chart-axis-attlist"/> @@ -2423,6 +2453,39 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. </rng:optional> </rng:define> + <!-- Chart Data Table - TODO no proposal --> + <rng:define name="chart-data-table"> + <rng:element name="loext:data-table"> + <rng:attribute name="chart:style-name"> + <rng:ref name="styleNameRef"/> + </rng:attribute> + </rng:element> + </rng:define> + + <!-- Chart Data Table Stlye Attributes - TODO no proposal --> + <rng:define name="style-chart-properties-attlist" combine="interleave"> + <rng:optional> + <rng:attribute name="loext:show-horizontal-border"> + <rng:ref name="boolean"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:attribute name="loext:show-vertical-border"> + <rng:ref name="boolean"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:attribute name="loext:show-outline"> + <rng:ref name="boolean"/> + </rng:attribute> + </rng:optional> + <rng:optional> + <rng:attribute name="loext:show-keys"> + <rng:ref name="boolean"/> + </rng:attribute> + </rng:optional> + </rng:define> + <!-- TODO no proposal --> <rng:define name="table-data-pilot-field-attlist" combine="interleave"> <rng:optional> diff --git a/xmloff/Library_xo.mk b/xmloff/Library_xo.mk index 50d268b470b1..2c59632c8537 100644 --- a/xmloff/Library_xo.mk +++ b/xmloff/Library_xo.mk @@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,xo,\ xmloff/source/chart/SchXMLAxisContext \ xmloff/source/chart/SchXMLCalculationSettingsContext \ xmloff/source/chart/SchXMLChartContext \ + xmloff/source/chart/SchXMLDataTableContext \ xmloff/source/chart/SchXMLEnumConverter \ xmloff/source/chart/SchXMLExport \ xmloff/source/chart/SchXMLImport \ diff --git a/xmloff/source/chart/PropertyMaps.cxx b/xmloff/source/chart/PropertyMaps.cxx index e40ac207a284..09a580512199 100644 --- a/xmloff/source/chart/PropertyMaps.cxx +++ b/xmloff/source/chart/PropertyMaps.cxx @@ -130,6 +130,12 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = MAP_ENTRY_ODF_EXT( "LabelFillBackground", LO_EXT, XML_FILL_HATCH_SOLID, XML_TYPE_BOOL ), MAP_ENTRY_ODF_EXT( "LabelFillHatchName", LO_EXT, XML_FILL_HATCH_NAME, XML_TYPE_STYLENAME), + // Data table + MAP_ENTRY_ODF_EXT( "HBorder", LO_EXT, XML_SHOW_HORIZONTAL_BORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "VBorder", LO_EXT, XML_SHOW_VERTICAL_BORDER, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "Outline", LO_EXT, XML_SHOW_OUTLINE, XML_TYPE_BOOL ), + MAP_ENTRY_ODF_EXT( "Keys", LO_EXT, XML_SHOW_KEYS, XML_TYPE_BOOL ), + MAP_ENTRY( "ScaleText", CHART, XML_SCALE_TEXT, XML_TYPE_BOOL ), // spline settings diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index 7d1a767e784f..d8be7470d013 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -20,6 +20,7 @@ #include "SchXMLChartContext.hxx" #include <SchXMLImport.hxx> #include "SchXMLLegendContext.hxx" +#include "SchXMLDataTableContext.hxx" #include "SchXMLPlotAreaContext.hxx" #include "SchXMLParagraphContext.hxx" #include "SchXMLTableContext.hxx" @@ -1070,6 +1071,9 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SchXMLChartContext::cr case XML_ELEMENT(CHART, XML_LEGEND): pContext = new SchXMLLegendContext( mrImportHelper, GetImport() ); break; + case XML_ELEMENT(LO_EXT, XML_DATA_TABLE): + pContext = new SchXMLDataTableContext(mrImportHelper, GetImport()); + break; case XML_ELEMENT(TABLE, XML_TABLE): { SchXMLTableContext * pTableContext = diff --git a/xmloff/source/chart/SchXMLDataTableContext.cxx b/xmloff/source/chart/SchXMLDataTableContext.cxx new file mode 100644 index 000000000000..4271221ed71f --- /dev/null +++ b/xmloff/source/chart/SchXMLDataTableContext.cxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "SchXMLDataTableContext.hxx" + +#include <xmloff/xmlimp.hxx> +#include <xmloff/xmlnamespace.hxx> +#include <xmloff/namespacemap.hxx> +#include <xmloff/xmluconv.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XDataTable.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +using namespace ::xmloff::token; +using namespace css; + +SchXMLDataTableContext::SchXMLDataTableContext(SchXMLImportHelper& rImpHelper, SvXMLImport& rImport) + : SvXMLImportContext(rImport) + , mrImportHelper(rImpHelper) +{ +} + +void SchXMLDataTableContext::startFastElement( + sal_Int32 /*nElement*/, const uno::Reference<xml::sax::XFastAttributeList>& xAttrList) +{ + printf("SchXMLDataTableContext::startFastElement\n"); + auto xChartDocument = mrImportHelper.GetChartDocument(); + if (!xChartDocument.is()) + return; + + uno::Reference<chart2::XChartDocument> xNewChartDocument(xChartDocument, uno::UNO_QUERY); + if (!xNewChartDocument.is()) + return; + + uno::Reference<chart2::XDiagram> xDiagram(xNewChartDocument->getFirstDiagram()); + if (!xDiagram.is()) + return; + + uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); + uno::Reference<chart2::XDataTable> xDataTable( + xFactory->createInstance("com.sun.star.chart2.DataTable"), uno::UNO_QUERY); + if (!xDataTable.is()) + return; + + xDiagram->setDataTable(xDataTable); + + OUString sAutoStyleName; + + for (auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList)) + { + if (aIter.getToken() == XML_ELEMENT(CHART, XML_STYLE_NAME)) + sAutoStyleName = aIter.toString(); + else + XMLOFF_WARN_UNKNOWN("xmloff", aIter); + } + + // set properties + uno::Reference<beans::XPropertySet> xPropertySet(xDataTable, uno::UNO_QUERY); + + if (!sAutoStyleName.isEmpty() && xPropertySet.is()) + { + mrImportHelper.FillAutoStyle(sAutoStyleName, xPropertySet); + } +} + +SchXMLDataTableContext::~SchXMLDataTableContext() {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/chart/SchXMLDataTableContext.hxx b/xmloff/source/chart/SchXMLDataTableContext.hxx new file mode 100644 index 000000000000..716f445ed61e --- /dev/null +++ b/xmloff/source/chart/SchXMLDataTableContext.hxx @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#pragma once + +#include <com/sun/star/xml/sax/XAttributeList.hpp> + +#include <xmloff/SchXMLImportHelper.hxx> +#include <xmloff/xmlictxt.hxx> + +class SchXMLDataTableContext : public SvXMLImportContext +{ +public: + SchXMLDataTableContext(SchXMLImportHelper& rImpHelper, SvXMLImport& rImport); + virtual ~SchXMLDataTableContext() override; + + virtual void SAL_CALL startFastElement( + sal_Int32 nElement, + const css::uno::Reference<css::xml::sax::XFastAttributeList>& xAttrList) override; + +private: + SchXMLImportHelper& mrImportHelper; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 533fcb569c33..0ed2683944ec 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -1147,6 +1147,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > return; } + const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion(mrExport.getSaneDefaultVersion()); + mxExpPropMapper->setChartDoc(xNewDoc); awt::Size aPageSize( getPageSize( xNewDoc )); @@ -1232,8 +1234,6 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > if( bExportContent ) { //export data provider in xlink:href attribute - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( - mrExport.getSaneDefaultVersion()); if (nCurrentODFVersion >= SvtSaveOptions::ODFSVER_012) { @@ -1407,9 +1407,6 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY ); if( xProp.is()) { - const SvtSaveOptions::ODFSaneDefaultVersion nCurrentODFVersion( - mrExport.getSaneDefaultVersion()); - // export legend anchor position try { @@ -1496,6 +1493,37 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument > aPropertyStates.clear(); } + // Data table + if (xNewDiagram.is() && nCurrentODFVersion & SvtSaveOptions::ODFSVER_EXTENDED) + { + auto xDataTable = xNewDiagram->getDataTable(); + + if (xDataTable.is()) + { + // get property states for autostyles + if (mxExpPropMapper.is()) + { + uno::Reference<beans::XPropertySet> xPropSet(xDataTable, uno::UNO_QUERY); + if (xPropSet.is()) + aPropertyStates = mxExpPropMapper->Filter(mrExport, xPropSet); + } + + if (bExportContent) + { + // add style name attribute + AddAutoStyleAttribute(aPropertyStates); + SvXMLElementExport aDataTableElement(mrExport, XML_NAMESPACE_LO_EXT, XML_DATA_TABLE, true, true); + } + else + { + CollectAutoStyle(std::move(aPropertyStates)); + } + } + + // remove property states for autostyles + aPropertyStates.clear(); + } + // plot-area element if( xDiagram.is()) exportPlotArea( xDiagram, xNewDiagram, aPageSize, bExportContent, bIncludeTable ); diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 71d10f72d338..30158b20660e 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -617,6 +617,7 @@ namespace xmloff::token { TOKEN( "data-stream-source", XML_DATA_STREAM_SOURCE ), TOKEN( "data-style", XML_DATA_STYLE ), TOKEN( "data-style-name", XML_DATA_STYLE_NAME ), + TOKEN( "data-table", XML_DATA_TABLE ), TOKEN( "data-type", XML_DATA_TYPE ), TOKEN( "database-display", XML_DATABASE_DISPLAY ), TOKEN( "database-name", XML_DATABASE_NAME ), @@ -1760,12 +1761,16 @@ namespace xmloff::token { TOKEN( "show-changes-by-datetime-second-datetime", XML_SHOW_CHANGES_BY_DATETIME_SECOND_DATETIME ), TOKEN( "show-changes-by-ranges", XML_SHOW_CHANGES_BY_RANGES ), TOKEN( "show-changes-by-ranges-list", XML_SHOW_CHANGES_BY_RANGES_LIST ), + TOKEN( "show-horizontal-border", XML_SHOW_HORIZONTAL_BORDER ), + TOKEN( "show-keys", XML_SHOW_KEYS ), TOKEN( "show-logo", XML_SHOW_LOGO ), TOKEN( "show-rejected-changes", XML_SHOW_REJECTED_CHANGES ), TOKEN( "show-shape", XML_SHOW_SHAPE ), TOKEN( "show-text", XML_SHOW_TEXT ), TOKEN( "show-unit", XML_SHOW_UNIT ), TOKEN( "show-value", XML_SHOW_VALUE ), + TOKEN( "show-vertical-border", XML_SHOW_VERTICAL_BORDER ), + TOKEN( "show-outline", XML_SHOW_OUTLINE ), TOKEN( "shows", XML_SHOWS ), TOKEN( "side-by-side", XML_SIDE_BY_SIDE ), TOKEN( "silver", XML_SILVER ), @@ -3428,9 +3433,9 @@ namespace xmloff::token { TOKEN( "rfc-language-tag", XML_RFC_LANGUAGE_TAG ), TOKEN( "rfc-language-tag-asian", XML_RFC_LANGUAGE_TAG_ASIAN ), TOKEN( "rfc-language-tag-complex", XML_RFC_LANGUAGE_TAG_COMPLEX ), - TOKEN( "data-table-show-horz-border", XML_DATA_TABLE_SHOW_HORZ_BORDER ), - TOKEN( "data-table-show-vert-border", XML_DATA_TABLE_SHOW_VERT_BORDER ), - TOKEN( "data-table-show-outline", XML_DATA_TABLE_SHOW_OUTLINE ), + TOKEN( "data-table-show-horz-border", XML_DATA_TABLE_SHOW_HORZ_BORDER ), // obsolete - use XML_SHOW_HORIZONTAL_BORDER + TOKEN( "data-table-show-vert-border", XML_DATA_TABLE_SHOW_VERT_BORDER ), // obsolete - use XML_SHOW_VERTICAL_BORDER + TOKEN( "data-table-show-outline", XML_DATA_TABLE_SHOW_OUTLINE ), // obsolete - use XML_SHOW_OUTLINE TOKEN( "display-units", XML_CHART_DUNITS_DISPLAYUNITS ), TOKEN( "display-units-built-in-unit", XML_CHART_DUNITS_BUILTINUNIT ), TOKEN( "external-data", XML_EXTERNALDATA), diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 0a3b256d2b99..918ab44981c4 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -522,6 +522,7 @@ data-range data-stream-source data-style data-style-name +data-table data-type database-display database-name @@ -1660,12 +1661,16 @@ show-changes-by-datetime-mode show-changes-by-datetime-second-datetime show-changes-by-ranges show-changes-by-ranges-list +show-horizontal-border +show-keys show-logo show-rejected-changes show-shape show-text show-unit show-value +show-vertical-border +show-outline shows side-by-side silver commit c38f5f44578fc91d6e0131f78c4a1076c8372712 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jul 29 15:49:31 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:03 2022 +0200 chart2: DataTable set properties to default to false Change-Id: If8caf59629327b623b2630776b1e650cbe4fbed1 diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx index 3957f2862a11..40ac5520d8f0 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -65,10 +65,10 @@ private: ::chart::CharacterProperties::AddDefaultsToMap(aMap); ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_HorizontalBorder, - true); + false); ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_VerticalBorder, - true); - ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, true); + false); + ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, false); ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false); ::chart::PropertyHelper::setPropertyValue( commit ba096d330fdfe3ab7dc1641534c9d9e4d0dd0b2c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jul 1 23:03:53 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:03 2022 +0200 chart2: InsertDataTable and DeleteDataTable for context menu Change-Id: I8ef0698252209af01b0741a59dec70f845f0c965 diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index f0f53c8b8990..81f3070403bc 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -440,6 +440,9 @@ private: void executeDispatch_OpenLegendDialog(); void executeDispatch_InsertAxes(); void executeDispatch_InsertGrid(); + + void executeDispatch_InsertDataTable(); + void executeDispatch_DeleteDataTable(); void executeDispatch_OpenInsertDataTableDialog(); void executeDispatch_InsertMenu_DataLabels(); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 70b15cf0fd04..5b5751dd5040 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1225,6 +1225,10 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_DeleteMajorGrid(); else if( aCommand == "DeleteMinorGrid" ) this->executeDispatch_DeleteMinorGrid(); + else if( aCommand == "InsertDataTable" ) + this->executeDispatch_InsertDataTable(); + else if( aCommand == "DeleteDataTable" ) + this->executeDispatch_DeleteDataTable(); //format objects else if( aCommand == "FormatSelection" ) this->executeDispatch_ObjectProperties(); @@ -1634,6 +1638,7 @@ const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommand "DeleteXErrorBars", "DeleteYErrorBars", "DeleteDataLabels", "DeleteDataLabel", "InsertMenuDataTable", + "InsertDataTable", "DeleteDataTable", //format objects "FormatSelection", "TransformDialog", "DiagramType", "View3D", diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index b1b0598d5070..99b3e74fffac 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -224,6 +224,32 @@ void ChartController::executeDispatch_OpenInsertDataTableDialog() } } +void ChartController::executeDispatch_InsertDataTable() +{ + SolarMutexGuard aGuard; + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + auto xDataTable = xDiagram->getDataTable(); + if (!xDataTable.is()) + { + uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable); + if (xNewDataTable.is()) + { + xDiagram->setDataTable(xNewDataTable); + } + } +} + +void ChartController::executeDispatch_DeleteDataTable() +{ + SolarMutexGuard aGuard; + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + auto xDataTable = xDiagram->getDataTable(); + if (xDataTable.is()) + { + xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + } +} + void ChartController::executeDispatch_InsertTitles() { UndoGuard aUndoGuard( diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 510420c91a2c..b21a6b20ae22 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -1020,14 +1020,18 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) aMenuName = m_pDrawViewWrapper->IsTextEdit() ? std::u16string_view( u"drawtext" ) : std::u16string_view( u"draw" ); else { + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + // todo: the context menu should be specified by an xml file in uiconfig sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); - xPopupMenu->insertSeparator( -1 ); + if (eObjectType != OBJECTTYPE_DATA_TABLE) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); + xPopupMenu->insertSeparator( -1 ); + } - ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); rtl::Reference< Diagram > xDiagram = getFirstDiagram(); OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); @@ -1219,8 +1223,14 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" ); if( bIsMinorGridVisible && !bIsSecondaryAxis ) lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" ); + if (bIsAxisVisible) + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, ".uno:InsertDataTable"); } } + else if (eObjectType == OBJECTTYPE_DATA_TABLE) + { + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, ".uno:DeleteDataTable"); + } if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 828d862f4306..5ddb9409cfa0 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -360,6 +360,8 @@ struct ModelState bool bSupportsStatistics; bool bSupportsAxes; + + bool bDataTable = false; }; ModelState::ModelState() : @@ -440,6 +442,8 @@ void ModelState::update( const rtl::Reference<::chart::ChartModel> & xModel ) bHasLegend = LegendHelper::hasLegend( xDiagram ); bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); bHasFloor = bHasWall && bIsThreeD; + + bDataTable = xDiagram->getDataTable().is(); } bool ModelState::HasAnyAxis() const @@ -695,6 +699,10 @@ void ControllerCommandDispatch::updateCommandAvailability() m_aCommandAvailability[ ".uno:FormatMinorGrid" ] = bIsWritable; m_aCommandAvailability[ ".uno:InsertMinorGrid" ] = bIsWritable; m_aCommandAvailability[ ".uno:DeleteMinorGrid" ] = bIsWritable; + + // data table + m_aCommandAvailability[ ".uno:InsertDataTable" ] = bIsWritable && bModelStateIsValid && !m_apModelState->bDataTable; + m_aCommandAvailability[ ".uno:DeleteDataTable" ] = bIsWritable && bModelStateIsValid && m_apModelState->bDataTable; } bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand ) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu index cb4a5dc728d0..453b96cf86c5 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu @@ -504,6 +504,17 @@ <value xml:lang="en-US">Format Single Data Label...</value> </prop> </node> + <!-- data table --> + <node oor:name=".uno:InsertDataTable" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Insert Data Table</value> + </prop> + </node> + <node oor:name=".uno:DeleteDataTable" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Delete Data Table</value> + </prop> + </node> <!-- data series and point --> <node oor:name=".uno:FormatDataSeries" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> commit c4a6e28a2b7cfb1763b0acf83992505b9d1addd6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jul 1 22:00:38 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Wed Aug 10 14:37:03 2022 +0200 chart2: InsertDataTableDialog for inserting/removing the data table Change-Id: Ie3c033c587b150723e7aa39cd5ddf5774104db9a diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index 4bc8c7497915..cc25cdd907ae 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -109,6 +109,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/dialogs/dlg_DataSource \ chart2/source/controller/dialogs/dlg_InsertAxis_Grid \ chart2/source/controller/dialogs/dlg_InsertDataLabel \ + chart2/source/controller/dialogs/dlg_InsertDataTable \ chart2/source/controller/dialogs/dlg_InsertErrorBars \ chart2/source/controller/dialogs/dlg_InsertLegend \ chart2/source/controller/dialogs/dlg_InsertTitle \ @@ -122,6 +123,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/dialogs/RangeSelectionListener \ chart2/source/controller/dialogs/res_BarGeometry \ chart2/source/controller/dialogs/res_DataLabel \ + chart2/source/controller/dialogs/res_DataTableProperties \ chart2/source/controller/dialogs/res_ErrorBar \ chart2/source/controller/dialogs/res_LegendPosition \ chart2/source/controller/dialogs/res_Titles \ diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk index 59af510c5845..274efd02638f 100644 --- a/chart2/UIConfig_chart2.mk +++ b/chart2/UIConfig_chart2.mk @@ -44,7 +44,9 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\ chart2/uiconfig/ui/combobox \ chart2/uiconfig/ui/datarangedialog \ chart2/uiconfig/ui/dlg_DataLabel \ + chart2/uiconfig/ui/dlg_InsertDataTable \ chart2/uiconfig/ui/dlg_InsertErrorBars \ + chart2/uiconfig/ui/dlg_InsertLegend \ chart2/uiconfig/ui/imagefragment \ chart2/uiconfig/ui/insertaxisdlg \ chart2/uiconfig/ui/insertgriddlg \ @@ -58,7 +60,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\ chart2/uiconfig/ui/smoothlinesdlg \ chart2/uiconfig/ui/steppedlinesdlg \ chart2/uiconfig/ui/titlerotationtabpage \ - chart2/uiconfig/ui/dlg_InsertLegend \ chart2/uiconfig/ui/tp_3D_SceneAppearance \ chart2/uiconfig/ui/tp_3D_SceneGeometry \ chart2/uiconfig/ui/tp_3D_SceneIllumination \ diff --git a/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx new file mode 100644 index 000000000000..4b5e928db057 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx @@ -0,0 +1,61 @@ +/* -*- 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 <dlg_InsertDataTable.hxx> + +namespace chart +{ +InsertDataTableDialog::InsertDataTableDialog(weld::Window* pWindow) + : GenericDialogController(pWindow, "modules/schart/ui/dlg_InsertDataTable.ui", + "InsertDataTableDialog") + , m_aDataTablePropertiesResources(*m_xBuilder) + , m_xCbShowDataTable(m_xBuilder->weld_check_button("showDataTable")) +{ + m_xCbShowDataTable->connect_toggled(LINK(this, InsertDataTableDialog, ShowDataTableToggle)); + init(m_aData); +} + +IMPL_LINK_NOARG(InsertDataTableDialog, ShowDataTableToggle, weld::Toggleable&, void) +{ + changeEnabled(); +} + +void InsertDataTableDialog::changeEnabled() +{ + bool bEnable = m_xCbShowDataTable->get_active(); + m_aDataTablePropertiesResources.setChecksSensitive(bEnable); + m_aData.mbShow = bEnable; +} + +void InsertDataTableDialog::init(DataTableDialogData const& rData) +{ + m_aData = rData; + m_aDataTablePropertiesResources.setHorizontalBorder(m_aData.mbHorizontalBorders); + m_aDataTablePropertiesResources.setVerticalBorder(m_aData.mbVerticalBorders); + m_aDataTablePropertiesResources.setOutline(m_aData.mbOutline); + m_aDataTablePropertiesResources.setKeys(m_aData.mbKeys); + m_xCbShowDataTable->set_active(m_aData.mbShow); + changeEnabled(); +} + +DataTableDialogData& InsertDataTableDialog::getDataTableDialogData() +{ + m_aData.mbShow = m_xCbShowDataTable->get_active(); + + m_aData.mbHorizontalBorders = m_aDataTablePropertiesResources.getHorizontalBorder(); + m_aData.mbVerticalBorders = m_aDataTablePropertiesResources.getVerticalBorder(); + m_aData.mbOutline = m_aDataTablePropertiesResources.getOutline(); + m_aData.mbKeys = m_aDataTablePropertiesResources.getKeys(); + + return m_aData; +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/res_DataTableProperties.cxx b/chart2/source/controller/dialogs/res_DataTableProperties.cxx new file mode 100644 index 000000000000..bf87b3e6b9e3 --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataTableProperties.cxx @@ -0,0 +1,111 @@ +/* -*- 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 <res_DataTableProperties.hxx> + +#include <chartview/ChartSfxItemIds.hxx> +#include <svl/eitem.hxx> + +using namespace css; + +namespace chart +{ +DataTablePropertiesResources::DataTablePropertiesResources(weld::Builder& rBuilder) + : m_xCbHorizontalBorder(rBuilder.weld_check_button("horizontalBorderCB")) + , m_xCbVerticalBorder(rBuilder.weld_check_button("verticalBorderCB")) + , m_xCbOutilne(rBuilder.weld_check_button("outlineCB")) + , m_xCbKeys(rBuilder.weld_check_button("keysCB")) +{ +} + +void DataTablePropertiesResources::setChecksSensitive(bool bSensitive) +{ + m_xCbHorizontalBorder->set_sensitive(bSensitive); + m_xCbVerticalBorder->set_sensitive(bSensitive); + m_xCbOutilne->set_sensitive(bSensitive); + m_xCbKeys->set_sensitive(bSensitive); +} + +void DataTablePropertiesResources::initFromItemSet(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem* pPoolItem = nullptr; + SfxItemState aState; + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, false, &pPoolItem); + if (aState == SfxItemState::DONTCARE) + { + m_xCbHorizontalBorder->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbHorizontalBorder->set_active( + static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false, &pPoolItem); + if (aState == SfxItemState::DONTCARE) + { + m_xCbVerticalBorder->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbVerticalBorder->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_OUTLINE, false, &pPoolItem); + if (aState == SfxItemState::DONTCARE) + { + m_xCbOutilne->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbOutilne->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_KEYS, false, &pPoolItem); + if (aState == SfxItemState::DONTCARE) + { + m_xCbKeys->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbKeys->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } +} + +bool DataTablePropertiesResources::writeToItemSet(SfxItemSet& rOutAttrs) const +{ + if (m_xCbHorizontalBorder->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put( + SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, m_xCbHorizontalBorder->get_active())); + } + if (m_xCbVerticalBorder->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put( + SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, m_xCbVerticalBorder->get_active())); + } + if (m_xCbOutilne->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, m_xCbOutilne->get_active())); + } + if (m_xCbKeys->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, m_xCbKeys->get_active())); + } + return true; +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_DataTable.cxx b/chart2/source/controller/dialogs/tp_DataTable.cxx index d7bed5a53900..e6982b4a5067 100644 --- a/chart2/source/controller/dialogs/tp_DataTable.cxx +++ b/chart2/source/controller/dialogs/tp_DataTable.cxx @@ -9,19 +9,13 @@ #include "tp_DataTable.hxx" -#include <chartview/ChartSfxItemIds.hxx> -#include <svl/eitem.hxx> - namespace chart { DataTableTabPage::DataTableTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) : SfxTabPage(pPage, pController, "modules/schart/ui/tp_DataTable.ui", "DataTableTabPage", &rInAttrs) - , m_xCbHorizontalBorder(m_xBuilder->weld_check_button("horizontalBorderCB")) - , m_xCbVerticalBorder(m_xBuilder->weld_check_button("verticalBorderCB")) - , m_xCbOutilne(m_xBuilder->weld_check_button("outlineCB")) - , m_xCbKeys(m_xBuilder->weld_check_button("keysCB")) + , m_aDataTablePropertiesResources(*m_xBuilder) { } @@ -34,78 +28,14 @@ std::unique_ptr<SfxTabPage> DataTableTabPage::Create(weld::Container* pPage, return std::make_unique<DataTableTabPage>(pPage, pController, *rAttrs); } -bool DataTableTabPage::FillItemSet(SfxItemSet* rOutAttrs) +bool DataTableTabPage::FillItemSet(SfxItemSet* pOutAttrs) { - if (m_xCbHorizontalBorder->get_state() != TRISTATE_INDET) - { - rOutAttrs->Put( - SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, m_xCbHorizontalBorder->get_active())); - } - if (m_xCbVerticalBorder->get_state() != TRISTATE_INDET) - { - rOutAttrs->Put( - SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, m_xCbVerticalBorder->get_active())); - } - if (m_xCbOutilne->get_state() != TRISTATE_INDET) - { - rOutAttrs->Put(SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, m_xCbOutilne->get_active())); - } - if (m_xCbKeys->get_state() != TRISTATE_INDET) - { - rOutAttrs->Put(SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, m_xCbKeys->get_active())); - } - return true; + return m_aDataTablePropertiesResources.writeToItemSet(*pOutAttrs); } void DataTableTabPage::Reset(const SfxItemSet* pInAttrs) { - const SfxPoolItem* pPoolItem = nullptr; - SfxItemState aState; - - aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, false, &pPoolItem); - if (aState == SfxItemState::DONTCARE) - { - m_xCbHorizontalBorder->set_state(TRISTATE_INDET); - } - else - { - if (aState == SfxItemState::SET) - m_xCbHorizontalBorder->set_active( - static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - } - - aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false, &pPoolItem); - if (aState == SfxItemState::DONTCARE) - { - m_xCbVerticalBorder->set_state(TRISTATE_INDET); - } - else - { - if (aState == SfxItemState::SET) - m_xCbVerticalBorder->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - } - - aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_OUTLINE, false, &pPoolItem); - if (aState == SfxItemState::DONTCARE) - { - m_xCbOutilne->set_state(TRISTATE_INDET); - } - else - { - if (aState == SfxItemState::SET) - m_xCbOutilne->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - } - - aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_KEYS, false, &pPoolItem); - if (aState == SfxItemState::DONTCARE) - { - m_xCbKeys->set_state(TRISTATE_INDET); - } - else - { - if (aState == SfxItemState::SET) - m_xCbKeys->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - } + m_aDataTablePropertiesResources.initFromItemSet(*pInAttrs); } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_DataTable.hxx b/chart2/source/controller/dialogs/tp_DataTable.hxx index 11bcfb9203e1..a4ef6d6cf436 100644 --- a/chart2/source/controller/dialogs/tp_DataTable.hxx +++ b/chart2/source/controller/dialogs/tp_DataTable.hxx @@ -10,21 +10,14 @@ #pragma once #include <sfx2/tabdlg.hxx> - -namespace weld -{ -class CheckButton; -} +#include <res_DataTableProperties.hxx> namespace chart { class DataTableTabPage : public SfxTabPage { private: - std::unique_ptr<weld::CheckButton> m_xCbHorizontalBorder; - std::unique_ptr<weld::CheckButton> m_xCbVerticalBorder; - std::unique_ptr<weld::CheckButton> m_xCbOutilne; - std::unique_ptr<weld::CheckButton> m_xCbKeys; + DataTablePropertiesResources m_aDataTablePropertiesResources; public: DataTableTabPage(weld::Container* pPage, weld::DialogController* pController, diff --git a/chart2/source/controller/inc/dlg_InsertDataTable.hxx b/chart2/source/controller/inc/dlg_InsertDataTable.hxx new file mode 100644 index 000000000000..5dda9c3444bc --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertDataTable.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <vcl/weld.hxx> +#include <res_DataTableProperties.hxx> + +namespace chart +{ +struct DataTableDialogData +{ + bool mbShow = true; + bool mbHorizontalBorders = false; + bool mbVerticalBorders = false; + bool mbOutline = false; + bool mbKeys = false; +}; + +class InsertDataTableDialog final : public weld::GenericDialogController +{ +private: + DataTablePropertiesResources m_aDataTablePropertiesResources; + std::unique_ptr<weld::CheckButton> m_xCbShowDataTable; + + DataTableDialogData m_aData; + + DECL_LINK(ShowDataTableToggle, weld::Toggleable&, void); + + void changeEnabled(); + +public: + InsertDataTableDialog(weld::Window* pParent); + + void init(DataTableDialogData const& rData); + DataTableDialogData& getDataTableDialogData(); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/res_DataTableProperties.hxx b/chart2/source/controller/inc/res_DataTableProperties.hxx new file mode 100644 index 000000000000..299934cb0211 --- /dev/null +++ b/chart2/source/controller/inc/res_DataTableProperties.hxx @@ -0,0 +1,47 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <svl/itemset.hxx> +#include <vcl/weld.hxx> + +namespace chart +{ +class DataTablePropertiesResources final +{ +private: + std::unique_ptr<weld::CheckButton> m_xCbHorizontalBorder; + std::unique_ptr<weld::CheckButton> m_xCbVerticalBorder; + std::unique_ptr<weld::CheckButton> m_xCbOutilne; + std::unique_ptr<weld::CheckButton> m_xCbKeys; + +public: + DataTablePropertiesResources(weld::Builder& rBuilder); + + void initFromItemSet(SfxItemSet const& rInAttrs); + bool writeToItemSet(SfxItemSet& rOutAttrs) const; + void setChecksSensitive(bool bSensitive); + + bool getHorizontalBorder() { return m_xCbHorizontalBorder->get_active(); } + void setHorizontalBorder(bool bActive) { m_xCbHorizontalBorder->set_active(bActive); } + + bool getVerticalBorder() { return m_xCbVerticalBorder->get_active(); } + void setVerticalBorder(bool bActive) { m_xCbVerticalBorder->set_active(bActive); } + + bool getOutline() { return m_xCbOutilne->get_active(); } + void setOutline(bool bActive) { m_xCbOutilne->set_active(bActive); } + + bool getKeys() { return m_xCbKeys->get_active(); } + void setKeys(bool bActive) { m_xCbKeys->set_active(bActive); } +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 46d00eedb89c..b1b0598d5070 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -25,6 +25,7 @@ #include <dlg_InsertLegend.hxx> #include <dlg_InsertErrorBars.hxx> #include <dlg_InsertTitle.hxx> +#include <dlg_InsertDataTable.hxx> #include <dlg_ObjectProperties.hxx> #include <Axis.hxx> @@ -57,6 +58,7 @@ #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <svx/ActionDescriptionProvider.hxx> #include <tools/diagnose_ex.h> @@ -158,18 +160,66 @@ void ChartController::executeDispatch_InsertGrid() void ChartController::executeDispatch_OpenInsertDataTableDialog() { - rtl::Reference<Diagram> xDiagram = getFirstDiagram(); SolarMutexGuard aGuard; - if (xDiagram->getDataTable().is()) + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + + InsertDataTableDialog aDialog(GetChartFrame()); { - xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + // init values + DataTableDialogData aData; + auto xDataTable = xDiagram->getDataTable(); + aData.mbShow = xDataTable.is(); + if (xDataTable.is()) + { + uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY); + + uno::Any aAny = xProperties->getPropertyValue("HBorder"); + if (aAny.has<bool>()) + aData.mbHorizontalBorders = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue("VBorder"); + if (aAny.has<bool>()) + aData.mbVerticalBorders = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue("Outline"); + if (aAny.has<bool>()) + aData.mbOutline = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue("Keys"); + if (aAny.has<bool>()) + aData.mbKeys = aAny.get<bool>(); + } + aDialog.init(aData); } - else + + // show the dialog + if (aDialog.run() == RET_OK) { - uno::Reference<chart2::XDataTable> xDataTable(new DataTable); - if (xDataTable.is()) + auto& rDialogData = aDialog.getDataTableDialogData(); + + auto xDataTable = xDiagram->getDataTable(); + if (!rDialogData.mbShow && xDataTable.is()) + { + xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + } + else if (rDialogData.mbShow && !xDataTable.is()) + { + uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable); + if (xNewDataTable.is()) + { + xDiagram->setDataTable(xNewDataTable); + } + } + + // Set the properties + xDataTable = xDiagram->getDataTable(); + if (rDialogData.mbShow && xDataTable.is()) { - xDiagram->setDataTable(xDataTable); + uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY); + xProperties->setPropertyValue("HBorder" , uno::Any(rDialogData.mbHorizontalBorders)); + xProperties->setPropertyValue("VBorder" , uno::Any(rDialogData.mbVerticalBorders)); + xProperties->setPropertyValue("Outline" , uno::Any(rDialogData.mbOutline)); + xProperties->setPropertyValue("Keys" , uno::Any(rDialogData.mbKeys)); } } } diff --git a/chart2/uiconfig/ui/dlg_InsertDataTable.ui b/chart2/uiconfig/ui/dlg_InsertDataTable.ui new file mode 100644 index 000000000000..77a4ca4a3618 --- /dev/null +++ b/chart2/uiconfig/ui/dlg_InsertDataTable.ui @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="chart"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkDialog" id="InsertDataTableDialog"> + <property name="can-focus">False</property> + <property name="border-width">6</property> + <property name="title" translatable="yes" context="dlg_InsertLegend|dlg_InsertLegend">Data Table</property> + <property name="modal">True</property> + <property name="default-width">0</property> + <property name="default-height">0</property> + <property name="type-hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can-focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can-focus">False</property> + <property name="layout-style">end</property> + <child> + <object class="GtkButton" id="ok"> + <property name="label" translatable="yes" context="stock">_OK</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="can-default">True</property> + <property name="has-default">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + </object> + <packing> ... etc. - the rest is truncated