summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-02-02 11:26:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2019-02-02 14:58:41 +0100
commit65d4676eedeb0de91cdf7105453f18f600b3f13a (patch)
tree97a6d98a1dae884fa41d7ebef6dd15b46721a012
parentb8ac898eb0e1ce9f068e5b4e0c4b04a729a394cb (diff)
weld ScTableProtectionDlg
Change-Id: Icbf9e3b679b58d2781a52a0f55b16511eed14485 Reviewed-on: https://gerrit.libreoffice.org/67279 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/ui/inc/protectiondlg.hxx44
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.cxx133
-rw-r--r--sc/source/ui/view/tabvwsh3.cxx9
-rw-r--r--sc/uiconfig/scalc/ui/protectsheetdlg.ui95
4 files changed, 175 insertions, 106 deletions
diff --git a/sc/source/ui/inc/protectiondlg.hxx b/sc/source/ui/inc/protectiondlg.hxx
index 3f30ea33180b..e0dd803e3f61 100644
--- a/sc/source/ui/inc/protectiondlg.hxx
+++ b/sc/source/ui/inc/protectiondlg.hxx
@@ -20,23 +20,18 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_PROTECTIONDLG_HXX
#define INCLUDED_SC_SOURCE_UI_INC_PROTECTIONDLG_HXX
-#include <vcl/dialog.hxx>
-#include <vcl/button.hxx>
-#include <vcl/layout.hxx>
-#include <svx/checklbx.hxx>
-
+#include <vcl/weld.hxx>
#include <scdllapi.h>
namespace vcl { class Window; }
class ScTableProtection;
-class ScTableProtectionDlg : public ModalDialog
+class ScTableProtectionDlg : public weld::GenericDialogController
{
public:
ScTableProtectionDlg() = delete;
- explicit SC_DLLPUBLIC ScTableProtectionDlg(vcl::Window* pParent);
+ explicit SC_DLLPUBLIC ScTableProtectionDlg(weld::Window* pParent);
virtual ~ScTableProtectionDlg() override;
- virtual void dispose() override;
void SetDialogData(const ScTableProtection& rData);
@@ -47,17 +42,6 @@ private:
void EnableOptionalWidgets(bool bEnable);
- VclPtr<CheckBox> m_pBtnProtect;
-
- VclPtr<VclContainer> m_pPasswords;
- VclPtr<VclContainer> m_pOptions;
- VclPtr<Edit> m_pPassword1Edit;
- VclPtr<Edit> m_pPassword2Edit;
-
- VclPtr<SvxCheckListBox> m_pOptionsListBox;
-
- VclPtr<OKButton> m_pBtnOk;
-
OUString m_aSelectLockedCells;
OUString m_aSelectUnlockedCells;
OUString m_aInsertColumns;
@@ -65,9 +49,25 @@ private:
OUString m_aDeleteColumns;
OUString m_aDeleteRows;
- DECL_LINK( OKHdl, Button*, void );
- DECL_LINK( CheckBoxHdl, Button*, void );
- DECL_LINK( PasswordModifyHdl, Edit&, void );
+ std::unique_ptr<weld::CheckButton> m_xBtnProtect;
+ std::unique_ptr<weld::Container> m_xPasswords;
+ std::unique_ptr<weld::Container> m_xOptions;
+ std::unique_ptr<weld::Entry> m_xPassword1Edit;
+ std::unique_ptr<weld::Entry> m_xPassword2Edit;
+ std::unique_ptr<weld::TreeView> m_xOptionsListBox;
+ std::unique_ptr<weld::Button> m_xBtnOk;
+ std::unique_ptr<weld::Label> m_xProtected;
+ std::unique_ptr<weld::Label> m_xUnprotected;
+ std::unique_ptr<weld::Label> m_xInsertColumns;
+ std::unique_ptr<weld::Label> m_xInsertRows;
+ std::unique_ptr<weld::Label> m_xDeleteColumns;
+ std::unique_ptr<weld::Label> m_xDeleteRows;
+
+ void InsertEntry(const OUString& rTxt);
+
+ DECL_LINK(OKHdl, weld::Button&, void);
+ DECL_LINK(CheckBoxHdl, weld::ToggleButton&, void);
+ DECL_LINK(PasswordModifyHdl, weld::Entry&, void);
};
#endif
diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx
index 28712c3b16c3..0f3e1384ae3c 100644
--- a/sc/source/ui/miscdlgs/protectiondlg.cxx
+++ b/sc/source/ui/miscdlgs/protectiondlg.cxx
@@ -38,118 +38,123 @@ const std::vector<ScTableProtection::Option> aOptions = {
}
-ScTableProtectionDlg::ScTableProtectionDlg(vcl::Window* pParent)
- : ModalDialog( pParent, "ProtectSheetDialog", "modules/scalc/ui/protectsheetdlg.ui" )
+ScTableProtectionDlg::ScTableProtectionDlg(weld::Window* pParent)
+ : weld::GenericDialogController(pParent, "modules/scalc/ui/protectsheetdlg.ui", "ProtectSheetDialog")
+ , m_xBtnProtect(m_xBuilder->weld_check_button("protect"))
+ , m_xPasswords(m_xBuilder->weld_container("passwords"))
+ , m_xOptions(m_xBuilder->weld_container("options"))
+ , m_xPassword1Edit(m_xBuilder->weld_entry("password1"))
+ , m_xPassword2Edit(m_xBuilder->weld_entry("password2"))
+ , m_xOptionsListBox(m_xBuilder->weld_tree_view("checklist"))
+ , m_xBtnOk(m_xBuilder->weld_button("ok"))
+ , m_xProtected(m_xBuilder->weld_label("protected"))
+ , m_xUnprotected(m_xBuilder->weld_label("unprotected"))
+ , m_xInsertColumns(m_xBuilder->weld_label("insert-columns"))
+ , m_xInsertRows(m_xBuilder->weld_label("insert-rows"))
+ , m_xDeleteColumns(m_xBuilder->weld_label("delete-columns"))
+ , m_xDeleteRows(m_xBuilder->weld_label("delete-rows"))
{
- get(m_pPasswords, "passwords");
- get(m_pOptions, "options");
- get(m_pBtnProtect, "protect");
- get(m_pOptionsListBox, "checklist");
- get(m_pPassword1Edit, "password1");
- get(m_pPassword2Edit, "password2");
- get(m_pBtnOk, "ok");
-
- m_aSelectLockedCells = get<FixedText>("protected")->GetText();
- m_aSelectUnlockedCells = get<FixedText>("unprotected")->GetText();
- m_aInsertColumns = get<FixedText>("insert-columns")->GetText();
- m_aInsertRows = get<FixedText>("insert-rows")->GetText();
- m_aDeleteColumns = get<FixedText>("delete-columns")->GetText();
- m_aDeleteRows = get<FixedText>("delete-rows")->GetText();
+ m_aSelectLockedCells = m_xProtected->get_label();
+ m_aSelectUnlockedCells = m_xUnprotected->get_label();
+ m_aInsertColumns = m_xInsertColumns->get_label();
+ m_aInsertRows = m_xInsertRows->get_label();
+ m_aDeleteColumns = m_xDeleteColumns->get_label();
+ m_aDeleteRows = m_xDeleteRows->get_label();
+
+ std::vector<int> aWidths;
+ aWidths.push_back(m_xOptionsListBox->get_approximate_digit_width() * 3 + 6);
+ m_xOptionsListBox->set_column_fixed_widths(aWidths);
Init();
}
ScTableProtectionDlg::~ScTableProtectionDlg()
{
- disposeOnce();
-}
-
-void ScTableProtectionDlg::dispose()
-{
- m_pBtnProtect.clear();
- m_pPasswords.clear();
- m_pOptions.clear();
- m_pPassword1Edit.clear();
- m_pPassword2Edit.clear();
- m_pOptionsListBox.clear();
- m_pBtnOk.clear();
- ModalDialog::dispose();
}
void ScTableProtectionDlg::SetDialogData(const ScTableProtection& rData)
{
for (size_t i = 0; i < aOptions.size(); ++i)
- m_pOptionsListBox->CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
+ m_xOptionsListBox->set_toggle(i, rData.isOptionEnabled(aOptions[i]), 0);
}
void ScTableProtectionDlg::WriteData(ScTableProtection& rData) const
{
- rData.setProtected(m_pBtnProtect->IsChecked());
+ rData.setProtected(m_xBtnProtect->get_active());
// We assume that the two password texts match.
- rData.setPassword(m_pPassword1Edit->GetText());
+ rData.setPassword(m_xPassword1Edit->get_text());
for (size_t i = 0; i < aOptions.size(); ++i)
- rData.setOption(aOptions[i], m_pOptionsListBox->IsChecked(i));
+ rData.setOption(aOptions[i], m_xOptionsListBox->get_toggle(i, 0));
+}
+
+void ScTableProtectionDlg::InsertEntry(const OUString& rTxt)
+{
+ m_xOptionsListBox->insert(nullptr, -1, nullptr, nullptr, nullptr,
+ nullptr, nullptr, false);
+ const int nRow = m_xOptionsListBox->n_children() - 1;
+ m_xOptionsListBox->set_toggle(nRow, false, 0);
+ m_xOptionsListBox->set_text(nRow, rTxt, 1);
}
void ScTableProtectionDlg::Init()
{
- m_pBtnProtect->SetClickHdl(LINK( this, ScTableProtectionDlg, CheckBoxHdl ));
+ m_xBtnProtect->connect_toggled(LINK(this, ScTableProtectionDlg, CheckBoxHdl));
- m_pBtnOk->SetClickHdl(LINK( this, ScTableProtectionDlg, OKHdl ));
+ m_xBtnOk->connect_clicked(LINK(this, ScTableProtectionDlg, OKHdl));
- Link<Edit&,void> aLink = LINK( this, ScTableProtectionDlg, PasswordModifyHdl );
- m_pPassword1Edit->SetModifyHdl(aLink);
- m_pPassword2Edit->SetModifyHdl(aLink);
+ Link<weld::Entry&,void> aLink = LINK(this, ScTableProtectionDlg, PasswordModifyHdl);
+ m_xPassword1Edit->connect_changed(aLink);
+ m_xPassword2Edit->connect_changed(aLink);
- m_pOptionsListBox->SetUpdateMode(false);
- m_pOptionsListBox->Clear();
+ m_xOptionsListBox->freeze();
+ m_xOptionsListBox->clear();
- m_pOptionsListBox->InsertEntry(m_aSelectLockedCells);
- m_pOptionsListBox->InsertEntry(m_aSelectUnlockedCells);
- m_pOptionsListBox->InsertEntry(m_aInsertColumns);
- m_pOptionsListBox->InsertEntry(m_aInsertRows);
- m_pOptionsListBox->InsertEntry(m_aDeleteColumns);
- m_pOptionsListBox->InsertEntry(m_aDeleteRows);
+ InsertEntry(m_aSelectLockedCells);
+ InsertEntry(m_aSelectUnlockedCells);
+ InsertEntry(m_aInsertColumns);
+ InsertEntry(m_aInsertRows);
+ InsertEntry(m_aDeleteColumns);
+ InsertEntry(m_aDeleteRows);
- m_pOptionsListBox->CheckEntryPos(0);
- m_pOptionsListBox->CheckEntryPos(1);
+ m_xOptionsListBox->set_toggle(0, true, 0);
+ m_xOptionsListBox->set_toggle(1, true, 0);
- m_pOptionsListBox->SetUpdateMode(true);
+ m_xOptionsListBox->thaw();
// Set the default state of the dialog.
- m_pBtnProtect->Check();
- m_pPassword1Edit->GrabFocus();
+ m_xBtnProtect->set_active(true);
+ m_xPassword1Edit->grab_focus();
}
void ScTableProtectionDlg::EnableOptionalWidgets(bool bEnable)
{
- m_pPasswords->Enable(bEnable);
- m_pOptions->Enable(bEnable);
- m_pOptionsListBox->Invalidate();
+ m_xPasswords->set_sensitive(bEnable);
+ m_xOptions->set_sensitive(bEnable);
+//TODO m_xOptionsListBox->Invalidate();
}
-IMPL_LINK( ScTableProtectionDlg, CheckBoxHdl, Button*, pBtn, void )
+IMPL_LINK(ScTableProtectionDlg, CheckBoxHdl, weld::ToggleButton&, rBtn, void)
{
- if (pBtn == m_pBtnProtect)
+ if (&rBtn == m_xBtnProtect.get())
{
- bool bChecked = m_pBtnProtect->IsChecked();
+ bool bChecked = m_xBtnProtect->get_active();
EnableOptionalWidgets(bChecked);
- m_pBtnOk->Enable(bChecked);
+ m_xBtnOk->set_sensitive(bChecked);
}
}
-IMPL_LINK_NOARG(ScTableProtectionDlg, OKHdl, Button*, void)
+IMPL_LINK_NOARG(ScTableProtectionDlg, OKHdl, weld::Button&, void)
{
- EndDialog(RET_OK);
+ m_xDialog->response(RET_OK);
}
-IMPL_LINK_NOARG(ScTableProtectionDlg, PasswordModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(ScTableProtectionDlg, PasswordModifyHdl, weld::Entry&, void)
{
- OUString aPass1 = m_pPassword1Edit->GetText();
- OUString aPass2 = m_pPassword2Edit->GetText();
- m_pBtnOk->Enable(aPass1 == aPass2);
+ OUString aPass1 = m_xPassword1Edit->get_text();
+ OUString aPass2 = m_xPassword2Edit->get_text();
+ m_xBtnOk->set_sensitive(aPass1 == aPass2);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
index 11c5b1eedbc4..002a846482fa 100644
--- a/sc/source/ui/view/tabvwsh3.cxx
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -1157,18 +1157,19 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
{
// Protect a current sheet.
- VclPtrInstance< ScTableProtectionDlg > pDlg(GetDialogParent());
+ vcl::Window* pWin = GetDialogParent();
+ ScTableProtectionDlg aDlg(pWin ? pWin->GetFrameWeld() : nullptr);
ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
if (pProtect)
- pDlg->SetDialogData(*pProtect);
+ aDlg.SetDialogData(*pProtect);
- if (pDlg->Execute() == RET_OK)
+ if (aDlg.run() == RET_OK)
{
pScMod->InputEnterHandler();
ScTableProtection aNewProtect;
- pDlg->WriteData(aNewProtect);
+ aDlg.WriteData(aNewProtect);
ProtectSheet(nTab, aNewProtect);
if (!pReqArgs)
{
diff --git a/sc/uiconfig/scalc/ui/protectsheetdlg.ui b/sc/uiconfig/scalc/ui/protectsheetdlg.ui
index 1a10eeae2c07..85f021b0d4de 100644
--- a/sc/uiconfig/scalc/ui/protectsheetdlg.ui
+++ b/sc/uiconfig/scalc/ui/protectsheetdlg.ui
@@ -1,13 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
- <requires lib="LibreOffice" version="1.0"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name check1 -->
+ <column type="gboolean"/>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ <!-- column-name checkvis1 -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="ProtectSheetDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="protectsheetdlg|ProtectSheetDialog">Protect Sheet</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</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>
@@ -144,7 +161,9 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
+ <property name="activates_default">True</property>
<property name="width_chars">24</property>
+ <property name="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -157,7 +176,9 @@
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
+ <property name="activates_default">True</property>
<property name="width_chars">24</property>
+ <property name="input_purpose">password</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -192,7 +213,7 @@
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="protectsheetdlg|label4">Allow all users of this sheet to:</property>
<property name="use_underline">True</property>
- <property name="mnemonic_widget">checklist:border</property>
+ <property name="mnemonic_widget">checklist</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -202,13 +223,55 @@
</packing>
</child>
<child>
- <object class="svxcorelo-SvxCheckListBox" id="checklist:border">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="Checked Tree List-selection1"/>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="checklist">
+ <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="headers_visible">False</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn4">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <property name="alignment">0.5</property>
+ <child>
+ <object class="GtkCellRendererToggle" id="cellrenderer5"/>
+ <attributes>
+ <attribute name="visible">3</attribute>
+ <attribute name="active">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+ <property name="resizable">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderer4"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -235,10 +298,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="unprotected">
+ <object class="GtkLabel" id="delete-rows">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="protectsheetdlg|unprotected">Select unprotected cells</property>
+ <property name="label" translatable="yes" context="protectsheetdlg|delete-rows">Delete rows</property>
</object>
<packing>
<property name="expand">False</property>
@@ -247,10 +310,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="insert-columns">
+ <object class="GtkLabel" id="insert-rows">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="protectsheetdlg|insert-columns">Insert columns</property>
+ <property name="label" translatable="yes" context="protectsheetdlg|insert-rows">Insert rows</property>
</object>
<packing>
<property name="expand">False</property>
@@ -259,10 +322,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="insert-rows">
+ <object class="GtkLabel" id="unprotected">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="protectsheetdlg|insert-rows">Insert rows</property>
+ <property name="label" translatable="yes" context="protectsheetdlg|unprotected">Select unprotected cells</property>
</object>
<packing>
<property name="expand">False</property>
@@ -271,10 +334,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="delete-columns">
+ <object class="GtkLabel" id="insert-columns">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="protectsheetdlg|delete-columns">Delete columns</property>
+ <property name="label" translatable="yes" context="protectsheetdlg|insert-columns">Insert columns</property>
</object>
<packing>
<property name="expand">False</property>
@@ -283,10 +346,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="delete-rows">
+ <object class="GtkLabel" id="delete-columns">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes" context="protectsheetdlg|delete-rows">Delete rows</property>
+ <property name="label" translatable="yes" context="protectsheetdlg|delete-columns">Delete columns</property>
</object>
<packing>
<property name="expand">False</property>