Kaydet (Commit) f920e86f authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SvxSearchDialog

I have to use the other way to specify an a11y role, both are implemented in
the vcl parser, but in my gtk3-3.24.7 the role tag crashes the gtk parser,
while the other route works fine.

The CONTENT_FLOWS_TO accessibility relation is another additional complexity
over the norm

Change-Id: Ia096bcbe9f00f9944e4e4d5ad9bb1a52d19c7b3f
Reviewed-on: https://gerrit.libreoffice.org/69569
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst da881f38
This diff is collapsed.
......@@ -141,6 +141,11 @@ public:
virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0;
virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) = 0;
virtual void
add_extra_accessible_relation(const css::accessibility::AccessibleRelation& rRelation)
= 0;
virtual void clear_extra_accessible_relations() = 0;
virtual void set_tooltip_text(const OUString& rTip) = 0;
virtual OUString get_tooltip_text() const = 0;
......
......@@ -67,6 +67,7 @@ enum class PointerStyle;
namespace com { namespace sun { namespace star {
namespace accessibility {
struct AccessibleRelation;
class XAccessible;
}
......@@ -1252,6 +1253,9 @@ public:
void SetAccessibleRelationMemberOf( vcl::Window* pMemberOf );
vcl::Window* GetAccessibleRelationMemberOf() const;
void AddExtraAccessibleRelation(const css::accessibility::AccessibleRelation &rRelation);
const std::vector<css::accessibility::AccessibleRelation>& GetExtraAccessibleRelations() const;
void ClearExtraAccessibleRelations();
// to avoid sending accessibility events in cases like closing dialogs
// by default checks complete parent path
......
......@@ -233,11 +233,11 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
ScGlobal::SetSearchItem( *pSearchItem );
bool bSuccess = SearchAndReplace( pSearchItem, true, rReq.IsAPI() );
const SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
SvxSearchDialogWrapper::GetChildWindowId());
if (pChildWindow)
{
SvxSearchDialog* pSearchDlg = static_cast<SvxSearchDialog*>(pChildWindow->GetWindow());
SvxSearchDialog* pSearchDlg = static_cast<SvxSearchDialog*>(pChildWindow->GetController().get());
if( pSearchDlg )
{
ScTabView* pTabView = GetViewData().GetView();
......@@ -303,11 +303,11 @@ void ScTabViewShell::ExecSearch( SfxRequest& rReq )
rReq.IsAPI() ? SfxCallMode::API|SfxCallMode::SYNCHRON :
SfxCallMode::RECORD,
{ &aSearchItem });
const SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
SvxSearchDialogWrapper::GetChildWindowId());
if (pChildWindow)
{
SvxSearchDialog* pSearchDlg = static_cast<SvxSearchDialog*>(pChildWindow->GetWindow());
SvxSearchDialog* pSearchDlg = static_cast<SvxSearchDialog*>(pChildWindow->GetController().get());
if( pSearchDlg )
{
ScTabView* pTabView = GetViewData().GetView();
......
......@@ -507,7 +507,7 @@ bool SdOutliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem)
if (pChildWin)
{
SvxSearchDialog* pSearchDlg =
static_cast<SvxSearchDialog*>(pChildWin->GetWindow());
static_cast<SvxSearchDialog*>(pChildWin->GetController().get());
pSearchDlg->SetDocWin( pViewShell->GetActiveWindow() );
pSearchDlg->SetSrchFlag(false);
}
......
......@@ -13861,7 +13861,6 @@ svtools/source/uno/wizard/wizardpagecontroller.cxx
svtools/source/uno/wizard/wizardpagecontroller.hxx
svtools/source/uno/wizard/wizardshell.cxx
svtools/source/uno/wizard/wizardshell.hxx
svx/inc/AccessibleSvxFindReplaceDialog.hxx
svx/inc/AccessibleTableShape.hxx
svx/inc/GalleryControl.hxx
svx/inc/dragmt3d.hxx
......@@ -13980,7 +13979,6 @@ svx/source/accessibility/AccessibleOLEShape.cxx
svx/source/accessibility/AccessibleShape.cxx
svx/source/accessibility/AccessibleShapeInfo.cxx
svx/source/accessibility/AccessibleShapeTreeInfo.cxx
svx/source/accessibility/AccessibleSvxFindReplaceDialog.cxx
svx/source/accessibility/AccessibleTextEventQueue.cxx
svx/source/accessibility/AccessibleTextEventQueue.hxx
svx/source/accessibility/AccessibleTextHelper.cxx
......
......@@ -89,7 +89,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/accessibility/AccessibleShape \
svx/source/accessibility/AccessibleShapeInfo \
svx/source/accessibility/AccessibleShapeTreeInfo \
svx/source/accessibility/AccessibleSvxFindReplaceDialog \
svx/source/accessibility/AccessibleTextEventQueue \
svx/source/accessibility/AccessibleTextHelper \
svx/source/accessibility/ChildrenManager \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SVX_INC_ACCESSIBLESVXFINDREPLACEDIALOG_HXX
#define INCLUDED_SVX_INC_ACCESSIBLESVXFINDREPLACEDIALOG_HXX
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/awt/vclxaccessiblecomponent.hxx>
#include <toolkit/awt/vclxwindows.hxx>
class VCLXAccessibleSvxFindReplaceDialog : public VCLXAccessibleComponent
{
public:
VCLXAccessibleSvxFindReplaceDialog(VCLXWindow* pVCLXindow);
virtual ~VCLXAccessibleSvxFindReplaceDialog() override;
virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
};
class VCLXSvxFindReplaceDialog : public VCLXDialog
{
public:
VCLXSvxFindReplaceDialog(vcl::Window* pSplDlg)
{
SetWindow(pSplDlg);
}
private:
virtual css::uno::Reference< css::accessibility::XAccessibleContext > CreateAccessibleContext() override
{
return new VCLXAccessibleSvxFindReplaceDialog(this);
}
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <AccessibleSvxFindReplaceDialog.hxx>
#include <svx/srchdlg.hxx>
#include <toolkit/awt/vclxwindow.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
VCLXAccessibleSvxFindReplaceDialog::VCLXAccessibleSvxFindReplaceDialog(VCLXWindow* pVCLXindow)
:VCLXAccessibleComponent( pVCLXindow )
{
}
VCLXAccessibleSvxFindReplaceDialog::~VCLXAccessibleSvxFindReplaceDialog()
{
}
void VCLXAccessibleSvxFindReplaceDialog::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
{
VCLXAccessibleComponent::FillAccessibleRelationSet( rRelationSet );
VclPtr<vcl::Window> pDlg = GetWindow();
if ( !pDlg )
return;
SvxSearchDialog* pSrchDlg = static_cast<SvxSearchDialog*>( pDlg.get() );
vcl::Window* pDocWin = pSrchDlg->GetDocWin();
if ( !pDocWin )
{
return;
}
Reference < css::accessibility::XAccessible > xDocAcc = pDocWin->GetAccessible();
if ( !xDocAcc.is() )
{
return;
}
Reference< css::accessibility::XAccessibleGetAccFlowTo > xGetAccFlowTo( xDocAcc, UNO_QUERY );
if ( !xGetAccFlowTo.is() )
{
return;
}
const sal_Int32 FORFINDREPLACEFLOWTO = 2;
uno::Sequence<uno::Any> aAnySeq = xGetAccFlowTo->getAccFlowTo( Any(pSrchDlg->GetSrchFlag()), FORFINDREPLACEFLOWTO );
sal_Int32 nLen = aAnySeq.getLength();
if ( nLen )
{
uno::Sequence< uno::Reference< uno::XInterface > > aSequence( nLen );
for ( sal_Int32 i = 0; i < nLen; i++ )
{
uno::Reference < css::accessibility::XAccessible > xAcc;
aAnySeq[i] >>= xAcc;
aSequence[i] = xAcc;
}
rRelationSet.AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::CONTENT_FLOWS_TO, aSequence ) );
}
}
// XServiceInfo
OUString VCLXAccessibleSvxFindReplaceDialog::getImplementationName()
{
return OUString( "VCLXAccessibleSvxFindReplaceDialog" );
}
Sequence< OUString > VCLXAccessibleSvxFindReplaceDialog::getSupportedServiceNames()
{
Sequence< OUString > aNames { "VCLXAccessibleSvxFindReplaceDialog" };
return aNames;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="svx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="FindReplaceDialog">
......@@ -7,7 +7,12 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="findreplacedialog|FindReplaceDialog">Find &amp; Replace</property>
<property name="resizable">False</property>
<property name="default_width">0</property>
<property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child>
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox3">
<property name="can_focus">False</property>
......@@ -91,7 +96,7 @@
<property name="margin_right">6</property>
<property name="hexpand">True</property>
<child>
<object class="GtkComboBox" id="searchterm">
<object class="GtkComboBoxText" id="searchterm">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
......@@ -100,6 +105,7 @@
<child internal-child="entry">
<object class="GtkEntry" id="combobox-entry">
<property name="can_focus">True</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
......@@ -109,7 +115,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="searchlist">
<object class="GtkComboBoxText" id="searchlist">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
......@@ -151,6 +157,7 @@
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<property name="yalign">0.55000001192092896</property>
</object>
......@@ -167,9 +174,11 @@
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<accessibility>
<role type="static"/>
</accessibility>
<child internal-child="accessible">
<object class="AtkObject" id="searchlabel-atkobject">
<property name="AtkObject::accessible-role" translatable="no">static</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -275,6 +284,18 @@
<property name="top_attach">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
......@@ -325,7 +346,7 @@
<property name="margin_right">6</property>
<property name="hexpand">True</property>
<child>
<object class="GtkComboBox" id="replaceterm">
<object class="GtkComboBoxText" id="replaceterm">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
......@@ -334,6 +355,7 @@
<child internal-child="entry">
<object class="GtkEntry" id="combobox-entry2">
<property name="can_focus">True</property>
<property name="activates_default">True</property>
</object>
</child>
</object>
......@@ -343,7 +365,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="replacelist">
<object class="GtkComboBoxText" id="replacelist">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
......@@ -385,6 +407,7 @@
<property name="no_show_all">True</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
</object>
<packing>
......@@ -392,6 +415,12 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
......@@ -1030,6 +1059,7 @@
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
<property name="group">rows</property>
<accessibility>
<relation type="member-of" target="searchdir"/>
</accessibility>
......
......@@ -655,7 +655,7 @@ SwCursor* SwShellCursor::Create( SwPaM* pRing ) const
short SwShellCursor::MaxReplaceArived()
{
short nRet = RET_YES;
vcl::Window* pDlg = SwView::GetSearchDialog();
SvxSearchDialog* pDlg = SwView::GetSearchDialog();
if( pDlg )
{
// Terminate old actions. The table-frames get constructed and
......@@ -671,7 +671,7 @@ short SwShellCursor::MaxReplaceArived()
}
vActionCounts.push_back(nActCnt);
}
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pDlg->GetFrameWeld(), "modules/swriter/ui/asksearchdialog.ui"));
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pDlg->getDialog(), "modules/swriter/ui/asksearchdialog.ui"));
std::unique_ptr<weld::MessageDialog> xDialog(xBuilder->weld_message_dialog("AskSearchDialog"));
nRet = xDialog->run();
auto pActionCount = vActionCounts.begin();
......
......@@ -204,8 +204,6 @@ void SwFieldDlg::ReInitTabPage(const OString& rPageId, bool bOnlyActivate)
// newly initialise after activation of a few TabPages
void SwFieldDlg::Activate()
{
fprintf(stderr, "SwFieldDlg::Activate()\n");
SwView* pView = ::GetActiveView();
if( pView )
{
......
......@@ -375,6 +375,9 @@ void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelation
uno::Sequence< uno::Reference< uno::XInterface > > aSequence { pMemberOf->GetAccessible() };
rRelationSet.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
}
for (const auto& rExtraRelation : pWindow->GetExtraAccessibleRelations())
rRelationSet.AddRelation(rExtraRelation);
}
}
......
......@@ -275,7 +275,8 @@ public:
css::uno::Reference< css::awt::XWindowPeer > mxWindowPeer;
css::uno::Reference< css::accessibility::XAccessible > mxAccessible;
std::shared_ptr< VclSizeGroup > m_xSizeGroup;
std::vector< VclPtr<FixedText> > m_aMnemonicLabels;
std::vector<VclPtr<FixedText>> m_aMnemonicLabels;
std::vector<css::accessibility::AccessibleRelation> m_aExtraAccessibleRelations;
std::unique_ptr<ImplAccessibleInfos> mpAccessibleInfos;
VCLXWindow* mpVCLXWindow;
vcl::Region maWinRegion; //< region to 'shape' the VCL window (frame coordinates)
......
......@@ -480,6 +480,16 @@ public:
m_xWidget->SetAccessibleRelationLabelFor(pAtkLabeled);
}
virtual void add_extra_accessible_relation(const css::accessibility::AccessibleRelation &rRelation) override
{
m_xWidget->AddExtraAccessibleRelation(rRelation);
}
virtual void clear_extra_accessible_relations() override
{
m_xWidget->ClearExtraAccessibleRelations();
}
virtual void set_tooltip_text(const OUString& rTip) override
{
m_xWidget->SetQuickHelpText(rTip);
......
......@@ -45,6 +45,7 @@
#include <salframe.hxx>
#include <scrwnd.hxx>
#include <com/sun/star/accessibility/AccessibleRelation.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
using namespace com::sun::star;
......@@ -1946,6 +1947,21 @@ const std::vector<VclPtr<FixedText> >& Window::list_mnemonic_labels() const
return mpWindowImpl->m_aMnemonicLabels;
}
void Window::AddExtraAccessibleRelation(const css::accessibility::AccessibleRelation &rRelation)
{
mpWindowImpl->m_aExtraAccessibleRelations.push_back(rRelation);
}
const std::vector<css::accessibility::AccessibleRelation>& Window::GetExtraAccessibleRelations() const
{
return mpWindowImpl->m_aExtraAccessibleRelations;
}
void Window::ClearExtraAccessibleRelations()
{
mpWindowImpl->m_aExtraAccessibleRelations.clear();
}
} /* namespace vcl */
void DrawFocusRect(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
......
......@@ -496,8 +496,8 @@ wrapper_get_index_in_parent( AtkObject *atk_obj )
/*****************************************************************************/
static void
relation_set_add(AtkRelationSet *pSet, const accessibility::AccessibleRelation& rRelation)
AtkRelation*
atk_object_wrapper_relation_new(const accessibility::AccessibleRelation& rRelation)
{
sal_uInt32 nTargetCount = rRelation.TargetSet.getLength();
......@@ -515,8 +515,8 @@ relation_set_add(AtkRelationSet *pSet, const accessibility::AccessibleRelation&
aTargets.data(), nTargetCount,
mapRelationType( rRelation.RelationType )
);
atk_relation_set_add( pSet, pRel );
g_object_unref( G_OBJECT( pRel ) );
return pRel;
}
static AtkRelationSet *
......@@ -540,7 +540,9 @@ wrapper_ref_relation_set( AtkObject *atk_obj )
sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0;
for( sal_Int32 n = 0; n < nRelations; n++ )
{
relation_set_add(pSet, xRelationSet->getRelation(n));
AtkRelation *pRel = atk_object_wrapper_relation_new(xRelationSet->getRelation(n));
atk_relation_set_add(pSet, pRel);
g_object_unref(pRel);
}
}
catch(const uno::Exception &) {
......
......@@ -98,6 +98,8 @@ void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper);
AtkStateType mapAtkState( sal_Int16 nState );
AtkRelation* atk_object_wrapper_relation_new(const css::accessibility::AccessibleRelation& rRelation);
void actionIfaceInit(AtkActionIface *iface);
void componentIfaceInit(AtkComponentIface *iface);
void editableTextIfaceInit(AtkEditableTextIface *iface);
......
......@@ -1299,6 +1299,7 @@ private:
gulong m_nDragLeaveSignalId;
rtl::Reference<GtkDropTarget> m_xDropTarget;
std::vector<AtkRelation*> m_aExtraAtkRelations;
static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget)
{
......@@ -1758,6 +1759,33 @@ public:
g_object_unref(pRelationSet);
}
virtual void add_extra_accessible_relation(const css::accessibility::AccessibleRelation &rRelation) override
{
AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
if (!pAtkObject)
return;
AtkRelationSet *pRelationSet = atk_object_ref_relation_set(pAtkObject);
AtkRelation *pRel = atk_object_wrapper_relation_new(rRelation);
m_aExtraAtkRelations.push_back(pRel);
atk_relation_set_add(pRelationSet, pRel);
g_object_unref(pRel);
g_object_unref(pRelationSet);
}
virtual void clear_extra_accessible_relations() override
{
AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
if (!pAtkObject)
return;
AtkRelationSet *pRelationSet = atk_object_ref_relation_set(pAtkObject);
for (AtkRelation* pRel : m_aExtraAtkRelations)
atk_relation_set_remove(pRelationSet, pRel);
m_aExtraAtkRelations.clear();
g_object_unref(pRelationSet);
}
virtual bool get_extents_relative_to(weld::Widget& rRelative, int& x, int &y, int& width, int &height) override
{
//for toplevel windows this is sadly futile under wayland, so we can't tell where a dialog is in order to allow
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment