12#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
13#include <com/sun/star/accessibility/XAccessibleContext.hpp>
14#include <com/sun/star/accessibility/XAccessibleText.hpp>
15#include <com/sun/star/uno/Reference.hxx>
17#include <rtl/ustrbuf.hxx>
23uno::Reference<accessibility::XAccessibleContext>
25 const uno::Reference<accessibility::XAccessibleContext>& xContext)
28 accessibility::AccessibleRelationType::CONTENT_FLOWS_FROM);
32 const uno::Reference<accessibility::XAccessibleContext>& xContext)
34 return getFirstRelationTargetOfType(xContext,
35 accessibility::AccessibleRelationType::CONTENT_FLOWS_TO);
40std::deque<uno::Reference<accessibility::XAccessibleContext>>
42 const uno::Reference<accessibility::XAccessibleContext>& xContext)
51 auto child = getPreviousFlowingSibling(children.front());
54 auto childParent = child->getAccessibleParent();
57 children.push_front(child);
58 child = getPreviousFlowingSibling(child);
61 child = getNextFlowingSibling(children.back());
64 auto childParent = child->getAccessibleParent();
67 children.push_back(child);
68 child = getNextFlowingSibling(child);
75 const uno::Reference<accessibility::XAccessibleContext>& xContext, rtl::OUStringBuffer& buffer,
80 std::cout <<
"collecting text for child of role " << roleName <<
"..." << std::endl;
86 std::u16string_view
name;
89 {
u"name", xContext->getAccessibleName() },
90 {
u"description", xContext->getAccessibleDescription() },
94 buffer.append(roleName);
95 for (
auto& attr : attrs)
97 if (attr.value.getLength() == 0)
100 buffer.append(attr.name);
101 buffer.append(u
"=\"" + attr.value.replaceAll(u
"\"", u
""") +
"\"");
105 auto openTagLength = buffer.getLength();
107 uno::Reference<accessibility::XAccessibleText> xText(xContext, uno::UNO_QUERY);
109 buffer.append(xText->getText());
111 for (
auto& childContext : getAllChildren(xContext))
112 collectText(childContext, buffer);
116 if (buffer.getLength() != openTagLength)
117 buffer.append(
"</" + roleName +
">");
121 buffer[openTagLength - 1] =
'/';
128 const uno::Reference<accessibility::XAccessibleContext>& xContext)
130 rtl::OUStringBuffer buf;
131 collectText(xContext, buf, isDocumentRole(xContext->getAccessibleRole()));
132 return buf.makeStringAndClear();
static css::uno::Reference< css::accessibility::XAccessibleContext > getFirstRelationTargetOfType(const css::uno::Reference< css::accessibility::XAccessibleContext > &xContext, sal_Int16 relationType)
virtual std::deque< css::uno::Reference< css::accessibility::XAccessibleContext > > getAllChildren(const css::uno::Reference< css::accessibility::XAccessibleContext > &xContext)
Tries to list all children of an accessible.
static css::uno::Reference< css::accessibility::XAccessibleContext > getPreviousFlowingSibling(const css::uno::Reference< css::accessibility::XAccessibleContext > &xContext)
virtual std::deque< css::uno::Reference< css::accessibility::XAccessibleContext > > getAllChildren(const css::uno::Reference< css::accessibility::XAccessibleContext > &xContext) override
This fetches regular children plus siblings linked with FLOWS_TO/FLOWS_FROM which are not already in ...
static css::uno::Reference< css::accessibility::XAccessibleContext > getNextFlowingSibling(const css::uno::Reference< css::accessibility::XAccessibleContext > &xContext)
OUString collectText()
Collects contents of the current document.