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: ...@@ -634,6 +634,7 @@ public:
virtual OUString get_text() const = 0; virtual OUString get_text() const = 0;
virtual void select_region(int nStartPos, int nEndPos) = 0; virtual void select_region(int nStartPos, int nEndPos) = 0;
virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) = 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; virtual void set_editable(bool bEditable) = 0;
int get_height_rows(int nRows) const int get_height_rows(int nRows) const
{ {
......
...@@ -69,6 +69,7 @@ struct SwDBFormatData ...@@ -69,6 +69,7 @@ struct SwDBFormatData
}; };
namespace weld { namespace weld {
class ComboBoxText;
class Window; class Window;
} }
...@@ -313,13 +314,19 @@ public: ...@@ -313,13 +314,19 @@ public:
/// Fill listbox with all table names of a database. /// Fill listbox with all table names of a database.
bool GetTableNames(ListBox* pListBox, const OUString& rDBName ); 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. /// Fill listbox with all column names of a database table.
void GetColumnNames(ListBox* pListBox, void GetColumnNames(ListBox* pListBox,
const OUString& rDBName, const OUString& rTableName); const OUString& rDBName, const OUString& rTableName);
void GetColumnNames(weld::ComboBoxText& rBox,
const OUString& rDBName, const OUString& rTableName);
static void GetColumnNames(ListBox* pListBox, static void GetColumnNames(ListBox* pListBox,
css::uno::Reference< css::sdbc::XConnection> const & xConnection, css::uno::Reference< css::sdbc::XConnection> const & xConnection,
const OUString& rTableName); 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, static sal_uLong GetColumnFormat( css::uno::Reference< css::sdbc::XDataSource> const & xSource,
css::uno::Reference< css::sdbc::XConnection> const & xConnection, css::uno::Reference< css::sdbc::XConnection> const & xConnection,
......
This diff is collapsed.
...@@ -29,28 +29,26 @@ class SwLabPage : public SfxTabPage ...@@ -29,28 +29,26 @@ class SwLabPage : public SfxTabPage
OUString sActDBName; OUString sActDBName;
SwLabItem aItem; SwLabItem aItem;
VclPtr<VclContainer> m_pAddressFrame; std::unique_ptr<weld::Widget> m_xAddressFrame;
std::unique_ptr<weld::CheckButton> m_xAddrBox;
VclPtr<CheckBox> m_pAddrBox; std::unique_ptr<weld::TextView> m_xWritingEdit;
VclPtr<VclMultiLineEdit> m_pWritingEdit; std::unique_ptr<weld::ComboBoxText> m_xDatabaseLB;
VclPtr<ListBox> m_pDatabaseLB; std::unique_ptr<weld::ComboBoxText> m_xTableLB;
VclPtr<ListBox> m_pTableLB; std::unique_ptr<weld::Button> m_xInsertBT;
VclPtr<PushButton> m_pInsertBT; std::unique_ptr<weld::ComboBoxText> m_xDBFieldLB;
VclPtr<ListBox> m_pDBFieldLB; std::unique_ptr<weld::RadioButton> m_xContButton;
std::unique_ptr<weld::RadioButton> m_xSheetButton;
VclPtr<RadioButton> m_pContButton; std::unique_ptr<weld::ComboBoxText> m_xMakeBox;
VclPtr<RadioButton> m_pSheetButton; std::unique_ptr<weld::ComboBoxText> m_xTypeBox;
VclPtr<ListBox> m_pMakeBox; std::unique_ptr<weld::ComboBoxText> m_xHiddenSortTypeBox;
VclPtr<ListBox> m_pTypeBox; std::unique_ptr<weld::Label> m_xFormatInfo;
VclPtr<ListBox> m_pHiddenSortTypeBox;
VclPtr<FixedText> m_pFormatInfo; DECL_LINK(AddrHdl, weld::ToggleButton&, void);
DECL_LINK(DatabaseHdl, weld::ComboBoxText&, void );
DECL_LINK(AddrHdl, Button*, void); DECL_LINK(FieldHdl, weld::Button&, void);
DECL_LINK(DatabaseHdl, ListBox&, void ); DECL_LINK(PageHdl, weld::ToggleButton&, void);
DECL_LINK(FieldHdl, Button *, void); DECL_LINK(MakeHdl, weld::ComboBoxText&, void);
DECL_LINK(PageHdl, Button *, void); DECL_LINK(TypeHdl, weld::ComboBoxText&, void);
DECL_LINK(MakeHdl, ListBox&, void);
DECL_LINK(TypeHdl, ListBox&, void);
void DisplayFormat (); void DisplayFormat ();
SwLabRec* GetSelectedEntryPos(); SwLabRec* GetSelectedEntryPos();
...@@ -59,10 +57,9 @@ class SwLabPage : public SfxTabPage ...@@ -59,10 +57,9 @@ class SwLabPage : public SfxTabPage
using TabPage::DeactivatePage; using TabPage::DeactivatePage;
public: public:
SwLabPage(vcl::Window* pParent, const SfxItemSet& rSet); SwLabPage(TabPageParent pParent, const SfxItemSet& rSet);
virtual ~SwLabPage() override; virtual ~SwLabPage() override;
virtual void dispose() override;
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet); static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet* rSet);
......
...@@ -752,6 +752,47 @@ bool SwDBManager::GetTableNames(ListBox* pListBox, const OUString& rDBName) ...@@ -752,6 +752,47 @@ bool SwDBManager::GetTableNames(ListBox* pListBox, const OUString& rDBName)
return bRet; 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 // fill Listbox with column names of a database
void SwDBManager::GetColumnNames(ListBox* pListBox, void SwDBManager::GetColumnNames(ListBox* pListBox,
const OUString& rDBName, const OUString& rTableName) const OUString& rDBName, const OUString& rTableName)
...@@ -771,6 +812,24 @@ void SwDBManager::GetColumnNames(ListBox* pListBox, ...@@ -771,6 +812,24 @@ void SwDBManager::GetColumnNames(ListBox* pListBox,
GetColumnNames(pListBox, xConnection, rTableName); 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, void SwDBManager::GetColumnNames(ListBox* pListBox,
uno::Reference< sdbc::XConnection> const & xConnection, uno::Reference< sdbc::XConnection> const & xConnection,
const OUString& rTableName) const OUString& rTableName)
...@@ -790,6 +849,25 @@ void SwDBManager::GetColumnNames(ListBox* pListBox, ...@@ -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) SwDBManager::SwDBManager(SwDoc* pDoc)
: m_aMergeStatus( MergeStatus::Ok ) : m_aMergeStatus( MergeStatus::Ok )
, bInitDBFields(false) , bInitDBFields(false)
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.20.4 -->
<interface domain="sw"> <interface domain="sw">
<requires lib="gtk+" version="3.18"/> <requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/> <requires lib="LibreOffice" version="1.0"/>
...@@ -64,8 +64,8 @@ ...@@ -64,8 +64,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="halign">end</property> <property name="halign">end</property>
<property name="use_underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </object>
...@@ -79,10 +79,10 @@ ...@@ -79,10 +79,10 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label2">Label text:</property> <property name="label" translatable="yes" context="cardmediumpage|label2">Label text:</property>
<property name="use_underline">True</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> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property> <property name="shadow_type">in</property>
<child> <child>
<object class="GtkTextView" id="textview:border"> <object class="GtkTextView" id="textview">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
...@@ -139,10 +139,10 @@ ...@@ -139,10 +139,10 @@
<object class="GtkLabel" id="label4"> <object class="GtkLabel" id="label4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label4">Database:</property> <property name="label" translatable="yes" context="cardmediumpage|label4">Database:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">database</property> <property name="mnemonic_widget">database</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -177,10 +177,10 @@ ...@@ -177,10 +177,10 @@
<object class="GtkLabel" id="label7"> <object class="GtkLabel" id="label7">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="cardmediumpage|label7">Table:</property> <property name="label" translatable="yes" context="cardmediumpage|label7">Table:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">table</property> <property name="mnemonic_widget">table</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -215,10 +215,10 @@ ...@@ -215,10 +215,10 @@
<object class="GtkLabel" id="label8"> <object class="GtkLabel" id="label8">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</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="label" translatable="yes" context="cardmediumpage|label8">Database field:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">field</property> <property name="mnemonic_widget">field</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -323,8 +323,8 @@ ...@@ -323,8 +323,8 @@
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
<property name="group">sheet</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -365,10 +365,10 @@ ...@@ -365,10 +365,10 @@
<object class="GtkLabel" id="label5"> <object class="GtkLabel" id="label5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="cardmediumpage|label5">Brand:</property> <property name="label" translatable="yes" context="cardmediumpage|label5">Brand:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">brand</property> <property name="mnemonic_widget">brand</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -379,10 +379,10 @@ ...@@ -379,10 +379,10 @@
<object class="GtkLabel" id="label3"> <object class="GtkLabel" id="label3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes" context="cardmediumpage|label3">_Type:</property> <property name="label" translatable="yes" context="cardmediumpage|label3">_Type:</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">type</property> <property name="mnemonic_widget">type</property>
<property name="xalign">1</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -390,7 +390,7 @@ ...@@ -390,7 +390,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="VclComboBoxText" id="brand"> <object class="GtkComboBoxText" id="brand">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
...@@ -402,7 +402,7 @@ ...@@ -402,7 +402,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="VclComboBoxText" id="type"> <object class="GtkComboBoxText" id="type">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
......
...@@ -1467,6 +1467,11 @@ public: ...@@ -1467,6 +1467,11 @@ public:
m_xTextView->SetText(rText); m_xTextView->SetText(rText);
} }
virtual void replace_selection(const OUString& rText) override
{
m_xTextView->ReplaceSelected(rText);
}
virtual OUString get_text() const override virtual OUString get_text() const override
{ {
return m_xTextView->GetText(); return m_xTextView->GetText();
......
...@@ -3401,6 +3401,14 @@ public: ...@@ -3401,6 +3401,14 @@ public:
return sRet; 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 virtual bool get_selection_bounds(int& rStartPos, int& rEndPos) override
{ {
GtkTextBuffer* pBuffer = gtk_text_view_get_buffer(m_pTextView); 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