Kaydet (Commit) eede8af7 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SwLabPage

Change-Id: I98abbf67470fdd7be43680b02261f207a101d31c
Reviewed-on: https://gerrit.libreoffice.org/53485Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 675e4798
......@@ -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
{
......
......@@ -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,
......
This diff is collapsed.
......@@ -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);
......
......@@ -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)
......
<?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>
......
......@@ -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();
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment