chart2/source/controller/dialogs/dlg_ObjectProperties.cxx | 1 chart2/source/view/main/DataTableView.cxx | 58 ++++++++++---- 2 files changed, 44 insertions(+), 15 deletions(-)
New commits: commit 25cf1afd485d6ff7a7278aa2260082596ca4d0f7 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Aug 12 17:29:36 2022 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Aug 24 22:49:09 2022 +0200 chart2: always set text props. of the first paragraph and not cell When setting the properties of the data table it is important to differentiate when we set the properties of the text of the (first and only) paragraph or set the properties for the current cell. In this chage we refactor the code so that we always set the text via UNO text::XText call for the current cell, and in the next step get the XPropertySet of the first paragraph and set the properties relevant for the text from the DataTable model. Change-Id: Ibe82b21c3416083cfe8e86b95443d77984da05f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138330 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 81a5f33101c18fb22a952b865c0c90418fd6a490) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138605 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/chart2/source/view/main/DataTableView.cxx b/chart2/source/view/main/DataTableView.cxx index aa1e7adb9e77..e7f577f04af3 100644 --- a/chart2/source/view/main/DataTableView.cxx +++ b/chart2/source/view/main/DataTableView.cxx @@ -58,6 +58,29 @@ void copyProperty(uno::Reference<beans::XPropertySet>& xOut, { xOut->setPropertyValue(sPropertyName, xIn->getPropertyValue(sPropertyName)); } + +uno::Reference<text::XTextRange> getFirstParagraph(uno::Reference<text::XText> const& xText) +{ + uno::Reference<text::XTextRange> xParagraph; + uno::Reference<container::XEnumerationAccess> xEnumAccess(xText, uno::UNO_QUERY); + if (!xEnumAccess.is()) + return xParagraph; + uno::Reference<container::XEnumeration> xEnumeration(xEnumAccess->createEnumeration()); + xParagraph.set(xEnumeration->nextElement(), uno::UNO_QUERY); + return xParagraph; +} + +uno::Reference<beans::XPropertySet> +getFirstParagraphProperties(uno::Reference<text::XText> const& xText) +{ + uno::Reference<beans::XPropertySet> xPropertySet; + auto xParagraph = getFirstParagraph(xText); + if (!xParagraph.is()) + return xPropertySet; + xPropertySet.set(xParagraph, uno::UNO_QUERY); + return xPropertySet; +} + } // end anonymous namespace DataTableView::DataTableView(uno::Reference<chart2::XChartDocument> const& xChartDoc, @@ -67,8 +90,8 @@ DataTableView::DataTableView(uno::Reference<chart2::XChartDocument> const& xChar , m_xDataTableModel(rDataTableModel) , m_xComponentContext(rComponentContext) { - uno::Reference<beans::XPropertySet> xProp(m_xDataTableModel); - m_aLineProperties.initFromPropertySet(xProp); + uno::Reference<beans::XPropertySet> xPropertySet(m_xDataTableModel); + m_aLineProperties.initFromPropertySet(xPropertySet); } void DataTableView::setCellCharAndParagraphProperties( @@ -275,14 +298,18 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY); if (xCellTextRange.is()) { - xCellTextRange->setString(rString); + auto xText = xCellTextRange->getText(); + xText->insertString(xText->getStart(), rString, false); + auto xTextPropertySet = getFirstParagraphProperties(xText); + if (!xTextPropertySet.is()) + continue; bool bLeft = (bOutline && nColumn == 1) || (bVBorder && nColumn > 1 && nColumn < nColumnCount); bool bRight = (bOutline && nColumn == nColumnCount) || (bVBorder && nColumn > 1 && nColumn < nColumnCount); + setCellCharAndParagraphProperties(xTextPropertySet); setCellProperties(xPropertySet, bLeft, bOutline, bRight, bOutline); - setCellCharAndParagraphProperties(xPropertySet); } nColumn++; } @@ -321,17 +348,14 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV bool bTop = (bOutline && nRow == 1) || (bHBorder && nRow > 1 && nRow < nRowCount); bool bBottom = (bOutline && nRow == nRowCount) || (bHBorder && nRow > 1 && nRow < nRowCount); - setCellProperties(xCellPropertySet, bOutline, bTop, bOutline, bBottom); auto xText = xCellTextRange->getText(); xText->insertString(xText->getStart(), rSeriesName, false); - uno::Reference<container::XEnumerationAccess> xEnumAccess(xText, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xEnumeration(xEnumAccess->createEnumeration()); - uno::Reference<text::XTextRange> xParagraph(xEnumeration->nextElement(), - uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTextPropertySet(xParagraph, uno::UNO_QUERY); - + auto xTextPropertySet = getFirstParagraphProperties(xText); + if (!xTextPropertySet.is()) + continue; setCellCharAndParagraphProperties(xTextPropertySet); + setCellProperties(xCellPropertySet, bOutline, bTop, bOutline, bBottom); xCellPropertySet->setPropertyValue("ParaAdjust", uno::makeAny(style::ParagraphAdjust_LEFT)); @@ -352,11 +376,15 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV for (auto const& rValue : rSeries) { uno::Reference<table::XCell> xCell = xTable->getCellByPosition(nColumn, nRow); - uno::Reference<beans::XPropertySet> xPropertySet(xCell, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xCellPropertySet(xCell, uno::UNO_QUERY); uno::Reference<text::XTextRange> xCellTextRange(xCell, uno::UNO_QUERY); if (xCellTextRange.is()) { - xCellTextRange->setString(rValue); + auto xText = xCellTextRange->getText(); + xText->insertString(xText->getStart(), rValue, false); + auto xTextPropertySet = getFirstParagraphProperties(xText); + if (!xTextPropertySet.is()) + continue; bool bLeft = false; bool bTop = false; @@ -375,8 +403,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& rStart, basegfx::B2DV if (nColumn == nColumnCount && bOutline) bRight = true; - setCellProperties(xPropertySet, bLeft, bTop, bRight, bBottom); - setCellCharAndParagraphProperties(xPropertySet); + setCellCharAndParagraphProperties(xTextPropertySet); + setCellProperties(xCellPropertySet, bLeft, bTop, bRight, bBottom); } nColumn++; } commit a6dc4f38ae1221d7ef327698577176d704cc7bf0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Aug 12 17:25:04 2022 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Aug 24 22:48:57 2022 +0200 chart2: add "font effects" tab page to the data table dialog Change-Id: I5530477dc86ba2174ba6e553dfe77f8fa355a863 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138329 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit e0599e403b9b8714794f4f80afe78feac0a77b32) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138604 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 9716463a780f..ce31b540b437 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -459,6 +459,7 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, 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); + AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); break; case OBJECTTYPE_DATA_CURVE_EQUATION: AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE);