chart2/source/view/main/DataTableView.cxx |   34 +++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

New commits:
commit 3fe3f3a985ae85e3cd3010f875ca4acc62219bb6
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Aug 11 22:44:56 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Thu Aug 11 22:44:56 2022 +0200

    chart2: render line legend symbols better in a data table
    
    Change-Id: I556b4f249688a3836bbeeb3f554cb9ecf1d31f65

diff --git a/chart2/source/view/main/DataTableView.cxx 
b/chart2/source/view/main/DataTableView.cxx
index eafb64c69f60..7202f332b143 100644
--- a/chart2/source/view/main/DataTableView.cxx
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -276,8 +276,10 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
         {
             xCellTextRange->setString(rString);
 
-            bool bLeft = (bOutline && nColumn == 1) || (bVBorder && nColumn > 
1 && nColumn < nColumnCount);
-            bool bRight = (bOutline && nColumn == nColumnCount) || (bVBorder 
&& nColumn > 1 && nColumn < nColumnCount);
+            bool bLeft
+                = (bOutline && nColumn == 1) || (bVBorder && nColumn > 1 && 
nColumn < nColumnCount);
+            bool bRight = (bOutline && nColumn == nColumnCount)
+                          || (bVBorder && nColumn > 1 && nColumn < 
nColumnCount);
             setCellProperties(xPropertySet, bLeft, bOutline, bRight, bOutline);
             setCellCharAndParagraphProperties(xPropertySet);
         }
@@ -285,16 +287,22 @@ void DataTableView::createShapes(basegfx::B2DVector 
const& rStart, basegfx::B2DV
     }
 
     // ROW HEADER
-    // Prepare keys
+    // Prepare keys (symbols)
+    sal_Int32 nMaxSymbolWidth = 0;
     if (bKeys)
     {
-        awt::Size aMaxSymbolExtent(300, 300);
         for (VSeriesPlotter* pSeriesPlotter : m_pSeriesPlotterList)
         {
             if (pSeriesPlotter)
             {
+                sal_Int32 nSymbolWidth = 300;
+                if (pSeriesPlotter->getLegendSymbolStyle() == 
LegendSymbolStyle::Line)
+                    nSymbolWidth = 600;
+
+                nMaxSymbolWidth = std::max(nSymbolWidth, nMaxSymbolWidth);
+
                 std::vector<ViewLegendSymbol> aNewEntries = 
pSeriesPlotter->createSymbols(
-                    aMaxSymbolExtent, m_xTarget, m_xComponentContext);
+                    { nSymbolWidth, 300 }, m_xTarget, m_xComponentContext);
                 aSymbols.insert(aSymbols.end(), aNewEntries.begin(), 
aNewEntries.end());
             }
         }
@@ -309,7 +317,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
         if (xCellTextRange.is())
         {
             bool bTop = (bOutline && nRow == 1) || (bHBorder && nRow > 1 && 
nRow < nRowCount);
-            bool bBottom = (bOutline && nRow == nRowCount) || (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();
@@ -324,7 +333,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
 
             xCellPropertySet->setPropertyValue("ParaAdjust", 
uno::Any(style::ParagraphAdjust_LEFT));
             if (bKeys)
-                xCellPropertySet->setPropertyValue("ParaLeftMargin", 
uno::Any(500));
+                xCellPropertySet->setPropertyValue("ParaLeftMargin",
+                                                   uno::Any(nMaxSymbolWidth + 
200));
         }
         nRow++;
     }
@@ -373,6 +383,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
     pTableObject->DistributeColumns(0, nColumnCount - 1, true, true);
     pTableObject->DistributeRows(0, nRowCount - 1, true, true);
 
+    xBroadcaster->lockBroadcasts();
     uno::Reference<beans::XPropertySet> 
xPropertySet(xTableColumns->getByIndex(0), uno::UNO_QUERY);
     sal_Int32 nWidth = 0;
     xPropertySet->getPropertyValue("Width") >>= nWidth;
@@ -403,6 +414,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
             nTotalHeight += nHeight;
         }
     }
+    xBroadcaster->unlockBroadcasts();
 }
 
 void DataTableView::initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& 
xTarget)
commit 7c630f846cb6d1e897a6eba1e2f3640236a74956
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Aug 11 22:40:27 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Thu Aug 11 22:40:27 2022 +0200

    chart2: fix rendering of table borders of row/column headers
    
    The row/column headers didn't enable/disable the table borders
    correctly when outline was enabled and horizontal and vertical
    borders properties were disabled.

diff --git a/chart2/source/view/main/DataTableView.cxx 
b/chart2/source/view/main/DataTableView.cxx
index 981eb873669d..eafb64c69f60 100644
--- a/chart2/source/view/main/DataTableView.cxx
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -264,6 +264,8 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
     sal_Int32 nColumn;
     sal_Int32 nRow;
 
+    // COLUMN HEADER
+
     nColumn = 1;
     for (auto const& rString : m_aXValues)
     {
@@ -273,13 +275,17 @@ void DataTableView::createShapes(basegfx::B2DVector 
const& rStart, basegfx::B2DV
         if (xCellTextRange.is())
         {
             xCellTextRange->setString(rString);
-            bool bLeft = bOutline || (bVBorder && nColumn > 1);
-            setCellProperties(xPropertySet, bLeft, bOutline, bOutline, 
bOutline);
+
+            bool bLeft = (bOutline && nColumn == 1) || (bVBorder && nColumn > 
1 && nColumn < nColumnCount);
+            bool bRight = (bOutline && nColumn == nColumnCount) || (bVBorder 
&& nColumn > 1 && nColumn < nColumnCount);
+            setCellProperties(xPropertySet, bLeft, bOutline, bRight, bOutline);
             setCellCharAndParagraphProperties(xPropertySet);
         }
         nColumn++;
     }
 
+    // ROW HEADER
+    // Prepare keys
     if (bKeys)
     {
         awt::Size aMaxSymbolExtent(300, 300);
@@ -302,8 +308,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);
-            setCellProperties(xCellPropertySet, bOutline, bTop, bOutline, 
bOutline);
+            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);
@@ -322,6 +329,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
         nRow++;
     }
 
+    // TABLE
     nRow = 1;
     for (auto const& rSeries : m_pDataSeriesValues)
     {

Reply via email to