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