chart2/source/controller/sidebar/ChartColorsPanel.cxx | 26 +++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-)
New commits: commit f99bc3659663164b0e1d36452f2935ac98324893 Author: Marco Cecchetti <marco.cecche...@collabora.com> AuthorDate: Tue May 20 14:41:48 2025 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Thu May 22 08:11:18 2025 +0200 chart color palette: assertion failure in getCID Change-Id: I5e5628abb4e7e23ccc0f884c8ccb17167a368f39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185557 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/chart2/source/controller/sidebar/ChartColorsPanel.cxx b/chart2/source/controller/sidebar/ChartColorsPanel.cxx index 3838ede4ff4b..14a17cc9585b 100644 --- a/chart2/source/controller/sidebar/ChartColorsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartColorsPanel.cxx @@ -44,12 +44,28 @@ namespace OUString getCID(const uno::Reference<frame::XModel>& xModel) { const uno::Reference<frame::XController> xController(xModel->getCurrentController()); - const uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xController, uno::UNO_QUERY); + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xController, uno::UNO_QUERY); if (!xSelectionSupplier.is()) - return OUString(); + return {}; + + uno::Any aAny = xSelectionSupplier->getSelection(); + if (!aAny.hasValue()) + { + // if no selection, default to diagram wall so sidebar can show some editable properties + if (auto* pController = dynamic_cast<ChartController*>(xController.get())) + { + pController->select( + uno::Any(ObjectIdentifier::createClassifiedIdentifier(OBJECTTYPE_PAGE, u""))); + xSelectionSupplier + = uno::Reference<css::view::XSelectionSupplier>(xController, uno::UNO_QUERY); + if (xSelectionSupplier.is()) + aAny = xSelectionSupplier->getSelection(); + } + + if (!aAny.hasValue()) + return {}; + } - const uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); OUString aCID; aAny >>= aCID; return aCID; @@ -186,6 +202,8 @@ void ChartColorsPanel::updateData() return; const OUString aCID = getCID(mxModel); + if (aCID.isEmpty()) + return; const ObjectType eType = ObjectIdentifier::getObjectType(aCID); if (std::find(maAcceptedTypes.begin(), maAcceptedTypes.end(), eType) == maAcceptedTypes.end())