loplugin:mergeclasse merge ScCbWarningBox with ScReplaceWarnBo
Change-Id: I7b55b036c1992b88b01b51053a3560e9f97986c9
This commit is contained in:
parent
0f67b8626b
commit
2a504a24e4
@ -92,7 +92,6 @@ merge SalPrinter with PspSalPrinter
|
||||
merge SalSession with (anonymous namespace)::IceSalSession
|
||||
merge SalSystem with SalGenericSystem
|
||||
merge ScBiffReader with ScQProReader
|
||||
merge ScCbWarningBox with ScReplaceWarnBox
|
||||
merge ScDBFunc with ScTabViewShell
|
||||
merge ScDPCache::DBConnector with (anonymous namespace)::DBConnector
|
||||
merge ScDocFunc with ScDocFuncDirect
|
||||
|
@ -22,34 +22,17 @@
|
||||
|
||||
#include <vcl/msgbox.hxx>
|
||||
|
||||
/** Message box with warning image and "Do not show again" checkbox. */
|
||||
class ScCbWarningBox : public WarningBox
|
||||
/** Warning box for "Replace cell contents?".
|
||||
With warning image and "Do not show again" checkbox. */
|
||||
class ScReplaceWarnBox : public WarningBox
|
||||
{
|
||||
public:
|
||||
/** @param rMsgStr Resource ID for the message text. */
|
||||
ScCbWarningBox( vcl::Window* pParent, const OUString& rMsgStr );
|
||||
ScReplaceWarnBox( vcl::Window* pParent );
|
||||
|
||||
/** Opens dialog if IsDialogEnabled() returns true.
|
||||
@descr If after executing the dialog the checkbox "Do not show again" is set,
|
||||
the method DisableDialog() will be called. */
|
||||
virtual sal_Int16 Execute() override;
|
||||
|
||||
/** Called before executing the dialog. If this method returns false, the dialog will not be opened. */
|
||||
virtual bool IsDialogEnabled();
|
||||
/** Called, when dialog is exited and the option "Do not show again" is set. */
|
||||
virtual void DisableDialog();
|
||||
};
|
||||
|
||||
/** Warning box for "Replace cell contents?". */
|
||||
class ScReplaceWarnBox : public ScCbWarningBox
|
||||
{
|
||||
public:
|
||||
ScReplaceWarnBox( vcl::Window* pParent );
|
||||
|
||||
/** Reads the configuration key "ReplaceCellsWarning". */
|
||||
virtual bool IsDialogEnabled() override;
|
||||
/** Sets the configuration key "ReplaceCellsWarning" to false. */
|
||||
virtual void DisableDialog() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -24,53 +24,31 @@
|
||||
#include "scresid.hxx"
|
||||
#include "sc.hrc"
|
||||
|
||||
ScCbWarningBox::ScCbWarningBox( vcl::Window* pParent, const OUString& rMsgStr ) :
|
||||
WarningBox( pParent, WB_YES_NO | WB_DEF_YES, rMsgStr )
|
||||
ScReplaceWarnBox::ScReplaceWarnBox( vcl::Window* pParent ) :
|
||||
WarningBox( pParent, WB_YES_NO | WB_DEF_YES, OUString( ScResId( STR_REPLCELLSWARN ) ) )
|
||||
{
|
||||
// By default, the check box is ON, and the user needs to un-check it to
|
||||
// disable all future warnings.
|
||||
SetCheckBoxState(true);
|
||||
SetCheckBoxText(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK));
|
||||
}
|
||||
|
||||
sal_Int16 ScCbWarningBox::Execute()
|
||||
{
|
||||
sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
|
||||
if( IsDialogEnabled() )
|
||||
{
|
||||
nRet = WarningBox::Execute();
|
||||
if (!GetCheckBoxState())
|
||||
DisableDialog();
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
||||
bool ScCbWarningBox::IsDialogEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScCbWarningBox::DisableDialog()
|
||||
{
|
||||
}
|
||||
|
||||
ScReplaceWarnBox::ScReplaceWarnBox( vcl::Window* pParent ) :
|
||||
ScCbWarningBox( pParent, OUString( ScResId( STR_REPLCELLSWARN ) ) )
|
||||
{
|
||||
SetHelpId( HID_SC_REPLCELLSWARN );
|
||||
}
|
||||
|
||||
bool ScReplaceWarnBox::IsDialogEnabled()
|
||||
{
|
||||
return (bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
|
||||
}
|
||||
|
||||
void ScReplaceWarnBox::DisableDialog()
|
||||
sal_Int16 ScReplaceWarnBox::Execute()
|
||||
{
|
||||
sal_Int16 nRet = RET_YES;
|
||||
if( (bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn() )
|
||||
{
|
||||
nRet = WarningBox::Execute();
|
||||
if (!GetCheckBoxState())
|
||||
{
|
||||
ScModule* pScMod = SC_MOD();
|
||||
ScInputOptions aInputOpt( pScMod->GetInputOptions() );
|
||||
aInputOpt.SetReplaceCellsWarn( false );
|
||||
pScMod->SetInputOptions( aInputOpt );
|
||||
}
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
Loading…
x
Reference in New Issue
Block a user