[Libreoffice-commits] core.git: include/vcl sw/inc sw/source sw/uiconfig vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Thu Apr 26 12:00:37 UTC 2018
include/vcl/weld.hxx | 1
sw/inc/dbmgr.hxx | 7
sw/source/ui/envelp/label1.cxx | 261 ++++++++++++++-----------------
sw/source/ui/envelp/swuilabimp.hxx | 45 ++---
sw/source/uibase/dbui/dbmgr.cxx | 78 +++++++++
sw/uiconfig/swriter/ui/cardmediumpage.ui | 26 +--
vcl/source/app/salvtables.cxx | 5
vcl/unx/gtk3/gtk3gtkinst.cxx | 8
8 files changed, 254 insertions(+), 177 deletions(-)
New commits:
commit eede8af74173293504749cfbdd0ca528b4aa7b75
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 23 16:55:02 2018 +0100
weld SwLabPage
Change-Id: I98abbf67470fdd7be43680b02261f207a101d31c
Reviewed-on: https://gerrit.libreoffice.org/53485
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 93c5b55ed644..d21c6aa96a9b 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -634,6 +634,7 @@ public:
virtual OUString get_text() const = 0;
virtual void select_region(int nStartPos, int nEndPos) = 0;
virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 0;
+ virtual void replace_selection(const OUString& rText) = 0;
virtual void set_editable(bool bEditable) = 0;
int get_height_rows(int nRows) const
{
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 863af57b4562..4af6308b6003 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -69,6 +69,7 @@ struct SwDBFormatData
};
namespace weld {
+ class ComboBoxText;
class Window;
}
@@ -313,13 +314,19 @@ public:
/// Fill listbox with all table names of a database.
bool GetTableNames(ListBox* pListBox, const OUString& rDBName );
+ bool GetTableNames(weld::ComboBoxText& rBox, const OUString& rDBName);
/// Fill listbox with all column names of a database table.
void GetColumnNames(ListBox* pListBox,
const OUString& rDBName, const OUString& rTableName);
+ void GetColumnNames(weld::ComboBoxText& rBox,
+ const OUString& rDBName, const OUString& rTableName);
static void GetColumnNames(ListBox* pListBox,
css::uno::Reference< css::sdbc::XConnection> const & xConnection,
const OUString& rTableName);
+ static void GetColumnNames(weld::ComboBoxText& rBox,
+ css::uno::Reference< css::sdbc::XConnection> const & xConnection,
+ const OUString& rTableName);
static sal_uLong GetColumnFormat( css::uno::Reference< css::sdbc::XDataSource> const & xSource,
css::uno::Reference< css::sdbc::XConnection> const & xConnection,
diff --git a/sw/source/ui/envelp/label1.cxx b/sw/source/ui/envelp/label1.cxx
index e3537834932f..82bc293a2aeb 100644
--- a/sw/source/ui/envelp/label1.cxx
+++ b/sw/source/ui/envelp/label1.cxx
@@ -225,148 +225,129 @@ Printer *SwLabDlg::GetPrt()
return nullptr;
}
-SwLabPage::SwLabPage(vcl::Window* pParent, const SfxItemSet& rSet)
- : SfxTabPage(pParent, "CardMediumPage",
- "modules/swriter/ui/cardmediumpage.ui", &rSet)
+SwLabPage::SwLabPage(TabPageParent pParent, const SfxItemSet& rSet)
+ : SfxTabPage(pParent, "modules/swriter/ui/cardmediumpage.ui", "CardMediumPage", &rSet)
, pDBManager(nullptr)
, aItem(static_cast<const SwLabItem&>(rSet.Get(FN_LABEL)))
-{
- WaitObject aWait( pParent );
-
- get(m_pAddressFrame, "addressframe");
- get(m_pAddrBox, "address");
- get(m_pWritingEdit, "textview");
- m_pWritingEdit->set_height_request(m_pWritingEdit->GetTextHeight() * 10);
- m_pWritingEdit->set_width_request(m_pWritingEdit->approximate_char_width() * 25);
- get(m_pDatabaseLB, "database");
- get(m_pTableLB, "table");
- get(m_pInsertBT, "insert");
- get(m_pDBFieldLB, "field");
- get(m_pContButton, "continuous");
- get(m_pSheetButton, "sheet");
- get(m_pMakeBox, "brand");
- get(m_pTypeBox, "type");
- get(m_pFormatInfo, "formatinfo");
- get(m_pHiddenSortTypeBox, "hiddentype");
- m_pHiddenSortTypeBox->SetStyle(m_pHiddenSortTypeBox->GetStyle() | WB_SORT);
-
- long nListBoxWidth = approximate_char_width() * 30;
- m_pTableLB->set_width_request(nListBoxWidth);
- m_pDatabaseLB->set_width_request(nListBoxWidth);
- m_pDBFieldLB->set_width_request(nListBoxWidth);
+ , m_xAddressFrame(m_xBuilder->weld_widget("addressframe"))
+ , m_xAddrBox(m_xBuilder->weld_check_button("address"))
+ , m_xWritingEdit(m_xBuilder->weld_text_view("textview"))
+ , m_xDatabaseLB(m_xBuilder->weld_combo_box_text("database"))
+ , m_xTableLB(m_xBuilder->weld_combo_box_text("table"))
+ , m_xInsertBT(m_xBuilder->weld_button("insert"))
+ , m_xDBFieldLB(m_xBuilder->weld_combo_box_text("field"))
+ , m_xContButton(m_xBuilder->weld_radio_button("continuous"))
+ , m_xSheetButton(m_xBuilder->weld_radio_button("sheet"))
+ , m_xMakeBox(m_xBuilder->weld_combo_box_text("brand"))
+ , m_xTypeBox(m_xBuilder->weld_combo_box_text("type"))
+ , m_xHiddenSortTypeBox(m_xBuilder->weld_combo_box_text("hiddentype"))
+ , m_xFormatInfo(m_xBuilder->weld_label("formatinfo"))
+{
+ WaitObject aWait(pParent.pParent);
+
+ m_xWritingEdit->set_size_request(m_xWritingEdit->get_approximate_digit_width() * 30,
+ m_xWritingEdit->get_height_rows(10));
+ m_xHiddenSortTypeBox->make_sorted();
+
+ long nListBoxWidth = m_xWritingEdit->get_approximate_digit_width() * 25;
+ m_xTableLB->set_size_request(nListBoxWidth, -1);
+ m_xDatabaseLB->set_size_request(nListBoxWidth, -1);
+ m_xDBFieldLB->set_size_request(nListBoxWidth, -1);
SetExchangeSupport();
// Install handlers
- m_pAddrBox->SetClickHdl (LINK(this, SwLabPage, AddrHdl ));
- m_pDatabaseLB->SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl ));
- m_pTableLB->SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl ));
- m_pDBFieldLB->SetSelectHdl(LINK(this, SwLabPage, DatabaseHdl ));
- m_pInsertBT->SetClickHdl (LINK(this, SwLabPage, FieldHdl ));
+ m_xAddrBox->connect_toggled(LINK(this, SwLabPage, AddrHdl));
+ m_xDatabaseLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xTableLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xDBFieldLB->connect_changed(LINK(this, SwLabPage, DatabaseHdl));
+ m_xInsertBT->connect_clicked(LINK(this, SwLabPage, FieldHdl));
// Disable insert button first,
- // it'll be enabled if m_pDatabaseLB, m_pTableLB and m_pInsertBT are filled
- m_pInsertBT->Disable();
- m_pContButton->SetClickHdl (LINK(this, SwLabPage, PageHdl ));
- m_pSheetButton->SetClickHdl (LINK(this, SwLabPage, PageHdl ));
- m_pMakeBox->SetSelectHdl(LINK(this, SwLabPage, MakeHdl ));
- m_pTypeBox->SetSelectHdl(LINK(this, SwLabPage, TypeHdl ));
+ // it'll be enabled if m_xDatabaseLB, m_pTableLB and m_pInsertBT are filled
+ m_xInsertBT->set_sensitive(false);
+ m_xContButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
+ m_xSheetButton->connect_toggled(LINK(this, SwLabPage, PageHdl));
+ m_xMakeBox->connect_changed(LINK(this, SwLabPage, MakeHdl));
+ m_xTypeBox->connect_changed(LINK(this, SwLabPage, TypeHdl));
InitDatabaseBox();
}
SwLabPage::~SwLabPage()
{
- disposeOnce();
-}
-
-void SwLabPage::dispose()
-{
- m_pAddressFrame.clear();
- m_pAddrBox.clear();
- m_pWritingEdit.clear();
- m_pDatabaseLB.clear();
- m_pTableLB.clear();
- m_pInsertBT.clear();
- m_pDBFieldLB.clear();
- m_pContButton.clear();
- m_pSheetButton.clear();
- m_pMakeBox.clear();
- m_pTypeBox.clear();
- m_pHiddenSortTypeBox.clear();
- m_pFormatInfo.clear();
- SfxTabPage::dispose();
}
void SwLabPage::SetToBusinessCard()
{
- SetHelpId(HID_BUSINESS_FMT_PAGE);
- m_pContButton->SetHelpId(HID_BUSINESS_FMT_PAGE_CONT);
- m_pSheetButton->SetHelpId(HID_BUSINESS_FMT_PAGE_SHEET);
- m_pMakeBox->SetHelpId(HID_BUSINESS_FMT_PAGE_BRAND);
- m_pTypeBox->SetHelpId(HID_BUSINESS_FMT_PAGE_TYPE);
- m_pAddressFrame->Hide();
+ m_xContainer->set_help_id(HID_BUSINESS_FMT_PAGE);
+ m_xContButton->set_help_id(HID_BUSINESS_FMT_PAGE_CONT);
+ m_xSheetButton->set_help_id(HID_BUSINESS_FMT_PAGE_SHEET);
+ m_xMakeBox->set_help_id(HID_BUSINESS_FMT_PAGE_BRAND);
+ m_xTypeBox->set_help_id(HID_BUSINESS_FMT_PAGE_TYPE);
+ m_xAddressFrame->hide();
};
-IMPL_LINK_NOARG(SwLabPage, AddrHdl, Button*, void)
+IMPL_LINK_NOARG(SwLabPage, AddrHdl, weld::ToggleButton&, void)
{
OUString aWriting;
- if ( m_pAddrBox->IsChecked() )
+ if (m_xAddrBox->get_active())
aWriting = convertLineEnd(MakeSender(), GetSystemLineEnd());
- m_pWritingEdit->SetText( aWriting );
- m_pWritingEdit->GrabFocus();
+ m_xWritingEdit->set_text(aWriting);
+ m_xWritingEdit->grab_focus();
}
-IMPL_LINK( SwLabPage, DatabaseHdl, ListBox&, rListBox, void )
+IMPL_LINK( SwLabPage, DatabaseHdl, weld::ComboBoxText&, rListBox, void )
{
- sActDBName = m_pDatabaseLB->GetSelectedEntry();
+ sActDBName = m_xDatabaseLB->get_active_text();
WaitObject aObj( GetParentSwLabDlg() );
- if (&rListBox == m_pDatabaseLB)
- GetDBManager()->GetTableNames(m_pTableLB, sActDBName);
+ if (&rListBox == m_xDatabaseLB.get())
+ GetDBManager()->GetTableNames(*m_xTableLB, sActDBName);
- if (&rListBox == m_pDatabaseLB || &rListBox == m_pTableLB)
- GetDBManager()->GetColumnNames(m_pDBFieldLB, sActDBName, m_pTableLB->GetSelectedEntry());
+ if (&rListBox == m_xDatabaseLB.get() || &rListBox == m_xTableLB.get())
+ GetDBManager()->GetColumnNames(*m_xDBFieldLB, sActDBName, m_xTableLB->get_active_text());
- if (!m_pDatabaseLB->GetSelectedEntry().isEmpty() && !m_pTableLB->GetSelectedEntry().isEmpty()
- && !m_pDBFieldLB->GetSelectedEntry().isEmpty())
- m_pInsertBT->Enable(true);
+ if (!m_xDatabaseLB->get_active_text().isEmpty() && !m_xTableLB->get_active_text().isEmpty()
+ && !m_xDBFieldLB->get_active_text().isEmpty())
+ m_xInsertBT->set_sensitive(true);
else
- m_pInsertBT->Enable(false);
+ m_xInsertBT->set_sensitive(false);
}
-IMPL_LINK_NOARG(SwLabPage, FieldHdl, Button*, void)
+IMPL_LINK_NOARG(SwLabPage, FieldHdl, weld::Button&, void)
{
- OUString aStr("<" + m_pDatabaseLB->GetSelectedEntry() + "." +
- m_pTableLB->GetSelectedEntry() + "." +
- (m_pTableLB->GetSelectedEntryData() == nullptr ? OUString("0") : OUString("1")) + "." +
- m_pDBFieldLB->GetSelectedEntry() + ">");
- m_pWritingEdit->ReplaceSelected(aStr);
- Selection aSel = m_pWritingEdit->GetSelection();
- m_pWritingEdit->GrabFocus();
- m_pWritingEdit->SetSelection(aSel);
+ OUString aStr("<" + m_xDatabaseLB->get_active_text() + "." +
+ m_xTableLB->get_active_text() + "." +
+ m_xTableLB->get_active_id() + "." +
+ m_xDBFieldLB->get_active_text() + ">");
+ m_xWritingEdit->replace_selection(aStr);
+ int nStartPos, nEndPos;
+ m_xWritingEdit->get_selection_bounds(nStartPos, nEndPos);
+ m_xWritingEdit->grab_focus();
+ m_xWritingEdit->select_region(nStartPos, nEndPos);
}
-IMPL_LINK_NOARG(SwLabPage, PageHdl, Button*, void)
+IMPL_LINK_NOARG(SwLabPage, PageHdl, weld::ToggleButton&, void)
{
- m_pMakeBox->GetSelectHdl().Call(*m_pMakeBox);
+ MakeHdl(*m_xMakeBox);
}
-IMPL_LINK_NOARG(SwLabPage, MakeHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwLabPage, MakeHdl, weld::ComboBoxText&, void)
{
WaitObject aWait( GetParentSwLabDlg() );
- m_pTypeBox->Clear();
- m_pHiddenSortTypeBox->Clear();
+ m_xTypeBox->clear();
+ m_xHiddenSortTypeBox->clear();
GetParentSwLabDlg()->TypeIds().clear();
- const OUString aMake = m_pMakeBox->GetSelectedEntry();
+ const OUString aMake = m_xMakeBox->get_active_text();
GetParentSwLabDlg()->ReplaceGroup( aMake );
aItem.m_aLstMake = aMake;
- const bool bCont = m_pContButton->IsChecked();
+ const bool bCont = m_xContButton->get_active();
const size_t nCount = GetParentSwLabDlg()->Recs().size();
size_t nLstType = 0;
@@ -379,14 +360,14 @@ IMPL_LINK_NOARG(SwLabPage, MakeHdl, ListBox&, void)
if (GetParentSwLabDlg()->Recs()[i]->m_aType == sCustom)
{
bInsert = true;
- m_pTypeBox->InsertEntry(aType );
+ m_xTypeBox->append_text(aType );
}
else if (GetParentSwLabDlg()->Recs()[i]->m_bCont == bCont)
{
- if ( m_pHiddenSortTypeBox->GetEntryPos(aType) == LISTBOX_ENTRY_NOTFOUND )
+ if (m_xHiddenSortTypeBox->find_text(aType) == -1)
{
bInsert = true;
- m_pHiddenSortTypeBox->InsertEntry( aType );
+ m_xHiddenSortTypeBox->append_text( aType );
}
}
if(bInsert)
@@ -396,21 +377,21 @@ IMPL_LINK_NOARG(SwLabPage, MakeHdl, ListBox&, void)
nLstType = GetParentSwLabDlg()->TypeIds().size();
}
}
- for(sal_Int32 nEntry = 0; nEntry < m_pHiddenSortTypeBox->GetEntryCount(); ++nEntry)
+ for (int nEntry = 0; nEntry < m_xHiddenSortTypeBox->get_count(); ++nEntry)
{
- m_pTypeBox->InsertEntry(m_pHiddenSortTypeBox->GetEntry(nEntry));
+ m_xTypeBox->append_text(m_xHiddenSortTypeBox->get_text(nEntry));
}
if (nLstType)
- m_pTypeBox->SelectEntry(aItem.m_aLstType);
+ m_xTypeBox->set_active(aItem.m_aLstType);
else
- m_pTypeBox->SelectEntryPos(0);
- m_pTypeBox->GetSelectHdl().Call(*m_pTypeBox);
+ m_xTypeBox->set_active(0);
+ TypeHdl(*m_xTypeBox);
}
-IMPL_LINK_NOARG(SwLabPage, TypeHdl, ListBox&, void)
+IMPL_LINK_NOARG(SwLabPage, TypeHdl, weld::ComboBoxText&, void)
{
DisplayFormat();
- aItem.m_aType = m_pTypeBox->GetSelectedEntry();
+ aItem.m_aType = m_xTypeBox->get_active_text();
}
void SwLabPage::DisplayFormat()
@@ -435,41 +416,41 @@ void SwLabPage::DisplayFormat()
" x " + aField->GetText() +
" (" + OUString::number( pRec->m_nCols ) +
" x " + OUString::number( pRec->m_nRows ) + ")";
- m_pFormatInfo->SetText(aText);
+ m_xFormatInfo->set_label(aText);
}
SwLabRec* SwLabPage::GetSelectedEntryPos()
{
- OUString sSelEntry(m_pTypeBox->GetSelectedEntry());
+ OUString sSelEntry(m_xTypeBox->get_active_text());
- return GetParentSwLabDlg()->GetRecord(sSelEntry, m_pContButton->IsChecked());
+ return GetParentSwLabDlg()->GetRecord(sSelEntry, m_xContButton->get_active());
}
void SwLabPage::InitDatabaseBox()
{
if( GetDBManager() )
{
- m_pDatabaseLB->Clear();
+ m_xDatabaseLB->clear();
css::uno::Sequence<OUString> aDataNames = SwDBManager::GetExistingDatabaseNames();
const OUString* pDataNames = aDataNames.getConstArray();
for (long i = 0; i < aDataNames.getLength(); i++)
- m_pDatabaseLB->InsertEntry(pDataNames[i]);
+ m_xDatabaseLB->append_text(pDataNames[i]);
OUString sDBName = sActDBName.getToken( 0, DB_DELIM );
OUString sTableName = sActDBName.getToken( 1, DB_DELIM );
- m_pDatabaseLB->SelectEntry(sDBName);
- if( !sDBName.isEmpty() && GetDBManager()->GetTableNames(m_pTableLB, sDBName))
+ m_xDatabaseLB->set_active(sDBName);
+ if( !sDBName.isEmpty() && GetDBManager()->GetTableNames(*m_xTableLB, sDBName))
{
- m_pTableLB->SelectEntry(sTableName);
- GetDBManager()->GetColumnNames(m_pDBFieldLB, sActDBName, sTableName);
+ m_xTableLB->set_active(sTableName);
+ GetDBManager()->GetColumnNames(*m_xDBFieldLB, sActDBName, sTableName);
}
else
- m_pDBFieldLB->Clear();
+ m_xDBFieldLB->clear();
}
}
VclPtr<SfxTabPage> SwLabPage::Create(TabPageParent pParent, const SfxItemSet* rSet)
{
- return VclPtr<SwLabPage>::Create(pParent.pParent, *rSet);
+ return VclPtr<SwLabPage>::Create(pParent, *rSet);
}
void SwLabPage::ActivatePage(const SfxItemSet& rSet)
@@ -487,18 +468,18 @@ DeactivateRC SwLabPage::DeactivatePage(SfxItemSet* _pSet)
void SwLabPage::FillItem(SwLabItem& rItem)
{
- rItem.m_bAddr = m_pAddrBox->IsChecked();
- rItem.m_aWriting = m_pWritingEdit->GetText();
- rItem.m_bCont = m_pContButton->IsChecked();
- rItem.m_aMake = m_pMakeBox->GetSelectedEntry();
- rItem.m_aType = m_pTypeBox->GetSelectedEntry();
+ rItem.m_bAddr = m_xAddrBox->get_active();
+ rItem.m_aWriting = m_xWritingEdit->get_text();
+ rItem.m_bCont = m_xContButton->get_active();
+ rItem.m_aMake = m_xMakeBox->get_active_text();
+ rItem.m_aType = m_xTypeBox->get_active_text();
rItem.m_sDBName = sActDBName;
SwLabRec* pRec = GetSelectedEntryPos();
pRec->FillItem( rItem );
- rItem.m_aLstMake = m_pMakeBox->GetSelectedEntry();
- rItem.m_aLstType = m_pTypeBox->GetSelectedEntry();
+ rItem.m_aLstMake = m_xMakeBox->get_active_text();
+ rItem.m_aLstType = m_xTypeBox->get_active_text();
}
bool SwLabPage::FillItemSet(SfxItemSet* rSet)
@@ -511,7 +492,7 @@ bool SwLabPage::FillItemSet(SfxItemSet* rSet)
void SwLabPage::Reset(const SfxItemSet* rSet)
{
- m_pMakeBox->Clear();
+ m_xMakeBox->clear();
size_t nLstGroup = 0;
@@ -519,52 +500,52 @@ void SwLabPage::Reset(const SfxItemSet* rSet)
for(size_t i = 0; i < nCount; ++i)
{
OUString& rStr = GetParentSwLabDlg()->Makes()[i];
- m_pMakeBox->InsertEntry( rStr );
+ m_xMakeBox->append_text(rStr);
if ( rStr == aItem.m_aLstMake)
nLstGroup = i;
}
- m_pMakeBox->SelectEntryPos( nLstGroup );
- m_pMakeBox->GetSelectHdl().Call(*m_pMakeBox);
+ m_xMakeBox->set_active( nLstGroup );
+ MakeHdl(*m_xMakeBox);
aItem = static_cast<const SwLabItem&>( rSet->Get(FN_LABEL));
OUString sDBName = aItem.m_sDBName;
OUString aWriting(convertLineEnd(aItem.m_aWriting, GetSystemLineEnd()));
- m_pAddrBox->Check( aItem.m_bAddr );
- m_pWritingEdit->SetText ( aWriting );
+ m_xAddrBox->set_active( aItem.m_bAddr );
+ m_xWritingEdit->set_text( aWriting );
for(std::vector<OUString>::const_iterator i = GetParentSwLabDlg()->Makes().begin(); i != GetParentSwLabDlg()->Makes().end(); ++i)
{
- if(m_pMakeBox->GetEntryPos(*i) == LISTBOX_ENTRY_NOTFOUND)
- m_pMakeBox->InsertEntry(*i);
+ if (m_xMakeBox->find_text(*i) == -1)
+ m_xMakeBox->append_text(*i);
}
- m_pMakeBox->SelectEntry( aItem.m_aMake );
+ m_xMakeBox->set_active(aItem.m_aMake);
//save the current type
OUString sType(aItem.m_aType);
- m_pMakeBox->GetSelectHdl().Call(*m_pMakeBox);
+ MakeHdl(*m_xMakeBox);
aItem.m_aType = sType;
//#102806# a newly added make may not be in the type ListBox already
- if (m_pTypeBox->GetEntryPos(aItem.m_aType) == LISTBOX_ENTRY_NOTFOUND && !aItem.m_aMake.isEmpty())
+ if (m_xTypeBox->find_text(aItem.m_aType) == -1 && !aItem.m_aMake.isEmpty())
GetParentSwLabDlg()->UpdateGroup( aItem.m_aMake );
- if (m_pTypeBox->GetEntryPos(aItem.m_aType) != LISTBOX_ENTRY_NOTFOUND)
+ if (m_xTypeBox->find_text(aItem.m_aType) != -1)
{
- m_pTypeBox->SelectEntry(aItem.m_aType);
- m_pTypeBox->GetSelectHdl().Call(*m_pTypeBox);
+ m_xTypeBox->set_active(aItem.m_aType);
+ TypeHdl(*m_xTypeBox);
}
- if (m_pDatabaseLB->GetEntryPos(sDBName) != LISTBOX_ENTRY_NOTFOUND)
+ if (m_xDatabaseLB->find_text(sDBName) != -1)
{
- m_pDatabaseLB->SelectEntry(sDBName);
- m_pDatabaseLB->GetSelectHdl().Call(*m_pDatabaseLB);
+ m_xDatabaseLB->set_active(sDBName);
+ DatabaseHdl(*m_xDatabaseLB);
}
if (aItem.m_bCont)
- m_pContButton->Check();
+ m_xContButton->set_active(true);
else
- m_pSheetButton->Check();
+ m_xSheetButton->set_active(true);
}
SwPrivateDataPage::SwPrivateDataPage(vcl::Window* pParent, const SfxItemSet& rSet)
diff --git a/sw/source/ui/envelp/swuilabimp.hxx b/sw/source/ui/envelp/swuilabimp.hxx
index 79b2e11eb09d..88c18e0685cd 100644
--- a/sw/source/ui/envelp/swuilabimp.hxx
+++ b/sw/source/ui/envelp/swuilabimp.hxx
@@ -29,28 +29,26 @@ class SwLabPage : public SfxTabPage
OUString sActDBName;
SwLabItem aItem;
- VclPtr<VclContainer> m_pAddressFrame;
-
- VclPtr<CheckBox> m_pAddrBox;
- VclPtr<VclMultiLineEdit> m_pWritingEdit;
- VclPtr<ListBox> m_pDatabaseLB;
- VclPtr<ListBox> m_pTableLB;
- VclPtr<PushButton> m_pInsertBT;
- VclPtr<ListBox> m_pDBFieldLB;
-
- VclPtr<RadioButton> m_pContButton;
- VclPtr<RadioButton> m_pSheetButton;
- VclPtr<ListBox> m_pMakeBox;
- VclPtr<ListBox> m_pTypeBox;
- VclPtr<ListBox> m_pHiddenSortTypeBox;
- VclPtr<FixedText> m_pFormatInfo;
-
- DECL_LINK(AddrHdl, Button*, void);
- DECL_LINK(DatabaseHdl, ListBox&, void );
- DECL_LINK(FieldHdl, Button *, void);
- DECL_LINK(PageHdl, Button *, void);
- DECL_LINK(MakeHdl, ListBox&, void);
- DECL_LINK(TypeHdl, ListBox&, void);
+ std::unique_ptr<weld::Widget> m_xAddressFrame;
+ std::unique_ptr<weld::CheckButton> m_xAddrBox;
+ std::unique_ptr<weld::TextView> m_xWritingEdit;
+ std::unique_ptr<weld::ComboBoxText> m_xDatabaseLB;
+ std::unique_ptr<weld::ComboBoxText> m_xTableLB;
+ std::unique_ptr<weld::Button> m_xInsertBT;
+ std::unique_ptr<weld::ComboBoxText> m_xDBFieldLB;
+ std::unique_ptr<weld::RadioButton> m_xContButton;
+ std::unique_ptr<weld::RadioButton> m_xSheetButton;
+ std::unique_ptr<weld::ComboBoxText> m_xMakeBox;
+ std::unique_ptr<weld::ComboBoxText> m_xTypeBox;
+ std::unique_ptr<weld::ComboBoxText> m_xHiddenSortTypeBox;
+ std::unique_ptr<weld::Label> m_xFormatInfo;
+
+ DECL_LINK(AddrHdl, weld::ToggleButton&, void);
+ DECL_LINK(DatabaseHdl, weld::ComboBoxText&, void );
+ DECL_LINK(FieldHdl, weld::Button&, void);
+ DECL_LINK(PageHdl, weld::ToggleButton&, void);
+ DECL_LINK(MakeHdl, weld::ComboBoxText&, void);
+ DECL_LINK(TypeHdl, weld::ComboBoxText&, void);
void DisplayFormat ();
SwLabRec* GetSelectedEntryPos();
@@ -59,10 +57,9 @@ class SwLabPage : public SfxTabPage
using TabPage::DeactivatePage;
public:
- SwLabPage(vcl::Window* pParent, const SfxItemSet& rSet);
+ SwLabPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SwLabPage() override;
- virtual void dispose() override;
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 31925ff0ce64..76b2a4adfa04 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -752,6 +752,47 @@ bool SwDBManager::GetTableNames(ListBox* pListBox, const OUString& rDBName)
return bRet;
}
+bool SwDBManager::GetTableNames(weld::ComboBoxText& rBox, const OUString& rDBName)
+{
+ bool bRet = false;
+ OUString sOldTableName(rBox.get_active_text());
+ rBox.clear();
+ SwDSParam* pParam = FindDSConnection(rDBName, false);
+ uno::Reference< sdbc::XConnection> xConnection;
+ if (pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ if ( !rDBName.isEmpty() )
+ xConnection = RegisterConnection( rDBName );
+ }
+ if (xConnection.is())
+ {
+ uno::Reference<sdbcx::XTablesSupplier> xTSupplier(xConnection, uno::UNO_QUERY);
+ if(xTSupplier.is())
+ {
+ uno::Reference<container::XNameAccess> xTables = xTSupplier->getTables();
+ uno::Sequence<OUString> aTables = xTables->getElementNames();
+ const OUString* pTables = aTables.getConstArray();
+ for (sal_Int32 i = 0; i < aTables.getLength(); ++i)
+ rBox.append("0", pTables[i]);
+ }
+ uno::Reference<sdb::XQueriesSupplier> xQSupplier(xConnection, uno::UNO_QUERY);
+ if(xQSupplier.is())
+ {
+ uno::Reference<container::XNameAccess> xQueries = xQSupplier->getQueries();
+ uno::Sequence<OUString> aQueries = xQueries->getElementNames();
+ const OUString* pQueries = aQueries.getConstArray();
+ for (sal_Int32 i = 0; i < aQueries.getLength(); i++)
+ rBox.append("1", pQueries[i]);
+ }
+ if (!sOldTableName.isEmpty())
+ rBox.set_active(sOldTableName);
+ bRet = true;
+ }
+ return bRet;
+}
+
// fill Listbox with column names of a database
void SwDBManager::GetColumnNames(ListBox* pListBox,
const OUString& rDBName, const OUString& rTableName)
@@ -771,6 +812,24 @@ void SwDBManager::GetColumnNames(ListBox* pListBox,
GetColumnNames(pListBox, xConnection, rTableName);
}
+void SwDBManager::GetColumnNames(weld::ComboBoxText& rBox,
+ const OUString& rDBName, const OUString& rTableName)
+{
+ SwDBData aData;
+ aData.sDataSource = rDBName;
+ aData.sCommand = rTableName;
+ aData.nCommandType = -1;
+ SwDSParam* pParam = FindDSData(aData, false);
+ uno::Reference< sdbc::XConnection> xConnection;
+ if(pParam && pParam->xConnection.is())
+ xConnection = pParam->xConnection;
+ else
+ {
+ xConnection = RegisterConnection( rDBName );
+ }
+ GetColumnNames(rBox, xConnection, rTableName);
+}
+
void SwDBManager::GetColumnNames(ListBox* pListBox,
uno::Reference< sdbc::XConnection> const & xConnection,
const OUString& rTableName)
@@ -790,6 +849,25 @@ void SwDBManager::GetColumnNames(ListBox* pListBox,
}
}
+void SwDBManager::GetColumnNames(weld::ComboBoxText& rBox,
+ uno::Reference< sdbc::XConnection> const & xConnection,
+ const OUString& rTableName)
+{
+ rBox.clear();
+ uno::Reference< sdbcx::XColumnsSupplier> xColsSupp = SwDBManager::GetColumnSupplier(xConnection, rTableName);
+ if(xColsSupp.is())
+ {
+ uno::Reference<container::XNameAccess> xCols = xColsSupp->getColumns();
+ const uno::Sequence<OUString> aColNames = xCols->getElementNames();
+ const OUString* pColNames = aColNames.getConstArray();
+ for (sal_Int32 nCol = 0; nCol < aColNames.getLength(); ++nCol)
+ {
+ rBox.append_text(pColNames[nCol]);
+ }
+ ::comphelper::disposeComponent( xColsSupp );
+ }
+}
+
SwDBManager::SwDBManager(SwDoc* pDoc)
: m_aMergeStatus( MergeStatus::Ok )
, bInitDBFields(false)
diff --git a/sw/uiconfig/swriter/ui/cardmediumpage.ui b/sw/uiconfig/swriter/ui/cardmediumpage.ui
index 4705078cd20f..6b916a804a0d 100644
--- a/sw/uiconfig/swriter/ui/cardmediumpage.ui
+++ b/sw/uiconfig/swriter/ui/cardmediumpage.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
@@ -64,8 +64,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="use_underline">True</property>
<property name="halign">end</property>
+ <property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
@@ -79,10 +79,10 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label2">Label text:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">textview:border</property>
+ <property name="mnemonic_widget">textview</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -103,7 +103,7 @@
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTextView" id="textview:border">
+ <object class="GtkTextView" id="textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
@@ -139,10 +139,10 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label4">Database:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">database</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -177,10 +177,10 @@
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label7">Table:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">table</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -215,10 +215,10 @@
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label8">Database field:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">field</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -323,8 +323,8 @@
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
+ <property name="active">True</property>
<property name="draw_indicator">True</property>
- <property name="group">sheet</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -365,10 +365,10 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="cardmediumpage|label5">Brand:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">brand</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -379,10 +379,10 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="cardmediumpage|label3">_Type:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">type</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -390,7 +390,7 @@
</packing>
</child>
<child>
- <object class="VclComboBoxText" id="brand">
+ <object class="GtkComboBoxText" id="brand">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -402,7 +402,7 @@
</packing>
</child>
<child>
- <object class="VclComboBoxText" id="type">
+ <object class="GtkComboBoxText" id="type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index a22721c52276..6ec83d72d0d8 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1467,6 +1467,11 @@ public:
m_xTextView->SetText(rText);
}
+ virtual void replace_selection(const OUString& rText) override
+ {
+ m_xTextView->ReplaceSelected(rText);
+ }
+
virtual OUString get_text() const override
{
return m_xTextView->GetText();
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e205e46c61d9..a204143cf5f1 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3401,6 +3401,14 @@ public:
return sRet;
}
+ virtual void replace_selection(const OUString& rText) override
+ {
+ GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(m_pTextView);
+ gtk_text_buffer_delete_selection(pBuffer, false, gtk_text_view_get_editable(m_pTextView));
+ OString sText(OUStringToOString(rText, RTL_TEXTENCODING_UTF8));
+ gtk_text_buffer_insert_at_cursor(pBuffer, sText.getStr(), sText.getLength());
+ }
+
virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override
{
GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(m_pTextView);
More information about the Libreoffice-commits
mailing list