summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-08 21:39:14 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-09 17:24:54 +0100
commitf50f0ae2fc9f0df7cc105cd075481172d33bc70a (patch)
tree091b2e940840be37d158fdd690a64d1710a952c7 /cui
parent6b9e78df3c1f0afe0352b07f7fdbd6587d5da940 (diff)
weld SvxSearchAttributeDialog
Change-Id: Ib929afd143cd02b49f87ae6d910500354197e826 Reviewed-on: https://gerrit.libreoffice.org/67572 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r--cui/source/dialogs/srchxtra.cxx60
-rw-r--r--cui/source/factory/dlgfact.cxx5
-rw-r--r--cui/source/factory/dlgfact.hxx2
-rw-r--r--cui/source/inc/srchxtra.hxx22
-rw-r--r--cui/uiconfig/ui/searchattrdialog.ui63
5 files changed, 96 insertions, 56 deletions
diff --git a/cui/source/dialogs/srchxtra.cxx b/cui/source/dialogs/srchxtra.cxx
index ecd2b1697d35..94ae52d9e0b4 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 56694622b723..ec2b6015dff0 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1144,12 +1144,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 d2312b21b6b6..7d7c165a4cee 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -760,7 +760,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>