Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / miscdlgs / warnbox.cxx
blob166e8123897f7ecb0c9b95ece6637ff7a20f2e42
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"
28 // ============================================================================
30 ScCbWarningBox::ScCbWarningBox( Window* pParent, const OUString& rMsgStr, bool bDefYes ) :
31 WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
33 // By default, the check box is ON, and the user needs to un-check it to
34 // disable all future warnings.
35 SetCheckBoxState(true);
36 SetCheckBoxText(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK));
39 sal_Int16 ScCbWarningBox::Execute()
41 sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
42 if( IsDialogEnabled() )
44 nRet = WarningBox::Execute();
45 if (!GetCheckBoxState())
46 DisableDialog();
48 return nRet;
51 bool ScCbWarningBox::IsDialogEnabled()
53 return true;
56 void ScCbWarningBox::DisableDialog()
61 // ----------------------------------------------------------------------------
63 ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
64 ScCbWarningBox( pParent, OUString( ScResId( STR_REPLCELLSWARN ) ), true )
66 SetHelpId( HID_SC_REPLCELLSWARN );
69 bool ScReplaceWarnBox::IsDialogEnabled()
71 return ((bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn()) == true;
74 void ScReplaceWarnBox::DisableDialog()
76 ScModule* pScMod = SC_MOD();
77 ScInputOptions aInputOpt( pScMod->GetInputOptions() );
78 aInputOpt.SetReplaceCellsWarn( false );
79 pScMod->SetInputOptions( aInputOpt );
83 // ============================================================================
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */