tdf#130857 qt: Let QtAccessibleWidget subclass QObject

This will allow to pass it in a QVariant, which will
be used to support custom accessible implementations
for QtInstanceDrawingArea in
QtInstanceBuilder::weld_drawing_area in an upcoming
commit.

At least the Qt 5 moc does not process Qt version
checks like

    #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)

which would result in failures like

    In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21:
    /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:91:29: error: unknown type name 'QAccessibleAttributesInterface'; did you mean 'QAccessibleActionInterface'?
       91 |         return static_cast< QAccessibleAttributesInterface*>(this);
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                             QAccessibleActionInterface
    /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here
      627 | class Q_GUI_EXPORT QAccessibleActionInterface
          |                    ^
    In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21:
    /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:97:29: error: unknown type name 'QAccessibleSelectionInterface'; did you mean 'QAccessibleActionInterface'?
       97 |         return static_cast< QAccessibleSelectionInterface*>(this);
          |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          |                             QAccessibleActionInterface
    /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here
      627 | class Q_GUI_EXPORT QAccessibleActionInterface
          |                    ^
    2 errors generated.

Explicitly exclude the Qt >= 6.x specific
code in the header from the moc run by making it
conditional on

    #ifndef Q_MOC_RUN

to make that work.

Change-Id: I1ea3c37d0041dac89d632970d810ae951ff4afbb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184876
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2025-05-01 21:59:51 +02:00
parent 960703ce7f
commit e5e4873576
4 changed files with 13 additions and 1 deletions

View File

@ -10,6 +10,7 @@
$(eval $(call gb_CustomTarget_CustomTarget,vcl/qt5))
$(call gb_CustomTarget_get_target,vcl/qt5) : \
$(gb_CustomTarget_workdir)/vcl/qt5/QtAccessibleWidget.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtClipboard.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtDoubleSpinBox.moc \
$(gb_CustomTarget_workdir)/vcl/qt5/QtExpander.moc \

View File

@ -10,6 +10,7 @@
$(eval $(call gb_CustomTarget_CustomTarget,vcl/qt6))
$(call gb_CustomTarget_get_target,vcl/qt6) : \
$(gb_CustomTarget_workdir)/vcl/qt6/QtAccessibleWidget.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtClipboard.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtDoubleSpinBox.moc \
$(gb_CustomTarget_workdir)/vcl/qt6/QtExpander.moc \

View File

@ -36,20 +36,27 @@ class XAccessibleTable;
class QtFrame;
class QtWidget;
class QtAccessibleWidget final : public QAccessibleInterface,
class QtAccessibleWidget final : public QObject,
public QAccessibleInterface,
public QAccessibleActionInterface,
#ifndef Q_MOC_RUN
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
public QAccessibleAttributesInterface,
#endif
#endif
public QAccessibleTextInterface,
public QAccessibleEditableTextInterface,
#ifndef Q_MOC_RUN
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
public QAccessibleSelectionInterface,
#endif
#endif
public QAccessibleTableCellInterface,
public QAccessibleTableInterface,
public QAccessibleValueInterface
{
Q_OBJECT
public:
QtAccessibleWidget(const css::uno::Reference<css::accessibility::XAccessible>& xAccessible,
QObject* pObject);
@ -88,6 +95,7 @@ public:
void doAction(const QString& actionName) override;
QStringList keyBindingsForAction(const QString& actionName) const override;
#ifndef Q_MOC_RUN
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
// helper method for QAccessibleAttributesInterface
QHash<QAccessible::Attribute, QVariant> attributes() const;
@ -95,6 +103,7 @@ public:
// QAccessibleAttributesInterface
QList<QAccessible::Attribute> attributeKeys() const override;
QVariant attributeValue(QAccessible::Attribute key) const override;
#endif
#endif
// QAccessibleTextInterface

View File

@ -18,6 +18,7 @@
*/
#include <QtAccessibleWidget.hxx>
#include <QtAccessibleWidget.moc>
#include <QtGui/QAccessibleInterface>