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 : // ============================================================================
29 :
30 0 : ScCbWarningBox::ScCbWarningBox( Window* pParent, const String& rMsgStr, bool bDefYes ) :
31 0 : WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
32 : {
33 : // By default, the check box is ON, and the user needs to un-check it to
34 : // disable all future warnings.
35 0 : SetCheckBoxState(true);
36 0 : SetCheckBoxText(String(ScResId(SCSTR_WARN_ME_IN_FUTURE_CHECK)));
37 0 : }
38 :
39 0 : sal_Int16 ScCbWarningBox::Execute()
40 : {
41 0 : sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
42 0 : if( IsDialogEnabled() )
43 : {
44 0 : nRet = WarningBox::Execute();
45 0 : if (!GetCheckBoxState())
46 0 : DisableDialog();
47 : }
48 0 : return nRet;
49 : }
50 :
51 0 : bool ScCbWarningBox::IsDialogEnabled()
52 : {
53 0 : return true;
54 : }
55 :
56 0 : void ScCbWarningBox::DisableDialog()
57 : {
58 0 : }
59 :
60 :
61 : // ----------------------------------------------------------------------------
62 :
63 0 : ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
64 0 : ScCbWarningBox( pParent, String( ScResId( STR_REPLCELLSWARN ) ), true )
65 : {
66 0 : SetHelpId( HID_SC_REPLCELLSWARN );
67 0 : }
68 :
69 0 : bool ScReplaceWarnBox::IsDialogEnabled()
70 : {
71 0 : return ((bool) SC_MOD()->GetInputOptions().GetReplaceCellsWarn()) == true;
72 : }
73 :
74 0 : void ScReplaceWarnBox::DisableDialog()
75 : {
76 0 : ScModule* pScMod = SC_MOD();
77 0 : ScInputOptions aInputOpt( pScMod->GetInputOptions() );
78 0 : aInputOpt.SetReplaceCellsWarn( false );
79 0 : pScMod->SetInputOptions( aInputOpt );
80 0 : }
81 :
82 :
83 : // ============================================================================
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|