xref: /aoo41x/main/sc/source/ui/dbgui/dbnamdlg.cxx (revision cdf0e10c)
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 // System - Includes ---------------------------------------------------------
32 
33 
34 
35 // INCLUDE -------------------------------------------------------------------
36 
37 #include <vcl/msgbox.hxx>
38 
39 #include "reffact.hxx"
40 #include "document.hxx"
41 #include "scresid.hxx"
42 #include "globstr.hrc"
43 #include "dbnamdlg.hrc"
44 #include "rangenam.hxx"		// IsNameValid
45 
46 #define _DBNAMDLG_CXX
47 #include "dbnamdlg.hxx"
48 #undef _DBNAMDLG_CXX
49 
50 
51 //============================================================================
52 
53 #define ABS_SREF		  SCA_VALID \
54 						| SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
55 #define ABS_DREF		  ABS_SREF \
56 						| SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
57 #define ABS_SREF3D		ABS_SREF | SCA_TAB_3D
58 #define ABS_DREF3D		ABS_DREF | SCA_TAB_3D
59 
60 //----------------------------------------------------------------------------
61 
62 class DBSaveData;
63 
64 static DBSaveData* pSaveObj = NULL;
65 
66 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
67 #define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
68 
69 //============================================================================
70 //	class DBSaveData
71 
72 class DBSaveData
73 {
74 public:
75 	DBSaveData( Edit& rEd, CheckBox& rHdr, CheckBox& rSize, CheckBox& rFmt,
76 							CheckBox& rStrip, ScRange& rArea )
77         : rEdAssign(rEd),
78           rBtnHeader(rHdr), rBtnSize(rSize), rBtnFormat(rFmt), rBtnStrip(rStrip),
79           rCurArea(rArea),
80           bHeader(sal_False), bSize(sal_False), bFormat(sal_False), bDirty(sal_False) {}
81 	void Save();
82 	void Restore();
83 
84 private:
85 	Edit&		rEdAssign;
86 	CheckBox&	rBtnHeader;
87 	CheckBox&	rBtnSize;
88 	CheckBox&	rBtnFormat;
89 	CheckBox&	rBtnStrip;
90 	ScRange&	rCurArea;
91 	String		aStr;
92 	ScRange		aArea;
93 	sal_Bool		bHeader:1;
94 	sal_Bool		bSize:1;
95 	sal_Bool		bFormat:1;
96 	sal_Bool		bStrip:1;
97 	sal_Bool		bDirty:1;
98 };
99 
100 
101 
102 //----------------------------------------------------------------------------
103 
104 void DBSaveData::Save()
105 {
106 	aArea   = rCurArea;
107 	aStr    = rEdAssign.GetText();
108 	bHeader = rBtnHeader.IsChecked();
109 	bSize   = rBtnSize.IsChecked();
110 	bFormat = rBtnFormat.IsChecked();
111 	bStrip	= rBtnStrip.IsChecked();
112 	bDirty  = sal_True;
113 }
114 
115 
116 //----------------------------------------------------------------------------
117 
118 void DBSaveData::Restore()
119 {
120 	if ( bDirty )
121 	{
122 		rCurArea = aArea;
123 		rEdAssign.SetText( aStr );
124 		rBtnHeader.Check ( bHeader );
125 		rBtnSize.Check   ( bSize );
126 		rBtnFormat.Check ( bFormat );
127 		rBtnStrip.Check  ( bStrip );
128 		bDirty = sal_False;
129 	}
130 }
131 
132 
133 //============================================================================
134 //	class ScDbNameDlg
135 
136 //----------------------------------------------------------------------------
137 
138 ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
139 						  ScViewData*	ptrViewData )
140 
141 	:	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_DBNAMES ),
142 		//
143         aFlName         ( this, ScResId( FL_NAME ) ),
144 		aEdName			( this, ScResId( ED_NAME ) ),
145 
146         aFlAssign       ( this, ScResId( FL_ASSIGN ) ),
147         aEdAssign       ( this, this, ScResId( ED_DBAREA ) ),
148 		aRbAssign		( this, ScResId( RB_DBAREA ), &aEdAssign, this ),
149 
150         aFlOptions      ( this, ScResId( FL_OPTIONS ) ),
151 		aBtnHeader		( this, ScResId( BTN_HEADER ) ),
152 		aBtnDoSize		( this, ScResId( BTN_SIZE ) ),
153 		aBtnKeepFmt		( this, ScResId( BTN_FORMAT ) ),
154 		aBtnStripData	( this, ScResId( BTN_STRIPDATA ) ),
155 		aFTSource		( this, ScResId( FT_SOURCE ) ),
156 		aFTOperations	( this, ScResId( FT_OPERATIONS ) ),
157 
158 		aBtnOk			( this, ScResId( BTN_OK ) ),
159 		aBtnCancel		( this, ScResId( BTN_CANCEL ) ),
160 		aBtnHelp		( this, ScResId( BTN_HELP ) ),
161 		aBtnAdd			( this, ScResId( BTN_ADD ) ),
162 		aBtnRemove		( this, ScResId( BTN_REMOVE ) ),
163 		aBtnMore		( this, ScResId( BTN_MORE ) ),
164 
165 		aStrAdd			( ScResId( STR_ADD ) ),
166 		aStrModify		( ScResId( STR_MODIFY ) ),
167 		aStrNoName		( ScGlobal::GetRscString(STR_DB_NONAME) ),
168 		aStrInvalid		( ScResId( STR_DB_INVALID ) ),
169 		//
170 		pViewData		( ptrViewData ),
171 		pDoc			( ptrViewData->GetDocument() ),
172 		bRefInputMode	( sal_False ),
173         aAddrDetails    ( pDoc->GetAddressConvention(), 0, 0 ),
174 		aLocalDbCol		( *(pDoc->GetDBCollection()) )
175 {
176 	// WB_NOLABEL can't be set in resource...
177 	aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
178 	aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );
179 
180 	//	damit die Strings in der Resource bei den FixedTexten bleiben koennen:
181 	aStrSource		= aFTSource.GetText();
182 	aStrOperations	= aFTOperations.GetText();
183 
184 	pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
185 						aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
186 	Init();
187 	FreeResource();
188 	aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
189 }
190 
191 
192 //----------------------------------------------------------------------------
193 
194 __EXPORT ScDbNameDlg::~ScDbNameDlg()
195 {
196 	DELETEZ( pSaveObj );
197 
198 	ScRange* pEntry = (ScRange*)aRemoveList.First();
199 	while ( pEntry )
200 	{
201         aRemoveList.Remove( pEntry );
202         delete pEntry;
203 		pEntry = (ScRange*)aRemoveList.Next();
204 	}
205 }
206 
207 
208 //----------------------------------------------------------------------------
209 
210 void ScDbNameDlg::Init()
211 {
212 	aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
213 
214     aBtnMore.AddWindow( &aFlOptions );
215 	aBtnMore.AddWindow( &aBtnHeader );
216 	aBtnMore.AddWindow( &aBtnDoSize );
217 	aBtnMore.AddWindow( &aBtnKeepFmt );
218 	aBtnMore.AddWindow( &aBtnStripData );
219 	aBtnMore.AddWindow( &aFTSource );
220 	aBtnMore.AddWindow( &aFTOperations );
221 
222 	String	theAreaStr;
223 	SCCOL	nStartCol 	= 0;
224 	SCROW	nStartRow 	= 0;
225 	SCTAB	nStartTab 	= 0;
226 	SCCOL	nEndCol 	= 0;
227 	SCROW	nEndRow		= 0;
228 	SCTAB	nEndTab 	= 0;
229 
230 	aBtnOk.SetClickHdl		( LINK( this, ScDbNameDlg, OkBtnHdl ) );
231 	aBtnCancel.SetClickHdl	( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
232 	aBtnAdd.SetClickHdl		( LINK( this, ScDbNameDlg, AddBtnHdl ) );
233 	aBtnRemove.SetClickHdl	( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
234 	aEdName.SetModifyHdl	( LINK( this, ScDbNameDlg, NameModifyHdl ) );
235 	aEdAssign.SetModifyHdl	( LINK( this, ScDbNameDlg, AssModifyHdl ) );
236 	UpdateNames();
237 
238 	if ( pViewData && pDoc )
239 	{
240 		ScDBCollection*	pDBColl	= pDoc->GetDBCollection();
241 		ScDBData*		pDBData = NULL;
242 
243 		pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
244 								  nEndCol,	 nEndRow,  nEndTab );
245 
246 		theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
247 							  ScAddress( nEndCol,   nEndRow,   nEndTab ) );
248 
249 		theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails );
250 
251 		if ( pDBColl )
252 		{
253 			// Feststellen, ob definierter DB-Bereich markiert wurde:
254 			pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, sal_True );
255 			if ( pDBData )
256 			{
257 				String		theDbName;
258 				ScAddress&	rStart = theCurArea.aStart;
259 				ScAddress&	rEnd   = theCurArea.aEnd;
260                 SCCOL nCol1;
261                 SCCOL  nCol2;
262                 SCROW  nRow1;
263                 SCROW  nRow2;
264                 SCTAB  nTab;
265 
266 				pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
267 
268 				if (   (rStart.Tab() == nTab)
269 					&& (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
270 					&& (rEnd.Col()   == nCol2) && (rEnd.Row()   == nRow2 ) )
271 				{
272 					pDBData->GetName( theDbName );
273 					if ( theDbName != aStrNoName )
274 						aEdName.SetText( theDbName );
275 					else
276 						aEdName.SetText( EMPTY_STRING );
277 					aBtnHeader.Check( pDBData->HasHeader() );
278 					aBtnDoSize.Check( pDBData->IsDoSize() );
279 					aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
280 					aBtnStripData.Check( pDBData->IsStripData() );
281 					SetInfoStrings( pDBData );
282 				}
283 			}
284 		}
285 	}
286 
287 	aEdAssign.SetText( theAreaStr );
288 	aEdName.GrabFocus();
289 	bSaved=sal_True;
290 	pSaveObj->Save();
291 	NameModifyHdl( 0 );
292 }
293 
294 
295 void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
296 {
297 	String aSource = aStrSource;
298 	if (pDBData)
299 	{
300 		aSource += ' ';
301 		aSource += pDBData->GetSourceString();
302 	}
303 	aFTSource.SetText( aSource );
304 
305 	String aOper = aStrOperations;
306 	if (pDBData)
307 	{
308 		aOper += ' ';
309 		aOper += pDBData->GetOperations();
310 	}
311 	aFTOperations.SetText( aOper );
312 }
313 
314 //----------------------------------------------------------------------------
315 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
316 //  neue Selektion im Referenz-Fenster angezeigt wird.
317 
318 void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
319 {
320 	if ( aEdAssign.IsEnabled() )
321 	{
322 		if ( rRef.aStart != rRef.aEnd )
323 			RefInputStart( &aEdAssign );
324 
325 		theCurArea = rRef;
326 
327 		String aRefStr;
328         theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
329 		aEdAssign.SetRefString( aRefStr );
330 		aBtnHeader.Enable();
331 		aBtnDoSize.Enable();
332 		aBtnKeepFmt.Enable();
333 		aBtnStripData.Enable();
334 		aFTSource.Enable();
335 		aFTOperations.Enable();
336 		aBtnAdd.Enable();
337 		bSaved=sal_True;
338 		pSaveObj->Save();
339 	}
340 }
341 
342 
343 //----------------------------------------------------------------------------
344 
345 sal_Bool __EXPORT ScDbNameDlg::Close()
346 {
347 	return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
348 }
349 
350 //------------------------------------------------------------------------
351 
352 void ScDbNameDlg::SetActive()
353 {
354 	aEdAssign.GrabFocus();
355 
356 	//	kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
357 	//	(nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
358 	//	(der ausgewaehlte DB-Name hat sich auch nicht veraendert)
359 
360 	RefInputDone();
361 }
362 
363 //------------------------------------------------------------------------
364 
365 void ScDbNameDlg::UpdateNames()
366 {
367 	sal_uInt16	nNameCount = aLocalDbCol.GetCount();
368 
369 	aEdName.SetUpdateMode( sal_False );
370 	//-----------------------------------------------------------
371 	aEdName.Clear();
372 	aEdAssign.SetText( EMPTY_STRING );
373 
374 	if ( nNameCount > 0 )
375 	{
376 		ScDBData*	pDbData = NULL;
377 		String		aString;
378 
379 		for ( sal_uInt16 i=0; i<nNameCount; i++ )
380 		{
381 			pDbData = (ScDBData*)(aLocalDbCol.At( i ));
382 			if ( pDbData )
383 			{
384 				pDbData->GetName( aString );
385 				if ( aString != aStrNoName )
386 					aEdName.InsertEntry( aString );
387 			}
388 		}
389 	}
390 	else
391 	{
392 		aBtnAdd.SetText( aStrAdd );
393 		aBtnAdd.Disable();
394 		aBtnRemove.Disable();
395 	}
396 	//-----------------------------------------------------------
397 	aEdName.SetUpdateMode( sal_True );
398 	aEdName.Invalidate();
399 }
400 
401 //------------------------------------------------------------------------
402 
403 void ScDbNameDlg::UpdateDBData( const String& rStrName )
404 {
405 	String		theArea;
406 	sal_uInt16 		nAt;
407 	ScDBData*	pData;
408 
409 	aLocalDbCol.SearchName( rStrName, nAt );
410 	pData = (ScDBData*)(aLocalDbCol.At( nAt ));
411 
412 	if ( pData )
413 	{
414 		SCCOL nColStart = 0;
415 		SCROW nRowStart = 0;
416 		SCCOL nColEnd	 = 0;
417 		SCROW nRowEnd	 = 0;
418 		SCTAB nTab		 = 0;
419 
420 		pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
421 		theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
422 							  ScAddress( nColEnd,	nRowEnd,   nTab ) );
423 		theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
424 		aEdAssign.SetText( theArea );
425 		aBtnAdd.SetText( aStrModify );
426 		aBtnHeader.Check( pData->HasHeader() );
427 		aBtnDoSize.Check( pData->IsDoSize() );
428 		aBtnKeepFmt.Check( pData->IsKeepFmt() );
429 		aBtnStripData.Check( pData->IsStripData() );
430 		SetInfoStrings( pData );
431 	}
432 
433 	aBtnAdd.SetText( aStrModify );
434 	aBtnAdd.Enable();
435 	aBtnRemove.Enable();
436 	aBtnHeader.Enable();
437 	aBtnDoSize.Enable();
438 	aBtnKeepFmt.Enable();
439 	aBtnStripData.Enable();
440 	aFTSource.Enable();
441 	aFTOperations.Enable();
442 }
443 
444 //------------------------------------------------------------------------
445 
446 
447 sal_Bool ScDbNameDlg::IsRefInputMode() const
448 {
449 	return bRefInputMode;
450 }
451 
452 //------------------------------------------------------------------------
453 // Handler:
454 // ========
455 
456 IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
457 {
458 	AddBtnHdl( 0 );
459 
460 	// Der View die Aenderungen und die Remove-Liste uebergeben:
461 	// beide werden nur als Referenz uebergeben, so dass an dieser
462 	// Stelle keine Speicherleichen entstehen koennen:
463 	if ( pViewData )
464 		pViewData->GetView()->
465 			NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
466 
467 	Close();
468 	return 0;
469 }
470 
471 //------------------------------------------------------------------------
472 
473 IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
474 {
475 	Close();
476 	return 0;
477 }
478 IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
479 
480 //------------------------------------------------------------------------
481 
482 IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
483 {
484 	String	aNewName = aEdName.GetText();
485 	String	aNewArea = aEdAssign.GetText();
486 
487 	aNewName.EraseLeadingChars( ' ' );
488 	aNewName.EraseTrailingChars( ' ' );
489 
490 	if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
491 	{
492 		if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
493 		{
494 			//	weil jetzt editiert werden kann, muss erst geparst werden
495 			ScRange aTmpRange;
496 			String aText = aEdAssign.GetText();
497 			if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
498 			{
499 				theCurArea = aTmpRange;
500 				ScAddress aStart = theCurArea.aStart;
501 				ScAddress aEnd   = theCurArea.aEnd;
502 
503 				ScDBData* pOldEntry = NULL;
504 				sal_uInt16 nFoundAt = 0;
505 				if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
506 					pOldEntry = aLocalDbCol[nFoundAt];
507 				if (pOldEntry)
508 				{
509 					//	Bereich veraendern
510 
511 					pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
512 														aEnd.Col(), aEnd.Row() );
513 					pOldEntry->SetByRow( sal_True );
514 					pOldEntry->SetHeader( aBtnHeader.IsChecked() );
515 					pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
516 					pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
517 					pOldEntry->SetStripData( aBtnStripData.IsChecked() );
518 				}
519 				else
520 				{
521 					//	neuen Bereich einfuegen
522 
523 					ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
524 														aStart.Col(), aStart.Row(),
525 														aEnd.Col(), aEnd.Row(),
526 														sal_True, aBtnHeader.IsChecked() );
527 					pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
528 					pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
529 					pNewEntry->SetStripData( aBtnStripData.IsChecked() );
530 
531 					if ( !aLocalDbCol.Insert( pNewEntry ) )
532 						delete pNewEntry;
533 				}
534 
535 				UpdateNames();
536 
537 				aEdName.SetText( EMPTY_STRING );
538 				aEdName.GrabFocus();
539 				aBtnAdd.SetText( aStrAdd );
540 				aBtnAdd.Disable();
541 				aBtnRemove.Disable();
542 				aEdAssign.SetText( EMPTY_STRING );
543 				aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
544 				aBtnDoSize.Check( sal_False );
545 				aBtnKeepFmt.Check( sal_False );
546 				aBtnStripData.Check( sal_False );
547 				SetInfoStrings( NULL );		// leer
548 				theCurArea = ScRange();
549 				bSaved=sal_True;
550 				pSaveObj->Save();
551 				NameModifyHdl( 0 );
552 			}
553 			else
554 			{
555 				ERRORBOX( aStrInvalid );
556 				aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
557 				aEdAssign.GrabFocus();
558 			}
559 		}
560 		else
561 		{
562 			ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
563 			aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
564 			aEdName.GrabFocus();
565 		}
566 	}
567 	return 0;
568 }
569 
570 //------------------------------------------------------------------------
571 
572 IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
573 {
574 	sal_uInt16		 nRemoveAt = 0;
575 	const String aStrEntry = aEdName.GetText();
576 
577 	if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
578 	{
579 		String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
580 		String aMsg		  = aStrDelMsg.GetToken( 0, '#' );
581 
582 		aMsg += aStrEntry;
583 		aMsg += aStrDelMsg.GetToken( 1, '#' );
584 
585 		if ( RET_YES == QUERYBOX(aMsg) )
586 		{
587 			ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
588 
589 			if ( pEntry )
590 			{
591                 SCTAB nTab;
592                 SCCOL nColStart, nColEnd;
593                 SCROW nRowStart, nRowEnd;
594                 pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
595 				aRemoveList.Insert(
596 					new ScRange( ScAddress( nColStart, nRowStart, nTab ),
597 								 ScAddress( nColEnd,   nRowEnd,   nTab ) ) );
598 			}
599 			aLocalDbCol.AtFree( nRemoveAt );
600 
601 			UpdateNames();
602 
603 			aEdName.SetText( EMPTY_STRING );
604 			aEdName.GrabFocus();
605 			aBtnAdd.SetText( aStrAdd );
606 			aBtnAdd.Disable();
607 			aBtnRemove.Disable();
608 			aEdAssign.SetText( EMPTY_STRING );
609 			theCurArea = ScRange();
610 			aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
611 			aBtnDoSize.Check( sal_False );
612 			aBtnKeepFmt.Check( sal_False );
613 			aBtnStripData.Check( sal_False );
614 			SetInfoStrings( NULL );		// leer
615 			bSaved=sal_False;
616 			pSaveObj->Restore();
617 			NameModifyHdl( 0 );
618 		}
619 	}
620 	return 0;
621 }
622 
623 //------------------------------------------------------------------------
624 
625 IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
626 {
627 	String	theName		= aEdName.GetText();
628 	sal_Bool	bNameFound  = (COMBOBOX_ENTRY_NOTFOUND
629 						   != aEdName.GetEntryPos( theName ));
630 
631 	if ( theName.Len() == 0 )
632 	{
633 		if ( aBtnAdd.GetText() != aStrAdd )
634 			aBtnAdd.SetText( aStrAdd );
635 		aBtnAdd		.Disable();
636 		aBtnRemove	.Disable();
637         aFlAssign   .Disable();
638 		aBtnHeader	.Disable();
639 		aBtnDoSize	.Disable();
640 		aBtnKeepFmt	.Disable();
641 		aBtnStripData.Disable();
642 		aFTSource	.Disable();
643 		aFTOperations.Disable();
644 		aEdAssign	.Disable();
645 		aRbAssign	.Disable();
646 		//bSaved=sal_False;
647 		//pSaveObj->Restore();
648 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
649 		//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
650 		bRefInputMode = sal_False;
651 	}
652 	else
653 	{
654 		if ( bNameFound )
655 		{
656 			if ( aBtnAdd.GetText() != aStrModify )
657 				aBtnAdd.SetText( aStrModify );
658 
659 			if(!bSaved)
660 			{
661 				bSaved=sal_True;
662 				pSaveObj->Save();
663 			}
664 			UpdateDBData( theName );
665 		}
666 		else
667 		{
668 			if ( aBtnAdd.GetText() != aStrAdd )
669 				aBtnAdd.SetText( aStrAdd );
670 
671 			bSaved=sal_False;
672 			pSaveObj->Restore();
673 
674 			if ( aEdAssign.GetText().Len() > 0 )
675 			{
676 				aBtnAdd.Enable();
677 				aBtnHeader.Enable();
678 				aBtnDoSize.Enable();
679 				aBtnKeepFmt.Enable();
680 				aBtnStripData.Enable();
681 				aFTSource.Enable();
682 				aFTOperations.Enable();
683 			}
684 			else
685 			{
686 				aBtnAdd.Disable();
687 				aBtnHeader.Disable();
688 				aBtnDoSize.Disable();
689 				aBtnKeepFmt.Disable();
690 				aBtnStripData.Disable();
691 				aFTSource.Disable();
692 				aFTOperations.Disable();
693 			}
694 			aBtnRemove.Disable();
695 		}
696 
697         aFlAssign.Enable();
698 		aEdAssign.Enable();
699 		aRbAssign.Enable();
700 
701 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
702 		//SFX_APPWINDOW->Enable();
703 		bRefInputMode = sal_True;
704 	}
705 	return 0;
706 }
707 
708 //------------------------------------------------------------------------
709 
710 IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
711 {
712 	//	hier parsen fuer Save() etc.
713 
714 	ScRange aTmpRange;
715 	String aText = aEdAssign.GetText();
716 	if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
717 		theCurArea = aTmpRange;
718 
719 	return 0;
720 }
721 
722 
723