[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - include/sfx2 include/tools sfx2/source vcl/source
Caolán McNamara
caolanm at redhat.com
Mon Jun 18 14:21:27 UTC 2018
include/sfx2/securitypage.hxx | 7 -
include/tools/wintypes.hxx | 3
sfx2/source/dialog/securitypage.cxx | 139 ++++++++++++++++--------------------
vcl/source/control/button.cxx | 5 -
4 files changed, 65 insertions(+), 89 deletions(-)
New commits:
commit 04f91f249b6ecaf87db983f7dcf514bbf4100b6b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Jun 18 09:29:38 2018 +0100
weld SfxSecurityPage
and drop the sole use of WB_EARLYTOGGLE
Change-Id: I01e7d085eb3f9daf5a62a048178ab90defb4c5b1
Reviewed-on: https://gerrit.libreoffice.org/55986
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/include/sfx2/securitypage.hxx b/include/sfx2/securitypage.hxx
index 67d27d076b84..deb7fe6d8f8c 100644
--- a/include/sfx2/securitypage.hxx
+++ b/include/sfx2/securitypage.hxx
@@ -20,11 +20,8 @@
#define INCLUDED_SFX2_SECURITYPAGE_HXX
#include <sfx2/tabdlg.hxx>
-#include <sfx2/htmlmode.hxx>
-
#include <memory>
-
struct SfxSecurityPage_Impl;
class SfxSecurityPage : public SfxTabPage
@@ -36,11 +33,11 @@ protected:
virtual void Reset( const SfxItemSet* ) override;
public:
- SfxSecurityPage(vcl::Window* pParent, const SfxItemSet&);
+ SfxSecurityPage(TabPageParent pParent, const SfxItemSet&);
static VclPtr<SfxTabPage> Create(TabPageParent pParent, const SfxItemSet*);
+ weld::Builder& GetBuilder() const { return *m_xBuilder; }
};
-
#endif // INCLUDED_SFX2_SECURITYPAGE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/tools/wintypes.hxx b/include/tools/wintypes.hxx
index b9e7d007fc55..9f5229806e3f 100644
--- a/include/tools/wintypes.hxx
+++ b/include/tools/wintypes.hxx
@@ -191,9 +191,6 @@ WinBits const WB_PATHELLIPSIS = 0x00100000;
WinBits const WB_EXTRAOFFSET = 0x02000000;
WinBits const WB_NOMULTILINE = 0x10000000;
-// Window-Bits for CheckBox
-WinBits const WB_EARLYTOGGLE = SAL_CONST_INT64(0x4000000000);
-
// Window-Bits for Edit
WinBits const WB_READONLY = 0x02000000;
WinBits const WB_NOHIDESELECTION = SAL_CONST_INT64(0x1000000000);
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: */
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index ebd5aaee80a9..6facf9159838 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3160,12 +3160,9 @@ void CheckBox::ImplCheck()
meState = eNewState;
VclPtr<vcl::Window> xWindow = this;
- if( GetStyle() & WB_EARLYTOGGLE )
- Toggle();
Invalidate();
Update();
- if( ! (GetStyle() & WB_EARLYTOGGLE) )
- Toggle();
+ Toggle();
if ( xWindow->IsDisposed() )
return;
Click();
More information about the Libreoffice-commits
mailing list