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 "namepast.hxx" 38 #include "scresid.hxx" 39 #include "miscdlgs.hrc" 40 #include "rangenam.hxx" 41 42 43 //================================================================== 44 45 ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, sal_Bool bInsList ) 46 : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ), 47 aLabelText ( this, ScResId( FT_LABEL ) ), 48 aNameList ( this, ScResId( LB_ENTRYLIST ) ), 49 aOKButton ( this, ScResId( BTN_OK ) ), 50 aCancelButton ( this, ScResId( BTN_CANCEL ) ), 51 aHelpButton ( this, ScResId( BTN_HELP ) ), 52 aInsListButton ( this, ScResId( BTN_ADD ) ) 53 { 54 if( ! bInsList ) 55 aInsListButton.Disable(); 56 57 aInsListButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) ); 58 aOKButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) ); 59 aNameList.SetSelectHdl( LINK( this,ScNamePasteDlg,ListSelHdl) ); 60 aNameList.SetDoubleClickHdl( LINK( this,ScNamePasteDlg,ListDblClickHdl) ); 61 62 sal_uInt16 nCnt = pList->GetCount(); 63 String aText; 64 65 for( sal_uInt16 i=0 ; i<nCnt ; i++ ) 66 { 67 ScRangeData* pData = (*pList)[ i ]; 68 69 if( pData ) 70 { 71 if ( !pData->HasType( RT_DATABASE ) 72 && !pData->HasType( RT_SHARED ) ) 73 { 74 pData->GetName( aText ); 75 aNameList.InsertEntry( aText ); 76 } 77 } 78 } 79 80 ListSelHdl( &aNameList ); 81 82 FreeResource(); 83 } 84 85 //------------------------------------------------------------------ 86 87 IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton ) 88 { 89 if( pButton == &aInsListButton ) 90 { 91 EndDialog( BTN_PASTE_LIST ); 92 } 93 else if( pButton == &aOKButton ) 94 { 95 EndDialog( BTN_PASTE_NAME ); 96 } 97 return 0; 98 } 99 100 //------------------------------------------------------------------ 101 102 IMPL_LINK( ScNamePasteDlg, ListSelHdl, ListBox *, pListBox ) 103 { 104 if( pListBox == &aNameList ) 105 { 106 if( aNameList.GetSelectEntryCount() ) 107 aOKButton.Enable(); 108 else 109 aOKButton.Disable(); 110 } 111 return 0; 112 } 113 114 //------------------------------------------------------------------ 115 116 IMPL_LINK_INLINE_START( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox ) 117 { 118 if( pListBox == &aNameList ) 119 { 120 ButtonHdl( &aOKButton ); 121 } 122 return 0; 123 } 124 IMPL_LINK_INLINE_END( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox ) 125 126 //------------------------------------------------------------------ 127 128 String ScNamePasteDlg::GetSelectedName() const 129 { 130 return aNameList.GetSelectEntry(); 131 } 132 133 134