From 763b86a5fac81783525442d5ec262e91ca1047ac Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 10 Sep 2024 10:30:32 +0200 Subject: [PATCH] Add arguments to Last 4 UNO Commands in CrashReport Dump Change-Id: I8ea1e95abb62374b51de7b1d37055c216b29e04c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173125 Reviewed-by: Xisco Fauli Tested-by: Jenkins --- ...b-can-be-private-symbols.functions.results | 1 - include/vcl/uitest/logger.hxx | 3 -- sfx2/source/control/unoctitm.cxx | 46 +++++++++++++++++-- vcl/source/uitest/logger.cxx | 45 ------------------ 4 files changed, 43 insertions(+), 52 deletions(-) diff --git a/bin/find-mergedlib-can-be-private-symbols.functions.results b/bin/find-mergedlib-can-be-private-symbols.functions.results index 5312bf9abdb4..5a3724db6792 100644 --- a/bin/find-mergedlib-can-be-private-symbols.functions.results +++ b/bin/find-mergedlib-can-be-private-symbols.functions.results @@ -9840,7 +9840,6 @@ UITestLogger::UITestLogger() UITestLogger::log(std::basic_string_view >) UITestLogger::logAction(VclPtr const&, VclEventId) UITestLogger::logAction(vcl::Window* const&, VclEventId) -UITestLogger::logCommand(std::basic_string_view >, com::sun::star::uno::Sequence const&) UITestLogger::logKeyInput(VclPtr const&, KeyEvent const&) URIHelper::SetMaybeFileHdl(Link const&) UnoControl::GetComponentServiceName() const diff --git a/include/vcl/uitest/logger.hxx b/include/vcl/uitest/logger.hxx index bc353ad4ea11..9888fab60493 100644 --- a/include/vcl/uitest/logger.hxx +++ b/include/vcl/uitest/logger.hxx @@ -43,9 +43,6 @@ private: public: UITestLogger(); - void logCommand(std::u16string_view rAction, - const css::uno::Sequence& rArgs); - void logAction(VclPtr const& xUIElement, VclEventId nEvent); void logAction(vcl::Window* const& xUIWin, VclEventId nEvent); diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index f39132c708ff..3c9643eed181 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -512,14 +512,54 @@ OUString SfxDispatchController_Impl::getSlaveCommand( const css::util::URL& rURL namespace { +OUString parseArguments(std::u16string_view rAction, + const css::uno::Sequence& rArgs) +{ + OUStringBuffer aBuffer(rAction); + + if (rArgs.hasElements()) + { + aBuffer.append(" {"); + for (const css::beans::PropertyValue& rProp : rArgs) + { + OUString aTypeName = rProp.Value.getValueTypeName(); + + if (aTypeName == "long" || aTypeName == "short") + { + sal_Int32 nValue = 0; + rProp.Value >>= nValue; + aBuffer.append("\"" + rProp.Name + "\": " + OUString::number(nValue) + ", "); + } + else if (aTypeName == "unsigned long") + { + sal_uInt32 nValue = 0; + rProp.Value >>= nValue; + aBuffer.append("\"" + rProp.Name + "\": " + OUString::number(nValue) + ", "); + } + else if (aTypeName == "boolean") + { + bool bValue = false; + rProp.Value >>= bValue; + aBuffer.append("\"" + rProp.Name + "\": "); + if (bValue) + aBuffer.append("True, "); + else + aBuffer.append("False, "); + } + } + aBuffer.append("}"); + } + + return aBuffer.makeStringAndClear(); +} + void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs) { static const char* pFile = std::getenv("LO_COLLECT_UIINFO"); if (!pFile) return; - UITestLogger::getInstance().logCommand( - Concat2View("Send UNO Command (\"" + rURL.Complete + "\") "), rArgs); + UITestLogger::getInstance().log(parseArguments(Concat2View("Send UNO Command (\"" + rURL.Complete + "\") "), rArgs)); } } @@ -530,7 +570,7 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, { if ( aURL.Protocol == ".uno:") { - CrashReporter::logUnoCommand(aURL.Path); + CrashReporter::logUnoCommand(parseArguments(aURL.Path, aArgs)); } collectUIInformation(aURL, aArgs); diff --git a/vcl/source/uitest/logger.cxx b/vcl/source/uitest/logger.cxx index 3920fcd39061..a034e4da1d5b 100644 --- a/vcl/source/uitest/logger.cxx +++ b/vcl/source/uitest/logger.cxx @@ -79,51 +79,6 @@ UITestLogger::UITestLogger() } } -void UITestLogger::logCommand(std::u16string_view rAction, - const css::uno::Sequence& rArgs) -{ - if (!mbValid) - return; - - OUStringBuffer aBuffer(rAction); - - if (rArgs.hasElements()) - { - aBuffer.append(" {"); - for (const css::beans::PropertyValue& rProp : rArgs) - { - OUString aTypeName = rProp.Value.getValueTypeName(); - - if (aTypeName == "long" || aTypeName == "short") - { - sal_Int32 nValue = 0; - rProp.Value >>= nValue; - aBuffer.append("\"" + rProp.Name + "\": " + OUString::number(nValue) + ", "); - } - else if (aTypeName == "unsigned long") - { - sal_uInt32 nValue = 0; - rProp.Value >>= nValue; - aBuffer.append("\"" + rProp.Name + "\": " + OUString::number(nValue) + ", "); - } - else if (aTypeName == "boolean") - { - bool bValue = false; - rProp.Value >>= bValue; - aBuffer.append("\"" + rProp.Name + "\": "); - if (bValue) - aBuffer.append("True, "); - else - aBuffer.append("False, "); - } - } - aBuffer.append("}"); - } - - OUString aCommand(aBuffer.makeStringAndClear()); - maStream.WriteLine(OUStringToOString(aCommand, RTL_TEXTENCODING_UTF8)); -} - namespace { // most likely this should be recursive