xref: /trunk/main/sc/source/ui/dbgui/dbnamdlg.cxx (revision 1a986828)
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:
DBSaveData(Edit & rEd,CheckBox & rHdr,CheckBox & rSize,CheckBox & rFmt,CheckBox & rStrip,ScRange & rArea)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 
Save()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 
Restore()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 
ScDbNameDlg(SfxBindings * pB,SfxChildWindow * pCW,Window * pParent,ScViewData * ptrViewData)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 
~ScDbNameDlg()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 
Init()208 void ScDbNameDlg::Init()
209 {
210     aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
211     aBtnDoSize.Check( sal_True );
212     aBtnKeepFmt.Check( sal_True );
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 ( !pDBData->IsInternalUnnamed()
274                          && !pDBData->IsInternalForAutoFilter() )
275                     {
276                         aEdName.SetText( theDbName );
277                     }
278                     else
279                     {
280                         aEdName.SetText( EMPTY_STRING );
281                     }
282                     aBtnHeader.Check( pDBData->HasHeader() );
283                     aBtnDoSize.Check( pDBData->IsDoSize() );
284                     aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
285                     aBtnStripData.Check( pDBData->IsStripData() );
286                     SetInfoStrings( pDBData );
287                 }
288             }
289         }
290     }
291 
292     aEdAssign.SetText( theAreaStr );
293     aEdName.GrabFocus();
294     bSaved=sal_True;
295     pSaveObj->Save();
296     NameModifyHdl( 0 );
297 }
298 
299 
SetInfoStrings(const ScDBData * pDBData)300 void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
301 {
302 	String aSource = aStrSource;
303 	if (pDBData)
304 	{
305 		aSource += ' ';
306 		aSource += pDBData->GetSourceString();
307 	}
308 	aFTSource.SetText( aSource );
309 
310 	String aOper = aStrOperations;
311 	if (pDBData)
312 	{
313 		aOper += ' ';
314 		aOper += pDBData->GetOperations();
315 	}
316 	aFTOperations.SetText( aOper );
317 }
318 
319 //----------------------------------------------------------------------------
320 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
321 //  neue Selektion im Referenz-Fenster angezeigt wird.
322 
SetReference(const ScRange & rRef,ScDocument * pDocP)323 void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
324 {
325 	if ( aEdAssign.IsEnabled() )
326 	{
327 		if ( rRef.aStart != rRef.aEnd )
328 			RefInputStart( &aEdAssign );
329 
330 		theCurArea = rRef;
331 
332 		String aRefStr;
333         theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
334 		aEdAssign.SetRefString( aRefStr );
335 		aBtnHeader.Enable();
336 		aBtnDoSize.Enable();
337 		aBtnKeepFmt.Enable();
338 		aBtnStripData.Enable();
339 		aFTSource.Enable();
340 		aFTOperations.Enable();
341 		aBtnAdd.Enable();
342 		bSaved=sal_True;
343 		pSaveObj->Save();
344 	}
345 }
346 
347 
348 //----------------------------------------------------------------------------
349 
Close()350 sal_Bool __EXPORT ScDbNameDlg::Close()
351 {
352 	return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
353 }
354 
355 //------------------------------------------------------------------------
356 
SetActive()357 void ScDbNameDlg::SetActive()
358 {
359 	aEdAssign.GrabFocus();
360 
361 	//	kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
362 	//	(nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
363 	//	(der ausgewaehlte DB-Name hat sich auch nicht veraendert)
364 
365 	RefInputDone();
366 }
367 
368 //------------------------------------------------------------------------
369 
UpdateNames()370 void ScDbNameDlg::UpdateNames()
371 {
372     sal_uInt16	nNameCount = aLocalDbCol.GetCount();
373 
374     aEdName.SetUpdateMode( sal_False );
375     //-----------------------------------------------------------
376     aEdName.Clear();
377     aEdAssign.SetText( EMPTY_STRING );
378 
379     if ( nNameCount > 0 )
380     {
381         ScDBData*	pDbData = NULL;
382         String		aString;
383 
384         for ( sal_uInt16 i=0; i<nNameCount; i++ )
385         {
386             pDbData = (ScDBData*)(aLocalDbCol.At( i ));
387             if ( pDbData )
388             {
389                 pDbData->GetName( aString );
390                 if ( !pDbData->IsInternalUnnamed()
391                      && !pDbData->IsInternalForAutoFilter() )
392                     aEdName.InsertEntry( aString );
393             }
394         }
395     }
396     else
397     {
398         aBtnAdd.SetText( aStrAdd );
399         aBtnAdd.Disable();
400         aBtnRemove.Disable();
401     }
402     //-----------------------------------------------------------
403     aEdName.SetUpdateMode( sal_True );
404     aEdName.Invalidate();
405 }
406 
407 //------------------------------------------------------------------------
408 
UpdateDBData(const String & rStrName)409 void ScDbNameDlg::UpdateDBData( const String& rStrName )
410 {
411 	String		theArea;
412 	sal_uInt16 		nAt;
413 	ScDBData*	pData;
414 
415 	aLocalDbCol.SearchName( rStrName, nAt );
416 	pData = (ScDBData*)(aLocalDbCol.At( nAt ));
417 
418 	if ( pData )
419 	{
420 		SCCOL nColStart = 0;
421 		SCROW nRowStart = 0;
422 		SCCOL nColEnd	 = 0;
423 		SCROW nRowEnd	 = 0;
424 		SCTAB nTab		 = 0;
425 
426 		pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
427 		theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
428 							  ScAddress( nColEnd,	nRowEnd,   nTab ) );
429 		theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
430 		aEdAssign.SetText( theArea );
431 		aBtnAdd.SetText( aStrModify );
432 		aBtnHeader.Check( pData->HasHeader() );
433 		aBtnDoSize.Check( pData->IsDoSize() );
434 		aBtnKeepFmt.Check( pData->IsKeepFmt() );
435 		aBtnStripData.Check( pData->IsStripData() );
436 		SetInfoStrings( pData );
437 	}
438 
439 	aBtnAdd.SetText( aStrModify );
440 	aBtnAdd.Enable();
441 	aBtnRemove.Enable();
442 	aBtnHeader.Enable();
443 	aBtnDoSize.Enable();
444 	aBtnKeepFmt.Enable();
445 	aBtnStripData.Enable();
446 	aFTSource.Enable();
447 	aFTOperations.Enable();
448 }
449 
450 //------------------------------------------------------------------------
451 
452 
IsRefInputMode() const453 sal_Bool ScDbNameDlg::IsRefInputMode() const
454 {
455 	return bRefInputMode;
456 }
457 
458 //------------------------------------------------------------------------
459 // Handler:
460 // ========
461 
IMPL_LINK(ScDbNameDlg,OkBtnHdl,void *,EMPTYARG)462 IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
463 {
464 	AddBtnHdl( 0 );
465 
466 	// Der View die Aenderungen und die Remove-Liste uebergeben:
467 	// beide werden nur als Referenz uebergeben, so dass an dieser
468 	// Stelle keine Speicherleichen entstehen koennen:
469 	if ( pViewData )
470 		pViewData->GetView()->
471 			NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
472 
473 	Close();
474 	return 0;
475 }
476 
477 //------------------------------------------------------------------------
478 
IMPL_LINK_INLINE_START(ScDbNameDlg,CancelBtnHdl,void *,EMPTYARG)479 IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
480 {
481 	Close();
482 	return 0;
483 }
IMPL_LINK_INLINE_END(ScDbNameDlg,CancelBtnHdl,void *,EMPTYARG)484 IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
485 
486 //------------------------------------------------------------------------
487 
488 IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
489 {
490 	String	aNewName = aEdName.GetText();
491 	String	aNewArea = aEdAssign.GetText();
492 
493 	aNewName.EraseLeadingChars( ' ' );
494 	aNewName.EraseTrailingChars( ' ' );
495 
496 	if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
497 	{
498 		if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
499 		{
500 			//	weil jetzt editiert werden kann, muss erst geparst werden
501 			ScRange aTmpRange;
502 			String aText = aEdAssign.GetText();
503 			if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
504 			{
505 				theCurArea = aTmpRange;
506 				ScAddress aStart = theCurArea.aStart;
507 				ScAddress aEnd   = theCurArea.aEnd;
508 
509 				ScDBData* pOldEntry = NULL;
510 				sal_uInt16 nFoundAt = 0;
511 				if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
512 					pOldEntry = aLocalDbCol[nFoundAt];
513 				if (pOldEntry)
514 				{
515 					//	Bereich veraendern
516 
517 					pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
518 														aEnd.Col(), aEnd.Row() );
519 					pOldEntry->SetByRow( sal_True );
520 					pOldEntry->SetHeader( aBtnHeader.IsChecked() );
521 					pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
522 					pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
523 					pOldEntry->SetStripData( aBtnStripData.IsChecked() );
524 				}
525 				else
526 				{
527 					//	neuen Bereich einfuegen
528 
529 					ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
530 														aStart.Col(), aStart.Row(),
531 														aEnd.Col(), aEnd.Row(),
532 														sal_True, aBtnHeader.IsChecked() );
533 					pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
534 					pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
535 					pNewEntry->SetStripData( aBtnStripData.IsChecked() );
536 
537 					if ( !aLocalDbCol.Insert( pNewEntry ) )
538 						delete pNewEntry;
539 				}
540 
541 				UpdateNames();
542 
543 				aEdName.SetText( EMPTY_STRING );
544 				aEdName.GrabFocus();
545 				aBtnAdd.SetText( aStrAdd );
546 				aBtnAdd.Disable();
547 				aBtnRemove.Disable();
548 				aEdAssign.SetText( EMPTY_STRING );
549 				aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
550 				aBtnDoSize.Check( sal_False );
551 				aBtnKeepFmt.Check( sal_False );
552 				aBtnStripData.Check( sal_False );
553 				SetInfoStrings( NULL );		// leer
554 				theCurArea = ScRange();
555 				bSaved=sal_True;
556 				pSaveObj->Save();
557 				NameModifyHdl( 0 );
558 			}
559 			else
560 			{
561 				ERRORBOX( aStrInvalid );
562 				aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
563 				aEdAssign.GrabFocus();
564 			}
565 		}
566 		else
567 		{
568 			ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
569 			aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
570 			aEdName.GrabFocus();
571 		}
572 	}
573 	return 0;
574 }
575 
576 //------------------------------------------------------------------------
577 
IMPL_LINK(ScDbNameDlg,RemoveBtnHdl,void *,EMPTYARG)578 IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
579 {
580 	sal_uInt16		 nRemoveAt = 0;
581 	const String aStrEntry = aEdName.GetText();
582 
583 	if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
584 	{
585 		String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
586 		String aMsg		  = aStrDelMsg.GetToken( 0, '#' );
587 
588 		aMsg += aStrEntry;
589 		aMsg += aStrDelMsg.GetToken( 1, '#' );
590 
591 		if ( RET_YES == QUERYBOX(aMsg) )
592 		{
593 			ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
594 
595 			if ( pEntry )
596 			{
597                 SCTAB nTab;
598                 SCCOL nColStart, nColEnd;
599                 SCROW nRowStart, nRowEnd;
600                 pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
601 				aRemoveList.Insert(
602 					new ScRange( ScAddress( nColStart, nRowStart, nTab ),
603 								 ScAddress( nColEnd,   nRowEnd,   nTab ) ) );
604 			}
605 			aLocalDbCol.AtFree( nRemoveAt );
606 
607 			UpdateNames();
608 
609 			aEdName.SetText( EMPTY_STRING );
610 			aEdName.GrabFocus();
611 			aBtnAdd.SetText( aStrAdd );
612 			aBtnAdd.Disable();
613 			aBtnRemove.Disable();
614 			aEdAssign.SetText( EMPTY_STRING );
615 			theCurArea = ScRange();
616 			aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
617 			aBtnDoSize.Check( sal_False );
618 			aBtnKeepFmt.Check( sal_False );
619 			aBtnStripData.Check( sal_False );
620 			SetInfoStrings( NULL );		// leer
621 			bSaved=sal_False;
622 			pSaveObj->Restore();
623 			NameModifyHdl( 0 );
624 		}
625 	}
626 	return 0;
627 }
628 
629 //------------------------------------------------------------------------
630 
IMPL_LINK(ScDbNameDlg,NameModifyHdl,void *,EMPTYARG)631 IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
632 {
633 	String	theName		= aEdName.GetText();
634 	sal_Bool	bNameFound  = (COMBOBOX_ENTRY_NOTFOUND
635 						   != aEdName.GetEntryPos( theName ));
636 
637 	if ( theName.Len() == 0 )
638 	{
639 		if ( aBtnAdd.GetText() != aStrAdd )
640 			aBtnAdd.SetText( aStrAdd );
641 		aBtnAdd		.Disable();
642 		aBtnRemove	.Disable();
643         aFlAssign   .Disable();
644 		aBtnHeader	.Disable();
645 		aBtnDoSize	.Disable();
646 		aBtnKeepFmt	.Disable();
647 		aBtnStripData.Disable();
648 		aFTSource	.Disable();
649 		aFTOperations.Disable();
650 		aEdAssign	.Disable();
651 		aRbAssign	.Disable();
652 		//bSaved=sal_False;
653 		//pSaveObj->Restore();
654 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
655 		//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
656 		bRefInputMode = sal_False;
657 	}
658 	else
659 	{
660 		if ( bNameFound )
661 		{
662 			if ( aBtnAdd.GetText() != aStrModify )
663 				aBtnAdd.SetText( aStrModify );
664 
665 			if(!bSaved)
666 			{
667 				bSaved=sal_True;
668 				pSaveObj->Save();
669 			}
670 			UpdateDBData( theName );
671 		}
672 		else
673 		{
674 			if ( aBtnAdd.GetText() != aStrAdd )
675 				aBtnAdd.SetText( aStrAdd );
676 
677 			bSaved=sal_False;
678 			pSaveObj->Restore();
679 
680 			if ( aEdAssign.GetText().Len() > 0 )
681 			{
682 				aBtnAdd.Enable();
683 				aBtnHeader.Enable();
684 				aBtnDoSize.Enable();
685 				aBtnKeepFmt.Enable();
686 				aBtnStripData.Enable();
687 				aFTSource.Enable();
688 				aFTOperations.Enable();
689 			}
690 			else
691 			{
692 				aBtnAdd.Disable();
693 				aBtnHeader.Disable();
694 				aBtnDoSize.Disable();
695 				aBtnKeepFmt.Disable();
696 				aBtnStripData.Disable();
697 				aFTSource.Disable();
698 				aFTOperations.Disable();
699 			}
700 			aBtnRemove.Disable();
701 		}
702 
703         aFlAssign.Enable();
704 		aEdAssign.Enable();
705 		aRbAssign.Enable();
706 
707 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
708 		//SFX_APPWINDOW->Enable();
709 		bRefInputMode = sal_True;
710 	}
711 	return 0;
712 }
713 
714 //------------------------------------------------------------------------
715 
IMPL_LINK(ScDbNameDlg,AssModifyHdl,void *,EMPTYARG)716 IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
717 {
718 	//	hier parsen fuer Save() etc.
719 
720 	ScRange aTmpRange;
721 	String aText = aEdAssign.GetText();
722 	if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
723 		theCurArea = aTmpRange;
724     if( aText.Len() > 0 && aEdName.GetText().Len() > 0 )
725     {
726 		aBtnAdd.Enable();
727 		aBtnHeader.Enable();
728 		aBtnDoSize.Enable();
729 		aBtnKeepFmt.Enable();
730 		aBtnStripData.Enable();
731 		aFTSource.Enable();
732 		aFTOperations.Enable();
733     }
734     else
735     {
736 		aBtnAdd.Disable();
737 		aBtnHeader.Disable();
738 		aBtnDoSize.Disable();
739 		aBtnKeepFmt.Disable();
740 		aBtnStripData.Disable();
741 		aFTSource.Disable();
742 		aFTOperations.Disable();
743     }
744 	return 0;
745 }
746 
IMPL_LINK(ScDbNameDlg,FocusToComoboxHdl,Timer *,pTi)747 IMPL_LINK( ScDbNameDlg, FocusToComoboxHdl, Timer*, pTi)
748 {
749 	(void)pTi;
750 	// 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...
751 	// aEdName.CallEventListeners( VCLEVENT_CONTROL_GETFOCUS );
752 	return 0;
753 }
754