1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 #undef SC_DLLIMPLEMENTATION 32 33 34 35 //------------------------------------------------------------------ 36 37 #include "delcodlg.hxx" 38 #include "scresid.hxx" 39 #include "miscdlgs.hrc" 40 41 42 //================================================================== 43 44 sal_Bool ScDeleteContentsDlg::bPreviousAllCheck = sal_False; 45 sal_uInt16 ScDeleteContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING | 46 IDF_NOTE | IDF_FORMULA | 47 IDF_VALUE); 48 49 //----------------------------------------------------------------------- 50 51 ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent, 52 sal_uInt16 nCheckDefaults ) : 53 ModalDialog ( pParent, ScResId( RID_SCDLG_DELCONT ) ), 54 // 55 aFlFrame ( this, ScResId( FL_FRAME ) ), 56 aBtnDelAll ( this, ScResId( BTN_DELALL ) ), 57 aBtnDelStrings ( this, ScResId( BTN_DELSTRINGS ) ), 58 aBtnDelNumbers ( this, ScResId( BTN_DELNUMBERS ) ), 59 aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ), 60 aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ), 61 aBtnDelNotes ( this, ScResId( BTN_DELNOTES ) ), 62 aBtnDelAttrs ( this, ScResId( BTN_DELATTRS ) ), 63 aBtnDelObjects ( this, ScResId( BTN_DELOBJECTS ) ), 64 aBtnOk ( this, ScResId( BTN_OK ) ), 65 aBtnCancel ( this, ScResId( BTN_CANCEL ) ), 66 aBtnHelp ( this, ScResId( BTN_HELP ) ), 67 bObjectsDisabled( sal_False ) 68 { 69 if ( nCheckDefaults != 0 ) 70 { 71 ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults; 72 ScDeleteContentsDlg::bPreviousAllCheck = sal_False; 73 } 74 75 aBtnDelAll.Check ( ScDeleteContentsDlg::bPreviousAllCheck ); 76 aBtnDelStrings.Check ( IS_SET( IDF_STRING, 77 ScDeleteContentsDlg::nPreviousChecks ) ); 78 aBtnDelNumbers.Check ( IS_SET( IDF_VALUE, 79 ScDeleteContentsDlg::nPreviousChecks ) ); 80 aBtnDelDateTime.Check( IS_SET( IDF_DATETIME, 81 ScDeleteContentsDlg::nPreviousChecks ) ); 82 aBtnDelFormulas.Check( IS_SET( IDF_FORMULA, 83 ScDeleteContentsDlg::nPreviousChecks ) ); 84 aBtnDelNotes.Check ( IS_SET( IDF_NOTE, 85 ScDeleteContentsDlg::nPreviousChecks ) ); 86 aBtnDelAttrs.Check ( IS_SET( IDF_ATTRIB, 87 ScDeleteContentsDlg::nPreviousChecks ) ); 88 aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS, 89 ScDeleteContentsDlg::nPreviousChecks ) ); 90 91 DisableChecks( aBtnDelAll.IsChecked() ); 92 93 aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) ); 94 95 //------------- 96 FreeResource(); 97 } 98 99 //------------------------------------------------------------------------ 100 101 sal_uInt16 ScDeleteContentsDlg::GetDelContentsCmdBits() const 102 { 103 ScDeleteContentsDlg::nPreviousChecks = 0; 104 105 if ( aBtnDelStrings.IsChecked() ) 106 ScDeleteContentsDlg::nPreviousChecks = IDF_STRING; 107 if ( aBtnDelNumbers.IsChecked() ) 108 ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE; 109 if ( aBtnDelDateTime.IsChecked()) 110 ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME; 111 if ( aBtnDelFormulas.IsChecked()) 112 ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA; 113 if ( aBtnDelNotes.IsChecked() ) 114 ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE; 115 if ( aBtnDelAttrs.IsChecked() ) 116 ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB; 117 if ( aBtnDelObjects.IsChecked() ) 118 ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS; 119 120 ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked(); 121 122 return ( (ScDeleteContentsDlg::bPreviousAllCheck) 123 ? IDF_ALL 124 : ScDeleteContentsDlg::nPreviousChecks ); 125 } 126 127 //------------------------------------------------------------------------ 128 129 void ScDeleteContentsDlg::DisableChecks( sal_Bool bDelAllChecked ) 130 { 131 if ( bDelAllChecked ) 132 { 133 aBtnDelStrings.Disable(); 134 aBtnDelNumbers.Disable(); 135 aBtnDelDateTime.Disable(); 136 aBtnDelFormulas.Disable(); 137 aBtnDelNotes.Disable(); 138 aBtnDelAttrs.Disable(); 139 aBtnDelObjects.Disable(); 140 } 141 else 142 { 143 aBtnDelStrings.Enable(); 144 aBtnDelNumbers.Enable(); 145 aBtnDelDateTime.Enable(); 146 aBtnDelFormulas.Enable(); 147 aBtnDelNotes.Enable(); 148 aBtnDelAttrs.Enable(); 149 if (bObjectsDisabled) 150 aBtnDelObjects.Disable(); 151 else 152 aBtnDelObjects.Enable(); 153 } 154 } 155 156 //------------------------------------------------------------------------ 157 158 void ScDeleteContentsDlg::DisableObjects() 159 { 160 bObjectsDisabled = sal_True; 161 aBtnDelObjects.Check(sal_False); 162 aBtnDelObjects.Disable(); 163 } 164 165 //------------------------------------------------------------------------ 166 167 IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG ) 168 { 169 DisableChecks( aBtnDelAll.IsChecked() ); 170 171 return 0; 172 } 173 IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG ) 174 175 __EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg() 176 { 177 } 178 179 180 181