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