chart2/source/view/main/DataTableView.cxx |   21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 79b066055797b1f48aac3feccd86f1c8d21ca76d
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Aug 11 22:44:56 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Wed Aug 24 20:15:07 2022 +0200

    chart2: render line legend symbols better in a data table
    
    Change-Id: I556b4f249688a3836bbeeb3f554cb9ecf1d31f65
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138301
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>
    (cherry picked from commit e4e5d77bcc30beb1d976fadf5da0247f00f5b9cc)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138603
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/chart2/source/view/main/DataTableView.cxx 
b/chart2/source/view/main/DataTableView.cxx
index 77d9943ab9ec..aa1e7adb9e77 100644
--- a/chart2/source/view/main/DataTableView.cxx
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -288,17 +288,23 @@ 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);
+        uno::Reference<lang::XMultiServiceFactory> xFactory(m_xChartModel, 
uno::UNO_QUERY);
         for (VSeriesPlotter* pSeriesPlotter : m_pSeriesPlotterList)
         {
             if (pSeriesPlotter)
             {
-                uno::Reference<lang::XMultiServiceFactory> 
xFactory(m_xChartModel, uno::UNO_QUERY);
+                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, xFactory, 
m_xComponentContext);
+                    { nSymbolWidth, 300 }, m_xTarget, xFactory, 
m_xComponentContext);
                 aSymbols.insert(aSymbols.end(), aNewEntries.begin(), 
aNewEntries.end());
             }
         }
@@ -330,7 +336,10 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
             xCellPropertySet->setPropertyValue("ParaAdjust",
                                                
uno::makeAny(style::ParagraphAdjust_LEFT));
             if (bKeys)
-                xCellPropertySet->setPropertyValue("ParaLeftMargin", 
uno::makeAny(sal_Int32(500)));
+            {
+                xCellPropertySet->setPropertyValue("ParaLeftMargin",
+                                                   
uno::makeAny(nMaxSymbolWidth + sal_Int32(200)));
+            }
         }
         nRow++;
     }
@@ -379,6 +388,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;
@@ -412,6 +422,7 @@ void DataTableView::createShapes(basegfx::B2DVector const& 
rStart, basegfx::B2DV
             nTotalHeight += nHeight;
         }
     }
+    xBroadcaster->unlockBroadcasts();
 }
 
 void DataTableView::initializeShapes(const 
css::uno::Reference<css::drawing::XShapes>& xTarget)

Reply via email to