From 47897fdd936d9b6e9ac8cb6110c79352ab080df7 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 17 Nov 2018 21:37:50 +0000 Subject: weld SwCondCollPage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and put back original SvTreeListBox a11y factory use Change-Id: I4ad8ce29d8fed6ec5d44e9a1d641919a89226b79 Reviewed-on: https://gerrit.libreoffice.org/63501 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/ui/chrdlg/swuiccoll.cxx | 262 +++++++++++++------------------ sw/source/ui/config/mailconfigpage.cxx | 4 +- sw/source/ui/dbui/addresslistdialog.hxx | 4 +- sw/source/ui/dbui/mmaddressblockpage.hxx | 2 +- sw/source/ui/inc/mmresultdialogs.hxx | 4 +- sw/source/ui/misc/bookmark.cxx | 2 +- sw/source/uibase/inc/glosbib.hxx | 2 +- sw/source/uibase/inc/swuiccoll.hxx | 43 +++-- 8 files changed, 139 insertions(+), 184 deletions(-) (limited to 'sw/source') diff --git a/sw/source/ui/chrdlg/swuiccoll.cxx b/sw/source/ui/chrdlg/swuiccoll.cxx index 59c00d5622c1..66ba6f6d2f97 100644 --- a/sw/source/ui/chrdlg/swuiccoll.cxx +++ b/sw/source/ui/chrdlg/swuiccoll.cxx @@ -44,57 +44,46 @@ const sal_uInt16 SwCondCollPage::m_aPageRg[] = { 0 }; -// Warning! This table is indicated directly in code (0, 1, ...) -static long nTabs[] = - { - 0, 100 - }; - -SwCondCollPage::SwCondCollPage(vcl::Window *pParent, const SfxItemSet &rSet) - : SfxTabPage(pParent, "ConditionPage", - "modules/swriter/ui/conditionpage.ui", &rSet) - , - m_rSh(::GetActiveView()->GetWrtShell()), - m_pCmds( SwCondCollItem::GetCmds() ), - m_pFormat(nullptr), - - m_bNewTemplate(false) +SwCondCollPage::SwCondCollPage(TabPageParent pParent, const SfxItemSet &rSet) + : SfxTabPage(pParent, "modules/swriter/ui/conditionpage.ui", "ConditionPage", &rSet) + , m_rSh(::GetActiveView()->GetWrtShell()) + , m_pCmds(SwCondCollItem::GetCmds()) + , m_pFormat(nullptr) + , m_bNewTemplate(false) + , m_xConditionCB(m_xBuilder->weld_check_button("condstyle")) + , m_xContextFT(m_xBuilder->weld_label("contextft")) + , m_xUsedFT(m_xBuilder->weld_label("usedft")) + , m_xTbLinks(m_xBuilder->weld_tree_view("links")) + , m_xStyleFT(m_xBuilder->weld_label("styleft")) + , m_xStyleLB(m_xBuilder->weld_tree_view("styles")) + , m_xFilterLB(m_xBuilder->weld_combo_box("filter")) + , m_xRemovePB(m_xBuilder->weld_button("remove")) + , m_xAssignPB(m_xBuilder->weld_button("apply")) { - get(m_pConditionCB, "condstyle"); - get(m_pContextFT, "contextft"); - get(m_pUsedFT, "usedft"); - get(m_pStyleFT, "styleft"); - get(m_pTbLinks, "links"); - get(m_pStyleLB, "styles"); - m_pStyleLB->SetStyle(m_pStyleLB->GetStyle() | WB_SORT); - m_pStyleLB->SetDropDownLineCount(12); - m_pTbLinks->set_height_request(m_pStyleLB->GetOptimalSize().Height()); - get(m_pFilterLB, "filter"); - get(m_pRemovePB, "remove"); - get(m_pAssignPB, "apply"); - - const sal_Int32 nStrCount = m_pFilterLB->GetEntryCount(); + m_xStyleLB->make_sorted(); + const auto nHeightRequest = m_xStyleLB->get_height_rows(12); + m_xStyleLB->set_size_request(-1, nHeightRequest); + m_xTbLinks->set_size_request(-1, nHeightRequest); + std::vector aWidths; + aWidths.push_back(m_xTbLinks->get_approximate_digit_width() * 40); + m_xTbLinks->set_column_fixed_widths(aWidths); + + const sal_Int32 nStrCount = m_xFilterLB->get_count(); for (sal_Int32 i = 0; i < nStrCount; ++i) - m_aStrArr.push_back(m_pFilterLB->GetEntry(i)); - m_pFilterLB->Clear(); + m_aStrArr.push_back(m_xFilterLB->get_text(i)); + m_xFilterLB->clear(); SetExchangeSupport(); // Install handlers - m_pConditionCB->SetClickHdl( LINK(this, SwCondCollPage, OnOffHdl)); - m_pTbLinks->SetDoubleClickHdl( LINK(this, SwCondCollPage, AssignRemoveTreeListBoxHdl )); - m_pStyleLB->SetDoubleClickHdl( LINK(this, SwCondCollPage, AssignRemoveHdl )); - m_pRemovePB->SetClickHdl( LINK(this, SwCondCollPage, AssignRemoveClickHdl )); - m_pAssignPB->SetClickHdl( LINK(this, SwCondCollPage, AssignRemoveClickHdl )); - m_pTbLinks->SetSelectHdl( LINK(this, SwCondCollPage, SelectTreeListBoxHdl)); - m_pStyleLB->SetSelectHdl( LINK(this, SwCondCollPage, SelectListBoxHdl)); - m_pFilterLB->SetSelectHdl( LINK(this, SwCondCollPage, SelectListBoxHdl)); - - m_pTbLinks->SetStyle(m_pTbLinks->GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN); - m_pTbLinks->SetSelectionMode( SelectionMode::Single ); - m_pTbLinks->SetTabs( SAL_N_ELEMENTS(nTabs), nTabs ); - m_pTbLinks->Resize(); // OS: Hack for the right selection - m_pTbLinks->SetSpaceBetweenEntries( 0 ); + m_xConditionCB->connect_toggled(LINK(this, SwCondCollPage, OnOffHdl)); + m_xTbLinks->connect_row_activated(LINK(this, SwCondCollPage, AssignRemoveTreeListBoxHdl)); + m_xStyleLB->connect_row_activated(LINK(this, SwCondCollPage, AssignRemoveTreeListBoxHdl)); + m_xRemovePB->connect_clicked(LINK(this, SwCondCollPage, AssignRemoveClickHdl)); + m_xAssignPB->connect_clicked(LINK(this, SwCondCollPage, AssignRemoveClickHdl)); + m_xTbLinks->connect_changed(LINK(this, SwCondCollPage, SelectTreeListBoxHdl)); + m_xStyleLB->connect_changed(LINK(this, SwCondCollPage, SelectTreeListBoxHdl)); + m_xFilterLB->connect_changed(LINK(this, SwCondCollPage, SelectListBoxHdl)); std::unique_ptr xFamilies(SW_MOD()->CreateStyleFamilies()); size_t nCount = xFamilies->size(); @@ -105,18 +94,13 @@ SwCondCollPage::SwCondCollPage(vcl::Window *pParent, const SfxItemSet &rSet) { const SfxStyleFilter& rFilterList = rFamilyItem.GetFilterList(); for (size_t i = 0; i < rFilterList.size(); ++i) - { - m_pFilterLB->InsertEntry(rFilterList[i].aName); - m_pFilterLB->SetEntryData(i, reinterpret_cast(sal_uInt16(rFilterList[i].nFlags))); - } + m_xFilterLB->append(OUString::number(int(rFilterList[i].nFlags)), rFilterList[i].aName); break; } } - m_pFilterLB->SelectEntryPos(1); - - m_pTbLinks->Show(); - + m_xFilterLB->set_active(1); + m_xTbLinks->show(); } SwCondCollPage::~SwCondCollPage() @@ -124,21 +108,6 @@ SwCondCollPage::~SwCondCollPage() disposeOnce(); } -void SwCondCollPage::dispose() -{ - m_pConditionCB.clear(); - m_pContextFT.clear(); - m_pUsedFT.clear(); - m_pTbLinks.clear(); - m_pStyleFT.clear(); - m_pStyleLB.clear(); - m_pFilterLB.clear(); - m_pRemovePB.clear(); - m_pAssignPB.clear(); - - SfxTabPage::dispose(); -} - DeactivateRC SwCondCollPage::DeactivatePage(SfxItemSet * _pSet) { if( _pSet ) @@ -149,7 +118,7 @@ DeactivateRC SwCondCollPage::DeactivatePage(SfxItemSet * _pSet) VclPtr SwCondCollPage::Create(TabPageParent pParent, const SfxItemSet *rSet) { - return VclPtr::Create(pParent.pParent, *rSet); + return VclPtr::Create(pParent, *rSet); } bool SwCondCollPage::FillItemSet(SfxItemSet *rSet) @@ -157,7 +126,7 @@ bool SwCondCollPage::FillItemSet(SfxItemSet *rSet) SwCondCollItem aCondItem; for (size_t i = 0; i < m_aStrArr.size(); ++i) { - const OUString sEntry = m_pTbLinks->GetEntryText(i, 1); + const OUString sEntry = m_xTbLinks->get_text(i, 1); aCondItem.SetStyle( &sEntry, i); } rSet->Put(aCondItem); @@ -166,29 +135,29 @@ bool SwCondCollPage::FillItemSet(SfxItemSet *rSet) void SwCondCollPage::Reset(const SfxItemSet *) { - if(m_bNewTemplate) - m_pConditionCB->Enable(); - if(RES_CONDTXTFMTCOLL == m_pFormat->Which()) - m_pConditionCB->Check(); - OnOffHdl(m_pConditionCB); + if (m_bNewTemplate) + m_xConditionCB->set_sensitive(true); + if (RES_CONDTXTFMTCOLL == m_pFormat->Which()) + m_xConditionCB->set_active(true); + OnOffHdl(*m_xConditionCB); - m_pTbLinks->Clear(); + m_xTbLinks->clear(); SfxStyleSheetBasePool* pPool = m_rSh.GetView().GetDocShell()->GetStyleSheetPool(); pPool->SetSearchMask(SfxStyleFamily::Para); - m_pStyleLB->Clear(); + m_xStyleLB->clear(); const SfxStyleSheetBase* pBase = pPool->First(); - while( pBase ) + while (pBase) { - if(!m_pFormat || pBase->GetName() != m_pFormat->GetName()) - m_pStyleLB->InsertEntry(pBase->GetName()); + if (!m_pFormat || pBase->GetName() != m_pFormat->GetName()) + m_xStyleLB->append_text(pBase->GetName()); pBase = pPool->Next(); } - m_pStyleLB->SelectEntryPos(0); + m_xStyleLB->select(0); for (size_t n = 0; n < m_aStrArr.size(); ++n) { - OUString aEntry( m_aStrArr[n] + "\t" ); + m_xTbLinks->append_text(m_aStrArr[n]); const SwCollCondition* pCond = nullptr; if( m_pFormat && RES_CONDTXTFMTCOLL == m_pFormat->Which() && @@ -196,115 +165,106 @@ void SwCondCollPage::Reset(const SfxItemSet *) HasCondition( SwCollCondition( nullptr, m_pCmds[n].nCnd, m_pCmds[n].nSubCond ) ) ) && pCond->GetTextFormatColl() ) { - aEntry += pCond->GetTextFormatColl()->GetName(); + m_xTbLinks->set_text(n, pCond->GetTextFormatColl()->GetName(), 1); } - SvTreeListEntry* pE = m_pTbLinks->InsertEntryToColumn( aEntry, n ); - if(0 == n) - m_pTbLinks->Select(pE); + if (0 == n) + { + m_xTbLinks->select(0); + SelectTreeListBoxHdl(*m_xTbLinks); + } } - } -IMPL_LINK( SwCondCollPage, OnOffHdl, Button*, pBox, void ) +IMPL_LINK(SwCondCollPage, OnOffHdl, weld::ToggleButton&, rBox, void) { - const bool bEnable = static_cast(pBox)->IsChecked(); - m_pContextFT->Enable( bEnable ); - m_pUsedFT->Enable( bEnable ); - m_pTbLinks->EnableList( bEnable ); - m_pStyleFT->Enable( bEnable ); - m_pStyleLB->Enable( bEnable ); - m_pFilterLB->Enable( bEnable ); - m_pRemovePB->Enable( bEnable ); - m_pAssignPB->Enable( bEnable ); - if( bEnable ) + const bool bEnable = rBox.get_active(); + m_xContextFT->set_sensitive(bEnable); + m_xUsedFT->set_sensitive(bEnable); + m_xTbLinks->set_sensitive(bEnable); + m_xStyleFT->set_sensitive(bEnable); + m_xStyleLB->set_sensitive(bEnable); + m_xFilterLB->set_sensitive(bEnable); + m_xRemovePB->set_sensitive(bEnable); + m_xAssignPB->set_sensitive(bEnable); + if (bEnable) SelectHdl(nullptr); } -IMPL_LINK( SwCondCollPage, AssignRemoveClickHdl, Button*, pBtn, void) +IMPL_LINK(SwCondCollPage, AssignRemoveClickHdl, weld::Button&, rBtn, void) { - AssignRemove(pBtn); + AssignRemove(&rBtn); } -IMPL_LINK( SwCondCollPage, AssignRemoveTreeListBoxHdl, SvTreeListBox*, pBtn, bool) -{ - AssignRemove(pBtn); - return true; // signal more to be done -} -IMPL_LINK( SwCondCollPage, AssignRemoveHdl, ListBox&, rBox, void) + +IMPL_LINK(SwCondCollPage, AssignRemoveTreeListBoxHdl, weld::TreeView&, rBtn, void) { - AssignRemove(&rBox); + AssignRemove(&rBtn); } -void SwCondCollPage::AssignRemove(void const * pBtn) + +void SwCondCollPage::AssignRemove(const weld::Widget* pBtn) { - SvTreeListEntry* pE = m_pTbLinks->FirstSelected(); - if (!pE) - { - OSL_ENSURE(false, "where's the empty entry from?"); - return; - } - sal_uLong const nPos(m_pTbLinks->GetModel()->GetAbsPos(pE)); - if (LISTBOX_ENTRY_NOTFOUND == nPos) + int nPos = m_xTbLinks->get_selected_index(); + if (nPos == -1) { return; } - OUString sSel = m_aStrArr[nPos] + "\t"; - - const bool bAssEnabled = pBtn != m_pRemovePB && m_pAssignPB->IsEnabled(); - m_pAssignPB->Enable( !bAssEnabled ); - m_pRemovePB->Enable( bAssEnabled ); - if ( bAssEnabled ) - sSel += m_pStyleLB->GetSelectedEntry(); - - m_pTbLinks->SetUpdateMode(false); - m_pTbLinks->GetModel()->Remove(pE); - pE = m_pTbLinks->InsertEntryToColumn(sSel, nPos); - m_pTbLinks->Select(pE); - m_pTbLinks->MakeVisible(pE); - m_pTbLinks->SetUpdateMode(true); + const bool bAssEnabled = pBtn != m_xRemovePB.get() && m_xAssignPB->get_sensitive(); + m_xAssignPB->set_sensitive(!bAssEnabled); + m_xRemovePB->set_sensitive(bAssEnabled); + if (bAssEnabled) + m_xTbLinks->set_text(nPos, m_xStyleLB->get_selected_text(), 1); + else + m_xTbLinks->set_text(nPos, "", 1); } -IMPL_LINK( SwCondCollPage, SelectTreeListBoxHdl, SvTreeListBox*, pBox, void) +IMPL_LINK(SwCondCollPage, SelectTreeListBoxHdl, weld::TreeView&, rBox, void) { - SelectHdl(pBox); + SelectHdl(&rBox); } -IMPL_LINK( SwCondCollPage, SelectListBoxHdl, ListBox&, rBox, void) + +IMPL_LINK(SwCondCollPage, SelectListBoxHdl, weld::ComboBox&, rBox, void) { SelectHdl(&rBox); } -void SwCondCollPage::SelectHdl(void const * pBox) + +void SwCondCollPage::SelectHdl(const weld::Widget* pBox) { - if (pBox == m_pFilterLB) + if (pBox == m_xFilterLB.get()) { - m_pStyleLB->Clear(); - const sal_Int32 nSelPos = static_cast(pBox)->GetSelectedEntryPos(); - const SfxStyleSearchBits nSearchFlags = static_cast(reinterpret_cast(m_pFilterLB->GetEntryData(nSelPos))); + m_xStyleLB->clear(); + const sal_Int32 nSelPos = m_xFilterLB->get_active(); + const SfxStyleSearchBits nSearchFlags = static_cast(m_xFilterLB->get_id(nSelPos).toInt32()); SfxStyleSheetBasePool* pPool = m_rSh.GetView().GetDocShell()->GetStyleSheetPool(); pPool->SetSearchMask(SfxStyleFamily::Para, nSearchFlags); const SfxStyleSheetBase* pBase = pPool->First(); - while( pBase ) + bool bEmpty = true; + while (pBase) { - if(!m_pFormat || pBase->GetName() != m_pFormat->GetName()) - m_pStyleLB->InsertEntry(pBase->GetName()); + if (!m_pFormat || pBase->GetName() != m_pFormat->GetName()) + { + m_xStyleLB->append_text(pBase->GetName()); + bEmpty = false; + } pBase = pPool->Next(); } - m_pStyleLB->SelectEntryPos(0); - SelectHdl(m_pStyleLB); - + if (!bEmpty) + m_xStyleLB->select(bEmpty ? -1 : 0); + SelectHdl(m_xStyleLB.get()); } else { - SvTreeListEntry* pE = m_pTbLinks->FirstSelected(); - const OUString sTbEntry = pE - ? m_pTbLinks->GetEntryText(pE).getToken(1, '\t') + int nSelected = m_xTbLinks->get_selected_index(); + const OUString sTbEntry = nSelected != -1 + ? m_xTbLinks->get_text(nSelected, 1) : OUString(); - const OUString sStyle = m_pStyleLB->GetSelectedEntry(); + const OUString sStyle = m_xStyleLB->get_selected_text(); - m_pAssignPB->Enable( sStyle != sTbEntry && m_pConditionCB->IsChecked() ); + m_xAssignPB->set_sensitive(sStyle != sTbEntry && m_xConditionCB->get_active()); - if(pBox != m_pStyleLB) - m_pRemovePB->Enable( m_pConditionCB->IsChecked() && !sTbEntry.isEmpty() ); + if (pBox != m_xStyleLB.get()) + m_xRemovePB->set_sensitive(m_xConditionCB->get_active() && !sTbEntry.isEmpty()); } } diff --git a/sw/source/ui/config/mailconfigpage.cxx b/sw/source/ui/config/mailconfigpage.cxx index ae4c5bcf1491..caf1759c83bb 100644 --- a/sw/source/ui/config/mailconfigpage.cxx +++ b/sw/source/ui/config/mailconfigpage.cxx @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/sw/source/ui/dbui/addresslistdialog.hxx b/sw/source/ui/dbui/addresslistdialog.hxx index 5344092e69cb..9e94c7f55457 100644 --- a/sw/source/ui/dbui/addresslistdialog.hxx +++ b/sw/source/ui/dbui/addresslistdialog.hxx @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/sw/source/ui/dbui/mmaddressblockpage.hxx b/sw/source/ui/dbui/mmaddressblockpage.hxx index d671a9083a50..3033f7ef6518 100644 --- a/sw/source/ui/dbui/mmaddressblockpage.hxx +++ b/sw/source/ui/dbui/mmaddressblockpage.hxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sw/source/ui/inc/mmresultdialogs.hxx b/sw/source/ui/inc/mmresultdialogs.hxx index a26ee9fa8b6f..01709ead04f2 100644 --- a/sw/source/ui/inc/mmresultdialogs.hxx +++ b/sw/source/ui/inc/mmresultdialogs.hxx @@ -29,8 +29,8 @@ #include #include #include -#include -#include +#include +#include #include class SwMailMergeWizard; diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index cb54e8eee021..37eac609f416 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include diff --git a/sw/source/uibase/inc/glosbib.hxx b/sw/source/uibase/inc/glosbib.hxx index 216bae4d6c45..12b9ca217148 100644 --- a/sw/source/uibase/inc/glosbib.hxx +++ b/sw/source/uibase/inc/glosbib.hxx @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include diff --git a/sw/source/uibase/inc/swuiccoll.hxx b/sw/source/uibase/inc/swuiccoll.hxx index e355c321cd5f..f8e2449c2577 100644 --- a/sw/source/uibase/inc/swuiccoll.hxx +++ b/sw/source/uibase/inc/swuiccoll.hxx @@ -20,26 +20,13 @@ #define INCLUDED_SW_SOURCE_UIBASE_INC_SWUICCOLL_HXX #include -#include +#include class SwWrtShell; class SwFormat; class SwCondCollPage : public SfxTabPage { - VclPtr m_pConditionCB; - - VclPtr m_pContextFT; - VclPtr m_pUsedFT; - VclPtr m_pTbLinks; - - VclPtr m_pStyleFT; - VclPtr m_pStyleLB; - VclPtr m_pFilterLB; - - VclPtr m_pRemovePB; - VclPtr m_pAssignPB; - std::vector m_aStrArr; SwWrtShell &m_rSh; @@ -48,19 +35,27 @@ class SwCondCollPage : public SfxTabPage bool m_bNewTemplate; + std::unique_ptr m_xConditionCB; + std::unique_ptr m_xContextFT; + std::unique_ptr m_xUsedFT; + std::unique_ptr m_xTbLinks; + std::unique_ptr m_xStyleFT; + std::unique_ptr m_xStyleLB; + std::unique_ptr m_xFilterLB; + std::unique_ptr m_xRemovePB; + std::unique_ptr m_xAssignPB; + virtual ~SwCondCollPage() override; - virtual void dispose() override; virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override; - DECL_LINK( OnOffHdl, Button*, void ); - DECL_LINK( AssignRemoveHdl, ListBox&, void); - DECL_LINK( AssignRemoveTreeListBoxHdl, SvTreeListBox*, bool); - DECL_LINK( AssignRemoveClickHdl, Button*, void); - DECL_LINK( SelectTreeListBoxHdl, SvTreeListBox*, void ); - DECL_LINK( SelectListBoxHdl, ListBox&, void ); - void AssignRemove(void const *); - void SelectHdl(void const *); + DECL_LINK(OnOffHdl, weld::ToggleButton&, void); + DECL_LINK(AssignRemoveTreeListBoxHdl, weld::TreeView&, void); + DECL_LINK(AssignRemoveClickHdl, weld::Button&, void); + DECL_LINK(SelectTreeListBoxHdl, weld::TreeView&, void); + DECL_LINK(SelectListBoxHdl, weld::ComboBox&, void); + void AssignRemove(const weld::Widget*); + void SelectHdl(const weld::Widget*); using SfxTabPage::ActivatePage; using SfxTabPage::DeactivatePage; @@ -68,7 +63,7 @@ class SwCondCollPage : public SfxTabPage static const sal_uInt16 m_aPageRg[]; public: - SwCondCollPage(vcl::Window *pParent, const SfxItemSet &rSet); + SwCondCollPage(TabPageParent pParent, const SfxItemSet &rSet); static VclPtr Create(TabPageParent pParent, const SfxItemSet *rSet); static const sal_uInt16* GetRanges() { return m_aPageRg; } -- cgit