xref: /aoo42x/main/sc/source/ui/miscdlgs/warnbox.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 #include "warnbox.hxx"
27 
28 #include "scmod.hxx"
29 #include "inputopt.hxx"
30 #include "scresid.hxx"
31 #include "sc.hrc"
32 
33 
34 // ============================================================================
35 
ScCbWarningBox(Window * pParent,const String & rMsgStr,bool bDefYes)36 ScCbWarningBox::ScCbWarningBox( Window* pParent, const String& rMsgStr, bool bDefYes ) :
37     WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
38 {
39     SetDefaultCheckBoxText();
40 }
41 
Execute()42 sal_Int16 ScCbWarningBox::Execute()
43 {
44     sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
45     if( IsDialogEnabled() )
46     {
47         nRet = WarningBox::Execute();
48         if( GetCheckBoxState() )
49             DisableDialog();
50     }
51     return nRet;
52 }
53 
IsDialogEnabled()54 bool ScCbWarningBox::IsDialogEnabled()
55 {
56     return true;
57 }
58 
DisableDialog()59 void ScCbWarningBox::DisableDialog()
60 {
61 }
62 
63 
64 // ----------------------------------------------------------------------------
65 
ScReplaceWarnBox(Window * pParent)66 ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
67     ScCbWarningBox( pParent, String( ScResId( STR_REPLCELLSWARN ) ), true )
68 {
69     SetHelpId( HID_SC_REPLCELLSWARN );
70 }
71 
IsDialogEnabled()72 bool ScReplaceWarnBox::IsDialogEnabled()
73 {
74     return SC_MOD()->GetInputOptions().GetReplaceCellsWarn() == sal_True;
75 }
76 
DisableDialog()77 void ScReplaceWarnBox::DisableDialog()
78 {
79     ScModule* pScMod = SC_MOD();
80     ScInputOptions aInputOpt( pScMod->GetInputOptions() );
81     aInputOpt.SetReplaceCellsWarn( sal_False );
82     pScMod->SetInputOptions( aInputOpt );
83 }
84 
85 
86 // ============================================================================
87 
88