formula/uiconfig/ui/formuladialog.ui | 31 +++++--- formula/uiconfig/ui/parameter.ui | 15 ++++ include/sfx2/sfxsids.hrc | 2 include/svl/srchitem.hxx | 3 include/svx/srchdlg.hxx | 3 officecfg/registry/data/org/openoffice/Office/Accelerators.xcu | 4 - sc/sdi/tabvwsh.sdi | 1 sc/source/ui/inc/tabvwsh.hxx | 2 sc/source/ui/view/tabvwsh4.cxx | 37 ++++++++++ sd/sdi/_drvwsh.sdi | 5 + sd/source/ui/inc/DrawViewShell.hxx | 2 sd/source/ui/view/drviewse.cxx | 36 +++++++++ sfx2/sdi/sfx.sdi | 1 svl/source/items/srchitem.cxx | 6 + svx/source/dialog/srchdlg.cxx | 24 +++++- sw/inc/view.hxx | 1 sw/sdi/_viewsh.sdi | 5 + sw/source/uibase/uiview/viewsrch.cxx | 27 +++++++ vcl/source/window/window.cxx | 7 + 19 files changed, 191 insertions(+), 21 deletions(-)
New commits: commit 1688fdc18f0fa4019afdc32c2af26a3cd4307af3 Author: Parth Raiyani <[email protected]> AuthorDate: Wed Sep 3 20:06:33 2025 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Feb 25 09:19:53 2026 +0100 Improve accessibility by adding static roles to GtkLabels - Adds static accessibility roles to GtkLabels to ensure proper rendering and enhance compatibility with assistive technologies - Introduces new `renderAsStatic` property in JSON which is set inside DumpAsPropertyTree method when label has static accessibility role Signed-off-by: Parth Raiyani <[email protected]> Change-Id: I8b8d0005b60fdda2af44eb87186e0b7982ee91f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190558 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200231 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/formula/uiconfig/ui/formuladialog.ui b/formula/uiconfig/ui/formuladialog.ui index 2cb9707c0266..44da712fc5e0 100644 --- a/formula/uiconfig/ui/formuladialog.ui +++ b/formula/uiconfig/ui/formuladialog.ui @@ -234,23 +234,17 @@ <property name="can-focus">False</property> <property name="halign">start</property> <property name="hexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="editname-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> </object> <packing> <property name="left-attach">0</property> <property name="top-attach">0</property> </packing> </child> - <child> - <object class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> @@ -323,6 +317,11 @@ <attributes> <attribute name="weight" value="bold"/> </attributes> + <child internal-child="accessible"> + <object class="AtkObject" id="headline-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> </object> <packing> <property name="expand">True</property> @@ -346,6 +345,11 @@ <property name="wrap">True</property> <property name="xalign">0</property> <property name="yalign">0</property> + <child internal-child="accessible"> + <object class="AtkObject" id="funcname-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> </object> <packing> <property name="left-attach">0</property> @@ -361,6 +365,11 @@ <property name="wrap">True</property> <property name="xalign">0</property> <property name="yalign">0</property> + <child internal-child="accessible"> + <object class="AtkObject" id="funcdesc-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> <attributes> <attribute name="scale" value="0.9"/> </attributes> diff --git a/formula/uiconfig/ui/parameter.ui b/formula/uiconfig/ui/parameter.ui index a646a6ffc12b..dc35e979f2fa 100644 --- a/formula/uiconfig/ui/parameter.ui +++ b/formula/uiconfig/ui/parameter.ui @@ -28,6 +28,11 @@ <property name="wrap">True</property> <property name="xalign">0</property> <property name="yalign">0</property> + <child internal-child="accessible"> + <object class="AtkObject" id="editdesc-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -41,6 +46,11 @@ <property name="can-focus">False</property> <property name="halign">start</property> <property name="hexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="parname-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> </object> <packing> <property name="expand">False</property> @@ -58,6 +68,11 @@ <property name="wrap">True</property> <property name="xalign">0</property> <property name="yalign">0</property> + <child internal-child="accessible"> + <object class="AtkObject" id="pardesc-atkobject"> + <property name="AtkObject::accessible-role">static</property> + </object> + </child> <attributes> <attribute name="scale" value="0.9"/> </attributes> diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index fedfc1b8eff7..ef0191582fe9 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -63,6 +63,7 @@ #include <dndeventdispatcher.hxx> #include <com/sun/star/accessibility/AccessibleRelation.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleEditableText.hpp> @@ -3409,6 +3410,12 @@ void Window::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) } } + // If GtkLabel has a static accessibility role, mark renderAsStatic. + // so LOK renders it as <span> instead of <label> for correct accessibility. + sal_uInt16 nAccessibleRole = GetAccessibleRole(); + if (nAccessibleRole == css::accessibility::AccessibleRole::STATIC && GetType() == WindowType::FIXEDTEXT) + rJsonWriter.put("renderAsStatic", true); + vcl::Window* pAccLabelFor = getAccessibleRelationLabelFor(); if (pAccLabelFor) rJsonWriter.put("labelFor", pAccLabelFor->get_id()); commit 802db977d0809a2bd1ba73a4bb6eb13b71dac540 Author: Parth Raiyani <[email protected]> AuthorDate: Tue Sep 23 14:58:58 2025 +0530 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Feb 25 09:19:39 2026 +0100 find-replace: set initial focus on Replace tab when shortcut is used - Added a new feature to set the initial focus on the 'Replace' tab in the search dialog. - Introduced a boolean property 'InitialFocusReplace' to manage this behavior and updates related constructors, methods, and UI bindings accordingly. - Fixed accessibility issue by setting initial focus on replace tab when replace shortcut is triggered in writer, calc, impress, draw Change-Id: Ib4833d817ee58ec13d377123de6c963f2817b626 Signed-off-by: Parth Raiyani <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191289 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200230 Reviewed-by: Caolán McNamara <[email protected]> diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 3da55d478324..d7a8308b3266 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -514,7 +514,7 @@ class SvxZoomItem; #define SID_BASICSTOP (SID_SFX_START + 958) #define SID_BASICCHOOSER (SID_SFX_START + 959) #define SID_GALLERY (SID_SFX_START + 960) -#define SID_SEARCH_DLG (SID_SFX_START + 961) +#define SID_SEARCH_DLG TypedWhichId<SfxBoolItem>(SID_SFX_START + 961) #define SID_SEARCH_QUIET (SID_SFX_START + 1684) #define SID_SEARCH (SID_SFX_START + 1685) #define SID_EXPORT_DIALOG (SID_SFX_START + 965) diff --git a/include/svl/srchitem.hxx b/include/svl/srchitem.hxx index f9c71d4e767b..911c5b2fcb71 100644 --- a/include/svl/srchitem.hxx +++ b/include/svl/srchitem.hxx @@ -86,6 +86,7 @@ class SVL_DLLPUBLIC SvxSearchItem final : // Start search at this point (absolute twips). sal_Int32 m_nStartPointX; sal_Int32 m_nStartPointY; + bool m_bInitialFocusOnReplace; virtual void ImplCommit() override; @@ -169,6 +170,8 @@ public: SvxSearchApp GetAppFlag() const { return m_nAppFlag; } void SetAppFlag(SvxSearchApp nNewAppFlag) { m_nAppFlag = nNewAppFlag; } + bool GetInitialFocusOnReplace() const { return m_bInitialFocusOnReplace; } + void SetInitialFocusOnReplace(bool bVal) { m_bInitialFocusOnReplace = bVal; } inline bool IsLevenshtein() const; void SetLevenshtein( bool bVal ); diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx index cf93f50299c4..6f26ada1c21a 100644 --- a/include/svx/srchdlg.hxx +++ b/include/svx/srchdlg.hxx @@ -122,7 +122,7 @@ friend class SvxSearchDialogWrapper; friend class SvxJSearchOptionsDialog; public: - SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind ); + SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind, bool bInitialFocusOnReplace = false ); virtual ~SvxSearchDialog() override; virtual void ChildWinDispose() override; @@ -151,6 +151,7 @@ private: bool m_bWriter; bool m_bSearch; bool m_bFormat; + bool m_bInitialFocusOnReplace; bool m_bReplaceBackwards; SearchOptionFlags m_nOptions; bool m_bSet; diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu index b6217abeff66..972c7be16146 100644 --- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu @@ -143,7 +143,7 @@ Ctrl+Shift+u aka U_SHIFT_MOD1 under GTK/IBUS is for unicode key input <node oor:name="H_MOD1" oor:op="replace"> <prop oor:name="Command"> <value xml:lang="x-no-translate">L10N SHORTCUTS - NO TRANSLATE</value> - <value xml:lang="en-US" install:module="unxwnt">.uno:SearchDialog</value> + <value xml:lang="en-US" install:module="unxwnt">.uno:SearchDialog?InitialFocusReplace:bool=true</value> </prop> </node> <node oor:name="G_MOD1" oor:op="replace"> @@ -471,7 +471,7 @@ Ctrl+Shift+u aka U_SHIFT_MOD1 under GTK/IBUS is for unicode key input <node oor:name="H_MOD1" oor:op="replace"> <prop oor:name="Command"> <value xml:lang="x-no-translate">L10N SHORTCUTS - NO TRANSLATE</value> - <value xml:lang="en-US" install:module="unxwnt">.uno:SearchDialog</value> + <value xml:lang="en-US" install:module="unxwnt">.uno:SearchDialog?InitialFocusReplace:bool=true</value> </prop> </node> <node oor:name="N_MOD1" oor:op="replace"> diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi index 42c6018edf1b..78b87b2b7145 100644 --- a/sc/sdi/tabvwsh.sdi +++ b/sc/sdi/tabvwsh.sdi @@ -227,6 +227,7 @@ interface TableEditView SID_NAVIGATOR_SELECT_COMMENT [ ExecMethod = ExecNavigatorWin; ] // search/replace + SID_SEARCH_DLG [ ExecMethod = SearchDialogHdl; StateMethod = GetState; ] FID_SEARCH_NOW [ ExecMethod = ExecSearch; StateMethod = NoState; ] SID_SEARCH_ITEM [ ExecMethod = ExecSearch; StateMethod = GetState; ] SID_SEARCH_OPTIONS [ ExecMethod = NoExec; StateMethod = GetState; ] diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 2d9c5cda5aee..670341b9d826 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -487,6 +487,8 @@ public: void SetInsertWizardUndoMark(); + DECL_LINK(SearchDialogHdl, SfxRequest&, void); + private: void ExecuteMoveTable( SfxRequest& rReq ); void DoMoveTableFromDialog( SfxRequest& rReq, const VclPtr<AbstractScMoveTableDlg>& pDlg ); diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx index 36d15e890ab2..d2a3d04e7133 100644 --- a/sc/source/ui/view/tabvwsh4.cxx +++ b/sc/source/ui/view/tabvwsh4.cxx @@ -90,6 +90,9 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> #include <sfx2/sidebar/SidebarController.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/srchitem.hxx> +#include <svx/srchdlg.hxx> using namespace com::sun::star; using namespace sfx2::sidebar; @@ -345,6 +348,40 @@ void ScTabViewShell::UpdateOleZoom() } } +IMPL_LINK(ScTabViewShell, SearchDialogHdl, SfxRequest&, rReq, void) +{ + // Get the parameter from the request + const SfxItemSet* pArgs = rReq.GetArgs(); + bool bInitialFocusOnReplace = false; + + if (pArgs) + { + const SfxBoolItem* pBoolItem = pArgs->GetItemIfSet(SID_SEARCH_DLG, false); + if (pBoolItem) + bInitialFocusOnReplace = pBoolItem->GetValue(); + } + + // Get existing search item to preserve settings + std::unique_ptr<SvxSearchItem> pSearchItem; + std::unique_ptr<SvxSearchItem> pExistingItem; + if (GetViewData().GetBindings().QueryState(SID_SEARCH_ITEM, pExistingItem) >= SfxItemState::DEFAULT && pExistingItem) + { + pSearchItem.reset(pExistingItem->Clone()); + } + else + { + pSearchItem = std::make_unique<SvxSearchItem>(SID_SEARCH_ITEM); + } + + // Only set the focus parameter, preserving all other settings + pSearchItem->SetInitialFocusOnReplace(bInitialFocusOnReplace); + + // Execute the search dialog with the configured item + const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr }; + GetViewData().GetDispatcher().Execute(SID_SEARCH_ITEM, SfxCallMode::SYNCHRON, ppArgs); + GetViewFrame().ToggleChildWindow(SvxSearchDialogWrapper::GetChildWindowId()); +} + void ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize, bool inplaceEditModeChange ) { Size aNewSize( rSize ); diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi index b6b2d805dfea..f8d917809da1 100644 --- a/sd/sdi/_drvwsh.sdi +++ b/sd/sdi/_drvwsh.sdi @@ -2483,6 +2483,11 @@ interface DrawView ExecMethod = Execute ; StateMethod = GetMenuState ; ] + SID_SEARCH_DLG + [ + ExecMethod = SearchDialogHdl ; + StateMethod = GetMenuState ; + ] SID_EXTRUSION_TOGGLE [ ExecMethod = FuTemporary ; diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx index dea836dd47c2..5ce4b0382400 100644 --- a/sd/source/ui/inc/DrawViewShell.hxx +++ b/sd/source/ui/inc/DrawViewShell.hxx @@ -394,6 +394,8 @@ public: virtual void RememberCanvasPageVisArea(const ::tools::Rectangle &aRect) override; + DECL_LINK(SearchDialogHdl, SfxRequest&, void); + protected: DECL_DLLPRIVATE_LINK( ClipboardChanged, TransferableDataHelper*, void ); DECL_DLLPRIVATE_LINK( TabSplitHdl, TabBar *, void ); diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 5d94d132275e..50bc05e02636 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -105,6 +105,8 @@ #include <SlideSorterViewShell.hxx> #include <controller/SlideSorterController.hxx> #include <controller/SlsClipboard.hxx> +#include <svl/srchitem.hxx> +#include <svx/srchdlg.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -800,6 +802,40 @@ void DrawViewShell::FuDeleteSelectedObjects() mpDrawView->DeleteMarked(); } +IMPL_LINK(DrawViewShell, SearchDialogHdl, SfxRequest&, rReq, void) +{ + // Get the parameter from the request + const SfxItemSet* pArgs = rReq.GetArgs(); + bool bInitialFocusOnReplace = false; + + if (pArgs) + { + const SfxBoolItem* pBoolItem = pArgs->GetItemIfSet(SID_SEARCH_DLG, false); + if (pBoolItem) + bInitialFocusOnReplace = pBoolItem->GetValue(); + } + + // Get existing search item to preserve settings + std::unique_ptr<SvxSearchItem> pSearchItem; + std::unique_ptr<SvxSearchItem> pExistingItem; + if (GetViewFrame()->GetBindings().QueryState(SID_SEARCH_ITEM, pExistingItem) >= SfxItemState::DEFAULT && pExistingItem) + { + pSearchItem.reset(pExistingItem->Clone()); + } + else + { + pSearchItem = std::make_unique<SvxSearchItem>(SID_SEARCH_ITEM); + } + + // Only set the focus parameter, preserving all other settings + pSearchItem->SetInitialFocusOnReplace(bInitialFocusOnReplace); + + // Execute the search dialog with the configured item + const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr }; + GetViewFrame()->GetBindings().GetDispatcher()->Execute(SID_SEARCH_ITEM, SfxCallMode::SYNCHRON, ppArgs); + GetViewFrame()->ToggleChildWindow(SvxSearchDialogWrapper::GetChildWindowId()); +} + void DrawViewShell::FuSupport(SfxRequest& rReq) { if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs()) diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 76af1e208b3c..74a27a4f8e6c 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -4051,6 +4051,7 @@ SfxBoolItem FocusToFindbar SID_SEARCH SfxBoolItem SearchDialog SID_SEARCH_DLG +(SfxBoolItem InitialFocusReplace SID_SEARCH_DLG) [ AutoUpdate = TRUE, FastCall = FALSE, diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx index 5f37d07b7674..fdbae924fc58 100644 --- a/svl/source/items/srchitem.cxx +++ b/svl/source/items/srchitem.cxx @@ -115,7 +115,8 @@ SvxSearchItem::SvxSearchItem( const sal_uInt16 nId ) : m_bContent ( false ), m_bAsianOptions ( false ), m_nStartPointX(0), - m_nStartPointY(0) + m_nStartPointY(0), + m_bInitialFocusOnReplace(false) { EnableNotification( lcl_GetNotifyNames() ); @@ -210,7 +211,8 @@ SvxSearchItem::SvxSearchItem( const SvxSearchItem& rItem ) : m_bContent ( rItem.m_bContent ), m_bAsianOptions ( rItem.m_bAsianOptions ), m_nStartPointX(rItem.m_nStartPointX), - m_nStartPointY(rItem.m_nStartPointY) + m_nStartPointY(rItem.m_nStartPointY), + m_bInitialFocusOnReplace(rItem.m_bInitialFocusOnReplace) { EnableNotification( lcl_GetNotifyNames() ); } diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx index 8a04cb940dcb..b94a6b38bd09 100644 --- a/svx/source/dialog/srchdlg.cxx +++ b/svx/source/dialog/srchdlg.cxx @@ -239,7 +239,7 @@ void SearchAttrItemList::Remove(size_t nPos) SrchAttrInfoList::erase( begin() + nPos, begin() + nPos + nLen ); } -SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind) +SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind, bool bInitialFocusOnReplace) : SfxModelessDialogController(&rBind, pChildWin, pParent, IsMobile() ? u"svx/ui/findreplacedialog-mobile.ui"_ustr : u"svx/ui/findreplacedialog.ui"_ustr, u"FindReplaceDialog"_ustr) @@ -248,6 +248,7 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi , m_bWriter(false) , m_bSearch(true) , m_bFormat(false) + , m_bInitialFocusOnReplace(bInitialFocusOnReplace) , m_bReplaceBackwards(false) , m_nOptions(SearchOptionFlags::ALL) , m_bSet(false) @@ -311,6 +312,7 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi { m_xCloseBtn->hide(); m_xHelpBtn->hide(); + m_bSearch = !m_bInitialFocusOnReplace; m_xSearchLB->set_entry_text(u""_ustr); m_xReplaceLB->set_entry_text(u""_ustr); m_xSearchLB->grab_focus(); @@ -348,7 +350,7 @@ SvxSearchDialog::SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWi m_xReplaceTmplLB->set_size_request(nTermWidth, -1); Construct_Impl(); - SetReplaceCtrlsVisible(false); + SetReplaceCtrlsVisible(m_bInitialFocusOnReplace); } IMPL_LINK_NOARG(SvxSearchDialog, PresentTimeoutHdl_Impl, Timer*, void) @@ -977,8 +979,11 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_xSearchTmplLB->show(); if (m_bConstruct) + { // Grab focus only after creating + m_bSearch = !m_bInitialFocusOnReplace; m_xSearchTmplLB->grab_focus(); + } m_xReplaceTmplLB->show(); m_xSearchLB->hide(); m_xReplaceLB->hide(); @@ -1020,8 +1025,11 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) m_xSearchLB->show(); if (m_bConstruct) + { // Grab focus only after creating + m_bSearch = !m_bInitialFocusOnReplace; m_xSearchLB->grab_focus(); + } m_xReplaceLB->show(); m_xSearchTmplLB->hide(); m_xReplaceTmplLB->hide(); @@ -1038,7 +1046,7 @@ void SvxSearchDialog::Init_Impl( bool bSearchPattern ) bDisableSearch = m_xSearchLB->get_active_text().isEmpty() && m_xSearchAttrText->get_label().isEmpty(); } - FocusHdl_Impl(*m_xSearchLB); + FocusHdl_Impl(m_bSearch ? *m_xSearchLB : *m_xReplaceLB); if ( bDisableSearch ) { @@ -2373,8 +2381,16 @@ SvxSearchDialogWrapper::SvxSearchDialogWrapper( vcl::Window* _pParent, sal_uInt1 SfxBindings* pBindings, SfxChildWinInfo const * pInfo ) : SfxChildWindow( _pParent, nId ) - , dialog(std::make_shared<SvxSearchDialog>(_pParent->GetFrameWeld(), this, *pBindings)) { + bool bInitialFocusOnReplace = false; + std::unique_ptr<SvxSearchItem> pItem; + if (pBindings->QueryState(SID_SEARCH_ITEM, pItem) >= SfxItemState::DEFAULT && pItem) + { + bInitialFocusOnReplace = pItem->GetInitialFocusOnReplace(); + } + + dialog = std::make_shared<SvxSearchDialog>(_pParent->GetFrameWeld(), this, *pBindings, bInitialFocusOnReplace); + SetController(dialog); dialog->Initialize( pInfo ); diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index eaf65e7637d2..77c670b9b7ac 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -366,6 +366,7 @@ public: // #i123922# Needs to be called from a 2nd place now as a helper method sal_Int32 m_nNaviExpandedStatus = -1; void SetFormShell( FmFormShell* pSh ) { m_pFormShell = pSh; } virtual void SelectShell(); + DECL_LINK(SearchDialogHdl, SfxRequest&, void); protected: diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index 5db24b03bc07..4047d2cb3f43 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -692,6 +692,11 @@ interface BaseTextEditView /* search and replace */ + SID_SEARCH_DLG + [ + ExecMethod = SearchDialogHdl ; + StateMethod = StateSearch ; + ] SID_SEARCH_ITEM // status() [ ExecMethod = ExecSearch ; diff --git a/sw/source/uibase/uiview/viewsrch.cxx b/sw/source/uibase/uiview/viewsrch.cxx index 45f963e5a9c9..c1db4542f664 100644 --- a/sw/source/uibase/uiview/viewsrch.cxx +++ b/sw/source/uibase/uiview/viewsrch.cxx @@ -53,6 +53,7 @@ #include <SwRewriter.hxx> #include <PostItMgr.hxx> +#include <sfx2/dispatch.hxx> using namespace com::sun::star; using namespace ::com::sun::star::lang; @@ -471,6 +472,32 @@ void SwView::ExecSearch(SfxRequest& rReq) } } +IMPL_LINK(SwView, SearchDialogHdl, SfxRequest&, rReq, void) +{ + // Get the parameter from the request + const SfxItemSet* pArgs = rReq.GetArgs(); + bool bInitialFocusOnReplace = false; + + if (pArgs) + { + const SfxBoolItem* pBoolItem = pArgs->GetItemIfSet(SID_SEARCH_DLG, false); + if (pBoolItem) + bInitialFocusOnReplace = pBoolItem->GetValue(); + } + + if (!s_pSrchItem) + s_pSrchItem = new SvxSearchItem(SID_SEARCH_ITEM); + + s_pSrchItem->SetInitialFocusOnReplace(bInitialFocusOnReplace); + + // Execute the search item to pass it to the dialog + const SfxPoolItem* ppArgs[] = { s_pSrchItem, nullptr }; + GetDispatcher().Execute(SID_SEARCH_ITEM, SfxCallMode::SYNCHRON, ppArgs); + + // Open the dialog + GetViewFrame().ToggleChildWindow(SvxSearchDialogWrapper::GetChildWindowId()); +} + bool SwView::SearchAndWrap(bool bApi) { SwSearchOptions aOpts( m_pWrtShell.get(), s_pSrchItem->GetBackward() );
