diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-06-18 09:29:38 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-06-18 16:20:50 +0200 |
commit | 2a99f3311829350a3287fda25661bc952d1646da (patch) | |
tree | fed5f2ef0bc19adcb11c933b8f2b091452469330 /sfx2 | |
parent | 9b19f99430e5ece638a6b2afee0ad77ccd0588f2 (diff) |
weld SfxSecurityPage
and drop the sole use of WB_EARLYTOGGLE
Change-Id: I01e7d085eb3f9daf5a62a048178ab90defb4c5b1
Reviewed-on: https://gerrit.libreoffice.org/55983
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/securitypage.cxx | 139 |
1 files changed, 62 insertions, 77 deletions
diff --git a/sfx2/source/dialog/securitypage.cxx b/sfx2/source/dialog/securitypage.cxx index cea3583a98cc..0633292f3239 100644 --- a/sfx2/source/dialog/securitypage.cxx +++ b/sfx2/source/dialog/securitypage.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - +#include <sfx2/htmlmode.hxx> #include <sfx2/securitypage.hxx> #include <sfx2/sfxresid.hxx> @@ -40,10 +40,8 @@ #include <sfx2/strings.hrc> - using namespace ::com::sun::star; - namespace { enum RedliningMode { RL_NONE, RL_WRITER, RL_CALC }; @@ -134,15 +132,10 @@ static bool lcl_IsPasswordCorrect( const OUString &rPassword ) return bRes; } - struct SfxSecurityPage_Impl { SfxSecurityPage & m_rMyTabPage; - VclPtr<CheckBox> m_pOpenReadonlyCB; - VclPtr<CheckBox> m_pRecordChangesCB; // for record changes - VclPtr<PushButton> m_pProtectPB; // for record changes - VclPtr<PushButton> m_pUnProtectPB; // for record changes RedliningMode m_eRedlingMode; // for record changes bool m_bOrigPasswordIsConfirmed; @@ -152,8 +145,13 @@ struct SfxSecurityPage_Impl OUString m_aEndRedliningWarning; bool m_bEndRedliningWarningDone; - DECL_LINK( RecordChangesCBToggleHdl, CheckBox&, void ); - DECL_LINK( ChangeProtectionPBHdl, Button*, void ); + std::unique_ptr<weld::CheckButton> m_xOpenReadonlyCB; + std::unique_ptr<weld::CheckButton> m_xRecordChangesCB; // for record changes + std::unique_ptr<weld::Button> m_xProtectPB; // for record changes + std::unique_ptr<weld::Button> m_xUnProtectPB; // for record changes + + DECL_LINK(RecordChangesCBToggleHdl, weld::ToggleButton&, void); + DECL_LINK(ChangeProtectionPBHdl, weld::Button&, void); SfxSecurityPage_Impl( SfxSecurityPage &rDlg ); @@ -161,29 +159,25 @@ struct SfxSecurityPage_Impl void Reset_Impl(); }; - -SfxSecurityPage_Impl::SfxSecurityPage_Impl( SfxSecurityPage &rTabPage ) : - m_rMyTabPage (rTabPage), - m_eRedlingMode ( RL_NONE ), - m_bOrigPasswordIsConfirmed ( false ), - m_bNewPasswordIsValid ( false ), - m_aEndRedliningWarning ( SfxResId(RID_SVXSTR_END_REDLINING_WARNING) ), - m_bEndRedliningWarningDone ( false ) +SfxSecurityPage_Impl::SfxSecurityPage_Impl(SfxSecurityPage &rTabPage) + : m_rMyTabPage(rTabPage) + , m_eRedlingMode(RL_NONE) + , m_bOrigPasswordIsConfirmed(false) + , m_bNewPasswordIsValid(false) + , m_aEndRedliningWarning(SfxResId(RID_SVXSTR_END_REDLINING_WARNING)) + , m_bEndRedliningWarningDone(false) + , m_xOpenReadonlyCB(rTabPage.GetBuilder().weld_check_button("readonly")) + , m_xRecordChangesCB(rTabPage.GetBuilder().weld_check_button("recordchanges")) + , m_xProtectPB(rTabPage.GetBuilder().weld_button("protect")) + , m_xUnProtectPB(rTabPage.GetBuilder().weld_button("unprotect")) { - rTabPage.get(m_pOpenReadonlyCB, "readonly"); - rTabPage.get(m_pRecordChangesCB, "recordchanges"); - rTabPage.get(m_pProtectPB, "protect"); - rTabPage.get(m_pUnProtectPB, "unprotect"); - m_pProtectPB->Show(); - m_pUnProtectPB->Hide(); - - // force toggle hdl called before visual change of checkbox - m_pRecordChangesCB->SetStyle( m_pRecordChangesCB->GetStyle() | WB_EARLYTOGGLE ); - m_pRecordChangesCB->SetToggleHdl( LINK( this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl ) ); - m_pProtectPB->SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); - m_pUnProtectPB->SetClickHdl( LINK( this, SfxSecurityPage_Impl, ChangeProtectionPBHdl ) ); -} + m_xProtectPB->show(); + m_xUnProtectPB->hide(); + m_xRecordChangesCB->connect_toggled(LINK(this, SfxSecurityPage_Impl, RecordChangesCBToggleHdl)); + m_xProtectPB->connect_clicked(LINK(this, SfxSecurityPage_Impl, ChangeProtectionPBHdl)); + m_xUnProtectPB->connect_clicked(LINK(this, SfxSecurityPage_Impl, ChangeProtectionPBHdl)); +} bool SfxSecurityPage_Impl::FillItemSet_Impl() { @@ -194,8 +188,8 @@ bool SfxSecurityPage_Impl::FillItemSet_Impl() { if (m_eRedlingMode != RL_NONE ) { - const bool bDoRecordChanges = m_pRecordChangesCB->IsChecked(); - const bool bDoChangeProtection = m_pUnProtectPB->IsVisible(); + const bool bDoRecordChanges = m_xRecordChangesCB->get_active(); + const bool bDoChangeProtection = m_xUnProtectPB->get_visible(); // sanity checks DBG_ASSERT( bDoRecordChanges || !bDoChangeProtection, "no change recording should imply no change protection" ); @@ -222,7 +216,7 @@ bool SfxSecurityPage_Impl::FillItemSet_Impl() } // open read-only? - const bool bDoOpenReadonly = m_pOpenReadonlyCB->IsChecked(); + const bool bDoOpenReadonly = m_xOpenReadonlyCB->get_active(); if (bDoOpenReadonly != pCurDocShell->IsSecurityOptOpenReadOnly()) { pCurDocShell->SetSecurityOptOpenReadOnly( bDoOpenReadonly ); @@ -241,12 +235,12 @@ void SfxSecurityPage_Impl::Reset_Impl() if (!pCurDocShell) { // no doc -> hide document settings - m_pOpenReadonlyCB->Disable(); - m_pRecordChangesCB->Disable(); - m_pProtectPB->Show(); - m_pProtectPB->Disable(); - m_pUnProtectPB->Hide(); - m_pUnProtectPB->Disable(); + m_xOpenReadonlyCB->set_sensitive(false); + m_xRecordChangesCB->set_sensitive(false); + m_xProtectPB->show(); + m_xProtectPB->set_sensitive(false); + m_xUnProtectPB->hide(); + m_xUnProtectPB->set_sensitive(false); } else { @@ -267,11 +261,11 @@ void SfxSecurityPage_Impl::Reset_Impl() bool bIsReadonly = pCurDocShell->IsReadOnly(); if (!bIsHTMLDoc) { - m_pOpenReadonlyCB->Check( pCurDocShell->IsSecurityOptOpenReadOnly() ); - m_pOpenReadonlyCB->Enable( !bIsReadonly ); + m_xOpenReadonlyCB->set_active(pCurDocShell->IsSecurityOptOpenReadOnly()); + m_xOpenReadonlyCB->set_sensitive(!bIsReadonly); } else - m_pOpenReadonlyCB->Disable(); + m_xOpenReadonlyCB->set_sensitive(false); bool bRecordChanges; if (QueryRecordChangesState( RL_WRITER, bRecordChanges ) && !bIsHTMLDoc) @@ -286,8 +280,8 @@ void SfxSecurityPage_Impl::Reset_Impl() bool bProtection(false); QueryRecordChangesProtectionState( m_eRedlingMode, bProtection ); - m_pProtectPB->Enable( !bIsReadonly ); - m_pUnProtectPB->Enable( !bIsReadonly ); + m_xProtectPB->set_sensitive(!bIsReadonly); + m_xUnProtectPB->set_sensitive(!bIsReadonly); // set the right text if (bProtection) { @@ -295,8 +289,8 @@ void SfxSecurityPage_Impl::Reset_Impl() bUnProtect = true; } - m_pRecordChangesCB->Check( bRecordChanges ); - m_pRecordChangesCB->Enable( /*!bProtection && */!bIsReadonly ); + m_xRecordChangesCB->set_active(bRecordChanges); + m_xRecordChangesCB->set_sensitive(/*!bProtection && */!bIsReadonly); m_bOrigPasswordIsConfirmed = true; // default case if no password is set uno::Sequence< sal_Int8 > aPasswordHash; @@ -310,24 +304,21 @@ void SfxSecurityPage_Impl::Reset_Impl() // A Calc document that is shared will have 'm_eRedlingMode == RL_NONE' // In shared documents change recording and protection must be disabled, // similar to documents that do not support change recording at all. - m_pRecordChangesCB->Check( false ); - m_pRecordChangesCB->Disable(); - m_pProtectPB->Check( false ); - m_pUnProtectPB->Check( false ); - m_pProtectPB->Disable(); - m_pUnProtectPB->Disable(); + m_xRecordChangesCB->set_active(false); + m_xRecordChangesCB->set_sensitive(false); + m_xProtectPB->set_sensitive(false); + m_xUnProtectPB->set_sensitive(false); } - m_pProtectPB->Show(bProtect); - m_pUnProtectPB->Show(bUnProtect); + m_xProtectPB->show(bProtect); + m_xUnProtectPB->show(bUnProtect); } } - -IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, CheckBox&, void) +IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, weld::ToggleButton&, void) { // when change recording gets disabled protection must be disabled as well - if (!m_pRecordChangesCB->IsChecked()) // the new check state is already present, thus the '!' + if (!m_xRecordChangesCB->get_active()) // the new check state is already present, thus the '!' { bool bAlreadyDone = false; if (!m_bEndRedliningWarningDone) @@ -343,7 +334,7 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, CheckBox&, void) } const bool bNeedPasssword = !m_bOrigPasswordIsConfirmed - && m_pProtectPB->IsVisible(); + && m_xProtectPB->get_visible(); if (!bAlreadyDone && bNeedPasssword) { OUString aPasswordText; @@ -360,27 +351,26 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, RecordChangesCBToggleHdl, CheckBox&, void) } if (bAlreadyDone) - m_pRecordChangesCB->Check(); // restore original state + m_xRecordChangesCB->set_active(true); // restore original state else { // remember required values to change protection and change recording in // FillItemSet_Impl later on if password was correct. m_bNewPasswordIsValid = true; m_aNewPassword.clear(); - m_pProtectPB->Show(); - m_pUnProtectPB->Hide(); + m_xProtectPB->show(); + m_xUnProtectPB->hide(); } } } - -IMPL_LINK_NOARG(SfxSecurityPage_Impl, ChangeProtectionPBHdl, Button*, void) +IMPL_LINK_NOARG(SfxSecurityPage_Impl, ChangeProtectionPBHdl, weld::Button&, void) { if (m_eRedlingMode == RL_NONE) return; // the push button text is always the opposite of the current state. Thus: - const bool bCurrentProtection = m_pUnProtectPB->IsVisible(); + const bool bCurrentProtection = m_xUnProtectPB->get_visible(); // ask user for password (if still necessary) OUString aPasswordText; @@ -408,26 +398,23 @@ IMPL_LINK_NOARG(SfxSecurityPage_Impl, ChangeProtectionPBHdl, Button*, void) m_bNewPasswordIsValid = true; m_aNewPassword = bNewProtection? aPasswordText : OUString(); - m_pRecordChangesCB->Check( bNewProtection ); + m_xRecordChangesCB->set_active(bNewProtection); - m_pUnProtectPB->Show(bNewProtection); - m_pProtectPB->Show(!bNewProtection); + m_xUnProtectPB->show(bNewProtection); + m_xProtectPB->show(!bNewProtection); } - -VclPtr<SfxTabPage> SfxSecurityPage::Create( TabPageParent pParent, const SfxItemSet * rItemSet ) +VclPtr<SfxTabPage> SfxSecurityPage::Create(TabPageParent pParent, const SfxItemSet * rItemSet) { - return VclPtr<SfxSecurityPage>::Create( pParent.pParent, *rItemSet ); + return VclPtr<SfxSecurityPage>::Create(pParent, *rItemSet); } - -SfxSecurityPage::SfxSecurityPage( vcl::Window* pParent, const SfxItemSet& rItemSet ) - : SfxTabPage(pParent, "SecurityInfoPage", "sfx/ui/securityinfopage.ui", &rItemSet) +SfxSecurityPage::SfxSecurityPage(TabPageParent pParent, const SfxItemSet& rItemSet) + : SfxTabPage(pParent, "sfx/ui/securityinfopage.ui", "SecurityInfoPage", &rItemSet) { m_pImpl.reset(new SfxSecurityPage_Impl( *this )); } - bool SfxSecurityPage::FillItemSet( SfxItemSet * /*rItemSet*/ ) { bool bModified = false; @@ -437,7 +424,6 @@ bool SfxSecurityPage::FillItemSet( SfxItemSet * /*rItemSet*/ ) return bModified; } - void SfxSecurityPage::Reset( const SfxItemSet * /*rItemSet*/ ) { DBG_ASSERT( m_pImpl.get(), "implementation pointer is 0. Still in c-tor?" ); @@ -445,5 +431,4 @@ void SfxSecurityPage::Reset( const SfxItemSet * /*rItemSet*/ ) m_pImpl->Reset_Impl(); } - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |