cui/source/dialogs/srchxtra.cxx | 60 ++++++++++++++-------------------- cui/source/factory/dlgfact.cxx | 5 +- cui/source/factory/dlgfact.hxx | 2 - cui/source/inc/srchxtra.hxx | 22 +++++------- cui/uiconfig/ui/searchattrdialog.ui | 63 +++++++++++++++++++++++++++++++++--- include/svx/svxdlg.hxx | 2 - 6 files changed, 97 insertions(+), 57 deletions(-)
New commits: commit 56c0ca9bf467c65ad379d7d7b238b453ba76a69b Author: Caolán McNamara <[email protected]> AuthorDate: Fri Feb 8 21:39:14 2019 +0000 Commit: Szymon Kłos <[email protected]> CommitDate: Thu May 21 09:09:09 2020 +0200 weld SvxSearchAttributeDialog Change-Id: Ib929afd143cd02b49f87ae6d910500354197e826 Reviewed-on: https://gerrit.libreoffice.org/67572 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94593 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx index a63691256f19..b41dcb987962 100644 --- a/cui/source/dialogs/srchxtra.cxx +++ b/cui/source/dialogs/srchxtra.cxx @@ -102,20 +102,21 @@ void SvxSearchFormatDialog::PageCreated(const OString& rId, SfxTabPage& rPage) } } -SvxSearchAttributeDialog::SvxSearchAttributeDialog(vcl::Window* pParent, +SvxSearchAttributeDialog::SvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges) - : ModalDialog(pParent, "SearchAttrDialog", "cui/ui/searchattrdialog.ui") + : GenericDialogController(pParent, "cui/ui/searchattrdialog.ui", "SearchAttrDialog") , rList(rLst) + , m_xAttrLB(m_xBuilder->weld_tree_view("treeview")) + , m_xOKBtn(m_xBuilder->weld_button("ok")) { - get(m_pOKBtn, "ok"); - get(m_pAttrLB, "treeview"); - m_pAttrLB->set_height_request(m_pAttrLB->GetTextHeight() * 12); - m_pAttrLB->set_width_request(m_pAttrLB->approximate_char_width() * 56); + m_xAttrLB->set_size_request(m_xAttrLB->get_approximate_digit_width() * 50, + m_xAttrLB->get_height_rows(12)); - m_pAttrLB->SetStyle( GetStyle() | WB_CLIPCHILDREN | WB_HSCROLL | WB_SORT ); - m_pAttrLB->GetModel()->SetSortMode( SortAscending ); + std::vector<int> aWidths; + aWidths.push_back(m_xAttrLB->get_approximate_digit_width() * 3 + 6); + m_xAttrLB->set_column_fixed_widths(aWidths); - m_pOKBtn->SetClickHdl( LINK( this, SvxSearchAttributeDialog, OKHdl ) ); + m_xOKBtn->connect_clicked(LINK( this, SvxSearchAttributeDialog, OKHdl)); SfxObjectShell* pSh = SfxObjectShell::Current(); DBG_ASSERT( pSh, "No DocShell" ); @@ -143,47 +144,38 @@ SvxSearchAttributeDialog::SvxSearchAttributeDialog(vcl::Window* pParent, // item resources are in svx sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot); - SvTreeListEntry* pEntry = nullptr; - if ( RESARRAY_INDEX_NOTFOUND != nId ) - pEntry = m_pAttrLB->SvTreeListBox::InsertEntry(SvxAttrNameTable::GetString(nId)); - else - SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); - - if ( pEntry ) + if (RESARRAY_INDEX_NOTFOUND != nId) { - m_pAttrLB->SetCheckButtonState( pEntry, bChecked ? SvButtonState::Checked : SvButtonState::Unchecked ); - pEntry->SetUserData( reinterpret_cast<void*>(nSlot) ); + m_xAttrLB->insert(nullptr, -1, nullptr, nullptr, nullptr, + nullptr, nullptr, false); + const int nRow = m_xAttrLB->n_children() - 1; + m_xAttrLB->set_toggle(nRow, bChecked, 0); + m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 1); + m_xAttrLB->set_id(nRow, OUString::number(nSlot)); } + else + SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) ); } nWhich = aIter.NextWhich(); } - m_pAttrLB->SetHighlightRange(); - m_pAttrLB->SelectEntryPos( 0 ); + m_xAttrLB->make_sorted(); + m_xAttrLB->select(0); } SvxSearchAttributeDialog::~SvxSearchAttributeDialog() { - disposeOnce(); } -void SvxSearchAttributeDialog::dispose() -{ - m_pAttrLB.clear(); - m_pOKBtn.clear(); - ModalDialog::dispose(); -} - - -IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, Button*, void) +IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button&, void) { SearchAttrItem aInvalidItem; aInvalidItem.pItem = INVALID_POOL_ITEM; - for ( sal_uLong i = 0; i < m_pAttrLB->GetEntryCount(); ++i ) + for (int i = 0, nCount = m_xAttrLB->n_children(); i < nCount; ++i) { - sal_uInt16 nSlot = static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pAttrLB->GetEntryData(i))); - bool bChecked = m_pAttrLB->IsChecked(i); + sal_uInt16 nSlot = m_xAttrLB->get_id(i).toUInt32(); + bool bChecked = m_xAttrLB->get_toggle(i, 0); sal_uInt16 j; for ( j = rList.Count(); j; ) @@ -216,7 +208,7 @@ IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, Button*, void) if ( !rList[ --n ].pItem ) rList.Remove( n ); - EndDialog( RET_OK ); + m_xDialog->response(RET_OK); } // class SvxSearchSimilarityDialog --------------------------------------- diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 5e6a9348c2fa..e520ebb99928 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -1156,12 +1156,11 @@ VclPtr<SfxAbstractTabDialog> AbstractDialogFactory_Impl::CreateTabItemDialog(wel pParent, rSet)); } -VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxSearchAttributeDialog( vcl::Window* pParent, +VclPtr<VclAbstractDialog> AbstractDialogFactory_Impl::CreateSvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges ) { - VclPtrInstance<SvxSearchAttributeDialog> pDlg( pParent, rLst, pWhRanges); - return VclPtr<CuiVclAbstractDialog_Impl>::Create( pDlg ); + return VclPtr<CuiAbstractController_Impl>::Create(std::make_unique<SvxSearchAttributeDialog>(pParent, rLst, pWhRanges)); } VclPtr<AbstractSvxSearchSimilarityDialog> AbstractDialogFactory_Impl::CreateSvxSearchSimilarityDialog(weld::Window* pParent, diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index 8cb6f5591c8a..dd45dc48650b 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -757,7 +757,7 @@ public: const OUString& rTarget, const OUString& rName, TargetList& rTargetList ) override; - virtual VclPtr<VclAbstractDialog> CreateSvxSearchAttributeDialog( vcl::Window* pParent, + virtual VclPtr<VclAbstractDialog> CreateSvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges) override; virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( weld::Window* pParent, diff --git a/cui/source/inc/srchxtra.hxx b/cui/source/inc/srchxtra.hxx index e6ca82ba9697..38ee2955aa0d 100644 --- a/cui/source/inc/srchxtra.hxx +++ b/cui/source/inc/srchxtra.hxx @@ -19,13 +19,10 @@ #ifndef INCLUDED_CUI_SOURCE_INC_SRCHXTRA_HXX #define INCLUDED_CUI_SOURCE_INC_SRCHXTRA_HXX -#include <vcl/field.hxx> -#include <vcl/weld.hxx> -#include <svtools/ctrltool.hxx> #include <sfx2/tabdlg.hxx> - -#include <svx/checklbx.hxx> +#include <svtools/ctrltool.hxx> #include <svx/srchdlg.hxx> +#include <vcl/weld.hxx> class SvxSearchFormatDialog : public SfxTabDialogController { @@ -42,21 +39,20 @@ private: // class SvxSearchFormatDialog ------------------------------------------- -class SvxSearchAttributeDialog : public ModalDialog +class SvxSearchAttributeDialog : public weld::GenericDialogController { public: - SvxSearchAttributeDialog( vcl::Window* pParent, SearchAttrItemList& rLst, - const sal_uInt16* pWhRanges ); + SvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst, + const sal_uInt16* pWhRanges); virtual ~SvxSearchAttributeDialog() override; - virtual void dispose() override; private: - VclPtr<SvxCheckListBox> m_pAttrLB; - VclPtr<OKButton> m_pOKBtn; - SearchAttrItemList& rList; - DECL_LINK(OKHdl, Button*, void); + std::unique_ptr<weld::TreeView> m_xAttrLB; + std::unique_ptr<weld::Button> m_xOKBtn; + + DECL_LINK(OKHdl, weld::Button&, void); }; // class SvxSearchSimilarityDialog --------------------------------------- diff --git a/cui/uiconfig/ui/searchattrdialog.ui b/cui/uiconfig/ui/searchattrdialog.ui index e5e0f249c6e2..f543ba732c8e 100644 --- a/cui/uiconfig/ui/searchattrdialog.ui +++ b/cui/uiconfig/ui/searchattrdialog.ui @@ -1,14 +1,28 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> + <object class="GtkTreeStore" id="liststore1"> + <columns> + <!-- column-name check1 --> + <column type="gboolean"/> + <!-- column-name text --> + <column type="gchararray"/> + <!-- column-name id --> + <column type="gchararray"/> + <!-- column-name checkvis1 --> + <column type="gboolean"/> + </columns> + </object> <object class="GtkDialog" id="SearchAttrDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="searchattrdialog|SearchAttrDialog">Attributes</property> <property name="resizable">False</property> <property name="type_hint">dialog</property> + <child> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -72,13 +86,52 @@ </packing> </child> <child> - <object class="svxcorelo-SvxCheckListBox" id="treeview:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection1"/> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="vexpand">True</property> + <property name="model">liststore1</property> + <property name="headers_visible">False</property> + <property name="search_column">0</property> + <property name="show_expanders">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="Macro Library List-selection2"/> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn4"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <property name="alignment">0.5</property> + <child> + <object class="GtkCellRendererToggle" id="cellrenderer5"/> + <attributes> + <attribute name="visible">3</attribute> + <attribute name="active">0</attribute> + </attributes> + </child> + </object> + </child> + <child> + <object class="GtkTreeViewColumn" id="treeviewcolumn5"> + <property name="resizable">True</property> + <property name="spacing">6</property> + <child> + <object class="GtkCellRendererText" id="cellrenderer4"/> + <attributes> + <attribute name="text">1</attribute> + </attributes> + </child> + </object> + </child> + </object> </child> </object> <packing> diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index e3e0f4a366e6..0147437c52e5 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -356,7 +356,7 @@ public: TargetList& rTargetList ) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateTabItemDialog(weld::Window* pParent, const SfxItemSet& rSet) = 0; - virtual VclPtr<VclAbstractDialog> CreateSvxSearchAttributeDialog( vcl::Window* pParent, + virtual VclPtr<VclAbstractDialog> CreateSvxSearchAttributeDialog(weld::Window* pParent, SearchAttrItemList& rLst, const sal_uInt16* pWhRanges)=0; virtual VclPtr<AbstractSvxSearchSimilarityDialog> CreateSvxSearchSimilarityDialog( weld::Window* pParent, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
