tdf#120397 - odf export fix missing texts in text box control
[LibreOffice.git] / chart2 / source / view / main / DataTableView.cxx
blobbec3999d61fef00f16ca8af42af99c803b1afa25
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <DataTableView.hxx>
11 #include <VSeriesPlotter.hxx>
12 #include <ShapeFactory.hxx>
13 #include <ExplicitCategoriesProvider.hxx>
14 #include <ChartModel.hxx>
15 #include <ObjectIdentifier.hxx>
17 #include <svx/svdotable.hxx>
19 #include <com/sun/star/table/BorderLine.hpp>
20 #include <com/sun/star/table/BorderLine2.hpp>
21 #include <com/sun/star/table/TableBorder.hpp>
22 #include <com/sun/star/table/BorderLineStyle.hpp>
23 #include <com/sun/star/text/XTextRange.hpp>
24 #include <com/sun/star/text/XText.hpp>
25 #include <com/sun/star/style/ParagraphAdjust.hpp>
26 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
27 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
28 #include <com/sun/star/drawing/LineDash.hpp>
29 #include <com/sun/star/drawing/LineStyle.hpp>
30 #include <com/sun/star/drawing/FillStyle.hpp>
31 #include <com/sun/star/util/XBroadcaster.hpp>
32 #include <com/sun/star/container/XNameContainer.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <o3tl/unit_conversion.hxx>
37 using namespace css;
39 namespace chart
41 namespace
43 void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet)
45 xPropertySet->setPropertyValue(u"FillColor"_ustr, uno::Any(Color(0xFFFFFF)));
46 xPropertySet->setPropertyValue(u"TextVerticalAdjust"_ustr,
47 uno::Any(drawing::TextVerticalAdjust_TOP));
48 xPropertySet->setPropertyValue(u"ParaAdjust"_ustr, uno::Any(style::ParagraphAdjust_CENTER));
50 table::BorderLine2 aBorderLine;
51 aBorderLine.LineWidth = 0;
52 aBorderLine.Color = 0x000000;
54 xPropertySet->setPropertyValue(u"TopBorder"_ustr, uno::Any(aBorderLine));
55 xPropertySet->setPropertyValue(u"LeftBorder"_ustr, uno::Any(aBorderLine));
58 void copyProperty(uno::Reference<beans::XPropertySet>& xOut,
59 uno::Reference<beans::XPropertySet>& xIn, OUString const& sPropertyName)
61 xOut->setPropertyValue(sPropertyName, xIn->getPropertyValue(sPropertyName));
64 uno::Reference<text::XTextRange> getFirstParagraph(uno::Reference<text::XText> const& xText)
66 uno::Reference<text::XTextRange> xParagraph;
67 uno::Reference<container::XEnumerationAccess> xEnumAccess(xText, uno::UNO_QUERY);
68 if (!xEnumAccess.is())
69 return xParagraph;
70 uno::Reference<container::XEnumeration> xEnumeration(xEnumAccess->createEnumeration());
71 xParagraph.set(xEnumeration->nextElement(), uno::UNO_QUERY);
72 return xParagraph;
75 uno::Reference<beans::XPropertySet>
76 getFirstParagraphProperties(uno::Reference<text::XText> const& xText)
78 uno::Reference<beans::XPropertySet> xPropertySet;
79 auto xParagraph = getFirstParagraph(xText);
80 if (!xParagraph.is())
81 return xPropertySet;
82 xPropertySet.set(xParagraph, uno::UNO_QUERY);
83 return xPropertySet;
86 } // end anonymous namespace
88 DataTableView::DataTableView(
89 rtl::Reference<::chart::ChartModel> const& xChartModel,
90 rtl::Reference<DataTable> const& rDataTableModel,
91 css::uno::Reference<css::uno::XComponentContext> const& rComponentContext,
92 bool bAlignAxisValuesWithColumns)
93 : m_xChartModel(xChartModel)
94 , m_xDataTableModel(rDataTableModel)
95 , m_xComponentContext(rComponentContext)
96 , m_bAlignAxisValuesWithColumns(bAlignAxisValuesWithColumns)
98 uno::Reference<beans::XPropertySet> xPropertySet(m_xDataTableModel);
99 m_aLineProperties.initFromPropertySet(xPropertySet);
102 void DataTableView::setCellCharAndParagraphProperties(
103 uno::Reference<beans::XPropertySet>& xPropertySet)
105 uno::Reference<beans::XPropertySet> xDataTableProperties(m_xDataTableModel);
107 copyProperty(xPropertySet, xDataTableProperties, u"CharColor"_ustr);
108 copyProperty(xPropertySet, xDataTableProperties, u"CharFontFamily"_ustr);
109 copyProperty(xPropertySet, xDataTableProperties, u"CharFontFamilyAsian"_ustr);
110 copyProperty(xPropertySet, xDataTableProperties, u"CharFontFamilyComplex"_ustr);
111 copyProperty(xPropertySet, xDataTableProperties, u"CharFontCharSet"_ustr);
112 copyProperty(xPropertySet, xDataTableProperties, u"CharFontCharSetAsian"_ustr);
113 copyProperty(xPropertySet, xDataTableProperties, u"CharFontCharSetComplex"_ustr);
114 copyProperty(xPropertySet, xDataTableProperties, u"CharFontName"_ustr);
115 copyProperty(xPropertySet, xDataTableProperties, u"CharFontNameAsian"_ustr);
116 copyProperty(xPropertySet, xDataTableProperties, u"CharFontNameComplex"_ustr);
117 copyProperty(xPropertySet, xDataTableProperties, u"CharFontPitch"_ustr);
118 copyProperty(xPropertySet, xDataTableProperties, u"CharFontPitchAsian"_ustr);
119 copyProperty(xPropertySet, xDataTableProperties, u"CharFontPitchComplex"_ustr);
120 copyProperty(xPropertySet, xDataTableProperties, u"CharFontStyleName"_ustr);
121 copyProperty(xPropertySet, xDataTableProperties, u"CharFontStyleNameAsian"_ustr);
122 copyProperty(xPropertySet, xDataTableProperties, u"CharFontStyleNameComplex"_ustr);
124 copyProperty(xPropertySet, xDataTableProperties, u"CharHeight"_ustr);
125 copyProperty(xPropertySet, xDataTableProperties, u"CharHeightAsian"_ustr);
126 copyProperty(xPropertySet, xDataTableProperties, u"CharHeightComplex"_ustr);
127 copyProperty(xPropertySet, xDataTableProperties, u"CharKerning"_ustr);
128 copyProperty(xPropertySet, xDataTableProperties, u"CharLocale"_ustr);
129 copyProperty(xPropertySet, xDataTableProperties, u"CharLocaleAsian"_ustr);
130 copyProperty(xPropertySet, xDataTableProperties, u"CharLocaleComplex"_ustr);
131 copyProperty(xPropertySet, xDataTableProperties, u"CharPosture"_ustr);
132 copyProperty(xPropertySet, xDataTableProperties, u"CharPostureAsian"_ustr);
133 copyProperty(xPropertySet, xDataTableProperties, u"CharPostureComplex"_ustr);
134 copyProperty(xPropertySet, xDataTableProperties, u"CharRelief"_ustr);
135 copyProperty(xPropertySet, xDataTableProperties, u"CharShadowed"_ustr);
136 copyProperty(xPropertySet, xDataTableProperties, u"CharStrikeout"_ustr);
137 copyProperty(xPropertySet, xDataTableProperties, u"CharUnderline"_ustr);
138 copyProperty(xPropertySet, xDataTableProperties, u"CharUnderlineColor"_ustr);
139 copyProperty(xPropertySet, xDataTableProperties, u"CharUnderlineHasColor"_ustr);
140 copyProperty(xPropertySet, xDataTableProperties, u"CharOverline"_ustr);
141 copyProperty(xPropertySet, xDataTableProperties, u"CharOverlineColor"_ustr);
142 copyProperty(xPropertySet, xDataTableProperties, u"CharOverlineHasColor"_ustr);
143 copyProperty(xPropertySet, xDataTableProperties, u"CharWeight"_ustr);
144 copyProperty(xPropertySet, xDataTableProperties, u"CharWeightAsian"_ustr);
145 copyProperty(xPropertySet, xDataTableProperties, u"CharWeightComplex"_ustr);
146 copyProperty(xPropertySet, xDataTableProperties, u"CharWordMode"_ustr);
148 drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
149 xDataTableProperties->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle;
150 if (eFillStyle == drawing::FillStyle_SOLID)
152 sal_Int32 aColor = 0;
153 if (xDataTableProperties->getPropertyValue(u"FillColor"_ustr) >>= aColor)
154 xPropertySet->setPropertyValue(u"CharBackColor"_ustr, uno::Any(aColor));
157 xPropertySet->setPropertyValue(u"ParaAdjust"_ustr, uno::Any(style::ParagraphAdjust_CENTER));
160 void DataTableView::setCellProperties(css::uno::Reference<beans::XPropertySet>& xPropertySet,
161 bool bLeft, bool bTop, bool bRight, bool bBottom)
163 xPropertySet->setPropertyValue(u"FillColor"_ustr, uno::Any(Color(0xFFFFFF)));
165 uno::Reference<beans::XPropertySet> xDataTableProperties(m_xDataTableModel);
166 float fFontHeight = 0.0;
167 xDataTableProperties->getPropertyValue(u"CharHeight"_ustr) >>= fFontHeight;
168 fFontHeight = o3tl::convert(fFontHeight, o3tl::Length::pt, o3tl::Length::mm100);
169 sal_Int32 nXDistance = std::round(fFontHeight * 0.18f);
170 sal_Int32 nYDistance = std::round(fFontHeight * 0.30f);
172 xPropertySet->setPropertyValue(u"TextLeftDistance"_ustr, uno::Any(nXDistance));
173 xPropertySet->setPropertyValue(u"TextRightDistance"_ustr, uno::Any(nXDistance));
174 xPropertySet->setPropertyValue(u"TextUpperDistance"_ustr, uno::Any(nYDistance));
175 xPropertySet->setPropertyValue(u"TextLowerDistance"_ustr, uno::Any(nYDistance));
177 xPropertySet->setPropertyValue(u"TextVerticalAdjust"_ustr,
178 uno::Any(drawing::TextVerticalAdjust_TOP));
180 drawing::LineStyle eStyle = drawing::LineStyle_NONE;
181 m_aLineProperties.LineStyle >>= eStyle;
183 if (eStyle != drawing::LineStyle_NONE)
185 table::BorderLine2 aBorderLine;
187 sal_Int32 nWidth = 0;
188 m_aLineProperties.Width >>= nWidth;
189 aBorderLine.LineWidth = o3tl::convert(nWidth, o3tl::Length::mm100, o3tl::Length::twip);
191 sal_Int32 nColor = 0;
192 m_aLineProperties.Color >>= nColor;
193 aBorderLine.Color = nColor;
195 aBorderLine.LineStyle = table::BorderLineStyle::SOLID;
197 if (eStyle == drawing::LineStyle_DASH)
199 OUString aDashName;
200 m_aLineProperties.DashName >>= aDashName;
201 if (!aDashName.isEmpty() && m_xChartModel.is())
203 uno::Reference<container::XNameContainer> xDashTable(
204 m_xChartModel->createInstance(u"com.sun.star.drawing.DashTable"_ustr),
205 uno::UNO_QUERY);
206 if (xDashTable.is() && xDashTable->hasByName(aDashName))
208 drawing::LineDash aLineDash;
209 xDashTable->getByName(aDashName) >>= aLineDash;
211 if (aLineDash.Dots == 0 && aLineDash.Dashes == 0)
212 aBorderLine.LineStyle = table::BorderLineStyle::SOLID;
213 else if (aLineDash.Dots == 1 && aLineDash.Dashes == 0)
214 aBorderLine.LineStyle = table::BorderLineStyle::DOTTED;
215 else if (aLineDash.Dots == 0 && aLineDash.Dashes == 1)
216 aBorderLine.LineStyle = table::BorderLineStyle::DASHED;
217 else if (aLineDash.Dots == 1 && aLineDash.Dashes == 1)
218 aBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT;
219 else if (aLineDash.Dots == 2 && aLineDash.Dashes == 1)
220 aBorderLine.LineStyle = table::BorderLineStyle::DASH_DOT_DOT;
221 else
222 aBorderLine.LineStyle = table::BorderLineStyle::DASHED;
227 if (bLeft)
228 xPropertySet->setPropertyValue(u"LeftBorder"_ustr, uno::Any(aBorderLine));
229 if (bTop)
230 xPropertySet->setPropertyValue(u"TopBorder"_ustr, uno::Any(aBorderLine));
231 if (bRight)
232 xPropertySet->setPropertyValue(u"RightBorder"_ustr, uno::Any(aBorderLine));
233 if (bBottom)
234 xPropertySet->setPropertyValue(u"BottomBorder"_ustr, uno::Any(aBorderLine));
238 void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector const& rEnd,
239 sal_Int32 nAxisStepWidth)
241 if (!m_xTarget.is())
242 return;
244 // Remove shapes first before we add the new ones
245 ShapeFactory::removeSubShapes(m_xTarget);
246 auto sParticle = ObjectIdentifier::createParticleForDataTable(m_xChartModel);
247 auto sCID = ObjectIdentifier::createClassifiedIdentifierForParticle(sParticle);
248 m_xTableShape = ShapeFactory::createTable(m_xTarget, sCID);
250 // calculate the table size
251 auto rDelta = rEnd - rStart;
252 sal_Int32 nTableSize = basegfx::fround(rDelta.getX());
253 m_xTableShape->setSize({ nTableSize, 0 });
257 m_xTableShape->getPropertyValue(u"Model"_ustr) >>= m_xTable;
259 catch (const uno::Exception&)
261 return;
264 if (!m_xTable.is())
265 return;
267 uno::Reference<util::XBroadcaster> xBroadcaster(m_xTable, uno::UNO_QUERY);
269 if (!xBroadcaster.is())
270 return;
272 xBroadcaster->lockBroadcasts();
274 auto* pTableObject = static_cast<sdr::table::SdrTableObj*>(m_xTableShape->GetSdrObject());
276 // get the data table properties from the model
277 bool bHBorder = false;
278 bool bVBorder = false;
279 bool bOutline = false;
280 bool bKeys = false;
282 std::vector<ViewLegendSymbol> aSymbols;
284 m_xDataTableModel->getPropertyValue(u"HBorder"_ustr) >>= bHBorder;
285 m_xDataTableModel->getPropertyValue(u"VBorder"_ustr) >>= bVBorder;
286 m_xDataTableModel->getPropertyValue(u"Outline"_ustr) >>= bOutline;
287 m_xDataTableModel->getPropertyValue(u"Keys"_ustr) >>= bKeys;
289 // set the data table row and column size
290 sal_Int32 nColumnCount = m_aXValues.size();
291 uno::Reference<table::XTableColumns> xTableColumns = m_xTable->getColumns();
292 xTableColumns->insertByIndex(0, nColumnCount);
294 sal_Int32 nRowCount = m_aDataSeriesNames.size();
295 uno::Reference<table::XTableRows> xTableRows = m_xTable->getRows();
296 xTableRows->insertByIndex(0, nRowCount);
298 sal_Int32 nColumnWidth = 0.0;
300 // If we don't align, we have to calculate the column width ourselves,
301 // otherwise the column width is taken from the x-axis width
302 if (m_bAlignAxisValuesWithColumns)
303 nColumnWidth = nAxisStepWidth;
304 else
305 nColumnWidth = double(nTableSize) / nColumnCount;
307 // Setup empty top-left cell
309 uno::Reference<table::XCell> xCell = m_xTable->getCellByPosition(0, 0);
310 uno::Reference<beans::XPropertySet> xPropertySet(xCell, uno::UNO_QUERY);
311 if (xPropertySet.is())
313 setTopCell(xPropertySet);
317 sal_Int32 nColumn;
318 sal_Int32 nRow;
320 // COLUMN HEADER
322 nColumn = 1;
323 for (auto const& rString : m_aXValues)
325 uno::Reference<table::XCell> xCell = m_xTable->getCellByPosition(nColumn, 0);
326 uno::Reference<beans::XPropertySet> xPropertySet(xCell, uno::UNO_QUERY);
327 uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY);
328 if (xCellTextRange.is())
330 auto xText = xCellTextRange->getText();
331 xText->insertString(xText->getStart(), rString, false);
332 auto xTextPropertySet = getFirstParagraphProperties(xText);
333 if (xTextPropertySet)
335 bool bLeft = (bOutline && nColumn == 1)
336 || (bVBorder && nColumn > 1 && nColumn < nColumnCount);
337 bool bRight = (bOutline && nColumn == nColumnCount)
338 || (bVBorder && nColumn > 1 && nColumn < nColumnCount);
339 setCellCharAndParagraphProperties(xTextPropertySet);
340 setCellProperties(xPropertySet, bLeft, bOutline, bRight, bOutline);
343 nColumn++;
346 // ROW HEADER
347 // Prepare keys (symbols)
348 sal_Int32 nMaxSymbolWidth = 0;
349 constexpr const sal_Int32 constSymbolMargin = 100; // 1mm
350 if (bKeys)
352 uno::Reference<beans::XPropertySet> xDataTableProperties(m_xDataTableModel);
353 float fFontHeight = 0.0;
354 xDataTableProperties->getPropertyValue(u"CharHeight"_ustr) >>= fFontHeight;
355 fFontHeight = o3tl::convert(fFontHeight, o3tl::Length::pt, o3tl::Length::mm100);
357 sal_Int32 nSymbolHeight = sal_Int32(fFontHeight * 0.6);
358 sal_Int32 nSymbolWidth = nSymbolHeight;
360 for (VSeriesPlotter* pSeriesPlotter : m_pSeriesPlotterList)
362 if (pSeriesPlotter)
364 awt::Size aCurrentRatio = pSeriesPlotter->getPreferredLegendKeyAspectRatio();
365 sal_Int32 nCurrentWidth = aCurrentRatio.Width;
366 if (aCurrentRatio.Height > 0)
367 nCurrentWidth = nSymbolHeight * aCurrentRatio.Width / aCurrentRatio.Height;
368 nSymbolWidth = std::max(nSymbolWidth, nCurrentWidth);
371 nMaxSymbolWidth = nSymbolWidth;
373 for (VSeriesPlotter* pSeriesPlotter : m_pSeriesPlotterList)
375 if (pSeriesPlotter)
377 awt::Size aSize(nSymbolWidth, nSymbolHeight);
378 std::vector<ViewLegendSymbol> aNewEntries
379 = pSeriesPlotter->createSymbols(aSize, m_xTarget, m_xComponentContext);
381 for (auto const& rSymbol : aNewEntries)
382 aSymbols.push_back(rSymbol);
387 nRow = 1;
388 for (auto const& rSeriesName : m_aDataSeriesNames)
390 uno::Reference<table::XCell> xCell = m_xTable->getCellByPosition(0, nRow);
391 uno::Reference<beans::XPropertySet> xCellPropertySet(xCell, uno::UNO_QUERY);
392 uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY);
393 if (xCellTextRange.is())
395 bool bTop = (bOutline && nRow == 1) || (bHBorder && nRow > 1 && nRow < nRowCount);
396 bool bBottom
397 = (bOutline && nRow == nRowCount) || (bHBorder && nRow > 1 && nRow < nRowCount);
399 auto xText = xCellTextRange->getText();
400 xText->insertString(xText->getStart(), rSeriesName, false);
401 auto xTextPropertySet = getFirstParagraphProperties(xText);
402 if (xTextPropertySet)
404 setCellCharAndParagraphProperties(xTextPropertySet);
405 setCellProperties(xCellPropertySet, bOutline, bTop, bOutline, bBottom);
407 xCellPropertySet->setPropertyValue(u"ParaAdjust"_ustr,
408 uno::Any(style::ParagraphAdjust_LEFT));
409 if (bKeys)
411 xCellPropertySet->setPropertyValue(
412 u"ParaLeftMargin"_ustr,
413 uno::Any(nMaxSymbolWidth + sal_Int32(2 * constSymbolMargin)));
417 nRow++;
420 // TABLE
421 nRow = 1;
422 const sal_Int32 nTableModelRowCount = m_xTable->getRowCount();
423 const sal_Int32 nTableModelColCount = m_xTable->getColumnCount();
424 // tdf#153182 the broken bounds are most likely because we don't know if the
425 // data-table has header rows and columns. Most likely it does not.
426 bool bBrokenBounds = false;
427 for (auto const& rSeries : m_pDataSeriesValues)
429 nColumn = 1;
430 for (auto const& rValue : rSeries)
432 if (nRow >= nTableModelRowCount || nColumn >= nTableModelColCount)
434 bBrokenBounds = true;
435 SAL_WARN("chart2", "exceeding bounds of table model?");
436 break;
438 uno::Reference<table::XCell> xCell = m_xTable->getCellByPosition(nColumn, nRow);
439 uno::Reference<beans::XPropertySet> xCellPropertySet(xCell, uno::UNO_QUERY);
440 uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY);
441 if (xCellTextRange.is())
443 auto xText = xCellTextRange->getText();
444 xText->insertString(xText->getStart(), rValue, false);
445 auto xTextPropertySet = getFirstParagraphProperties(xText);
446 if (xTextPropertySet.is())
448 bool bLeft = false;
449 bool bTop = false;
450 bool bRight = false;
451 bool bBottom = false;
453 if (nColumn > 1 && bVBorder)
454 bLeft = true;
456 if (nRow > 1 && bHBorder)
457 bTop = true;
459 if (nRow == nRowCount && bOutline)
460 bBottom = true;
462 if (nColumn == nColumnCount && bOutline)
463 bRight = true;
465 setCellCharAndParagraphProperties(xTextPropertySet);
466 setCellProperties(xCellPropertySet, bLeft, bTop, bRight, bBottom);
469 nColumn++;
471 if (bBrokenBounds)
472 break;
473 nRow++;
476 // force recalculation of column widths in the table shape
477 xBroadcaster->unlockBroadcasts();
478 pTableObject->DistributeColumns(0, nColumnCount, true, true);
480 xBroadcaster->lockBroadcasts();
482 // reposition the data table
483 changePosition(basegfx::fround(rStart.getX()), basegfx::fround(rStart.getY()));
485 sal_Int32 nTableX = m_xTableShape->getPosition().X;
486 sal_Int32 nTableY = m_xTableShape->getPosition().Y;
488 uno::Reference<beans::XPropertySet> xPropertySet(xTableColumns->getByIndex(0), uno::UNO_QUERY);
490 for (sal_Int32 i = 1; i < xTableColumns->getCount(); ++i)
492 xPropertySet.set(xTableColumns->getByIndex(i), uno::UNO_QUERY);
493 xPropertySet->setPropertyValue(u"Width"_ustr, uno::Any(nColumnWidth));
496 // force recalculation of row heights in the table shape
497 xBroadcaster->unlockBroadcasts();
498 pTableObject->DistributeRows(0, nRowCount, true, true);
500 if (bKeys)
502 sal_Int32 nTotalHeight = 0;
503 for (sal_Int32 i = 0; i < xTableRows->getCount(); i++)
505 sal_Int32 nSymbolIndex = i - 1;
506 if (nSymbolIndex < sal_Int32(aSymbols.size()))
508 xPropertySet.set(xTableRows->getByIndex(i), uno::UNO_QUERY);
509 sal_Int32 nHeight = 0;
510 xPropertySet->getPropertyValue(u"Height"_ustr) >>= nHeight;
511 if (i > 0)
513 auto& rSymbol = aSymbols[nSymbolIndex].xSymbol;
514 sal_Int32 nSymbolHeight = rSymbol->getSize().Height;
515 sal_Int32 nSymbolY
516 = basegfx::fround(double(nHeight) / 2.0 - double(nSymbolHeight) / 2.0);
517 rSymbol->setPosition(
518 { nTableX + constSymbolMargin, nTableY + nTotalHeight + nSymbolY });
520 nTotalHeight += nHeight;
526 void DataTableView::changePosition(sal_Int32 x, sal_Int32 y)
528 if (!m_xTable.is())
529 return;
531 uno::Reference<table::XTableColumns> xTableColumns = m_xTable->getColumns();
532 uno::Reference<beans::XPropertySet> xPropertySet(xTableColumns->getByIndex(0), uno::UNO_QUERY);
534 sal_Int32 nWidth = 0;
535 xPropertySet->getPropertyValue(u"Width"_ustr) >>= nWidth;
537 m_xTarget->setPosition({ x - nWidth, y });
540 void DataTableView::initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& xTarget)
542 m_xTarget = xTarget;
545 void DataTableView::initializeValues(
546 std::vector<std::unique_ptr<VSeriesPlotter>>& rSeriesPlotterList)
548 for (auto& rSeriesPlotter : rSeriesPlotterList)
550 m_pSeriesPlotterList.push_back(rSeriesPlotter.get());
552 for (auto const& rCategory :
553 rSeriesPlotter->getExplicitCategoriesProvider()->getSimpleCategories())
555 m_aXValues.push_back(rCategory);
558 for (auto const& rString : rSeriesPlotter->getAllSeriesNames())
560 m_aDataSeriesNames.push_back(rString);
563 for (VDataSeries* pSeries : rSeriesPlotter->getAllSeries())
565 auto& rValues = m_pDataSeriesValues.emplace_back();
566 for (int i = 0; i < pSeries->getTotalPointCount(); i++)
568 double nValue = pSeries->getYValue(i);
569 rValues.push_back(rSeriesPlotter->getLabelTextForValue(*pSeries, i, nValue, false));
575 } //namespace chart
577 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */