Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / miscdlgs / warnbox.cxx
blob8d500490f13c038d49b284344d602370ffc411a8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "warnbox.hxx"
22 #include "scmod.hxx"
23 #include "inputopt.hxx"
24 #include "scresid.hxx"
25 #include "sc.hrc"
27 ScCbWarningBox::ScCbWarningBox( vcl::Window* pParent, const OUString& rMsgStr ) :
28 WarningBox( pParent, WB_YES_NO | WB_DEF_YES, rMsgStr )
30 // By default, the check box is ON, and the user needs to un-check it to
31 // disable all future warnings.
32 SetCheckBoxState(true);
33 SetCheckBoxText(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK));
36 sal_Int16 ScCbWarningBox::Execute()
38 sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
39 if( IsDialogEnabled() )
41 nRet = WarningBox::Execute();
42 if (!GetCheckBoxState())
43 DisableDialog();
45 return nRet;
48 bool ScCbWarningBox::IsDialogEnabled()
50 return true;
53 void ScCbWarningBox::DisableDialog()
57 ScReplaceWarnBox::ScReplaceWarnBox( vcl::Window* pParent ) :
58 ScCbWarningBox( pParent, OUString( ScResId( STR_REPLCELLSWARN ) ) )
60 SetHelpId( HID_SC_REPLCELLSWARN );
63 bool ScReplaceWarnBox::IsDialogEnabled()
65 return (bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
68 void ScReplaceWarnBox::DisableDialog()
70 ScModule* pScMod = SC_MOD();
71 ScInputOptions aInputOpt( pScMod->GetInputOptions() );
72 aInputOpt.SetReplaceCellsWarn( false );
73 pScMod->SetInputOptions( aInputOpt );
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */