Rebased ref, commits from common ancestor: commit f39ac2b1acadd07e14b1cb3e10be3c8ebc100a2b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jun 30 23:43:52 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:43:52 2022 +0200
chart2: add some data table default properties Change-Id: I4fac46ac2a119275bcdaa6ebc8b7382ad6fb5684 diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx index 0620ce5ccaba..c67fab5c1740 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -70,6 +70,14 @@ private: true); ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Outilne, true); ::chart::PropertyHelper::setPropertyValueDefault(aMap, DataTableProperty_Keys, false); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight); + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight); + ::chart::PropertyHelper::setPropertyValue( + aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight); } }; commit 0bf157a9c90546416e27aead961e02d46c413ec3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Jun 30 23:34:19 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:54 2022 +0200 chart2: add "InsertDataTable" action to menu Change-Id: Ib60a2b061966eb61834480b63dc0653410a43a14 diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 505b109fdcc7..e8b78a309e12 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -440,6 +440,7 @@ private: void executeDispatch_OpenLegendDialog(); void executeDispatch_InsertAxes(); void executeDispatch_InsertGrid(); + void executeDispatch_InsertDataTable(); void executeDispatch_InsertMenu_DataLabels(); void executeDispatch_InsertMenu_Trendlines(); diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index a4bd7a3972cc..79e05b77e885 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -1169,6 +1169,8 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_InsertErrorBars(false); else if( aCommand == "InsertMenuYErrorBars" ) this->executeDispatch_InsertErrorBars(true); + else if( aCommand == "InsertDataTable" ) + this->executeDispatch_InsertDataTable(); else if( aCommand == "InsertSymbol" ) this->executeDispatch_InsertSpecialCharacter(); else if( aCommand == "InsertTrendline" ) @@ -1631,6 +1633,7 @@ const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommand "DeleteTrendline", "DeleteMeanValue", "DeleteTrendlineEquation", "DeleteXErrorBars", "DeleteYErrorBars", "DeleteDataLabels", "DeleteDataLabel", + "InsertDataTable", //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 4f39f1068cdb..7c660af86f81 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -52,6 +52,7 @@ #include <ObjectNameProvider.hxx> #include <Legend.hxx> #include <LegendHelper.hxx> +#include <DataTable.hxx> #include <RegressionCurveModel.hxx> #include <com/sun/star/chart2/XRegressionCurve.hpp> @@ -155,6 +156,24 @@ void ChartController::executeDispatch_InsertGrid() } } +void ChartController::executeDispatch_InsertDataTable() +{ + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + SolarMutexGuard aGuard; + if (xDiagram->getDataTable().is()) + { + xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + } + else + { + uno::Reference<chart2::XDataTable> xDataTable(new DataTable); + if (xDataTable.is()) + { + xDiagram->setDataTable(xDataTable); + } + } +} + void ChartController::executeDispatch_InsertTitles() { UndoGuard aUndoGuard( diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index e5035b4f053c..b7872b93e708 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -584,6 +584,7 @@ void ControllerCommandDispatch::updateCommandAvailability() m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; m_aCommandAvailability[ ".uno:InsertSymbol" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsTextObject; + m_aCommandAvailability[ ".uno:InsertDataTable" ] = bIsWritable; // format objects bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected; diff --git a/chart2/uiconfig/menubar/menubar.xml b/chart2/uiconfig/menubar/menubar.xml index 354ebbc1903a..581aff37153b 100644 --- a/chart2/uiconfig/menubar/menubar.xml +++ b/chart2/uiconfig/menubar/menubar.xml @@ -56,6 +56,7 @@ <menu:menuitem menu:id=".uno:InsertMenuLegend"/> <menu:menuitem menu:id=".uno:InsertMenuAxes"/> <menu:menuitem menu:id=".uno:InsertMenuGrids"/> + <menu:menuitem menu:id=".uno:InsertDataTable"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:InsertMenuDataLabels"/> <menu:menuitem menu:id=".uno:InsertMenuTrendlines"/> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu index d3a54a052c8e..7739522a866e 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu @@ -64,6 +64,11 @@ <value xml:lang="en-US">Y Error ~Bars...</value> </prop> </node> + <node oor:name=".uno:InsertDataTable" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Data Table</value> + </prop> + </node> <!-- Menu - Format --> <node oor:name=".uno:FormatSelection" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> commit 08255fc3ad043ca238a2a25ffd2a35bbb20e5d08 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jun 29 19:25:47 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 chart2: allow to select the data table, fix object CID Change-Id: I0a8d3643fcaefe8105e935b929947174bd9bdc96 diff --git a/chart2/source/view/axes/VAxisBase.cxx b/chart2/source/view/axes/VAxisBase.cxx index 7d985051a4a7..814d3afd7858 100644 --- a/chart2/source/view/axes/VAxisBase.cxx +++ b/chart2/source/view/axes/VAxisBase.cxx @@ -187,7 +187,7 @@ bool VAxisBase::prepareShapeCreation() 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); + m_xDataTableTarget = ShapeFactory::createGroup2D(m_xFinalTarget); return true; } diff --git a/chart2/source/view/inc/ShapeFactory.hxx b/chart2/source/view/inc/ShapeFactory.hxx index d6c05af04d18..b44612e74a4f 100644 --- a/chart2/source/view/inc/ShapeFactory.hxx +++ b/chart2/source/view/inc/ShapeFactory.hxx @@ -217,7 +217,7 @@ public: const css::uno::Reference< css::beans::XPropertySet > & xTextProperties, double nRotation, const OUString& aName, sal_Int32 nTextMaxWidth ); - static rtl::Reference<SvxTableShape> createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget); + static rtl::Reference<SvxTableShape> createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget, OUString const& rName = OUString()); static rtl::Reference<SvxShapeRect> createInvisibleRectangle( diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index f899e724839e..210753bcb07e 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -12,6 +12,7 @@ #include <ShapeFactory.hxx> #include <ExplicitCategoriesProvider.hxx> #include <ChartModel.hxx> +#include <ObjectIdentifier.hxx> #include <svx/svdotable.hxx> @@ -191,7 +192,9 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV return; ShapeFactory::removeSubShapes(m_xTarget); - m_xTableShape = ShapeFactory::createTable(m_xTarget); + auto sParticle = ObjectIdentifier::createParticleForDataTable(m_xChartModel); + auto sCID = ObjectIdentifier::createClassifiedIdentifierForParticle(sParticle); + m_xTableShape = ShapeFactory::createTable(m_xTarget, sCID); uno::Reference<table::XTable> xTable; try diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 7fddc5d018d5..8f9f29ced232 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -2533,16 +2533,17 @@ void ShapeFactory::removeSubShapes( const rtl::Reference<SvxShapeGroupAnyD>& xSh } rtl::Reference<SvxTableShape> -ShapeFactory::createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget) +ShapeFactory::createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget, OUString const& rName) { - if( !xTarget.is() ) + if (!xTarget.is()) return nullptr; //create table shape rtl::Reference<SvxTableShape> xShape = new SvxTableShape(nullptr); xShape->setShapeKind(SdrObjKind::Table); xTarget->addShape(*xShape); - + if (!rName.isEmpty()) + setShapeName(xShape, rName); return xShape; } commit 4d844e58797165cd84e30e7c325f7f75759a708b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Jun 28 07:48:45 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 chart2: add UI to the data table This adds a new object type "Data Table", with all the object identifiers and converters of properties. The data table is now shown in the drop-down of chart elements. A properties dialog was added, which allows to change properties of a data table. This contains the area, line and font tab pages and a new tab page specific for data tables, to change if the horiz. or vert. borders, key or the outline should be show. Change-Id: I9b4cd58cffbcc952daaa2c0c8f8a5a17e38ac293 diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index b7c449cef582..4bc8c7497915 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -138,6 +138,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/dialogs/tp_DataLabel \ chart2/source/controller/dialogs/tp_DataPointOption \ chart2/source/controller/dialogs/tp_DataSource \ + chart2/source/controller/dialogs/tp_DataTable \ chart2/source/controller/dialogs/tp_ErrorBars \ chart2/source/controller/dialogs/tp_LegendPosition \ chart2/source/controller/dialogs/tp_PointGeometry \ @@ -153,6 +154,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/itemsetwrapper/AxisItemConverter \ chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter \ chart2/source/controller/itemsetwrapper/DataPointItemConverter \ + chart2/source/controller/itemsetwrapper/DataTableItemConverter \ chart2/source/controller/itemsetwrapper/ErrorBarItemConverter \ chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter \ chart2/source/controller/itemsetwrapper/ItemConverter \ diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk index 67d64b18b597..59af510c5845 100644 --- a/chart2/UIConfig_chart2.mk +++ b/chart2/UIConfig_chart2.mk @@ -68,6 +68,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\ chart2/uiconfig/ui/tp_DataLabel \ chart2/uiconfig/ui/tp_DataPointOption \ chart2/uiconfig/ui/tp_DataSource \ + chart2/uiconfig/ui/tp_DataTable \ chart2/uiconfig/ui/tp_ErrorBars \ chart2/uiconfig/ui/tp_LegendPosition \ chart2/uiconfig/ui/tp_PolarOptions \ diff --git a/chart2/inc/strings.hrc b/chart2/inc/strings.hrc index ab6ca48c8376..9a9943df1f3c 100644 --- a/chart2/inc/strings.hrc +++ b/chart2/inc/strings.hrc @@ -48,6 +48,7 @@ #define STR_PAGE_APPEARANCE NC_("STR_PAGE_APPEARANCE", "Appearance") #define STR_PAGE_ILLUMINATION NC_("STR_PAGE_ILLUMINATION", "Illumination") #define STR_PAGE_ASIAN NC_("STR_PAGE_ASIAN", "Asian Typography") +#define STR_PAGE_DATA_TABLE NC_("STR_PAGE_DATA_TABLE", "Data Table") #define STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS NC_("STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS", "Mean value line with value %AVERAGE_VALUE and standard deviation %STD_DEVIATION") #define STR_OBJECT_AXIS NC_("STR_OBJECT_AXIS", "Axis") #define STR_OBJECT_AXIS_X NC_("STR_OBJECT_AXIS_X", "X Axis") @@ -97,6 +98,7 @@ #define STR_OBJECT_DIAGRAM_WALL NC_("STR_OBJECT_DIAGRAM_WALL", "Chart Wall") #define STR_OBJECT_DIAGRAM_FLOOR NC_("STR_OBJECT_DIAGRAM_FLOOR", "Chart Floor") #define STR_OBJECT_SHAPE NC_("STR_OBJECT_SHAPE", "Drawing Object") +#define STR_OBJECT_DATA_TABLE NC_("STR_OBJECT_DATA_TABLE", "Data Table") #define STR_TIP_DATASERIES NC_("STR_TIP_DATASERIES", "Data Series '%SERIESNAME'") #define STR_TIP_DATAPOINT_INDEX NC_("STR_TIP_DATAPOINT_INDEX", "Data Point %POINTNUMBER") #define STR_TIP_DATAPOINT_VALUES NC_("STR_TIP_DATAPOINT_VALUES", "Values: %POINTVALUES") diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 07b7f3503e92..b105ecc61211 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -314,6 +314,9 @@ OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) case OBJECTTYPE_DATA_CURVE_EQUATION: aRet=SchResId(STR_OBJECT_CURVE_EQUATION); break; + case OBJECTTYPE_DATA_TABLE: + aRet=SchResId(STR_OBJECT_DATA_TABLE); + break; default: //OBJECTTYPE_UNKNOWN ; } diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index c511ebb28527..0ba0b76518cb 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -35,6 +35,7 @@ #include "tp_TitleRotation.hxx" #include "tp_PolarOptions.hxx" #include "tp_DataPointOption.hxx" +#include "tp_DataTable.hxx" #include <ResId.hxx> #include <ViewElementListProvider.hxx> #include <ChartModelHelper.hxx> @@ -458,6 +459,12 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, case OBJECTTYPE_UNKNOWN: // nothing break; + case OBJECTTYPE_DATA_TABLE: + AddTabPage("datatable", SchResId(STR_PAGE_DATA_TABLE), DataTableTabPage::Create); + AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + break; case OBJECTTYPE_DATA_CURVE_EQUATION: AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); diff --git a/chart2/source/controller/dialogs/tp_DataTable.cxx b/chart2/source/controller/dialogs/tp_DataTable.cxx new file mode 100644 index 000000000000..d7bed5a53900 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataTable.cxx @@ -0,0 +1,113 @@ +/* -*- 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 "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")) +{ +} + +DataTableTabPage::~DataTableTabPage() = default; + +std::unique_ptr<SfxTabPage> DataTableTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrs) +{ + return std::make_unique<DataTableTabPage>(pPage, pController, *rAttrs); +} + +bool DataTableTabPage::FillItemSet(SfxItemSet* rOutAttrs) +{ + 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; +} + +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()); + } +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_DataTable.hxx b/chart2/source/controller/dialogs/tp_DataTable.hxx new file mode 100644 index 000000000000..11bcfb9203e1 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataTable.hxx @@ -0,0 +1,43 @@ +/* -*- 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 <sfx2/tabdlg.hxx> + +namespace weld +{ +class CheckButton; +} + +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; + +public: + DataTableTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs); + virtual ~DataTableTabPage() override; + + static std::unique_ptr<SfxTabPage> + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs); + + virtual bool FillItemSet(SfxItemSet* rOutAttrs) override; + virtual void Reset(const SfxItemSet* rInAttrs) override; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/DataTableItemConverter.hxx b/chart2/source/controller/inc/DataTableItemConverter.hxx new file mode 100644 index 000000000000..ad5d1aed4fc4 --- /dev/null +++ b/chart2/source/controller/inc/DataTableItemConverter.hxx @@ -0,0 +1,60 @@ +/* -*- 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 "ItemConverter.hxx" +#include <rtl/ref.hxx> +#include <vector> + +namespace com::sun::star::awt +{ +struct Size; +} +namespace com::sun::star::beans +{ +class XPropertySet; +} +namespace chart +{ +class ChartModel; +} + +class SdrModel; + +namespace chart::wrapper +{ +class DataTableItemConverter final : public ItemConverter +{ +public: + DataTableItemConverter(const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, + SfxItemPool& rItemPool, SdrModel& rDrawModel, + const rtl::Reference<::chart::ChartModel>& xChartDoc, + const css::awt::Size* pRefSize); + + virtual ~DataTableItemConverter() override; + + virtual void FillItemSet(SfxItemSet& rOutItemSet) const override; + virtual bool ApplyItemSet(const SfxItemSet& rItemSet) override; + +protected: + virtual const WhichRangesContainer& GetWhichPairs() const override; + virtual bool GetItemProperty(tWhichIdType nWhichId, + tPropertyNameWithMemberId& rOutProperty) const override; + + virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet& rOutItemSet) const override; + virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet& rItemSet) override; + +private: + std::vector<std::unique_ptr<ItemConverter>> m_aConverters; + rtl::Reference<::chart::ChartModel> m_xChartDoc; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx new file mode 100644 index 000000000000..103724816d42 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx @@ -0,0 +1,119 @@ +/* -*- 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 <DataTableItemConverter.hxx> +#include <ItemPropertyMap.hxx> +#include <CharacterPropertyItemConverter.hxx> +#include <GraphicPropertyItemConverter.hxx> +#include <chartview/ChartSfxItemIds.hxx> +#include <chartview/ExplicitScaleValues.hxx> +#include <chartview/ExplicitValueProvider.hxx> +#include "SchWhichPairs.hxx" +#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <CommonConverters.hxx> +#include <ChartType.hxx> +#include <ChartTypeHelper.hxx> +#include <Diagram.hxx> +#include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> +#include <memory> + +#include <osl/diagnose.h> +#include <o3tl/any.hxx> +#include <svl/eitem.hxx> +#include <svx/chrtitem.hxx> +#include <svx/sdangitm.hxx> +#include <svl/intitem.hxx> +#include <rtl/math.hxx> + +using namespace css; + +namespace chart::wrapper +{ +namespace +{ +ItemPropertyMapType& lclDataTablePropertyMap() +{ + static ItemPropertyMapType aPropertyMap{ + { SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, { "HBorder", 0 } }, + { SCHATTR_DATA_TABLE_VERTICAL_BORDER, { "VBorder", 0 } }, + { SCHATTR_DATA_TABLE_OUTLINE, { "Outline", 0 } }, + { SCHATTR_DATA_TABLE_KEYS, { "Keys", 0 } }, + }; + return aPropertyMap; +}; +} + +DataTableItemConverter::DataTableItemConverter( + const uno::Reference<beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, + SdrModel& rDrawModel, const rtl::Reference<::chart::ChartModel>& xChartDoc, + const awt::Size* pRefSize) + : ItemConverter(rPropertySet, rItemPool) + , m_xChartDoc(xChartDoc) +{ + m_aConverters.emplace_back(new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, xChartDoc, GraphicObjectType::LineProperties)); + m_aConverters.emplace_back( + new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); +} + +DataTableItemConverter::~DataTableItemConverter() = default; + +void DataTableItemConverter::FillItemSet(SfxItemSet& rOutItemSet) const +{ + for (const auto& pConv : m_aConverters) + { + pConv->FillItemSet(rOutItemSet); + } + + // own items + ItemConverter::FillItemSet(rOutItemSet); +} + +bool DataTableItemConverter::ApplyItemSet(const SfxItemSet& rItemSet) +{ + bool bResult = false; + + for (const auto& pConv : m_aConverters) + { + bResult = pConv->ApplyItemSet(rItemSet) || bResult; + } + + // own items + return ItemConverter::ApplyItemSet(rItemSet) || bResult; +} + +void DataTableItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet& rOutItemSet) const {} + +bool DataTableItemConverter::ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet& rItemSet) +{ + return false; +} + +const WhichRangesContainer& DataTableItemConverter::GetWhichPairs() const +{ + return nDataTableWhichPairs; +} + +bool DataTableItemConverter::GetItemProperty(tWhichIdType nWhichId, + tPropertyNameWithMemberId& rOutProperty) const +{ + ItemPropertyMapType& rMap(lclDataTablePropertyMap()); + auto aIt = rMap.find(nWhichId); + if (aIt == rMap.cend()) + return false; + + rOutProperty = (*aIt).second; + + return true; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index 3c1387009afd..3b33a1b57b29 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -171,4 +171,12 @@ const WhichRangesContainer nRegEquationWhichPairs(svl::Items< SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters >); +const WhichRangesContainer nDataTableWhichPairs(svl::Items< + SCHATTR_TEXT_START, SCHATTR_TEXT_END, + SCHATTR_DATA_TABLE_START, SCHATTR_DATA_TABLE_END, + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx + EE_ITEMS_START, EE_ITEMS_END +>); + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 1b72833f93bc..feb8cc6c8a59 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -33,6 +33,7 @@ #include <MultipleChartConverters.hxx> #include <TitleItemConverter.hxx> #include <LegendItemConverter.hxx> +#include <DataTableItemConverter.hxx> #include <RegressionCurveItemConverter.hxx> #include <RegressionEquationItemConverter.hxx> #include <ErrorBarItemConverter.hxx> @@ -287,6 +288,17 @@ wrapper::ItemConverter* createItemConverter( rDrawModel, xChartModel, wrapper::GraphicObjectType::LineAndFillProperties ); break; + case OBJECTTYPE_DATA_TABLE: + { + std::unique_ptr<awt::Size> pRefSize; + if (pRefSizeProvider) + pRefSize.reset(new awt::Size(pRefSizeProvider->getPageSize())); + + pItemConverter = new wrapper::DataTableItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, xChartModel, pRefSize.get()); + } + break; default: //OBJECTTYPE_UNKNOWN break; } diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index c696a94d8fcd..acf1417e3dc7 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -217,6 +217,14 @@ void ObjectHierarchy::createAxesTree( if( !bSupportsAxesGrids ) return; + // Data Table + uno::Reference<chart2::XDataTable> xDataTable = xDiagram->getDataTable(); + if (xDataTable.is()) + { + rContainer.push_back(ObjectIdentifier::createClassifiedIdentifierForObject(xDataTable, xChartDoc)); + } + + // Axes std::vector< rtl::Reference< Axis > > aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ); if( !m_bOrderingForElementSelector ) { diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx index 0c64234fc68b..b79a5fe9ca1e 100644 --- a/chart2/source/inc/ObjectIdentifier.hxx +++ b/chart2/source/inc/ObjectIdentifier.hxx @@ -74,6 +74,7 @@ enum ObjectType OBJECTTYPE_DATA_STOCK_RANGE, OBJECTTYPE_DATA_STOCK_LOSS, OBJECTTYPE_DATA_STOCK_GAIN, + OBJECTTYPE_DATA_TABLE, OBJECTTYPE_SHAPE, OBJECTTYPE_UNKNOWN }; @@ -149,6 +150,9 @@ public: static OUString createParticleForLegend( const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString createParticleForDataTable( + const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString addChildParticle( std::u16string_view rParticle, std::u16string_view rChildParticle ); static OUString createChildParticleWithIndex( ObjectType eObjectType, sal_Int32 nIndex ); static sal_Int32 getIndexFromParticleOrCID( const OUString& rParticleOrCID ); diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 45773344f873..a5099cc0c31a 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -194,7 +194,14 @@ constexpr TypedWhichId<SfxStringItem> SCHATTR_REGRESSION_YNAME constexpr TypedWhichId<SfxInt32Item> SCHATTR_REGRESSION_MOVING_TYPE (SCHATTR_REGRESSION_START + 12); constexpr sal_uInt16 SCHATTR_REGRESSION_END (SCHATTR_REGRESSION_MOVING_TYPE); -constexpr sal_uInt16 SCHATTR_END (SCHATTR_REGRESSION_END); +constexpr sal_uInt16 SCHATTR_DATA_TABLE_START (SCHATTR_REGRESSION_END + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_HORIZONTAL_BORDER (SCHATTR_DATA_TABLE_START + 0); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_VERTICAL_BORDER (SCHATTR_DATA_TABLE_START + 1); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_OUTLINE (SCHATTR_DATA_TABLE_START + 2); +constexpr TypedWhichId<SfxBoolItem> SCHATTR_DATA_TABLE_KEYS (SCHATTR_DATA_TABLE_START + 3); +constexpr sal_uInt16 SCHATTR_DATA_TABLE_END (SCHATTR_DATA_TABLE_KEYS); + +constexpr sal_uInt16 SCHATTR_END (SCHATTR_DATA_TABLE_END); // values for Items diff --git a/chart2/source/tools/ObjectIdentifier.cxx b/chart2/source/tools/ObjectIdentifier.cxx index 38bbdebe3aed..e6a375817a37 100644 --- a/chart2/source/tools/ObjectIdentifier.cxx +++ b/chart2/source/tools/ObjectIdentifier.cxx @@ -322,6 +322,12 @@ OUString ObjectIdentifier::createClassifiedIdentifierForObject( } + uno::Reference<chart2::XDataTable> xDataTable(xObject, uno::UNO_QUERY); + if (xDataTable.is()) + { + return createClassifiedIdentifierForParticle(createParticleForDataTable(xChartModel)); + } + //axis Reference< XAxis > xAxis( xObject, uno::UNO_QUERY ); if( xAxis.is() ) @@ -544,6 +550,11 @@ OUString ObjectIdentifier::createParticleForLegend( return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType( OBJECTTYPE_LEGEND ) + "="; } +OUString ObjectIdentifier::createParticleForDataTable(const rtl::Reference<::chart::ChartModel>& /* xChartModel */) +{ + return ObjectIdentifier::createParticleForDiagram() + ":" + getStringForType(OBJECTTYPE_DATA_TABLE) + "="; +} + OUString ObjectIdentifier::createClassifiedIdentifier( enum ObjectType eObjectType //e.g. OBJECTTYPE_DATA_SERIES , std::u16string_view rParticleID )//e.g. SeriesID @@ -870,6 +881,9 @@ OUString ObjectIdentifier::getStringForType( ObjectType eObjectType ) case OBJECTTYPE_DATA_STOCK_GAIN: aRet="StockGain"; break; + case OBJECTTYPE_DATA_TABLE: + aRet="DataTable"; + break; default: //OBJECTTYPE_UNKNOWN ; } @@ -941,6 +955,8 @@ ObjectType ObjectIdentifier::getObjectType( std::u16string_view aCID ) eRet = OBJECTTYPE_DATA_STOCK_LOSS; else if( o3tl::starts_with(aCID, u"StockGain") ) eRet = OBJECTTYPE_DATA_STOCK_GAIN; + else if( o3tl::starts_with(aCID, u"DataTable") ) + eRet = OBJECTTYPE_DATA_TABLE; else eRet = OBJECTTYPE_UNKNOWN; @@ -1240,6 +1256,13 @@ Reference< beans::XPropertySet > ObjectIdentifier::getObjectPropertySet( xChartType->getPropertyValue( "WhiteDay" ) >>= xObjectProperties; } break; + case OBJECTTYPE_DATA_TABLE: + { + if (xDiagram.is()) + xObjectProperties.set(xDiagram->getDataTable(), uno::UNO_QUERY); + } + break; + break; default: //OBJECTTYPE_UNKNOWN break; } diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index 37e78c116b76..3cf5a99fc29d 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -175,6 +175,11 @@ ChartItemPool::ChartItemPool(): rPoolDefaults[SCHATTR_REGRESSION_YNAME - SCHATTR_START] = new SfxStringItem(SCHATTR_REGRESSION_YNAME, "f(x)"); rPoolDefaults[SCHATTR_REGRESSION_MOVING_TYPE - SCHATTR_START] = new SfxInt32Item(SCHATTR_REGRESSION_MOVING_TYPE, css::chart2::MovingAverageType::Prior); + rPoolDefaults[SCHATTR_DATA_TABLE_HORIZONTAL_BORDER - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, false); + rPoolDefaults[SCHATTR_DATA_TABLE_VERTICAL_BORDER - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false); + rPoolDefaults[SCHATTR_DATA_TABLE_OUTLINE - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, false); + rPoolDefaults[SCHATTR_DATA_TABLE_KEYS - SCHATTR_START] = new SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, false); + /************************************************************************** * ItemInfos **************************************************************************/ diff --git a/chart2/uiconfig/ui/tp_DataTable.ui b/chart2/uiconfig/ui/tp_DataTable.ui new file mode 100644 index 000000000000..b9544f7c3e4e --- /dev/null +++ b/chart2/uiconfig/ui/tp_DataTable.ui @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface domain="chart"> + <requires lib="gtk+" version="3.20"/> + <object class="GtkBox" id="DataTableTabPage"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="border-width">6</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> + <child> + <object class="GtkFrame" id="frame2"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="label-xalign">0</property> + <property name="shadow-type">none</property> + <child> + <object class="GtkBox" id="box4"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="margin-top">6</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <child> + <object class="GtkCheckButton" id="horizontalBorderCB"> + <property name="label" translatable="yes" context="tp_DataTable|horizontalBorderCB">Show Horizontal Border</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="verticalBorderCB"> + <property name="label" translatable="yes" context="tp_DataTable|verticalBorderCB">Show Vertical Border</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="outlineCB"> + <property name="label" translatable="yes" context="tp_DataTable|outlineCB">Show Outline</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="keysCB"> + <property name="label" translatable="yes" context="tp_DataTable|keysCB">Show Keys</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="halign">start</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="dataTablePropertiesLabel"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="tp_axisLabel|textflowL">Data Table Properties</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> commit 625be58440eadebb33b5e8adc538e7f376808ed3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jun 17 16:38:54 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 chart2: remove unneeded class prefix in ObjectHierarchy.cxx Change-Id: Iee007f7ff4d9665ee089712e7ba98090a8090609 diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index ab1fa891377e..c696a94d8fcd 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -115,7 +115,7 @@ void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& xCh ObjectIdentifier aDiaOID; if( xDiagram.is() ) aDiaOID = ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( static_cast<cppu::OWeakObject*>(xDiagram.get()), xChartDocument ) ); - ObjectHierarchy::tChildContainer aTopLevelContainer; + tChildContainer aTopLevelContainer; // First Level @@ -158,7 +158,7 @@ void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& xCh createDiagramTree( aTopLevelContainer, xChartDocument, xDiagram ); else { - ObjectHierarchy::tChildContainer aSubContainer; + tChildContainer aSubContainer; createDiagramTree( aSubContainer, xChartDocument, xDiagram ); if( !aSubContainer.empty() ) m_aChildMap[ aDiaOID ] = aSubContainer; @@ -179,11 +179,11 @@ void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& xCh aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, u"" ) ); if( ! aTopLevelContainer.empty()) - m_aChildMap[ ObjectHierarchy::getRootNodeOID() ] = aTopLevelContainer; + m_aChildMap[ObjectHierarchy::getRootNodeOID()] = aTopLevelContainer; } void ObjectHierarchy::createLegendTree( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference<::chart::ChartModel> & xChartDoc, const rtl::Reference< Diagram > & xDiagram ) { @@ -199,7 +199,7 @@ void ObjectHierarchy::createLegendTree( rtl::Reference< SvxShapeGroupAnyD > xLegendShapeContainer = dynamic_cast<SvxShapeGroupAnyD*>( m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ).get() ); - ObjectHierarchy::tChildContainer aLegendEntryOIDs; + tChildContainer aLegendEntryOIDs; lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer ); m_aChildMap[ aLegendOID ] = aLegendEntryOIDs; @@ -207,7 +207,7 @@ void ObjectHierarchy::createLegendTree( } void ObjectHierarchy::createAxesTree( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference<::chart::ChartModel> & xChartDoc, const rtl::Reference< Diagram > & xDiagram ) { @@ -271,7 +271,7 @@ void ObjectHierarchy::createAxesTree( } void ObjectHierarchy::createWallAndFloor( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference< Diagram > & xDiagram ) { sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); @@ -289,7 +289,7 @@ void ObjectHierarchy::createWallAndFloor( } void ObjectHierarchy::createDiagramTree( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference<::chart::ChartModel> & xChartDoc, const rtl::Reference< Diagram > & xDiagram ) { @@ -307,7 +307,7 @@ void ObjectHierarchy::createDiagramTree( } void ObjectHierarchy::createDataSeriesTree( - ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, + tChildContainer & rOutDiagramSubContainer, const rtl::Reference< Diagram > & xDiagram ) { try @@ -334,7 +334,7 @@ void ObjectHierarchy::createDataSeriesTree( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForParticle( aSeriesParticle ) ) ); rOutDiagramSubContainer.push_back( aSeriesOID ); - ObjectHierarchy::tChildContainer aSeriesSubContainer; + tChildContainer aSeriesSubContainer; rtl::Reference< DataSeries > const & xSeries = aSeriesSeq[nSeriesIdx]; @@ -406,7 +406,7 @@ void ObjectHierarchy::createDataSeriesTree( } } -void ObjectHierarchy::createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer ) +void ObjectHierarchy::createAdditionalShapesTree(tChildContainer& rContainer) { try { @@ -453,7 +453,7 @@ const ObjectHierarchy::tChildContainer & ObjectHierarchy::getChildren( const Obj if( aIt != m_aChildMap.end()) return aIt->second; } - static const ObjectHierarchy::tChildContainer EMPTY; + static const tChildContainer EMPTY; return EMPTY; } @@ -463,13 +463,13 @@ const ObjectHierarchy::tChildContainer & ObjectHierarchy::getSiblings( const Obj { for (auto const& child : m_aChildMap) { - ObjectHierarchy::tChildContainer::const_iterator aElemIt( + tChildContainer::const_iterator aElemIt( std::find( child.second.begin(), child.second.end(), rNode )); if( aElemIt != child.second.end()) return child.second; } } - static const ObjectHierarchy::tChildContainer EMPTY; + static const tChildContainer EMPTY; return EMPTY; } @@ -478,8 +478,8 @@ ObjectIdentifier ObjectHierarchy::getParentImpl( const ObjectIdentifier & rOID ) const { // search children - ObjectHierarchy::tChildContainer aChildren( getChildren( rParentOID )); - ObjectHierarchy::tChildContainer::const_iterator aIt( + tChildContainer aChildren( getChildren( rParentOID )); + tChildContainer::const_iterator aIt( std::find( aChildren.begin(), aChildren.end(), rOID )); // recursion end if( aIt != aChildren.end()) commit c64da2fb40a009eafb1191864636f78b98e55795 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jun 17 16:29:23 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 chart2: call clear instead of creating a new empty map Change-Id: I8b21909e92b558240e84cffd9432e0d9e270284e diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index e1f3697e6250..ab1fa891377e 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -105,7 +105,7 @@ namespace chart void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& xChartDocument ) { - m_aChildMap = tChildMap();//clear tree + m_aChildMap.clear(); if( !xChartDocument.is() ) return; commit 9a039f9dd8b6beb6fd78c4775d522f95295550c8 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jun 17 16:28:38 2022 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 chart2: remove unneeded class prefix in ObjectHierarchy.hxx Change-Id: I1c851933e9b25dcd9a0dc29758baad8f3be7cb2e diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx b/chart2/source/controller/inc/ObjectHierarchy.hxx index 1255b7ac9910..1531866aaf2b 100644 --- a/chart2/source/controller/inc/ObjectHierarchy.hxx +++ b/chart2/source/controller/inc/ObjectHierarchy.hxx @@ -52,11 +52,10 @@ public: static bool isRootNode( const ObjectIdentifier& rOID ); /// equal to getChildren( getRootNodeOID()) - const tChildContainer & getTopLevelChildren() const; - bool hasChildren( const ObjectIdentifier& rParent ) const; - const tChildContainer & getChildren( const ObjectIdentifier& rParent ) const; - - const tChildContainer & getSiblings( const ObjectIdentifier& rNode ) const; + const tChildContainer& getTopLevelChildren() const; + bool hasChildren(const ObjectIdentifier& rParent) const; + const tChildContainer& getChildren(const ObjectIdentifier& rParent) const; + const tChildContainer& getSiblings(const ObjectIdentifier& rNode) const; /// The result is empty, if the node cannot be found in the tree ObjectIdentifier getParent( const ObjectIdentifier& rNode ) const; @@ -66,30 +65,29 @@ public: private: void createTree( const rtl::Reference<::chart::ChartModel> & xChartDocument ); void createAxesTree( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference<::chart::ChartModel> & xChartDoc, const rtl::Reference< ::chart::Diagram > & xDiagram ); void createDiagramTree( - ObjectHierarchy::tChildContainer& rContainer, + tChildContainer& rContainer, const rtl::Reference<::chart::ChartModel>& xChartDoc, const rtl::Reference< ::chart::Diagram >& xDiagram ); void createDataSeriesTree( - ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, + tChildContainer & rOutDiagramSubContainer, const rtl::Reference< ::chart::Diagram > & xDiagram ); static void createWallAndFloor( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference< ::chart::Diagram > & xDiagram ); void createLegendTree( - ObjectHierarchy::tChildContainer & rContainer, + tChildContainer & rContainer, const rtl::Reference<::chart::ChartModel> & xChartDoc, const rtl::Reference< ::chart::Diagram > & xDiagram ); - void createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer ); + void createAdditionalShapesTree(tChildContainer& rContainer); ObjectIdentifier getParentImpl( const ObjectIdentifier& rParentOID, const ObjectIdentifier& rOID ) const; - typedef std::map< ObjectIdentifier, ObjectHierarchy::tChildContainer > - tChildMap; + typedef std::map<ObjectIdentifier, tChildContainer> tChildMap; tChildMap m_aChildMap; ExplicitValueProvider* m_pExplicitValueProvider; bool m_bFlattenDiagram; commit 023937cf74e85cc5bbe952ece575444c8095e951 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 23 15:50:59 2022 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Thu Jun 30 23:41:53 2022 +0200 oox export: export line/fill and text props. of a data table Change-Id: I02a4c35693b599578e073d52a2d22ad59bc31786 diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 988fe4413529..458f72112907 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -2066,6 +2066,9 @@ void ChartExport::exportDataTable( ) if (bShowKeys) pFS->singleElement(FSNS(XML_c, XML_showKeys), XML_val, "1"); + exportShapeProps(aPropSet); + exportTextProps(aPropSet); + pFS->endElement(FSNS(XML_c, XML_dTable)); } commit 23b6b00a78fcf6c1e6e30386cb51bc5883e8777b 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: Thu Jun 30 23:41:53 2022 +0200 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 73f934867133..f899e724839e 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 bd2d4e54d52d988fe9747dd0afded19e50d22f97 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: Thu Jun 30 23:41:52 2022 +0200 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 83ebd9e3a6e2..0620ce5ccaba 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -91,8 +91,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); @@ -211,7 +212,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 883450d70091f3eced9e42950481b5b5c7cea0fe 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: Thu Jun 30 23:41:52 2022 +0200 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 3b2015b1634c81f34360a862a48f479c5997ada5 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: Thu Jun 30 23:41:52 2022 +0200 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 096586279454..d7e78d5d2e85 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -37,6 +37,7 @@ #include <svx/unoshtxt.hxx> #include <VSeriesPlotter.hxx> #include <DataTableView.hxx> +#include <ChartModel.hxx> #include <comphelper/scopeguard.hxx> @@ -1993,11 +1994,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..0a6ebe06f47d 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> 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 4a68f4a2bfa1..73f934867133 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() && m_xChartModel.is()) + { + 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 cb85ab7e251e241f4fc2482b9abbad3c3e20c897 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: Thu Jun 30 23:41:52 2022 +0200 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 02f186a25a14..83ebd9e3a6e2 100644 --- a/chart2/source/model/main/DataTable.cxx +++ b/chart2/source/model/main/DataTable.cxx @@ -33,20 +33,19 @@ enum DataTableProperty_Keys, }; -void lcl_AddPropertiesToVector(std::vector<beans::Property>& rOutProperties) -{ - 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("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 StaticDataTableDefaults_Initializer commit 2f88dfe5f485d343d73b54c926e677a6ac5fa758 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: Thu Jun 30 23:41:52 2022 +0200 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 db1abe739787..0fea6c4da7f9 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -137,9 +137,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 }; @@ -381,21 +378,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 1a3d9423fbb76a32e772c692549454ea0401196e 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: Thu Jun 30 23:41:52 2022 +0200 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 2266dd143d2e..096586279454 100644 --- a/chart2/source/view/axes/VCartesianAxis.cxx +++ b/chart2/source/view/axes/VCartesianAxis.cxx @@ -1997,7 +1997,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 35dca6a85767..4a68f4a2bfa1 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 e5ad9eaab1d17fdc91872de646399903b9afef9a 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: Thu Jun 30 23:41:51 2022 +0200 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 d22ff0404042495c3ff456a4d3b0a8560fb19867 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: Thu Jun 30 23:41:51 2022 +0200 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 8cb9e0eec7ee..f39420c9ce02 100644 --- a/chart2/source/view/axes/VAxisProperties.cxx +++ b/chart2/source/view/axes/VAxisProperties.cxx @@ -153,8 +153,9 @@ TickmarkProperties AxisProperties::getBiggestTickmarkProperties() return aTickmarkProperties; } -AxisProperties::AxisProperties( rtl::Reference< Axis > xAxisModel - , ExplicitCategoriesProvider* pExplicitCategoriesProvider ) +AxisProperties::AxisProperties(rtl::Reference<::chart::Axis> xAxisModel, + ExplicitCategoriesProvider* pExplicitCategoriesProvider, + rtl::Reference<::chart::DataTable> const& xDataTableModel) : m_xAxisModel(std::move(xAxisModel)) , m_nDimensionIndex(0) , m_bIsMainAxis(true) @@ -174,6 +175,7 @@ AxisProperties::AxisProperties( rtl::Reference< Axis > xAxisModel , m_bComplexCategories(false) , m_pExplicitCategoriesProvider(pExplicitCategoriesProvider) , m_bLimitSpaceForLabels(false) + , m_xDataTableModel(xDataTableModel) { } @@ -256,7 +258,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 d66b2f3a919e..6b6b7c361ea2 100644 --- a/chart2/source/view/axes/VAxisProperties.hxx +++ b/chart2/source/view/axes/VAxisProperties.hxx @@ -21,6 +21,7 @@ #include "TickmarkProperties.hxx" #include <Axis.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( rtl::Reference< ::chart::Axis > xAxisModel - , ExplicitCategoriesProvider* pExplicitCategoriesProvider ); + AxisProperties(rtl::Reference<::chart::Axis> 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); ... etc. - the rest is truncated