xref: /trunk/main/sc/source/ui/namedlg/namedlg.cxx (revision dffa72de)
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 
27 // System - Includes ---------------------------------------------------------
28 
29 
30 
31 // INCLUDE -------------------------------------------------------------------
32 
33 #include "global.hxx"
34 #include "reffact.hxx"
35 #include "document.hxx"
36 #include "docfunc.hxx"
37 #include "scresid.hxx"
38 #include "globstr.hrc"
39 #include "namedlg.hrc"
40 
41 #define _NAMEDLG_CXX
42 #include "namedlg.hxx"
43 #undef _NAMEDLG_CXX
44 #include <vcl/msgbox.hxx>
45 
46 
47 
48 // defines -------------------------------------------------------------------
49 
50 #define ABS_SREF		  SCA_VALID \
51 						| SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
52 #define ABS_DREF		  ABS_SREF \
53 						| SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
54 #define ABS_SREF3D		ABS_SREF | SCA_TAB_3D
55 #define ABS_DREF3D		ABS_DREF | SCA_TAB_3D
56 
57 const sal_uInt16  SHEETNAMEPOS = 33;
58 
59 //============================================================================
60 // Hilfsklasse: Merken der aktuellen Bereichsoptionen,
61 // wenn ein Name in der ComboBox gefunden wird.
62 
63 struct SaveData
64 {
SaveDataSaveData65 	SaveData()
66 		: bCriteria(sal_False),bPrintArea(sal_False),
67 		  bColHeader(sal_False),bRowHeader(sal_False),
68 		  bDirty(sal_False) {}
69 
ClearSaveData70 	void Clear()
71 		{
72 			aStrSymbol.Erase();
73 			bCriteria  = bPrintArea =
74 			bColHeader = bRowHeader = sal_False;
75 			bDirty = sal_True;
76 		}
77 
78 	String	aStrSymbol;
79 	sal_Bool	bCriteria:1;
80 	sal_Bool	bPrintArea:1;
81 	sal_Bool	bColHeader:1;
82 	sal_Bool	bRowHeader:1;
83 	sal_Bool	bDirty:1;
84 };
85 
86 static SaveData* pSaveObj = NULL;
87 
88 #define SAVE_DATA() \
89 	pSaveObj->aStrSymbol = aEdAssign.GetText(); 		\
90 	pSaveObj->bCriteria  = aBtnCriteria.IsChecked();	\
91 	pSaveObj->bPrintArea = aBtnPrintArea.IsChecked();	\
92 	pSaveObj->bColHeader = aBtnColHeader.IsChecked();	\
93 	pSaveObj->bRowHeader = aBtnRowHeader.IsChecked();	\
94 	pSaveObj->bDirty	 = sal_True;
95 
96 #define RESTORE_DATA() \
97 	if ( pSaveObj->bDirty ) 							\
98 	{													\
99 		aEdAssign.SetText( pSaveObj->aStrSymbol );		\
100 		aBtnCriteria.Check( pSaveObj->bCriteria );		\
101 		aBtnPrintArea.Check( pSaveObj->bPrintArea );	\
102 		aBtnColHeader.Check( pSaveObj->bColHeader );	\
103 		aBtnRowHeader.Check( pSaveObj->bRowHeader );	\
104 		pSaveObj->bDirty = sal_False;						\
105 	}
106 
107 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
108 
109 
110 //============================================================================
111 //	class ScNameDlg
112 
113 //----------------------------------------------------------------------------
114 
ScNameDlg(SfxBindings * pB,SfxChildWindow * pCW,Window * pParent,ScViewData * ptrViewData,const ScAddress & aCursorPos)115 ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
116 					  ScViewData*		ptrViewData,
117 					  const ScAddress&	aCursorPos )
118 
119 	:	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_NAMES ),
120 		//
121         aFlName         ( this, ScResId( FL_NAME ) ),
122 		aEdName 		( this, ScResId( ED_NAME ) ),
123 		aLBNames 		( this, ScResId( LB_NAMES ) ),
124 		//
125         aFlAssign       ( this, ScResId( FL_ASSIGN ) ),
126         aEdAssign       ( this, this, ScResId( ED_ASSIGN ) ),
127 		aRbAssign		( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
128 		//
129 		aFlType 		( this, ScResId( FL_TYPE ) ),
130 		aBtnPrintArea	( this, ScResId( BTN_PRINTAREA ) ),
131 		aBtnColHeader	( this, ScResId( BTN_COLHEADER ) ),
132 		aBtnCriteria	( this, ScResId( BTN_CRITERIA ) ),
133 		aBtnRowHeader	( this, ScResId( BTN_ROWHEADER ) ),
134 		//
135 		aBtnOk			( this, ScResId( BTN_OK ) ),
136 		aBtnCancel		( this, ScResId( BTN_CANCEL ) ),
137 		aBtnHelp		( this, ScResId( BTN_HELP ) ),
138 		aBtnAdd 		( this, ScResId( BTN_ADD ) ),
139 		aBtnRemove		( this, ScResId( BTN_REMOVE ) ),
140 		aBtnMore		( this, ScResId( BTN_MORE ) ),
141 		//
142 		bSaved			(sal_False),
143 		aStrAdd 		( ScResId( STR_ADD ) ),
144 		aStrModify		( ScResId( STR_MODIFY ) ),
145 		errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
146 		//
147 		pViewData		( ptrViewData ),
148 		pDoc			( ptrViewData->GetDocument() ),
149 		aLocalRangeName ( *(pDoc->GetRangeName()) ),
150 		theCursorPos	( aCursorPos ),  // zum Berechnen der Referenzen
151 		aSelectedRangeScope(MAXTABCOUNT)
152 {
153 	pSaveObj = new SaveData;
154 	Init();
155 	FreeResource();
156 
157 	aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
158 }
159 
160 
161 //----------------------------------------------------------------------------
162 
~ScNameDlg()163 __EXPORT ScNameDlg::~ScNameDlg()
164 {
165 	DELETEZ( pSaveObj );
166 }
167 
168 
169 //----------------------------------------------------------------------------
170 
Init()171 void __EXPORT ScNameDlg::Init()
172 {
173 	String	aAreaStr;
174 	ScRange aRange;
175 
176 	DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
177 
178 	aBtnOk.SetClickHdl		( LINK( this, ScNameDlg, OkBtnHdl ) );
179 	aBtnCancel.SetClickHdl	( LINK( this, ScNameDlg, CancelBtnHdl ) );
180 	aBtnAdd.SetClickHdl		( LINK( this, ScNameDlg, AddBtnHdl ) );
181 	aBtnRemove.SetClickHdl	( LINK( this, ScNameDlg, RemoveBtnHdl ) );
182 	aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
183 	aEdAssign.SetModifyHdl	( LINK( this, ScNameDlg, EdModifyHdl ) );
184 	aEdName.SetModifyHdl 	( LINK( this, ScNameDlg, EdModifyHdl ) );
185 	aLBNames.SetSelectHdl 	( LINK( this, ScNameDlg, NameSelectHdl ) );
186 
187 	aBtnCriteria .Hide();
188 	aBtnPrintArea.Hide();
189 	aBtnColHeader.Hide();
190 	aBtnRowHeader.Hide();
191 
192 	aBtnMore.AddWindow( &aFlType );
193 	aBtnMore.AddWindow( &aBtnCriteria );
194 	aBtnMore.AddWindow( &aBtnPrintArea );
195 	aBtnMore.AddWindow( &aBtnColHeader );
196 	aBtnMore.AddWindow( &aBtnRowHeader );
197 
198 	UpdateNames();
199 
200 	pViewData->GetSimpleArea( aRange );
201 	aRange.Format( aAreaStr, ABS_DREF3D, pDoc,
202                    ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) );
203 
204 	theCurSel = Selection( 0, SELECTION_MAX );
205 	aEdAssign.GrabFocus();
206 	aEdAssign.SetText( aAreaStr );
207 	aEdAssign.SetSelection( theCurSel );
208 	aEdName.GrabFocus();
209 
210 	aBtnAdd.Disable();
211 	aBtnRemove.Disable();
212 	//if ( aEdName.GetEntryCount() > 0 )
213 	if ( aLBNames.GetEntryCount() > 0 )
214 		aBtnAdd.SetText( aStrAdd );
215 	UpdateChecks();
216 	EdModifyHdl( 0 );
217 
218 	bSaved=sal_True;
219 	SAVE_DATA()
220 
221 	//@BugID 54702
222 	//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
223 }
224 
225 //----------------------------------------------------------------------------
IsRefInputMode() const226 sal_Bool ScNameDlg::IsRefInputMode() const
227 {
228 	return aEdAssign.IsEnabled();
229 }
230 
RefInputDone(sal_Bool bForced)231 void ScNameDlg::RefInputDone( sal_Bool bForced)
232 {
233 	ScAnyRefDlg::RefInputDone(bForced);
234 	EdModifyHdl(&aEdAssign);
235 }
236 //----------------------------------------------------------------------------
237 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
238 // neue Selektion im Referenz-Edit angezeigt wird.
239 
240 
SetReference(const ScRange & rRef,ScDocument * pDocP)241 void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
242 {
243 	if ( aEdAssign.IsEnabled() )
244 	{
245 		if ( rRef.aStart != rRef.aEnd )
246 			RefInputStart(&aEdAssign);
247 		String aRefStr;
248         rRef.Format( aRefStr, ABS_DREF3D, pDocP,
249                      ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) );
250 		aEdAssign.SetRefString( aRefStr );
251 	}
252 }
253 
254 
255 //----------------------------------------------------------------------------
Close()256 sal_Bool __EXPORT ScNameDlg::Close()
257 {
258 	return DoClose( ScNameDlgWrapper::GetChildWindowId() );
259 }
260 
261 
262 //----------------------------------------------------------------------------
263 
SetActive()264 void ScNameDlg::SetActive()
265 {
266 	aEdAssign.GrabFocus();
267 	RefInputDone();
268 }
269 
270 
271 //----------------------------------------------------------------------------
272 
UpdateChecks()273 void __EXPORT ScNameDlg::UpdateChecks()
274 {
275 	sal_uInt16		 nCurPos=0;
276 
277 	if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos, aSelectedRangeScope))
278 	{
279 		ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos ));
280 		aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
281 		aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
282 		aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
283 		aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
284 	}
285 
286 	// Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren:
287 
288 	if ( aEdName.GetText().Len() != 0 )
289 	{
290 		if ( !aFlType.IsEnabled() )
291 		{
292 			aFlType.Enable();
293 			aBtnCriteria .Enable();
294 			aBtnPrintArea.Enable();
295 			aBtnColHeader.Enable();
296 			aBtnRowHeader.Enable();
297                         aFlAssign.Enable();
298 			aEdAssign.Enable();
299 			aRbAssign.Enable();
300 		}
301 	}
302 	else if ( aFlType.IsEnabled() )
303 	{
304 		aFlType.Disable();
305 		aBtnCriteria.Disable();
306 		aBtnPrintArea.Disable();
307 		aBtnColHeader.Disable();
308 		aBtnRowHeader.Disable();
309                 aFlAssign.Disable();
310 		aEdAssign.Disable();
311 		aRbAssign.Disable();
312 	}
313 }
314 
315 
316 //----------------------------------------------------------------------------
317 
UpdateNames()318 void __EXPORT ScNameDlg::UpdateNames()
319 {
320 	sal_uInt16	nRangeCount = aLocalRangeName.GetCount();
321 
322 	//aEdName.SetUpdateMode( FALSE );
323 	aLBNames.SetUpdateMode( false );
324 	//-----------------------------------------------------------
325 	//USHORT  nNamePos = aEdName.GetTopEntry();
326 	//aEdName.Clear();
327 	sal_uInt16  nNamePos = aLBNames.GetTopEntry();
328 	aLBNames.Clear();
329 
330 	aEdAssign.SetText( EMPTY_STRING );
331 
332 	if ( nRangeCount > 0 )
333 	{
334 		ScRangeData*	pRangeData = NULL;
335 		String			aString;
336                 SCTAB tabIndex = 0;
337 
338 		for ( sal_uInt16 i=0; i<nRangeCount; i++ )
339 		{
340 			pRangeData = (ScRangeData*)(aLocalRangeName.At( i ));
341 			if ( pRangeData )
342 			{
343 				if (   !pRangeData->HasType( RT_DATABASE )
344 					&& !pRangeData->HasType( RT_SHARED ) )
345 				{
346 					pRangeData->GetName( aString );
347 					if ( (tabIndex = pRangeData->GetRangeScope() ) != MAXTABCOUNT)
348 					{
349                                                  String tabName;
350 							pDoc->GetName(tabIndex,tabName);
351 							if (aString.Len() < SHEETNAMEPOS)
352 								aString.Expand(SHEETNAMEPOS);
353 							else
354 								aString.AppendAscii( " ");
355 							aString.AppendAscii( "(");
356 							aString += tabName;
357 							aString.AppendAscii( ")");
358 					}
359 
360 					//aEdName.InsertEntry( aString );
361                                    aLBNames.InsertEntry( aString );
362 				}
363 			}
364 		}
365 	}
366 	else
367 	{
368 		aBtnAdd.SetText( aStrAdd );
369 		aBtnAdd.Disable();
370 		aBtnRemove.Disable();
371 	}
372 	//-----------------------------------------------------------
373 	//aEdName.SetUpdateMode( TRUE );
374 	//aEdName.SetTopEntry(nNamePos);
375 	//aEdName.Invalidate();
376 	aLBNames.SetUpdateMode( true );
377 	aLBNames.SetTopEntry(nNamePos);
378 	aLBNames.Invalidate();
379 }
380 
381 
382 //----------------------------------------------------------------------------
383 
CalcCurTableAssign(String & aAssign,sal_uInt16 nCurPos)384 void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, sal_uInt16 nCurPos )
385 {
386 	ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos ));
387 
388 	if ( pRangeData )
389 	{
390         rtl::OUStringBuffer sBuffer;
391 		pRangeData->UpdateSymbol( sBuffer, theCursorPos );
392         aAssign = sBuffer;
393 	}
394 	else
395 	{
396 		aAssign.Erase();
397 	}
398 }
399 
400 
401 //----------------------------------------------------------------------------
402 // Handler:
403 // ========
404 
IMPL_LINK(ScNameDlg,OkBtnHdl,void *,EMPTYARG)405 IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
406 {
407 	if ( aBtnAdd.IsEnabled() )
408 		AddBtnHdl( 0 );
409 
410 	if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() )
411 	{
412 		ScDocShell* pDocSh = pViewData->GetDocShell();
413 		ScDocFunc aFunc(*pDocSh);
414 		aFunc.ModifyRangeNames( aLocalRangeName, sal_False );
415 		Close();
416 	}
417 	return 0;
418 }
419 
420 
421 //----------------------------------------------------------------------------
422 
IMPL_LINK_INLINE_START(ScNameDlg,CancelBtnHdl,void *,EMPTYARG)423 IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
424 {
425 	Close();
426 	return 0;
427 }
IMPL_LINK_INLINE_END(ScNameDlg,CancelBtnHdl,void *,EMPTYARG)428 IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
429 
430 
431 //----------------------------------------------------------------------------
432 
433 IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
434 {
435 	sal_Bool	bAdded	  = sal_False;
436 	String	aNewEntry = aEdName.GetText();
437 	//USHORT  nNamePos = aEdName.GetTopEntry();
438         sal_uInt16  nNamePos = aLBNames.GetTopEntry();
439 	aNewEntry.EraseLeadingChars( ' ' );
440 	aNewEntry.EraseTrailingChars( ' ' );
441 
442 	if ( aNewEntry.Len() > 0 )
443 	{
444 		if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) )
445 		{
446 			if ( pDoc )
447 			{
448 				ScRangeData*	pNewEntry	= NULL;
449 				RangeType		nType		= RT_NAME;
450 				sal_uInt16			nFoundAt	= 0;
451 				String			theSymbol	= aEdAssign.GetText();
452 				String			aStrPos;
453 				String			aStrArea;
454 
455 				pNewEntry = new ScRangeData( pDoc,
456 											 aNewEntry,
457 											 theSymbol,
458 											 theCursorPos,
459 											 nType );
460 				if (aBtnAdd.GetText() == aStrModify)
461 					pNewEntry->SetRangeScope(aSelectedRangeScope);
462 				else
463 					aSelectedRangeScope = MAXTABCOUNT;
464 				if (pNewEntry)
465 				{
466 					nType = nType
467 					| (aBtnRowHeader .IsChecked() ? RT_ROWHEADER  : RangeType(0))
468 					| (aBtnColHeader .IsChecked() ? RT_COLHEADER  : RangeType(0))
469 					| (aBtnPrintArea .IsChecked() ? RT_PRINTAREA  : RangeType(0))
470 					| (aBtnCriteria  .IsChecked() ? RT_CRITERIA   : RangeType(0));
471 					pNewEntry->AddType(nType);
472 				}
473 
474 				// theSymbol gueltig?
475 				// (= konnte theSymbol im ScRangeData-Ctor
476 				//	  in ein Token-Array uebersetzt werden?)
477 				if ( 0 == pNewEntry->GetErrCode() )
478 				{
479 					// Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
480 					if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt, aSelectedRangeScope ) )
481 					{									// alten Index uebernehmen
482 						pNewEntry->SetIndex(
483 							((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() );
484 						aLocalRangeName.AtFree( nFoundAt );
485 					}
486 					else
487 						pSaveObj->Clear();
488 
489 					if ( !aLocalRangeName.Insert( pNewEntry ) )
490 						delete pNewEntry;
491 
492 					UpdateNames();
493 					bSaved=sal_False;
494 					RESTORE_DATA()
495 					aEdName.SetText(EMPTY_STRING);
496 					aEdName.GrabFocus();
497 					UpdateChecks();
498 					aBtnAdd.SetText( aStrAdd );
499 					aBtnAdd.Disable();
500 					aBtnRemove.Disable();
501 
502 					//@BugID 54702 raus mit dem Sch.
503 					//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
504 
505 					bAdded = sal_True;
506 				}
507 				else // theSymbol ungueltig
508 				{
509 					delete pNewEntry;
510 					ERRORBOX( errMsgInvalidSym );
511 					theCurSel = Selection( 0, SELECTION_MAX );
512 					aEdAssign.GrabFocus();
513 				}
514 			}
515 		}
516 		else
517 		{
518 			ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
519 			aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
520 			aEdName.GrabFocus();
521 		}
522 	}
523 
524     //aEdName.SetTopEntry(nNamePos);
525 	aLBNames.SetTopEntry(nNamePos);
526 	return bAdded;
527 }
528 
529 
530 //----------------------------------------------------------------------------
531 
IMPL_LINK(ScNameDlg,RemoveBtnHdl,void *,EMPTYARG)532 IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
533 {
534 	sal_uInt16		 nRemoveAt = 0;
535 	const String aStrEntry = aEdName.GetText();
536 
537 	if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt, aSelectedRangeScope ) )
538 	{
539 		String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
540 		String aMsg		  = aStrDelMsg.GetToken( 0, '#' );
541 
542 		aMsg += aStrEntry;
543 		aMsg += aStrDelMsg.GetToken( 1, '#' );
544 
545 		if ( RET_YES ==
546 			 QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
547 		{
548 			aLocalRangeName.AtFree( nRemoveAt );
549 			UpdateNames();
550 			UpdateChecks();
551 			bSaved=sal_False;
552 			RESTORE_DATA()
553 			theCurSel = Selection( 0, SELECTION_MAX );
554 			aEdName.SetText(EMPTY_STRING);
555 			aBtnAdd.SetText( aStrAdd );
556 			aBtnAdd.Disable();
557 			aBtnRemove.Disable();
558 		}
559 	}
560 	return 0;
561 }
562 
563 
564 //----------------------------------------------------------------------------
565 
IMPL_LINK(ScNameDlg,NameSelectHdl,void *,EMPTYARG)566 IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
567 {
568 	sal_uInt16 nAtPos;
569        String rangeName = aLBNames.GetSelectEntry();
570        if ( ')' == rangeName.GetChar(rangeName.Len()-1) )
571        {
572             xub_StrLen sheetNamePos = rangeName.Search('(');
573 	     String sheetName(rangeName, sheetNamePos+1, rangeName.Len()-2-sheetNamePos);
574             pDoc->GetTable(sheetName,aSelectedRangeScope);
575 	     rangeName.Erase(sheetNamePos);
576 	     rangeName.EraseTrailingChars();
577 
578 	}
579 	else
580            aSelectedRangeScope = MAXTABCOUNT;
581 
582 	//if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) )
583 	if ( aLocalRangeName.SearchName( rangeName, nAtPos, aSelectedRangeScope ) )
584 	{
585 		String		 aSymbol;
586 		ScRangeData* pData	= (ScRangeData*)(aLocalRangeName.At( nAtPos ));
587 
588 		if ( pData )
589 		{
590 			pData->GetSymbol( aSymbol );
591 			CalcCurTableAssign( aSymbol, nAtPos );
592 	   		aEdAssign.SetText( aSymbol );
593 			aBtnAdd.SetText( aStrModify );
594 			aEdName.SetText(rangeName);
595 			theCurSel = Selection( 0, SELECTION_MAX );
596 			aBtnAdd.SetText( aStrModify );
597 			aBtnAdd.Enable();
598 			aBtnRemove.Enable();
599 		}
600 	}
601 	UpdateChecks();
602 	return 0;
603 }
604 
605 
606 //----------------------------------------------------------------------------
607 
IMPL_LINK(ScNameDlg,EdModifyHdl,Edit *,pEd)608 IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd )
609 {
610 	String	theName 	= aEdName.GetText();
611 	String	theSymbol	= aEdAssign.GetText();
612  bool	bNameFound	= (LISTBOX_ENTRY_NOTFOUND
613 						   != aLBNames.GetEntryPos( theName ));
614 
615 	if ( pEd == &aEdName )
616 	{
617 		if ( theName.Len() == 0 )
618 		{
619 			if ( aBtnAdd.GetText() != aStrAdd )
620 				aBtnAdd.SetText( aStrAdd );
621 			aBtnAdd.Disable();
622 			aBtnRemove.Disable();
623             aFlAssign.Disable();
624 			aEdAssign.Disable();
625 			aRbAssign.Disable();
626 			//@BugID 54702 raus mit dem Sch.
627 			//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
628 		}
629 		else
630 		{
631 		 /*
632 			if ( bNameFound )
633 			{
634 				if ( aBtnAdd.GetText() != aStrModify )
635 					aBtnAdd.SetText( aStrModify );
636 
637 				aBtnRemove.Enable();
638 
639 				if(!bSaved)
640 				{
641 					bSaved=TRUE;
642 					SAVE_DATA()
643 				}
644 				NameSelectHdl( 0 );
645 			}
646 			else
647 			{
648 				if ( aBtnAdd.GetText() != aStrAdd )
649 					aBtnAdd.SetText( aStrAdd );
650 				aBtnRemove.Disable();
651 
652 				bSaved=FALSE;
653 				RESTORE_DATA()
654 			}
655 			*/
656 
657 		       if ( aBtnAdd.GetText() != aStrAdd )
658 			    aBtnAdd.SetText( aStrAdd );
659 			theSymbol = aEdAssign.GetText();
660 
661 			if ( theSymbol.Len() > 0 )
662 				aBtnAdd.Enable();
663 			else
664 				aBtnAdd.Disable();
665 
666             aFlAssign.Enable();
667 			aEdAssign.Enable();
668 			aRbAssign.Enable();
669 			aBtnRemove.Disable();
670 			//@BugID 54702 raus mit dem Sch.
671 			//SFX_APPWINDOW->Enable();
672 		}
673 		UpdateChecks();
674 		theCurSel = Selection( 0, SELECTION_MAX );
675 	}
676 	else if ( pEd == &aEdAssign )
677 	{
678 		if ( (theName.Len()>0) && (theSymbol.Len()>0) )
679 		{
680 			aBtnAdd.Enable();
681 			if ( bNameFound )
682 				aBtnRemove.Enable();
683 		}
684 		else
685 		{
686 			aBtnAdd.Disable();
687 			aBtnRemove.Disable();
688 		}
689 	}
690 	return 0;
691 }
692 
693 //------------------------------------------------------------------------
694 
IMPL_LINK_INLINE_START(ScNameDlg,AssignGetFocusHdl,void *,EMPTYARG)695 IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
696 {
697 	EdModifyHdl( &aEdAssign );
698 	return 0;
699 }
700 IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
701 
702 
703