Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "warnbox.hxx"
21 :
22 : #include "scmod.hxx"
23 : #include "inputopt.hxx"
24 : #include "scresid.hxx"
25 : #include "sc.hrc"
26 :
27 :
28 0 : ScCbWarningBox::ScCbWarningBox( Window* pParent, const OUString& rMsgStr, bool bDefYes ) :
29 0 : WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
30 : {
31 : // By default, the check box is ON, and the user needs to un-check it to
32 : // disable all future warnings.
33 0 : SetCheckBoxState(true);
34 0 : SetCheckBoxText(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK));
35 0 : }
36 :
37 0 : sal_Int16 ScCbWarningBox::Execute()
38 : {
39 0 : sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
40 0 : if( IsDialogEnabled() )
41 : {
42 0 : nRet = WarningBox::Execute();
43 0 : if (!GetCheckBoxState())
44 0 : DisableDialog();
45 : }
46 0 : return nRet;
47 : }
48 :
49 0 : bool ScCbWarningBox::IsDialogEnabled()
50 : {
51 0 : return true;
52 : }
53 :
54 0 : void ScCbWarningBox::DisableDialog()
55 : {
56 0 : }
57 :
58 :
59 0 : ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
60 0 : ScCbWarningBox( pParent, OUString( ScResId( STR_REPLCELLSWARN ) ), true )
61 : {
62 0 : SetHelpId( HID_SC_REPLCELLSWARN );
63 0 : }
64 :
65 0 : bool ScReplaceWarnBox::IsDialogEnabled()
66 : {
67 0 : return ((bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn()) == true;
68 : }
69 :
70 0 : void ScReplaceWarnBox::DisableDialog()
71 : {
72 0 : ScModule* pScMod = SC_MOD();
73 0 : ScInputOptions aInputOpt( pScMod->GetInputOptions() );
74 0 : aInputOpt.SetReplaceCellsWarn( false );
75 0 : pScMod->SetInputOptions( aInputOpt );
76 0 : }
77 :
78 :
79 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|