From c650658fe23eae895ca1e0383d5a8c591eb4dd09 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 29 Nov 2018 23:49:29 +0000 Subject: weld SwGlossaryGroupDlg MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I142123b474e0e35f6da375977e33d40e0ad39054 Reviewed-on: https://gerrit.libreoffice.org/64324 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- sw/source/ui/misc/glosbib.cxx | 301 +++++++++++++++---------------- sw/source/ui/misc/glossary.cxx | 6 +- sw/source/uibase/inc/glosbib.hxx | 79 +++----- sw/uiconfig/swriter/ui/editcategories.ui | 124 +++++++++---- 4 files changed, 261 insertions(+), 249 deletions(-) (limited to 'sw') diff --git a/sw/source/ui/misc/glosbib.cxx b/sw/source/ui/misc/glosbib.cxx index 3e8d9a3f7bde..82febac648ed 100644 --- a/sw/source/ui/misc/glosbib.cxx +++ b/sw/source/ui/misc/glosbib.cxx @@ -44,53 +44,55 @@ #define RENAME_TOKEN_DELIM u'\x0001' -SwGlossaryGroupDlg::SwGlossaryGroupDlg(vcl::Window * pParent, +SwGlossaryGroupDlg::SwGlossaryGroupDlg(weld::Window * pParent, std::vector const& rPathArr, SwGlossaryHdl *pHdl) - : SvxStandardDialog(pParent, "EditCategoriesDialog", - "modules/swriter/ui/editcategories.ui") + : SfxDialogController(pParent, "modules/swriter/ui/editcategories.ui", + "EditCategoriesDialog") + , m_pParent(pParent) , pGlosHdl(pHdl) + , m_xNameED(m_xBuilder->weld_entry("name")) + , m_xPathLB(m_xBuilder->weld_combo_box("pathlb")) + , m_xGroupTLB(m_xBuilder->weld_tree_view("group")) + , m_xNewPB(m_xBuilder->weld_button("new")) + , m_xDelPB(m_xBuilder->weld_button("delete")) + , m_xRenamePB(m_xBuilder->weld_button("rename")) { - get(m_pPathLB, "pathlb"); - get(m_pNewPB, "new"); - get(m_pDelPB, "delete"); - get(m_pRenamePB, "rename"); - get(m_pNameED, "name"); - get(m_pGroupTLB, "group"); - - const int nAppFontUnits = 130; - long nWidth = LogicToPixel(Size(nAppFontUnits, 0), MapMode(MapUnit::MapAppFont)).Width(); - m_pPathLB->set_width_request(nWidth); + int nWidth = m_xGroupTLB->get_approximate_digit_width() * 34; + m_xPathLB->set_size_request(nWidth, -1); //just has to be something small, real size will be available space - m_pGroupTLB->set_width_request(nWidth); - m_pGroupTLB->set_height_request(GetTextHeight() * 10); + m_xGroupTLB->set_size_request(nWidth, m_xGroupTLB->get_height_rows(10)); - long nTabs[] = { 0, nAppFontUnits }; + std::vector aWidths; + aWidths.push_back(nWidth); + m_xGroupTLB->set_column_fixed_widths(aWidths); + m_xGroupTLB->connect_changed(LINK(this, SwGlossaryGroupDlg, SelectHdl)); - m_pGroupTLB->SetTabs( SAL_N_ELEMENTS(nTabs), nTabs ); - m_pGroupTLB->SetSelectHdl(LINK(this, SwGlossaryGroupDlg, SelectHdl)); - m_pGroupTLB->GetModel()->SetSortMode(SortAscending); - m_pNewPB->SetClickHdl(LINK(this, SwGlossaryGroupDlg, NewHdl)); - m_pDelPB->SetClickHdl(LINK(this, SwGlossaryGroupDlg, DeleteHdl)); - m_pNameED->SetModifyHdl(LINK(this, SwGlossaryGroupDlg, ModifyHdl)); - m_pPathLB->SetSelectHdl(LINK(this, SwGlossaryGroupDlg, ModifyListBoxHdl)); - m_pRenamePB->SetClickHdl(LINK(this, SwGlossaryGroupDlg, RenameHdl)); + m_xNewPB->connect_clicked(LINK(this, SwGlossaryGroupDlg, NewHdl)); + m_xDelPB->connect_clicked(LINK(this, SwGlossaryGroupDlg, DeleteHdl)); + m_xNameED->connect_changed(LINK(this, SwGlossaryGroupDlg, ModifyHdl)); + m_xNameED->connect_insert_text(LINK(this, SwGlossaryGroupDlg, EditInsertTextHdl)); + m_xPathLB->connect_changed(LINK(this, SwGlossaryGroupDlg, ModifyListBoxHdl)); + m_xRenamePB->connect_clicked(LINK(this, SwGlossaryGroupDlg, RenameHdl)); + + m_xNameED->connect_size_allocate(LINK(this, SwGlossaryGroupDlg, EntrySizeAllocHdl)); + m_xPathLB->connect_size_allocate(LINK(this, SwGlossaryGroupDlg, EntrySizeAllocHdl)); for (size_t i = 0; i < rPathArr.size(); ++i) { INetURLObject aTempURL(rPathArr[i]); const OUString sPath = aTempURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset ); - m_pPathLB->InsertEntry(sPath); - sal_uLong nCaseReadonly = 0; + sal_uInt32 nCaseReadonly = 0; utl::TempFile aTempFile(&sPath); aTempFile.EnableKillingFile(); if(!aTempFile.IsValid()) nCaseReadonly |= PATH_READONLY; else if( SWUnoHelper::UCB_IsCaseSensitiveFileName( aTempFile.GetURL())) nCaseReadonly |= PATH_CASE_SENSITIVE; - m_pPathLB->SetEntryData(i, reinterpret_cast(nCaseReadonly)); + OUString sId(OUString::number(nCaseReadonly)); + m_xPathLB->append(sId, sPath); } - m_pPathLB->SelectEntryPos(0); - m_pPathLB->Enable(); + m_xPathLB->set_active(0); + m_xPathLB->set_sensitive(true); const size_t nCount = pHdl->GetGroupCnt(); /* tdf#111870 "My AutoText" comes from mytexts.bau but should be translated @@ -108,34 +110,38 @@ SwGlossaryGroupDlg::SwGlossaryGroupDlg(vcl::Window * pParent, pData->sGroupTitle = SwResId(STR_MY_AUTOTEXT); else pData->sGroupTitle = sTitle; - pData->sPath = m_pPathLB->GetEntry(sGroup.getToken(1, GLOS_DELIM).toInt32()); - SvTreeListEntry* pEntry = m_pGroupTLB->InsertEntry(pData->sGroupTitle + "\t" + pData->sPath); - pEntry->SetUserData(pData); + pData->sPath = m_xPathLB->get_text(sGroup.getToken(1, GLOS_DELIM).toInt32()); + OUString sId(OUString::number(reinterpret_cast(pData))); + m_xGroupTLB->append(sId, pData->sGroupTitle); + int nEntry = m_xGroupTLB->find_id(sId); + m_xGroupTLB->set_text(nEntry, pData->sPath, 1); } - m_pGroupTLB->GetModel()->Resort(); + m_xGroupTLB->make_sorted(); } SwGlossaryGroupDlg::~SwGlossaryGroupDlg() { - disposeOnce(); + int nCount = m_xGroupTLB->n_children(); + for (int i = 0; i < nCount; ++i) + { + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(i).toInt64()); + delete pUserData; + } } -void SwGlossaryGroupDlg::dispose() +short SwGlossaryGroupDlg::run() { - m_pNameED.clear(); - m_pPathLB.clear(); - m_pGroupTLB.clear(); - m_pNewPB.clear(); - m_pDelPB.clear(); - m_pRenamePB.clear(); - SvxStandardDialog::dispose(); + short nRet = SfxDialogController::run(); + if (nRet == RET_OK) + Apply(); + return nRet; } void SwGlossaryGroupDlg::Apply() { - if(m_pNewPB->IsEnabled()) - NewHdl(m_pNewPB); + if (m_xNewPB->get_sensitive()) + NewHdl(*m_xNewPB); OUString aActGroup = SwGlossaryDlg::GetCurrGroup(); @@ -145,10 +151,9 @@ void SwGlossaryGroupDlg::Apply() if( sDelGroup == aActGroup ) { //when the current group is deleted, the current group has to be relocated - if(m_pGroupTLB->GetEntryCount()) + if (m_xGroupTLB->n_children()) { - SvTreeListEntry* pFirst = m_pGroupTLB->First(); - GlosBibUserData* pUserData = static_cast(pFirst->GetUserData()); + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(0).toInt64()); pGlosHdl->SetCurGroup(pUserData->sGroupName); } } @@ -157,8 +162,7 @@ void SwGlossaryGroupDlg::Apply() + sTitle + SwResId(STR_QUERY_DELETE_GROUP2)); - vcl::Window* pWin = GetParent(); - std::unique_ptr xQueryBox(Application::CreateMessageDialog(pWin ? pWin->GetFrameWeld() : nullptr, + std::unique_ptr xQueryBox(Application::CreateMessageDialog(m_pParent, VclMessageType::Question, VclButtonsType::YesNo, sMsg)); xQueryBox->set_default_response(RET_NO); if (RET_YES == xQueryBox->run()) @@ -189,57 +193,72 @@ void SwGlossaryGroupDlg::Apply() } } -IMPL_LINK_NOARG( SwGlossaryGroupDlg, SelectHdl, SvTreeListBox*, void ) +IMPL_LINK_NOARG( SwGlossaryGroupDlg, SelectHdl, weld::TreeView&, void ) { - m_pNewPB->Enable(false); - SvTreeListEntry* pFirstEntry = m_pGroupTLB->FirstSelected(); - if(pFirstEntry) + m_xNewPB->set_sensitive(false); + int nFirstEntry = m_xGroupTLB->get_selected_index(); + if (nFirstEntry != -1) { - GlosBibUserData* pUserData = static_cast(pFirstEntry->GetUserData()); + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(nFirstEntry).toInt64()); OUString sEntry(pUserData->sGroupName); - OUString sName(m_pNameED->GetText()); + OUString sName(m_xNameED->get_text()); bool bExists = false; - sal_uLong nPos = m_pGroupTLB->GetEntryPos(sName, 0); - if( 0xffffffff > nPos) + int nPos = m_xGroupTLB->find_text(sName); + if (nPos != -1) { - SvTreeListEntry* pEntry = m_pGroupTLB->GetEntry(nPos); - GlosBibUserData* pFoundData = static_cast(pEntry->GetUserData()); + GlosBibUserData* pFoundData = reinterpret_cast(m_xGroupTLB->get_id(nPos).toInt64()); + fprintf(stderr, "comparing %s and %s\n", + OUStringToOString(pFoundData->sGroupName, RTL_TEXTENCODING_UTF8).getStr(), + OUStringToOString(sEntry, RTL_TEXTENCODING_UTF8).getStr()); bExists = pFoundData->sGroupName == sEntry; } - m_pRenamePB->Enable(!bExists && !sName.isEmpty()); - m_pDelPB->Enable(IsDeleteAllowed(sEntry)); + m_xRenamePB->set_sensitive(!bExists && !sName.isEmpty()); + fprintf(stderr, "one rename %d\n", !bExists && !sName.isEmpty()); + m_xDelPB->set_sensitive(IsDeleteAllowed(sEntry)); } } -IMPL_LINK_NOARG(SwGlossaryGroupDlg, NewHdl, Button*, void) +IMPL_LINK_NOARG(SwGlossaryGroupDlg, NewHdl, weld::Button&, void) { - OUString sGroup = m_pNameED->GetText() + OUString sGroup = m_xNameED->get_text() + OUStringLiteral1(GLOS_DELIM) - + OUString::number(m_pPathLB->GetSelectedEntryPos()); + + OUString::number(m_xPathLB->get_active()); OSL_ENSURE(!pGlosHdl->FindGroupName(sGroup), "group already available!"); m_InsertedArr.push_back(sGroup); - const OUString sTemp(m_pNameED->GetText() + "\t" + m_pPathLB->GetSelectedEntry()); - SvTreeListEntry* pEntry = m_pGroupTLB->InsertEntry(sTemp); GlosBibUserData* pData = new GlosBibUserData; - pData->sPath = m_pPathLB->GetSelectedEntry(); + pData->sPath = m_xPathLB->get_active_text(); pData->sGroupName = sGroup; - pData->sGroupTitle = m_pNameED->GetText(); - pEntry->SetUserData(pData); - m_pGroupTLB->Select(pEntry); - m_pGroupTLB->MakeVisible(pEntry); - m_pGroupTLB->GetModel()->Resort(); + pData->sGroupTitle = m_xNameED->get_text(); + OUString sId(OUString::number(reinterpret_cast(pData))); + m_xGroupTLB->append(sId, m_xNameED->get_text()); + int nEntry = m_xGroupTLB->find_id(sId); + m_xGroupTLB->set_text(nEntry, pData->sPath, 1); + m_xGroupTLB->select(nEntry); + SelectHdl(*m_xGroupTLB); + m_xGroupTLB->scroll_to_row(nEntry); } -IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton, void ) +IMPL_LINK_NOARG(SwGlossaryGroupDlg, EntrySizeAllocHdl, const Size&, void) { - SvTreeListEntry* pEntry = m_pGroupTLB->FirstSelected(); - if(!pEntry) + std::vector aWidths; + int x, y, width, height; + if (m_xPathLB->get_extents_relative_to(*m_xGroupTLB, x, y, width, height)) { - pButton->Enable(false); + aWidths.push_back(x); + m_xGroupTLB->set_column_fixed_widths(aWidths); + } +} + +IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, weld::Button&, rButton, void ) +{ + int nEntry = m_xGroupTLB->get_selected_index(); + if (nEntry == -1) + { + rButton.set_sensitive(false); return; } - GlosBibUserData* pUserData = static_cast(pEntry->GetUserData()); + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(nEntry).toInt64()); OUString const sEntry(pUserData->sGroupName); // if the name to be deleted is among the new ones - get rid of it bool bDelete = true; @@ -265,23 +284,24 @@ IMPL_LINK( SwGlossaryGroupDlg, DeleteHdl, Button*, pButton, void ) m_RemovedArr.emplace_back(pUserData->sGroupName + "\t" + pUserData->sGroupTitle); } delete pUserData; - m_pGroupTLB->GetModel()->Remove(pEntry); - if(!m_pGroupTLB->First()) - pButton->Enable(false); + m_xGroupTLB->remove(nEntry); + if (!m_xGroupTLB->n_children()) + rButton.set_sensitive(false); //the content must be deleted - otherwise the new handler would be called in Apply() - m_pNameED->SetText(aEmptyOUStr); + m_xNameED->set_text(aEmptyOUStr); + ModifyHdl(*m_xNameED); } -IMPL_LINK_NOARG(SwGlossaryGroupDlg, RenameHdl, Button*, void) +IMPL_LINK_NOARG(SwGlossaryGroupDlg, RenameHdl, weld::Button&, void) { - SvTreeListEntry* pEntry = m_pGroupTLB->FirstSelected(); - GlosBibUserData* pUserData = static_cast(pEntry->GetUserData()); + int nEntry = m_xGroupTLB->get_selected_index(); + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(nEntry).toInt64()); OUString sEntry(pUserData->sGroupName); - const OUString sNewTitle(m_pNameED->GetText()); + const OUString sNewTitle(m_xNameED->get_text()); OUString sNewName = sNewTitle + OUStringLiteral1(GLOS_DELIM) - + OUString::number(m_pPathLB->GetSelectedEntryPos()); + + OUString::number(m_xPathLB->get_active()); OSL_ENSURE(!pGlosHdl->FindGroupName(sNewName), "group already available!"); // if the name to be renamed is among the new ones - replace @@ -299,47 +319,49 @@ IMPL_LINK_NOARG(SwGlossaryGroupDlg, RenameHdl, Button*, void) + OUStringLiteral1(RENAME_TOKEN_DELIM) + sNewTitle; m_RenamedArr.push_back(sEntry); } - delete static_cast(pEntry->GetUserData()); - m_pGroupTLB->GetModel()->Remove(pEntry); - pEntry = m_pGroupTLB->InsertEntry(m_pNameED->GetText() + "\t" - + m_pPathLB->GetSelectedEntry()); + delete pUserData; + m_xGroupTLB->remove(nEntry); + GlosBibUserData* pData = new GlosBibUserData; - pData->sPath = m_pPathLB->GetSelectedEntry(); + pData->sPath = m_xPathLB->get_active_text(); pData->sGroupName = sNewName; pData->sGroupTitle = sNewTitle; - pEntry->SetUserData(pData); - m_pGroupTLB->Select(pEntry); - m_pGroupTLB->MakeVisible(pEntry); - m_pGroupTLB->GetModel()->Resort(); + + OUString sId(OUString::number(reinterpret_cast(pData))); + m_xGroupTLB->append(sId, m_xNameED->get_text()); + nEntry = m_xGroupTLB->find_id(sId); + m_xGroupTLB->set_text(nEntry, m_xPathLB->get_active_text(), 1); + m_xGroupTLB->select(nEntry); + SelectHdl(*m_xGroupTLB); + m_xGroupTLB->scroll_to_row(nEntry); } -IMPL_LINK_NOARG(SwGlossaryGroupDlg, ModifyListBoxHdl, ListBox&, void) +IMPL_LINK_NOARG(SwGlossaryGroupDlg, ModifyListBoxHdl, weld::ComboBox&, void) { - ModifyHdl(*m_pNameED); + ModifyHdl(*m_xNameED); } -IMPL_LINK_NOARG(SwGlossaryGroupDlg, ModifyHdl, Edit&, void) + +IMPL_LINK_NOARG(SwGlossaryGroupDlg, ModifyHdl, weld::Entry&, void) { - OUString sEntry(m_pNameED->GetText()); + OUString sEntry(m_xNameED->get_text()); bool bEnableNew = true; bool bEnableDel = false; - sal_uLong nCaseReadonly = - reinterpret_cast(m_pPathLB->GetSelectedEntryData()); + sal_uInt32 nCaseReadonly = m_xPathLB->get_active_id().toUInt32(); bool bDirReadonly = 0 != (nCaseReadonly&PATH_READONLY); - if(sEntry.isEmpty() || bDirReadonly) + if (sEntry.isEmpty() || bDirReadonly) bEnableNew = false; else if(!sEntry.isEmpty()) { - sal_uLong nPos = m_pGroupTLB->GetEntryPos(sEntry, 0); + int nPos = m_xGroupTLB->find_text(sEntry); //if it's not case sensitive you have to search for yourself - if( 0xffffffff == nPos) + if (nPos == -1) { const ::utl::TransliterationWrapper& rSCmp = GetAppCmpStrIgnore(); - for(sal_uLong i = 0; i < m_pGroupTLB->GetEntryCount(); i++) + for (int i = 0, nEntryCount = m_xGroupTLB->n_children(); i < nEntryCount; ++i) { - OUString sTemp = m_pGroupTLB->GetEntryText( i, 0 ); - nCaseReadonly = reinterpret_cast(m_pPathLB->GetEntryData( - m_pPathLB->GetEntryPos(m_pGroupTLB->GetEntryText(i,1)))); + OUString sTemp = m_xGroupTLB->get_text(i, 0); + nCaseReadonly = m_xPathLB->get_id(m_xPathLB->find_text(m_xGroupTLB->get_text(i,1))).toUInt32(); bool bCase = 0 != (nCaseReadonly & PATH_CASE_SENSITIVE); if( !bCase && rSCmp.isEqual( sTemp, sEntry )) @@ -349,23 +371,25 @@ IMPL_LINK_NOARG(SwGlossaryGroupDlg, ModifyHdl, Edit&, void) } } } - if( 0xffffffff > nPos) + if (nPos != -1) { bEnableNew = false; - m_pGroupTLB->Select(m_pGroupTLB->GetEntry( nPos )); - m_pGroupTLB->MakeVisible(m_pGroupTLB->GetEntry( nPos )); + m_xGroupTLB->select(nPos); + m_xGroupTLB->scroll_to_row(nPos); + SelectHdl(*m_xGroupTLB); } } - SvTreeListEntry* pEntry = m_pGroupTLB->FirstSelected(); - if(pEntry) + int nEntry = m_xGroupTLB->get_selected_index(); + if (nEntry != -1) { - GlosBibUserData* pUserData = static_cast(pEntry->GetUserData()); + GlosBibUserData* pUserData = reinterpret_cast(m_xGroupTLB->get_id(nEntry).toInt64()); bEnableDel = IsDeleteAllowed(pUserData->sGroupName); } - m_pDelPB->Enable(bEnableDel); - m_pNewPB->Enable(bEnableNew); - m_pRenamePB->Enable(bEnableNew && pEntry); + m_xDelPB->set_sensitive(bEnableDel); + m_xNewPB->set_sensitive(bEnableNew); + m_xRenamePB->set_sensitive(bEnableNew && nEntry != -1); + fprintf(stderr, "two rename %d\n", bEnableNew && nEntry != -1); } bool SwGlossaryGroupDlg::IsDeleteAllowed(const OUString &rGroup) @@ -383,47 +407,10 @@ bool SwGlossaryGroupDlg::IsDeleteAllowed(const OUString &rGroup) return bDel; } -void FEdit::KeyInput( const KeyEvent& rKEvent ) -{ - vcl::KeyCode aCode = rKEvent.GetKeyCode(); - if( KEYGROUP_CURSOR == aCode.GetGroup() || - ( KEYGROUP_MISC == aCode.GetGroup() && - KEY_DELETE >= aCode.GetCode() ) || - SVT_SEARCHPATH_DELIMITER != rKEvent.GetCharCode() ) - Edit::KeyInput( rKEvent ); -} - -VCL_BUILDER_FACTORY(FEdit) - -void SwGlossaryGroupTLB::RequestHelp( const HelpEvent& rHEvt ) +IMPL_STATIC_LINK(SwGlossaryGroupDlg, EditInsertTextHdl, OUString&, rText, bool) { - Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); - SvTreeListEntry* pEntry = GetEntry( aPos ); - if(pEntry) - { - SvLBoxTab* pTab; - SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); - if(pItem) - { - aPos = GetEntryPosition( pEntry ); - Size aSize(pItem->GetSize( this, pEntry )); - aPos.setX( GetTabPos( pEntry, pTab ) ); - - if((aPos.X() + aSize.Width()) > GetSizePixel().Width()) - aSize.setWidth( GetSizePixel().Width() - aPos.X() ); - aPos = OutputToScreenPixel(aPos); - tools::Rectangle aItemRect( aPos, aSize ); - GlosBibUserData* pData = static_cast(pEntry->GetUserData()); - const OUString sMsg = pData->sPath + "/" - + pData->sGroupName.getToken(0, GLOS_DELIM) - + SwGlossaries::GetExtension(); - - Help::ShowQuickHelp( this, aItemRect, sMsg, - QuickHelpFlags::Left|QuickHelpFlags::VCenter ); - } - } + rText = rText.replaceAll(OUStringLiteral1(SVT_SEARCHPATH_DELIMITER), ""); + return true; } -VCL_BUILDER_FACTORY(SwGlossaryGroupTLB) - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx index 3e5467407377..32cb5103562a 100644 --- a/sw/source/ui/misc/glossary.cxx +++ b/sw/source/ui/misc/glossary.cxx @@ -632,12 +632,12 @@ IMPL_LINK_NOARG(SwGlossaryDlg, BibHdl, Button*, void) if(bIsWritable) { - ScopedVclPtrInstance< SwGlossaryGroupDlg > pDlg( this, pGloss->GetPathArray(), pGlossaryHdl ); - if ( RET_OK == pDlg->Execute() ) + SwGlossaryGroupDlg aDlg(GetFrameWeld(), pGloss->GetPathArray(), pGlossaryHdl); + if (aDlg.run() == RET_OK) { Init(); //if new groups were created - select one of them - const OUString sNewGroup = pDlg->GetCreatedGroupName(); + const OUString sNewGroup = aDlg.GetCreatedGroupName(); SvTreeListEntry* pEntry = m_pCategoryBox->First(); while (!sNewGroup.isEmpty() && pEntry) { diff --git a/sw/source/uibase/inc/glosbib.hxx b/sw/source/uibase/inc/glosbib.hxx index 12b9ca217148..b5ba48a97711 100644 --- a/sw/source/uibase/inc/glosbib.hxx +++ b/sw/source/uibase/inc/glosbib.hxx @@ -20,31 +20,14 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_GLOSBIB_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_GLOSBIB_HXX -#include -#include - -#include -#include - -#include -#include +#include #include +#include #include class SwGlossaryHdl; -class FEdit : public Edit -{ -public: - FEdit(vcl::Window* pParent) - : Edit(pParent, WB_LEFT|WB_VCENTER|WB_BORDER|WB_3DLOOK) - { - } - - virtual void KeyInput( const KeyEvent& rKEvent ) override; -}; - struct GlosBibUserData { OUString sPath; @@ -52,51 +35,43 @@ struct GlosBibUserData OUString sGroupTitle; }; -class SwGlossaryGroupTLB : public SvTabListBox -{ -public: - SwGlossaryGroupTLB(vcl::Window* pParent) - : SvTabListBox(pParent, WB_BORDER|WB_HSCROLL|WB_CLIPCHILDREN|WB_SORT) - { - } - - virtual void RequestHelp( const HelpEvent& rHEvt ) override; -}; - -class SwGlossaryGroupDlg final : public SvxStandardDialog +class SwGlossaryGroupDlg final : public SfxDialogController { - VclPtr m_pNameED; - VclPtr m_pPathLB; - VclPtr m_pGroupTLB; - - VclPtr m_pNewPB; - VclPtr m_pDelPB; - VclPtr m_pRenamePB; - std::vector m_RemovedArr; std::vector m_InsertedArr; std::vector m_RenamedArr; - SwGlossaryHdl *pGlosHdl; + weld::Window* m_pParent; + SwGlossaryHdl* pGlosHdl; OUString sCreatedGroup; - bool IsDeleteAllowed(const OUString &rGroup); + std::unique_ptr m_xNameED; + std::unique_ptr m_xPathLB; + std::unique_ptr m_xGroupTLB; + + std::unique_ptr m_xNewPB; + std::unique_ptr m_xDelPB; + std::unique_ptr m_xRenamePB; + + bool IsDeleteAllowed(const OUString &rGroup); - virtual void Apply() override; - DECL_LINK( SelectHdl, SvTreeListBox*, void ); - DECL_LINK( NewHdl, Button *, void ); - DECL_LINK( DeleteHdl, Button*, void ); - DECL_LINK( ModifyHdl, Edit&, void ); - DECL_LINK( ModifyListBoxHdl, ListBox&, void ); - DECL_LINK( RenameHdl, Button *, void ); + void Apply(); + DECL_LINK(SelectHdl, weld::TreeView&, void); + DECL_LINK(NewHdl, weld::Button&, void); + DECL_LINK(DeleteHdl, weld::Button&, void); + DECL_LINK(ModifyHdl, weld::Entry&, void); + DECL_LINK(ModifyListBoxHdl, weld::ComboBox&, void); + DECL_LINK(RenameHdl, weld::Button&, void); + DECL_STATIC_LINK(SwGlossaryGroupDlg, EditInsertTextHdl, OUString&, bool); + DECL_LINK(EntrySizeAllocHdl, const Size&, void); public: - SwGlossaryGroupDlg(vcl::Window * pParent, - std::vector const& rPathArr, - SwGlossaryHdl *pGlosHdl); + SwGlossaryGroupDlg(weld::Window* pParent, + std::vector const& rPathArr, + SwGlossaryHdl *pGlosHdl); + virtual short run() override; virtual ~SwGlossaryGroupDlg() override; - virtual void dispose() override; const OUString& GetCreatedGroupName() const {return sCreatedGroup;} }; diff --git a/sw/uiconfig/swriter/ui/editcategories.ui b/sw/uiconfig/swriter/ui/editcategories.ui index 2bcfad0846b3..74dbdffbe07e 100644 --- a/sw/uiconfig/swriter/ui/editcategories.ui +++ b/sw/uiconfig/swriter/ui/editcategories.ui @@ -1,12 +1,28 @@ - + + + + + + + + + + + False 6 Edit Categories + True + 0 + 0 dialog + + + False @@ -17,12 +33,11 @@ False end - - gtk-ok + + gtk-new True + False True - True - True True True @@ -33,9 +48,10 @@ - - gtk-cancel + + gtk-delete True + False True True True @@ -47,12 +63,13 @@ - - gtk-help + + _Rename True + False True True - True + True False @@ -61,10 +78,12 @@ - - gtk-new + + gtk-ok True True + True + True True True @@ -75,8 +94,8 @@ - - gtk-delete + + gtk-cancel True True True @@ -89,17 +108,18 @@ - - _Rename + + gtk-help True True True - True + True False True 5 + True @@ -123,31 +143,69 @@ True False - 0 Selection list True group + 0 0 2 2 - 1 - + True - False + True True True - label + in + + + True + True + True + True + True + liststore1 + False + 0 + False + + + + + + True + 6 + + + + 0 + + + + + + + True + 6 + + + + 1 + + + + + + 0 3 2 - 1 @@ -159,44 +217,38 @@ 1 1 - 1 - 1 True False - 0 Path True pathlb + 0 1 0 - 1 - 1 True False - 0 Category True name + 0 0 0 - 1 - 1 - + True True 256 @@ -204,8 +256,6 @@ 0 1 - 1 - 1 @@ -218,12 +268,12 @@ + new + delete + rename ok cancel help - new - delete - rename -- cgit