summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-09-14 23:55:20 +0200
committerTomaž Vajngerl <quikee@gmail.com>2022-09-15 12:38:22 +0200
commit23c01f82682469e25fa2a8407c55100e89ab86de (patch)
tree38d85d60d058d46e8c5876d552fbc45c2c9df5a0 /chart2
parentd0760109b7bb965187243cdb1d3a07df83039db1 (diff)
Add documentation for data table added classes and functions
Change-Id: Idc9756bf5b468d8ed0d11e6a75703d96350e1273 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139960 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/dialogs/tp_DataTable.hxx1
-rw-r--r--chart2/source/controller/inc/DataTableItemConverter.hxx1
-rw-r--r--chart2/source/controller/inc/dlg_InsertDataTable.hxx5
-rw-r--r--chart2/source/controller/inc/res_DataTableProperties.hxx1
-rw-r--r--chart2/source/controller/main/ChartController_Insert.cxx4
-rw-r--r--chart2/source/inc/ObjectIdentifier.hxx1
-rw-r--r--chart2/source/model/main/DataTable.cxx1
-rw-r--r--chart2/source/view/inc/DataTableView.hxx25
-rw-r--r--chart2/source/view/main/DataTableView.cxx9
9 files changed, 46 insertions, 2 deletions
diff --git a/chart2/source/controller/dialogs/tp_DataTable.hxx b/chart2/source/controller/dialogs/tp_DataTable.hxx
index a4ef6d6cf436..00ab64cf89ce 100644
--- a/chart2/source/controller/dialogs/tp_DataTable.hxx
+++ b/chart2/source/controller/dialogs/tp_DataTable.hxx
@@ -14,6 +14,7 @@
namespace chart
{
+/** Tab page for the data table properties */
class DataTableTabPage : public SfxTabPage
{
private:
diff --git a/chart2/source/controller/inc/DataTableItemConverter.hxx b/chart2/source/controller/inc/DataTableItemConverter.hxx
index 5dbfaf60bba9..68c5790ba345 100644
--- a/chart2/source/controller/inc/DataTableItemConverter.hxx
+++ b/chart2/source/controller/inc/DataTableItemConverter.hxx
@@ -30,6 +30,7 @@ class SdrModel;
namespace chart::wrapper
{
+/** Convert data table properties to and from ItemSet and UNO PropertySet */
class DataTableItemConverter final : public ItemConverter
{
public:
diff --git a/chart2/source/controller/inc/dlg_InsertDataTable.hxx b/chart2/source/controller/inc/dlg_InsertDataTable.hxx
index 346f7b651c24..cd77099864c4 100644
--- a/chart2/source/controller/inc/dlg_InsertDataTable.hxx
+++ b/chart2/source/controller/inc/dlg_InsertDataTable.hxx
@@ -14,6 +14,7 @@
namespace chart
{
+/** The data table properties (data) used by the dialog */
struct DataTableDialogData
{
bool mbShow = true;
@@ -23,6 +24,7 @@ struct DataTableDialogData
bool mbKeys = false;
};
+/** The dialog to change the data table specific properties */
class InsertDataTableDialog final : public weld::GenericDialogController
{
private:
@@ -38,7 +40,10 @@ private:
public:
InsertDataTableDialog(weld::Window* pParent);
+ /** Set the initial state of the data table properties */
void init(DataTableDialogData const& rData);
+
+ /** Get the state of the data table properties from the dialog */
DataTableDialogData& getDataTableDialogData();
};
diff --git a/chart2/source/controller/inc/res_DataTableProperties.hxx b/chart2/source/controller/inc/res_DataTableProperties.hxx
index 299934cb0211..4b2aaa4f2ef7 100644
--- a/chart2/source/controller/inc/res_DataTableProperties.hxx
+++ b/chart2/source/controller/inc/res_DataTableProperties.hxx
@@ -14,6 +14,7 @@
namespace chart
{
+/** The shared UI elements for the data table properties */
class DataTablePropertiesResources final
{
private:
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx
index 78005072a009..c75ac20457e5 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -235,6 +235,7 @@ void ChartController::executeDispatch_OpenInsertDataTableDialog()
}
}
+/** Create and insert a data table to the chart */
void ChartController::executeDispatch_InsertDataTable()
{
auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_DATA_TABLE));
@@ -254,16 +255,17 @@ void ChartController::executeDispatch_InsertDataTable()
}
}
+/** Delete a data table from the chart */
void ChartController::executeDispatch_DeleteDataTable()
{
auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Delete, SchResId(STR_DATA_TABLE));
UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager);
-
rtl::Reference<Diagram> xDiagram = getFirstDiagram();
auto xDataTable = xDiagram->getDataTable();
if (xDataTable.is())
{
+ // insert a empty data table reference
xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
aUndoGuard.commit();
}
diff --git a/chart2/source/inc/ObjectIdentifier.hxx b/chart2/source/inc/ObjectIdentifier.hxx
index b79a5fe9ca1e..14b684f59f46 100644
--- a/chart2/source/inc/ObjectIdentifier.hxx
+++ b/chart2/source/inc/ObjectIdentifier.hxx
@@ -150,6 +150,7 @@ public:
static OUString createParticleForLegend(
const rtl::Reference<::chart::ChartModel>& xChartModel );
+ /** Creates an identifier for the data table */
static OUString createParticleForDataTable(
const rtl::Reference<::chart::ChartModel>& xChartModel );
diff --git a/chart2/source/model/main/DataTable.cxx b/chart2/source/model/main/DataTable.cxx
index a81cc6dedf7a..d21febb14e47 100644
--- a/chart2/source/model/main/DataTable.cxx
+++ b/chart2/source/model/main/DataTable.cxx
@@ -25,6 +25,7 @@ using namespace css;
namespace
{
+/** DataTable Properties */
enum
{
DataTableProperty_HorizontalBorder,
diff --git a/chart2/source/view/inc/DataTableView.hxx b/chart2/source/view/inc/DataTableView.hxx
index ba0a5f8d051d..0bccaaddde31 100644
--- a/chart2/source/view/inc/DataTableView.hxx
+++ b/chart2/source/view/inc/DataTableView.hxx
@@ -23,26 +23,43 @@ class VSeriesPlotter;
class ChartModel;
class LegendEntryProvider;
+/**
+ * DataTableView is responsible to create the table object, set the cell
+ * properties accordingly to the model and fill it with the chart series
+ * data.
+ */
class DataTableView final
{
private:
rtl::Reference<::chart::ChartModel> m_xChartModel;
+ // the target shape
rtl::Reference<SvxShapeGroupAnyD> m_xTarget;
+ // the data table shape
rtl::Reference<SvxTableShape> m_xTableShape;
+ // the data table model
rtl::Reference<DataTable> m_xDataTableModel;
css::uno::Reference<css::uno::XComponentContext> m_xComponentContext;
css::uno::Reference<css::table::XTable> m_xTable;
VLineProperties m_aLineProperties;
std::vector<VSeriesPlotter*> m_pSeriesPlotterList;
+ // data series names
std::vector<OUString> m_aDataSeriesNames;
+ // X axis names
std::vector<OUString> m_aXValues;
+ // list of data series values
std::vector<std::vector<OUString>> m_pDataSeriesValues;
+
+ // if the header vales should be aligned with the x-axis vales
bool m_bAlignAxisValuesWithColumns;
+ /** Set the char and paragraph properties for the input (value) cell */
void
setCellCharAndParagraphProperties(css::uno::Reference<css::beans::XPropertySet>& xPropertySet);
+ /** Set the common cell properties (for all cells in the data table,
+ * including headers)
+ */
void setCellProperties(css::uno::Reference<css::beans::XPropertySet>& xPropertySet, bool bLeft,
bool bTop, bool bRight, bool bBottom);
@@ -51,10 +68,18 @@ public:
rtl::Reference<DataTable> const& rDataTableModel,
css::uno::Reference<css::uno::XComponentContext> const& rComponentContext,
bool bAlignAxisValuesWithColumns);
+
+ /** Initializes and prepares the target and data table shape */
void initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& xTarget);
+
+ /** Prepares the values of the chart, which will be shown it the data table */
void initializeValues(std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList);
+
+ /** Creates the data table and fills the values */
void createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector const& rEnd,
sal_Int32 nAxisStepWidth);
+
+ /** Repositions the data table shape */
void changePosition(sal_Int32 x, sal_Int32 y);
};
diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx
index 45b199b59d69..c3c807ca099b 100644
--- a/chart2/source/view/main/DataTableView.cxx
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -239,11 +239,13 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV
if (!m_xTarget.is())
return;
+ // Remove shapes first before we add the new ones
ShapeFactory::removeSubShapes(m_xTarget);
auto sParticle = ObjectIdentifier::createParticleForDataTable(m_xChartModel);
auto sCID = ObjectIdentifier::createClassifiedIdentifierForParticle(sParticle);
m_xTableShape = ShapeFactory::createTable(m_xTarget, sCID);
+ // calculate the table size
auto rDelta = rEnd - rStart;
sal_Int32 nTableSize = basegfx::fround(rDelta.getX());
m_xTableShape->setSize({ nTableSize, 0 });
@@ -269,6 +271,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV
auto* pTableObject = static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject());
+ // get the data table properties from the model
bool bHBorder = false;
bool bVBorder = false;
bool bOutline = false;
@@ -281,6 +284,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV
m_xDataTableModel->getPropertyValue("Outline") >>= bOutline;
m_xDataTableModel->getPropertyValue("Keys") >>= bKeys;
+ // set the data table row and column size
sal_Int32 nColumnCount = m_aXValues.size();
uno::Reference<table::XTableColumns> xTableColumns = m_xTable->getColumns();
xTableColumns->insertByIndex(0, nColumnCount);
@@ -291,7 +295,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV
sal_Int32 nColumnWidth = 0.0;
- // If we don't align, we have to calculate the column width ourselves
+ // If we don't align, we have to calculate the column width ourselves,
+ // otherwise the column width is taken from the x-axis width
if (m_bAlignAxisValuesWithColumns)
nColumnWidth = nAxisStepWidth;
else
@@ -452,11 +457,13 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV
xBroadcaster->unlockBroadcasts();
+ // force recalculation of all cells in the table shape
pTableObject->DistributeColumns(0, nColumnCount, true, true);
pTableObject->DistributeRows(0, nRowCount, true, true);
xBroadcaster->lockBroadcasts();
+ // reposition the data table
changePosition(basegfx::fround(rStart.getX()), basegfx::fround(rStart.getY()));
sal_Int32 nTableX = m_xTableShape->getPosition().X;