[Libreoffice-commits] core.git: sw/source sw/uiconfig
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Mar 1 10:04:59 UTC 2019
sw/source/ui/dbui/addresslistdialog.cxx | 345 ++++++++++----------------
sw/source/ui/dbui/addresslistdialog.hxx | 54 ++--
sw/source/ui/dbui/mmaddressblockpage.cxx | 14 -
sw/uiconfig/swriter/ui/selectaddressdialog.ui | 109 ++++----
4 files changed, 236 insertions(+), 286 deletions(-)
New commits:
commit 3963bab7c1cd31b946646131cdc5576894675293
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 28 14:52:50 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 1 11:04:25 2019 +0100
weld SwCreateAddressListDialog
Change-Id: I3ae15af8a2c7475394dfc5f6e54b89950d2238c0
Reviewed-on: https://gerrit.libreoffice.org/68511
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/ui/dbui/addresslistdialog.cxx b/sw/source/ui/dbui/addresslistdialog.cxx
index 9d62691d751c..20633a13e692 100644
--- a/sw/source/ui/dbui/addresslistdialog.cxx
+++ b/sw/source/ui/dbui/addresslistdialog.cxx
@@ -71,9 +71,6 @@ using namespace ::com::sun::star::task;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::ui::dialogs;
-#define ITEMID_NAME 1
-#define ITEMID_TABLE 2
-
struct AddressUserData_Impl
{
uno::Reference<XDataSource> xSource;
@@ -125,90 +122,52 @@ static OUString lcl_getFlatURL( uno::Reference<beans::XPropertySet> const & xSou
return OUString();
}
-class SwAddrSourceLB : public SvSimpleTable
-{
-public:
- explicit SwAddrSourceLB(SvSimpleTableContainer& rParent)
- : SvSimpleTable(rParent, 0)
- {
- }
- virtual void Resize() override;
- void setColSizes();
-};
-
-void SwAddrSourceLB::Resize()
-{
- SvSimpleTable::Resize();
- setColSizes();
-}
-
-void SwAddrSourceLB::setColSizes()
+SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
+ : SfxDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/selectaddressdialog.ui", "SelectAddressDialog")
+ , m_bInSelectHdl(false)
+ , m_xAddressPage(pParent)
+ , m_xDescriptionFI(m_xBuilder->weld_label("desc"))
+ , m_xConnecting(m_xBuilder->weld_label("connecting"))
+ , m_xListLB(m_xBuilder->weld_tree_view("sources"))
+ , m_xLoadListPB(m_xBuilder->weld_button("add"))
+ , m_xCreateListPB(m_xBuilder->weld_button("create"))
+ , m_xFilterPB(m_xBuilder->weld_button("filter"))
+ , m_xEditPB(m_xBuilder->weld_button("edit"))
+ , m_xTablePB(m_xBuilder->weld_button("changetable"))
+ , m_xOK(m_xBuilder->weld_button("ok"))
+ , m_xIter(m_xListLB->make_iterator())
{
- HeaderBar &rHB = GetTheHeaderBar();
- if (rHB.GetItemCount() < 2)
- return;
+ m_sConnecting = m_xConnecting->get_label();
- long nWidth = rHB.GetSizePixel().Width();
+ const OUString sTemp(m_xDescriptionFI->get_label()
+ .replaceFirst("%1", m_xLoadListPB->get_label())
+ .replaceFirst("%2", m_xCreateListPB->get_label()));
+ m_xDescriptionFI->set_label(sTemp);
+ m_xFilterPB->connect_clicked( LINK( this, SwAddressListDialog, FilterHdl_Impl ));
+ m_xLoadListPB->connect_clicked( LINK( this, SwAddressListDialog, LoadHdl_Impl ));
+ m_xCreateListPB->connect_clicked( LINK( this, SwAddressListDialog,CreateHdl_Impl ));
+ m_xEditPB->connect_clicked(LINK( this, SwAddressListDialog, EditHdl_Impl));
+ m_xTablePB->connect_clicked(LINK( this, SwAddressListDialog, TableSelectHdl_Impl));
- long nTabs[] = { 0, nWidth/2 };
+ m_xListLB->set_size_request(m_xListLB->get_approximate_digit_width() * 52,
+ m_xListLB->get_height_rows(9));
- SvSimpleTable::SetTabs(SAL_N_ELEMENTS(nTabs), nTabs, MapUnit::MapPixel);
-}
-
-SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
- : SfxModalDialog(pParent, "SelectAddressDialog",
- "modules/swriter/ui/selectaddressdialog.ui")
+ std::vector<int> aWidths;
+ aWidths.push_back(m_xListLB->get_approximate_digit_width() * 26);
+ m_xListLB->set_column_fixed_widths(aWidths);
- ,
-
- m_pCreatedDataSource(nullptr),
- m_bInSelectHdl(false),
- m_pAddressPage(pParent)
-{
- get(m_pDescriptionFI, "desc");
- get(m_pLoadListPB, "add");
- get(m_pCreateListPB, "create");
- get(m_pFilterPB, "filter");
- get(m_pEditPB, "edit");
- get(m_pTablePB, "changetable");
- get(m_pOK, "ok");
-
- OUString sName = get<FixedText>("name")->GetText();
- OUString sTable = get<FixedText>("table")->GetText();
- m_sConnecting = get<FixedText>("connecting")->GetText();
-
- const OUString sTemp(m_pDescriptionFI->GetText()
- .replaceFirst("%1", m_pLoadListPB->GetText())
- .replaceFirst("%2", m_pCreateListPB->GetText()));
- m_pDescriptionFI->SetText(sTemp);
- m_pFilterPB->SetClickHdl( LINK( this, SwAddressListDialog, FilterHdl_Impl ));
- m_pLoadListPB->SetClickHdl( LINK( this, SwAddressListDialog, LoadHdl_Impl ));
- m_pCreateListPB->SetClickHdl( LINK( this, SwAddressListDialog,CreateHdl_Impl ));
- m_pEditPB->SetClickHdl(LINK( this, SwAddressListDialog, EditHdl_Impl));
- m_pTablePB->SetClickHdl(LINK( this, SwAddressListDialog, TableSelectHdl_Impl));
-
- SvSimpleTableContainer *pHeaderTreeContainer = get<SvSimpleTableContainer>("sources");
- Size aSize = pHeaderTreeContainer->LogicToPixel(Size(182 , 102), MapMode(MapUnit::MapAppFont));
- pHeaderTreeContainer->set_width_request(aSize.Width());
- pHeaderTreeContainer->set_height_request(aSize.Height());
- m_pListLB = VclPtr<SwAddrSourceLB>::Create(*pHeaderTreeContainer);
-
- m_pListLB->InsertHeaderEntry(sName + "\t" + sTable);
- m_pListLB->setColSizes();
-
- m_pListLB->SetStyle( m_pListLB->GetStyle() | WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP );
- m_pListLB->SetSelectionMode( SelectionMode::Single );
- m_pOK->SetClickHdl( LINK( this, SwAddressListDialog, OKHdl_Impl));
+ m_xListLB->make_sorted();
+ m_xOK->connect_clicked(LINK(this, SwAddressListDialog, OKHdl_Impl));
uno::Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
m_xDBContext = DatabaseContext::create(xContext);
- SwMailMergeConfigItem& rConfigItem = m_pAddressPage->GetWizard()->GetConfigItem();
+ SwMailMergeConfigItem& rConfigItem = m_xAddressPage->GetWizard()->GetConfigItem();
const SwDBData& rCurrentData = rConfigItem.GetCurrentDBData();
bool bEnableEdit = false;
bool bEnableOK = true;
- m_pListLB->SelectAll( false );
+ m_xListLB->unselect_all();
SwDBConfig aDb;
const OUString sBibliography = aDb.GetBibliographySource().sDataSource;
@@ -218,13 +177,15 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
{
if ( pNames[nName] == sBibliography )
continue;
- SvTreeListEntry* pEntry = m_pListLB->InsertEntry(pNames[nName]);
- AddressUserData_Impl* pUserData = new AddressUserData_Impl();
- pEntry->SetUserData(pUserData);
- if(pNames[nName] == rCurrentData.sDataSource)
+ m_xListLB->append(m_xIter.get());
+ m_xListLB->set_text(*m_xIter, pNames[nName], 0);
+ m_aUserData.emplace_back(new AddressUserData_Impl);
+ AddressUserData_Impl* pUserData = m_aUserData.back().get();
+ m_xListLB->set_id(*m_xIter, OUString::number(reinterpret_cast<sal_Int64>(pUserData)));
+ if (pNames[nName] == rCurrentData.sDataSource)
{
- m_pListLB->Select(pEntry);
- m_pListLB->SetEntryText(rCurrentData.sCommand, pEntry, ITEMID_TABLE - 1);
+ m_xListLB->select(*m_xIter);
+ m_xListLB->set_text(*m_xIter, rCurrentData.sCommand, 1);
pUserData->nCommandType = rCurrentData.nCommandType;
pUserData->xSource = rConfigItem.GetSource();
pUserData->xConnection = rConfigItem.GetConnection();
@@ -249,50 +210,28 @@ SwAddressListDialog::SwAddressListDialog(SwMailMergeAddressBlockPage* pParent)
}
}
- m_pOK->Enable(m_pListLB->GetEntryCount()>0 && bEnableOK);
- m_pEditPB->Enable(bEnableEdit);
- m_pListLB->SetSelectHdl(LINK(this, SwAddressListDialog, ListBoxSelectHdl_Impl));
- TableSelectHdl_Impl(nullptr);
+ m_xOK->set_sensitive(m_xListLB->n_children() > 0 && bEnableOK);
+ m_xEditPB->set_sensitive(bEnableEdit);
+ m_xListLB->connect_changed(LINK(this, SwAddressListDialog, ListBoxSelectHdl_Impl));
+ TableSelectHdl(nullptr);
}
SwAddressListDialog::~SwAddressListDialog()
{
- disposeOnce();
-}
-
-void SwAddressListDialog::dispose()
-{
- SvTreeListEntry* pEntry = m_pListLB->First();
- while(pEntry)
- {
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pEntry->GetUserData());
- delete pUserData;
- pEntry = m_pListLB->Next( pEntry );
- }
- m_pListLB.disposeAndClear();
- m_pAddressPage.clear();
- m_pDescriptionFI.clear();
- m_pLoadListPB.clear();
- m_pCreateListPB.clear();
- m_pFilterPB.clear();
- m_pEditPB.clear();
- m_pTablePB.clear();
- m_pOK.clear();
- SfxModalDialog::dispose();
}
-IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl, weld::Button&, void)
{
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
+ int nSelect = m_xListLB->get_selected_index();
uno::Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
- if(pSelect)
+ if (nSelect != -1)
{
- const OUString sCommand = SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sCommand = m_xListLB->get_text(nSelect, 1);
if (sCommand.isEmpty())
return;
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
- if(pUserData->xConnection.is() )
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
+ if (pUserData->xConnection.is() )
{
try
{
@@ -304,7 +243,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl, Button*, void)
xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY);
uno::Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY);
xRowProperties->setPropertyValue("DataSourceName",
- makeAny(SvTabListBox::GetEntryText(pSelect, ITEMID_NAME - 1)));
+ makeAny(m_xListLB->get_text(nSelect, 0)));
xRowProperties->setPropertyValue("Command", makeAny(sCommand));
xRowProperties->setPropertyValue("CommandType", makeAny(pUserData->nCommandType));
xRowProperties->setPropertyValue("ActiveConnection", makeAny(pUserData->xConnection.getTyped()));
@@ -321,7 +260,7 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl, Button*, void)
if ( RET_OK == xDialog->execute() )
{
- WaitObject aWO( nullptr );
+ weld::WaitObject aWait(m_xDialog.get());
pUserData->sFilter = xComposer->getFilter();
}
::comphelper::disposeComponent(xRowSet);
@@ -334,23 +273,27 @@ IMPL_LINK_NOARG(SwAddressListDialog, FilterHdl_Impl, Button*, void)
}
}
-IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, LoadHdl_Impl, weld::Button&, void)
{
- SwView* pView = m_pAddressPage->GetWizard()->GetSwView();
+ SwView* pView = m_xAddressPage->GetWizard()->GetSwView();
- const OUString sNewSource = SwDBManager::LoadAndRegisterDataSource(GetFrameWeld(), pView ? pView->GetDocShell() : nullptr);
+ const OUString sNewSource = SwDBManager::LoadAndRegisterDataSource(m_xDialog.get(), pView ? pView->GetDocShell() : nullptr);
if(!sNewSource.isEmpty())
{
- SvTreeListEntry* pNewSource = m_pListLB->InsertEntry(sNewSource);
- pNewSource->SetUserData(new AddressUserData_Impl());
- m_pListLB->Select(pNewSource);
+ m_xListLB->append(m_xIter.get());
+ m_xListLB->set_text(*m_xIter, sNewSource, 0);
+ m_aUserData.emplace_back(new AddressUserData_Impl);
+ AddressUserData_Impl* pUserData = m_aUserData.back().get();
+ m_xListLB->set_id(*m_xIter, OUString::number(reinterpret_cast<sal_Int64>(pUserData)));
+ m_xListLB->select(*m_xIter);
+ ListBoxSelectHdl_Impl(*m_xListLB);
}
}
-IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, weld::Button&, void)
{
OUString sInputURL;
- SwCreateAddressListDialog aDlg(GetFrameWeld(), sInputURL, m_pAddressPage->GetWizard()->GetConfigItem());
+ SwCreateAddressListDialog aDlg(m_xDialog.get(), sInputURL, m_xAddressPage->GetWizard()->GetConfigItem());
if (RET_OK == aDlg.run())
{
//register the URL a new datasource
@@ -407,13 +350,15 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, Button*, void)
uno::Reference<XNamingService> xNaming(m_xDBContext, UNO_QUERY);
xNaming->registerObject( sFind, xNewInstance );
//now insert the new source into the ListBox
- m_pCreatedDataSource = m_pListLB->InsertEntry(sFind + "\t" + aFilters[0]);
- AddressUserData_Impl* pUserData = new AddressUserData_Impl();
- pUserData->sURL = sURL;
- m_pCreatedDataSource->SetUserData(pUserData);
- m_pListLB->Select(m_pCreatedDataSource);
- m_pCreateListPB->Enable(false);
-
+ m_xListLB->append(m_xIter.get());
+ m_xListLB->set_text(*m_xIter, sFind, 0);
+ m_xListLB->set_text(*m_xIter, aFilters[0], 1);
+ m_aUserData.emplace_back(new AddressUserData_Impl);
+ AddressUserData_Impl* pUserData = m_aUserData.back().get();
+ m_xListLB->set_id(*m_xIter, OUString::number(reinterpret_cast<sal_Int64>(pUserData)));
+ m_xListLB->select(*m_xIter);
+ ListBoxSelectHdl_Impl(*m_xListLB);
+ m_xCreateListPB->set_sensitive(false);
}
catch (const Exception&)
{
@@ -421,15 +366,15 @@ IMPL_LINK_NOARG(SwAddressListDialog, CreateHdl_Impl, Button*, void)
}
}
-IMPL_LINK_NOARG(SwAddressListDialog, EditHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, EditHdl_Impl, weld::Button&, void)
{
- SvTreeListEntry* pEntry = m_pListLB->FirstSelected();
- AddressUserData_Impl* pUserData = pEntry ? static_cast<AddressUserData_Impl*>(pEntry->GetUserData()) : nullptr;
- if(pUserData && !pUserData->sURL.isEmpty())
+ int nEntry = m_xListLB->get_selected_index();
+ AddressUserData_Impl* pUserData = nEntry != -1 ? reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nEntry).toInt64()) : nullptr;
+ if (pUserData && !pUserData->sURL.isEmpty())
{
if(pUserData->xResultSet.is())
{
- SwMailMergeConfigItem& rConfigItem = m_pAddressPage->GetWizard()->GetConfigItem();
+ SwMailMergeConfigItem& rConfigItem = m_xAddressPage->GetWizard()->GetConfigItem();
if(rConfigItem.GetResultSet() != pUserData->xResultSet)
::comphelper::disposeComponent( pUserData->xResultSet );
pUserData->xResultSet = nullptr;
@@ -440,87 +385,71 @@ IMPL_LINK_NOARG(SwAddressListDialog, EditHdl_Impl, Button*, void)
pUserData->xColumnsSupplier.clear();
pUserData->xConnection.clear();
// will automatically close if it was the las reference
- SwCreateAddressListDialog aDlg(GetFrameWeld(), pUserData->sURL,
- m_pAddressPage->GetWizard()->GetConfigItem());
+ SwCreateAddressListDialog aDlg(m_xDialog.get(), pUserData->sURL,
+ m_xAddressPage->GetWizard()->GetConfigItem());
aDlg.run();
}
};
-IMPL_LINK_NOARG(SwAddressListDialog, ListBoxSelectHdl_Impl, SvTreeListBox*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, ListBoxSelectHdl_Impl, weld::TreeView&, void)
{
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
+ int nSelect = m_xListLB->get_selected_index();
Application::PostUserEvent( LINK( this, SwAddressListDialog,
- StaticListBoxSelectHdl_Impl ), pSelect, true );
+ StaticListBoxSelectHdl_Impl ), reinterpret_cast<void*>(nSelect) );
}
IMPL_LINK(SwAddressListDialog, StaticListBoxSelectHdl_Impl, void*, p, void)
{
- SvTreeListEntry* pSelect = static_cast<SvTreeListEntry*>(p);
+ int nSelect = reinterpret_cast<sal_IntPtr>(p);
//prevent nested calls of the select handler
- if(m_bInSelectHdl)
+ if (m_bInSelectHdl)
return;
- EnterWait();
+ weld::WaitObject aWait(m_xDialog.get());
m_bInSelectHdl = true;
AddressUserData_Impl* pUserData = nullptr;
- if(pSelect)
+ if (nSelect != -1)
{
- const OUString sTable(SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1));
- if(sTable.isEmpty())
+ const OUString sTable(m_xListLB->get_text(nSelect, 1));
+ if (sTable.isEmpty())
{
- m_pListLB->SetEntryText(m_sConnecting, pSelect, ITEMID_TABLE - 1);
- // allow painting of the new entry
- m_pListLB->Window::Invalidate(InvalidateFlags::Update);
- Application::Reschedule( true );
+ m_xListLB->set_text(nSelect, m_sConnecting, 1);
}
- pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
if(pUserData->nTableAndQueryCount > 1 || pUserData->nTableAndQueryCount == -1)
{
- /*
- * We're a callback from a selection from a list box, which takes
- * place on mouse down before mouse up. The next dialog also has a
- * list box. Spawning it means this list box doesn't get the mouse
- * down event. So it sticks on "making selection" mode. So if you
- * cancel the next dialog and just move the mouse out of this entry
- * and back then the dialog pops up again, without requiring a click
- *
- * Most expedient thing to do is to manually end the parent selection
- * here.
- */
- m_pListLB->EndSelection();
- DetectTablesAndQueries(pSelect, sTable.isEmpty());
+ DetectTablesAndQueries(nSelect, sTable.isEmpty());
}
else
{
//otherwise set the selected db-data
- m_aDBData.sDataSource = SvTabListBox::GetEntryText(pSelect, ITEMID_NAME - 1);
- m_aDBData.sCommand = SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1);
+ m_aDBData.sDataSource = m_xListLB->get_text(nSelect, 0);
+ m_aDBData.sCommand = m_xListLB->get_text(nSelect, 1);
m_aDBData.nCommandType = pUserData->nCommandType;
- m_pOK->Enable();
+ m_xOK->set_sensitive(true);
}
- if(SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1) == m_sConnecting)
- m_pListLB->SetEntryText(OUString(), pSelect, ITEMID_TABLE - 1);
+ if (m_xListLB->get_text(nSelect, 1) == m_sConnecting)
+ m_xListLB->set_text(nSelect, OUString(), 1);
}
- m_pEditPB->Enable(pUserData && !pUserData->sURL.isEmpty() &&
+ m_xEditPB->set_sensitive(pUserData && !pUserData->sURL.isEmpty() &&
SWUnoHelper::UCB_IsFile( pUserData->sURL ) && //#i97577#
!SWUnoHelper::UCB_IsReadOnlyFileName( pUserData->sURL ) );
m_bInSelectHdl = false;
- LeaveWait();
}
// detect the number of tables for a data source
// if only one is available then set it at the entry
void SwAddressListDialog::DetectTablesAndQueries(
- SvTreeListEntry* pSelect,
+ int nSelect,
bool bWidthDialog)
{
try
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
uno::Reference<XCompletedConnection> xComplConnection;
if(!pUserData->xConnection.is())
{
- m_aDBData.sDataSource = SvTabListBox::GetEntryText(pSelect, ITEMID_NAME - 1);
+ m_aDBData.sDataSource = m_xListLB->get_text(nSelect, 0);
m_xDBContext->getByName(m_aDBData.sDataSource) >>= xComplConnection;
pUserData->xSource.set(xComplConnection, UNO_QUERY);
@@ -551,8 +480,8 @@ void SwAddressListDialog::DetectTablesAndQueries(
if(nTables > 1 && bWidthDialog)
{
//now call the table select dialog - if more than one table exists
- SwSelectDBTableDialog aDlg(GetFrameWeld(), pUserData->xConnection);
- const OUString sTable = SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1);
+ SwSelectDBTableDialog aDlg(m_xDialog.get(), pUserData->xConnection);
+ const OUString sTable = m_xListLB->get_text(nSelect, 1);
if(!sTable.isEmpty())
aDlg.SetSelectedTable(sTable, pUserData->nCommandType == CommandType::TABLE);
if(RET_OK == aDlg.run())
@@ -589,53 +518,57 @@ void SwAddressListDialog::DetectTablesAndQueries(
SwDBSelect::TABLE : SwDBSelect::QUERY );
//#i97577#
if( pUserData->xColumnsSupplier.is() )
- m_pListLB->SetEntryText(m_aDBData.sCommand, pSelect, ITEMID_TABLE - 1);
+ m_xListLB->set_text(nSelect, m_aDBData.sCommand, 1);
else
- m_pListLB->SetEntryText(OUString(), pSelect, ITEMID_TABLE - 1);
+ m_xListLB->set_text(nSelect, OUString(), 1);
}
- const OUString sCommand = SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1);
- m_pOK->Enable(pSelect && !sCommand.isEmpty());
- m_pFilterPB->Enable( pUserData->xConnection.is() && !sCommand.isEmpty() );
- m_pTablePB->Enable( pUserData->nTableAndQueryCount > 1 );
+ const OUString sCommand = m_xListLB->get_text(nSelect, 1);
+ m_xOK->set_sensitive(!sCommand.isEmpty());
+ m_xFilterPB->set_sensitive( pUserData->xConnection.is() && !sCommand.isEmpty() );
+ m_xTablePB->set_sensitive( pUserData->nTableAndQueryCount > 1 );
}
catch (const Exception&)
{
OSL_FAIL("exception caught in SwAddressListDialog::DetectTablesAndQueries");
- m_pOK->Enable( false );
+ m_xOK->set_sensitive(false);
}
}
-IMPL_LINK(SwAddressListDialog, TableSelectHdl_Impl, Button*, pButton, void)
+IMPL_LINK(SwAddressListDialog, TableSelectHdl_Impl, weld::Button&, rButton, void)
+{
+ TableSelectHdl(&rButton);
+}
+
+void SwAddressListDialog::TableSelectHdl(weld::Button* pButton)
{
- EnterWait();
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
- if(pSelect)
+ weld::WaitObject aWait(m_xDialog.get());
+
+ int nSelect = m_xListLB->get_selected_index();
+ if (nSelect != -1)
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
//only call the table select dialog if tables have not been searched for or there
//are more than 1
- const OUString sTable = SvTabListBox::GetEntryText(pSelect, ITEMID_TABLE - 1);
+ const OUString sTable = m_xListLB->get_text(nSelect, 1);
if( pUserData->nTableAndQueryCount > 1 || pUserData->nTableAndQueryCount == -1)
{
- DetectTablesAndQueries(pSelect, (pButton != nullptr) || sTable.isEmpty());
+ DetectTablesAndQueries(nSelect, (pButton != nullptr) || sTable.isEmpty());
}
}
-
- LeaveWait();
}
-IMPL_LINK_NOARG(SwAddressListDialog, OKHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(SwAddressListDialog, OKHdl_Impl, weld::Button&, void)
{
- EndDialog(RET_OK);
+ m_xDialog->response(RET_OK);
}
uno::Reference< XDataSource> SwAddressListDialog::GetSource()
{
uno::Reference< XDataSource> xRet;
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
- if(pSelect)
+ int nSelect = m_xListLB->get_selected_index();
+ if (nSelect != -1)
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
xRet = pUserData->xSource;
}
return xRet;
@@ -645,10 +578,10 @@ uno::Reference< XDataSource> SwAddressListDialog::GetSource()
SharedConnection SwAddressListDialog::GetConnection()
{
SharedConnection xRet;
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
- if(pSelect)
+ int nSelect = m_xListLB->get_selected_index();
+ if (nSelect != -1)
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
xRet = pUserData->xConnection;
}
return xRet;
@@ -657,21 +590,21 @@ SharedConnection SwAddressListDialog::GetConnection()
uno::Reference< XColumnsSupplier> SwAddressListDialog::GetColumnsSupplier()
{
uno::Reference< XColumnsSupplier> xRet;
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
- if(pSelect)
+ int nSelect = m_xListLB->get_selected_index();
+ if (nSelect != -1)
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
xRet = pUserData->xColumnsSupplier;
}
return xRet;
}
-OUString SwAddressListDialog::GetFilter()
+OUString SwAddressListDialog::GetFilter()
{
- SvTreeListEntry* pSelect = m_pListLB->FirstSelected();
- if(pSelect)
+ int nSelect = m_xListLB->get_selected_index();
+ if (nSelect != -1)
{
- AddressUserData_Impl* pUserData = static_cast<AddressUserData_Impl*>(pSelect->GetUserData());
+ AddressUserData_Impl* pUserData = reinterpret_cast<AddressUserData_Impl*>(m_xListLB->get_id(nSelect).toInt64());
return pUserData->sFilter;
}
return OUString();
diff --git a/sw/source/ui/dbui/addresslistdialog.hxx b/sw/source/ui/dbui/addresslistdialog.hxx
index 9e94c7f55457..1f56408bcb45 100644
--- a/sw/source/ui/dbui/addresslistdialog.hxx
+++ b/sw/source/ui/dbui/addresslistdialog.hxx
@@ -41,50 +41,50 @@ namespace com{namespace sun{namespace star{
}
}}}
class SwMailMergeAddressBlockPage;
-class SwAddrSourceLB;
-class SwAddressListDialog : public SfxModalDialog
-{
- VclPtr<FixedText> m_pDescriptionFI;
-
- VclPtr<SwAddrSourceLB> m_pListLB;
-
- VclPtr<PushButton> m_pLoadListPB;
- VclPtr<PushButton> m_pCreateListPB;
- VclPtr<PushButton> m_pFilterPB;
- VclPtr<PushButton> m_pEditPB;
- VclPtr<PushButton> m_pTablePB;
-
- VclPtr<OKButton> m_pOK;
+struct AddressUserData_Impl;
+class SwAddressListDialog : public SfxDialogController
+{
OUString m_sConnecting;
- SvTreeListEntry* m_pCreatedDataSource;
-
bool m_bInSelectHdl;
- VclPtr<SwMailMergeAddressBlockPage> m_pAddressPage;
+ VclPtr<SwMailMergeAddressBlockPage> m_xAddressPage;
css::uno::Reference< css::sdb::XDatabaseContext> m_xDBContext;
SwDBData m_aDBData;
- void DetectTablesAndQueries(SvTreeListEntry* pSelect, bool bWidthDialog);
-
- DECL_LINK(FilterHdl_Impl, Button*, void);
- DECL_LINK(LoadHdl_Impl, Button*, void);
- DECL_LINK(CreateHdl_Impl, Button*, void);
- DECL_LINK(ListBoxSelectHdl_Impl, SvTreeListBox*, void);
- DECL_LINK(EditHdl_Impl, Button*, void);
- DECL_LINK(TableSelectHdl_Impl, Button*, void);
- DECL_LINK(OKHdl_Impl, Button*, void);
+ std::vector<std::unique_ptr<AddressUserData_Impl>> m_aUserData;
+
+ std::unique_ptr<weld::Label> m_xDescriptionFI;
+ std::unique_ptr<weld::Label> m_xConnecting;
+ std::unique_ptr<weld::TreeView> m_xListLB;
+ std::unique_ptr<weld::Button> m_xLoadListPB;
+ std::unique_ptr<weld::Button> m_xCreateListPB;
+ std::unique_ptr<weld::Button> m_xFilterPB;
+ std::unique_ptr<weld::Button> m_xEditPB;
+ std::unique_ptr<weld::Button> m_xTablePB;
+ std::unique_ptr<weld::Button> m_xOK;
+ std::unique_ptr<weld::TreeIter> m_xIter;
+
+ void DetectTablesAndQueries(int Select, bool bWidthDialog);
+
+ DECL_LINK(FilterHdl_Impl, weld::Button&, void);
+ DECL_LINK(LoadHdl_Impl, weld::Button&, void);
+ DECL_LINK(CreateHdl_Impl, weld::Button&, void);
+ DECL_LINK(ListBoxSelectHdl_Impl, weld::TreeView&, void);
+ DECL_LINK(EditHdl_Impl, weld::Button&, void);
+ DECL_LINK(TableSelectHdl_Impl, weld::Button&, void);
+ void TableSelectHdl(weld::Button* pButton);
+ DECL_LINK(OKHdl_Impl, weld::Button&, void);
DECL_LINK(StaticListBoxSelectHdl_Impl, void*, void);
public:
SwAddressListDialog(SwMailMergeAddressBlockPage* pParent);
virtual ~SwAddressListDialog() override;
- virtual void dispose() override;
css::uno::Reference< css::sdbc::XDataSource>
GetSource();
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx b/sw/source/ui/dbui/mmaddressblockpage.cxx
index 2e50668fef41..4ff0595800aa 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -168,16 +168,16 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, AddressListHdl_Impl, Button*, void)
{
try
{
- ScopedVclPtrInstance< SwAddressListDialog > xAddrDialog(this);
- if(RET_OK == xAddrDialog->Execute())
+ SwAddressListDialog aAddrDialog(this);
+ if (RET_OK == aAddrDialog.run())
{
SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
rConfigItem.SetCurrentConnection(
- xAddrDialog->GetSource(),
- xAddrDialog->GetConnection(),
- xAddrDialog->GetColumnsSupplier(),
- xAddrDialog->GetDBData());
- OUString sFilter = xAddrDialog->GetFilter();
+ aAddrDialog.GetSource(),
+ aAddrDialog.GetConnection(),
+ aAddrDialog.GetColumnsSupplier(),
+ aAddrDialog.GetDBData());
+ OUString sFilter = aAddrDialog.GetFilter();
rConfigItem.SetFilter( sFilter );
InsertDataHdl_Impl(nullptr);
GetWizard()->UpdateRoadmap();
diff --git a/sw/uiconfig/swriter/ui/selectaddressdialog.ui b/sw/uiconfig/swriter/ui/selectaddressdialog.ui
index a4c872614123..fee262987398 100644
--- a/sw/uiconfig/swriter/ui/selectaddressdialog.ui
+++ b/sw/uiconfig/swriter/ui/selectaddressdialog.ui
@@ -1,14 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name text2 -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="SelectAddressDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="selectaddressdialog|SelectAddressDialog">Select Address List</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>
@@ -82,10 +94,11 @@
<object class="GtkLabel" id="desc">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="selectaddressdialog|desc">Select an address list. Click '%1' to select recipients from a different list. If you do not have an address list you can create one by clicking '%2'.</property>
<property name="wrap">True</property>
+ <property name="width_chars">52</property>
<property name="max_width_chars">52</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -104,8 +117,8 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="selectaddressdialog|label2">Your recipients are currently selected from:</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -197,48 +210,63 @@
</packing>
</child>
<child>
- <object class="GtkGrid" id="grid3">
- <property name="visible">True</property>
+ <object class="GtkLabel" id="connecting">
<property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="label" translatable="yes" context="selectaddressdialog|connecting">Connecting to data source...</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="svtlo-SvSimpleTableContainer" id="sources:border">
+ <object class="GtkTreeView" id="sources">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="receives_default">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="model">liststore1</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
<child internal-child="selection">
- <object class="GtkTreeSelection" id="Simple Table Container-selection4"/>
+ <object class="GtkTreeSelection" id="Macro Library List-selection1"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="title" translatable="yes" context="selectaddressdialog|name">Name</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="title" translatable="yes" context="selectaddressdialog|table">Table</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer2"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="name">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="selectaddressdialog|name">Name</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="selectaddressdialog|table">Table</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
</child>
</object>
<packing>
@@ -246,17 +274,6 @@
<property name="top_attach">1</property>
</packing>
</child>
- <child>
- <object class="GtkLabel" id="connecting">
- <property name="can_focus">False</property>
- <property name="no_show_all">True</property>
- <property name="label" translatable="yes" context="selectaddressdialog|connecting">Connecting to data source...</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
</object>
<packing>
<property name="left_attach">0</property>
More information about the Libreoffice-commits
mailing list