diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2023-11-01 22:49:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-11-11 22:22:52 +0100 |
commit | 96ed41755b82cd47c27f40d4231e6ed9f915a976 (patch) | |
tree | cac7145ed68977bc8cfc94818476548052dd706a /sfx2 | |
parent | e0f5719095e43e5c185d334b3ac3754e3aa4e276 (diff) |
lok: a11y: implemented support for notifying core log to client
In this way core log can be printed to the browser console.
This may help in understanding if some core event occurs earlier or
later wrt a client event.
Change-Id: I720ef9b149e98ddbc252aa069649019e79ef6cb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158780
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Marco Cecchetti <marco.cecchetti@collabora.com>
(cherry picked from commit d8dc138be7e69750d1a346b3b49cecc1201e8d46)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159331
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 33 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 51 |
2 files changed, 59 insertions, 25 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index e7fdc3d024be..31981159ca02 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -9,7 +9,9 @@ #include <sal/config.h> +#include <string> #include <string_view> +#include <list> #include <sfx2/lokcomponenthelpers.hxx> #include <sfx2/lokhelper.hxx> @@ -79,6 +81,8 @@ LanguageTag g_loadLanguageTag("en-US", true); //< The language used to load. LOKDeviceFormFactor g_deviceFormFactor = LOKDeviceFormFactor::UNKNOWN; bool g_isDefaultTimezoneSet = false; OUString g_DefaultTimezone; +const std::size_t g_logNotifierCacheMaxSize = 50; +::std::list<::std::string> g_logNotifierCache; } int SfxLokHelper::createView(SfxViewFrame& rViewFrame, ViewShellDocId docId) @@ -322,6 +326,7 @@ void SfxLokHelper::setAccessibilityState(int nId, bool nEnabled) { if (pViewShell->GetViewShellId() == ViewShellId(nId)) { + LOK_INFO("lok.a11y", "SfxLokHelper::setAccessibilityState: view id: " << nId << ", nEnabled: " << nEnabled); pViewShell->SetLOKAccessibilityState(nEnabled); return; } @@ -732,6 +737,34 @@ void SfxLokHelper::notifyContextChange(const css::ui::ContextChangeEventObject& pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_CHANGED, aBuffer.toUtf8()); } +void SfxLokHelper::notifyLog(const std::ostringstream& stream) +{ + if (DisableCallbacks::disabled()) + return; + + SfxViewShell* pViewShell = SfxViewShell::Current(); + if (!pViewShell) + return; + if (pViewShell->getLibreOfficeKitViewCallback()) + { + if (!g_logNotifierCache.empty()) + { + for (const auto& msg : g_logNotifierCache) + { + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CORE_LOG, msg.c_str()); + } + g_logNotifierCache.clear(); + } + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CORE_LOG, stream.str().c_str()); + } + else + { + while (g_logNotifierCache.size() >= g_logNotifierCacheMaxSize) + g_logNotifierCache.pop_front(); + g_logNotifierCache.push_back(stream.str()); + } +} + void SfxLokHelper::notifyUpdate(SfxViewShell const* pThisView, int nType) { if (DisableCallbacks::disabled()) diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 8f2218c66175..6c5377a3bed2 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -480,7 +480,7 @@ void aboutEvent(std::string msg, const accessibility::AccessibleEventObject& aEv if (xContext.is()) { - SAL_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId + LOK_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId << "\n xSource: " << xSource.get() << "\n role: " << xContext->getAccessibleRole() << "\n name: " << xContext->getAccessibleName() @@ -491,13 +491,13 @@ void aboutEvent(std::string msg, const accessibility::AccessibleEventObject& aEv } else { - SAL_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId + LOK_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId << ", no accessible context!"); } } else { - SAL_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId + LOK_INFO("lok.a11y", msg << ": event id: " << aEvent.EventId << ", no accessible source!"); } uno::Reference< accessibility::XAccessible > xOldValue; @@ -528,8 +528,8 @@ void aboutEvent(std::string msg, const accessibility::AccessibleEventObject& aEv if (xContext.is()) { - SAL_INFO("lok.a11y", msg << ": " - "\n xNewValue: " << xNewValue.get() + LOK_INFO("lok.a11y", msg << ": " + "\n xNewValue: " << xNewValue.get() << "\n role: " << xContext->getAccessibleRole() << "\n name: " << xContext->getAccessibleName() << "\n index in parent: " << xContext->getAccessibleIndexInParent() @@ -541,7 +541,7 @@ void aboutEvent(std::string msg, const accessibility::AccessibleEventObject& aEv } catch( const lang::IndexOutOfBoundsException& /*e*/ ) { - SAL_WARN("lok.a11y", "Focused object has invalid index in parent"); + LOK_WARN("lok.a11y", "Focused object has invalid index in parent"); } } @@ -940,7 +940,7 @@ void LOKDocumentFocusListener::notifyEditingInSelectionState(bool bParagraph) std::string aPayload = aStream.str(); if (m_pViewShell) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEditingInSelectionState: payload: \n" << aPayload); + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEditingInSelectionState: payload: \n" << aPayload); m_pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_A11Y_EDITING_IN_SELECTION_STATE, aPayload.c_str()); } } @@ -1352,8 +1352,8 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO aEvent.NewValue >>= nState; sal_Int64 nOldState = accessibility::AccessibleStateType::INVALID; aEvent.OldValue >>= nOldState; - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: STATE_CHANGED: " - " New State: " << stateSetToString(nState) + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: STATE_CHANGED: " + " New State: " << stateSetToString(nState) << ", Old State: " << stateSetToString(nOldState)); // check validity @@ -1476,8 +1476,8 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO if (nNewPos >= 0) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: CARET_CHANGED: " - "new pos: " << nNewPos << ", nOldPos: " << nOldPos); + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: CARET_CHANGED: " + "new pos: " << nNewPos << ", nOldPos: " << nOldPos); uno::Reference<XAccessibleText> xAccText(getAccessible(aEvent), uno::UNO_QUERY); if (xAccText.is()) @@ -1511,12 +1511,12 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO if (aEvent.OldValue >>= aDeletedText) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: TEXT_CHANGED: " + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: TEXT_CHANGED: " "deleted text: >" << aDeletedText.SegmentText << "<"); } if (aEvent.NewValue >>= aInsertedText) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: TEXT_CHANGED: " + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: TEXT_CHANGED: " "inserted text: >" << aInsertedText.SegmentText << "<"); } uno::Reference<XAccessibleText> xAccText(getAccessible(aEvent), uno::UNO_QUERY); @@ -1584,7 +1584,7 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO return; // selecting the same object; note: on editing selected object is cleared else m_xSelectedObject = xSelectedObject; - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: SELECTION_CHANGED: " + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::notifyEvent: SELECTION_CHANGED: " "m_xSelectedObject.is(): " << m_xSelectedObject.is()); OUString sAction = selectionEventTypeToString(aEvent.EventId); @@ -1641,7 +1641,7 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO } case AccessibleEventId::INVALIDATE_ALL_CHILDREN: { - SAL_INFO("lok.a11y", "Invalidate all children called"); + LOK_INFO("lok.a11y", "Invalidate all children called"); break; } default: @@ -1650,7 +1650,7 @@ void LOKDocumentFocusListener::notifyEvent(const accessibility::AccessibleEventO } catch( const lang::IndexOutOfBoundsException& ) { - SAL_WARN("lok.a11y", + LOK_WARN("lok.a11y", "LOKDocumentFocusListener::notifyEvent:Focused object has invalid index in parent"); } } @@ -1680,7 +1680,7 @@ uno::Reference< accessibility::XAccessible > LOKDocumentFocusListener::getAccess } } - SAL_WARN("lok.a11y", + LOK_WARN("lok.a11y", "LOKDocumentFocusListener::getAccessible: Can't get any accessible object from event source."); return uno::Reference< accessibility::XAccessible >(); @@ -1690,7 +1690,7 @@ void LOKDocumentFocusListener::attachRecursive( const uno::Reference< accessibility::XAccessible >& xAccessible ) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(1): xAccessible: " << xAccessible.get()); + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(1): xAccessible: " << xAccessible.get()); uno::Reference< accessibility::XAccessibleContext > xContext = xAccessible->getAccessibleContext(); @@ -1704,7 +1704,7 @@ void LOKDocumentFocusListener::attachRecursive( const uno::Reference< accessibility::XAccessibleContext >& xContext ) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(2): xAccessible: " << xAccessible.get() + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(2): xAccessible: " << xAccessible.get() << ", role: " << xContext->getAccessibleRole() << ", name: " << xContext->getAccessibleName() << ", parent: " << xContext->getAccessibleParent().get() @@ -1728,7 +1728,7 @@ void LOKDocumentFocusListener::attachRecursive( ) { aboutView("LOKDocumentFocusListener::attachRecursive (3)", this, m_pViewShell); - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #1: this: " << this + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #1: this: " << this << ", xAccessible: " << xAccessible.get() << ", role: " << xContext->getAccessibleRole() << ", name: " << xContext->getAccessibleName() @@ -1741,12 +1741,12 @@ void LOKDocumentFocusListener::attachRecursive( if (!xBroadcaster.is()) return; - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #2: xBroadcaster.is()"); + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #2: xBroadcaster.is()"); // If not already done, add the broadcaster to the list and attach as listener. const uno::Reference< uno::XInterface >& xInterface = xBroadcaster; if( m_aRefList.insert(xInterface).second ) { - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #3: m_aRefList.insert(xInterface).second"); + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::attachRecursive(3) #3: m_aRefList.insert(xInterface).second"); xBroadcaster->addAccessibleEventListener(static_cast< accessibility::XAccessibleEventListener *>(this)); if (isDocument(xContext->getAccessibleRole())) @@ -1831,7 +1831,7 @@ void LOKDocumentFocusListener::detachRecursive( aboutView("LOKDocumentFocusListener::detachRecursive (2)", this, m_pViewShell); sal_Int64 nStateSet = xContext->getAccessibleStateSet(); - SAL_INFO("lok.a11y", "LOKDocumentFocusListener::detachRecursive(2): this: " << this + LOK_INFO("lok.a11y", "LOKDocumentFocusListener::detachRecursive(2): this: " << this << ", name: " << xContext->getAccessibleName() << ", parent: " << xContext->getAccessibleParent().get() << ", child count: " << xContext->getAccessibleChildCount()); @@ -3283,6 +3283,7 @@ void SfxViewShell::libreOfficeKitViewAddPendingInvalidateTiles() void SfxViewShell::afterCallbackRegistered() { + LOK_INFO("sfx.view", "SfxViewShell::afterCallbackRegistered invoked"); if (GetLOKAccessibilityState()) { LOKDocumentFocusListener& rDocFocusListener = GetLOKDocumentFocusListener(); @@ -3373,7 +3374,7 @@ void SfxViewShell::SetLOKAccessibilityState(bool bEnabled) } catch (const uno::Exception&) { - SAL_WARN("lok.a11y", "Exception caught processing LOKDocumentFocusListener::attachRecursive"); + LOK_WARN("SetLOKAccessibilityState", "Exception caught processing LOKDocumentFocusListener::attachRecursive"); } } else @@ -3384,7 +3385,7 @@ void SfxViewShell::SetLOKAccessibilityState(bool bEnabled) } catch (const uno::Exception&) { - SAL_WARN("lok.a11y", "Exception caught processing LOKDocumentFocusListener::detachRecursive"); + LOK_WARN("SetLOKAccessibilityState", "Exception caught processing LOKDocumentFocusListener::detachRecursive"); } } } |