Update ooo320-m1
[ooovba.git] / sc / source / ui / miscdlgs / namepast.cxx
blob2478e3220b14818e1973c5d8d27fbd7cfec1b7ef
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: namepast.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #undef SC_DLLIMPLEMENTATION
38 //------------------------------------------------------------------
40 #include "namepast.hxx"
41 #include "scresid.hxx"
42 #include "miscdlgs.hrc"
43 #include "rangenam.hxx"
46 //==================================================================
48 ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, BOOL bInsList )
49 : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
50 aLabelText ( this, ScResId( FT_LABEL ) ),
51 aNameList ( this, ScResId( LB_ENTRYLIST ) ),
52 aOKButton ( this, ScResId( BTN_OK ) ),
53 aCancelButton ( this, ScResId( BTN_CANCEL ) ),
54 aHelpButton ( this, ScResId( BTN_HELP ) ),
55 aInsListButton ( this, ScResId( BTN_ADD ) )
57 if( ! bInsList )
58 aInsListButton.Disable();
60 aInsListButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
61 aOKButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
62 aNameList.SetSelectHdl( LINK( this,ScNamePasteDlg,ListSelHdl) );
63 aNameList.SetDoubleClickHdl( LINK( this,ScNamePasteDlg,ListDblClickHdl) );
65 USHORT nCnt = pList->GetCount();
66 String aText;
68 for( USHORT i=0 ; i<nCnt ; i++ )
70 ScRangeData* pData = (*pList)[ i ];
72 if( pData )
74 if ( !pData->HasType( RT_DATABASE )
75 && !pData->HasType( RT_SHARED ) )
77 pData->GetName( aText );
78 aNameList.InsertEntry( aText );
83 ListSelHdl( &aNameList );
85 FreeResource();
88 //------------------------------------------------------------------
90 IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
92 if( pButton == &aInsListButton )
94 EndDialog( BTN_PASTE_LIST );
96 else if( pButton == &aOKButton )
98 EndDialog( BTN_PASTE_NAME );
100 return 0;
103 //------------------------------------------------------------------
105 IMPL_LINK( ScNamePasteDlg, ListSelHdl, ListBox *, pListBox )
107 if( pListBox == &aNameList )
109 if( aNameList.GetSelectEntryCount() )
110 aOKButton.Enable();
111 else
112 aOKButton.Disable();
114 return 0;
117 //------------------------------------------------------------------
119 IMPL_LINK_INLINE_START( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
121 if( pListBox == &aNameList )
123 ButtonHdl( &aOKButton );
125 return 0;
127 IMPL_LINK_INLINE_END( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
129 //------------------------------------------------------------------
131 String ScNamePasteDlg::GetSelectedName() const
133 return aNameList.GetSelectEntry();