xref: /aoo41x/main/sc/source/ui/dbgui/dbnamdlg.cxx (revision 57b4fa3c)
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 		aStrNoName		( ScGlobal::GetRscString(STR_DB_NONAME) ),
164 		aStrInvalid		( ScResId( STR_DB_INVALID ) ),
165 		//
166 		pViewData		( ptrViewData ),
167 		pDoc			( ptrViewData->GetDocument() ),
168 		bRefInputMode	( sal_False ),
169         aAddrDetails    ( pDoc->GetAddressConvention(), 0, 0 ),
170 		aLocalDbCol		( *(pDoc->GetDBCollection()) )
171 {
172 	// WB_NOLABEL can't be set in resource...
173 	aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
174 	aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );
175 
176 	//	damit die Strings in der Resource bei den FixedTexten bleiben koennen:
177 	aStrSource		= aFTSource.GetText();
178 	aStrOperations	= aFTOperations.GetText();
179 
180 	pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
181 						aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
182 	Init();
183 	FreeResource();
184 	aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
185 }
186 
187 
188 //----------------------------------------------------------------------------
189 
190 __EXPORT ScDbNameDlg::~ScDbNameDlg()
191 {
192 	DELETEZ( pSaveObj );
193 
194 	ScRange* pEntry = (ScRange*)aRemoveList.First();
195 	while ( pEntry )
196 	{
197         aRemoveList.Remove( pEntry );
198         delete pEntry;
199 		pEntry = (ScRange*)aRemoveList.Next();
200 	}
201 }
202 
203 
204 //----------------------------------------------------------------------------
205 
206 void ScDbNameDlg::Init()
207 {
208 	aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
209 
210     aBtnMore.AddWindow( &aFlOptions );
211 	aBtnMore.AddWindow( &aBtnHeader );
212 	aBtnMore.AddWindow( &aBtnDoSize );
213 	aBtnMore.AddWindow( &aBtnKeepFmt );
214 	aBtnMore.AddWindow( &aBtnStripData );
215 	aBtnMore.AddWindow( &aFTSource );
216 	aBtnMore.AddWindow( &aFTOperations );
217 
218 	String	theAreaStr;
219 	SCCOL	nStartCol 	= 0;
220 	SCROW	nStartRow 	= 0;
221 	SCTAB	nStartTab 	= 0;
222 	SCCOL	nEndCol 	= 0;
223 	SCROW	nEndRow		= 0;
224 	SCTAB	nEndTab 	= 0;
225 
226 	aBtnOk.SetClickHdl		( LINK( this, ScDbNameDlg, OkBtnHdl ) );
227 	aBtnCancel.SetClickHdl	( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
228 	aBtnAdd.SetClickHdl		( LINK( this, ScDbNameDlg, AddBtnHdl ) );
229 	aBtnRemove.SetClickHdl	( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
230 	aEdName.SetModifyHdl	( LINK( this, ScDbNameDlg, NameModifyHdl ) );
231 	aEdAssign.SetModifyHdl	( LINK( this, ScDbNameDlg, AssModifyHdl ) );
232 	UpdateNames();
233 
234 	if ( pViewData && pDoc )
235 	{
236 		ScDBCollection*	pDBColl	= pDoc->GetDBCollection();
237 		ScDBData*		pDBData = NULL;
238 
239 		pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
240 								  nEndCol,	 nEndRow,  nEndTab );
241 
242 		theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
243 							  ScAddress( nEndCol,   nEndRow,   nEndTab ) );
244 
245 		theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails );
246 
247 		if ( pDBColl )
248 		{
249 			// Feststellen, ob definierter DB-Bereich markiert wurde:
250 			pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, sal_True );
251 			if ( pDBData )
252 			{
253 				String		theDbName;
254 				ScAddress&	rStart = theCurArea.aStart;
255 				ScAddress&	rEnd   = theCurArea.aEnd;
256                 SCCOL nCol1;
257                 SCCOL  nCol2;
258                 SCROW  nRow1;
259                 SCROW  nRow2;
260                 SCTAB  nTab;
261 
262 				pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
263 
264 				if (   (rStart.Tab() == nTab)
265 					&& (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
266 					&& (rEnd.Col()   == nCol2) && (rEnd.Row()   == nRow2 ) )
267 				{
268 					pDBData->GetName( theDbName );
269 					//if ( theDbName != aStrNoName )
270 					if ( !pDBData->IsBuildin() )
271 						aEdName.SetText( theDbName );
272 					else
273 						aEdName.SetText( EMPTY_STRING );
274 					aBtnHeader.Check( pDBData->HasHeader() );
275 					aBtnDoSize.Check( pDBData->IsDoSize() );
276 					aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
277 					aBtnStripData.Check( pDBData->IsStripData() );
278 					SetInfoStrings( pDBData );
279 				}
280 			}
281 		}
282 	}
283 
284 	aEdAssign.SetText( theAreaStr );
285 	aEdName.GrabFocus();
286 	bSaved=sal_True;
287 	pSaveObj->Save();
288 	NameModifyHdl( 0 );
289 }
290 
291 
292 void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
293 {
294 	String aSource = aStrSource;
295 	if (pDBData)
296 	{
297 		aSource += ' ';
298 		aSource += pDBData->GetSourceString();
299 	}
300 	aFTSource.SetText( aSource );
301 
302 	String aOper = aStrOperations;
303 	if (pDBData)
304 	{
305 		aOper += ' ';
306 		aOper += pDBData->GetOperations();
307 	}
308 	aFTOperations.SetText( aOper );
309 }
310 
311 //----------------------------------------------------------------------------
312 // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
313 //  neue Selektion im Referenz-Fenster angezeigt wird.
314 
315 void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
316 {
317 	if ( aEdAssign.IsEnabled() )
318 	{
319 		if ( rRef.aStart != rRef.aEnd )
320 			RefInputStart( &aEdAssign );
321 
322 		theCurArea = rRef;
323 
324 		String aRefStr;
325         theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
326 		aEdAssign.SetRefString( aRefStr );
327 		aBtnHeader.Enable();
328 		aBtnDoSize.Enable();
329 		aBtnKeepFmt.Enable();
330 		aBtnStripData.Enable();
331 		aFTSource.Enable();
332 		aFTOperations.Enable();
333 		aBtnAdd.Enable();
334 		bSaved=sal_True;
335 		pSaveObj->Save();
336 	}
337 }
338 
339 
340 //----------------------------------------------------------------------------
341 
342 sal_Bool __EXPORT ScDbNameDlg::Close()
343 {
344 	return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
345 }
346 
347 //------------------------------------------------------------------------
348 
349 void ScDbNameDlg::SetActive()
350 {
351 	aEdAssign.GrabFocus();
352 
353 	//	kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
354 	//	(nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
355 	//	(der ausgewaehlte DB-Name hat sich auch nicht veraendert)
356 
357 	RefInputDone();
358 }
359 
360 //------------------------------------------------------------------------
361 
362 void ScDbNameDlg::UpdateNames()
363 {
364 	sal_uInt16	nNameCount = aLocalDbCol.GetCount();
365 
366 	aEdName.SetUpdateMode( sal_False );
367 	//-----------------------------------------------------------
368 	aEdName.Clear();
369 	aEdAssign.SetText( EMPTY_STRING );
370 
371 	if ( nNameCount > 0 )
372 	{
373 		ScDBData*	pDbData = NULL;
374 		String		aString;
375 
376 		for ( sal_uInt16 i=0; i<nNameCount; i++ )
377 		{
378 			pDbData = (ScDBData*)(aLocalDbCol.At( i ));
379 			if ( pDbData )
380 			{
381 				pDbData->GetName( aString );
382 				//if ( aString != aStrNoName )
383 				if ( !pDbData->IsBuildin() )
384 					aEdName.InsertEntry( aString );
385 			}
386 		}
387 	}
388 	else
389 	{
390 		aBtnAdd.SetText( aStrAdd );
391 		aBtnAdd.Disable();
392 		aBtnRemove.Disable();
393 	}
394 	//-----------------------------------------------------------
395 	aEdName.SetUpdateMode( sal_True );
396 	aEdName.Invalidate();
397 }
398 
399 //------------------------------------------------------------------------
400 
401 void ScDbNameDlg::UpdateDBData( const String& rStrName )
402 {
403 	String		theArea;
404 	sal_uInt16 		nAt;
405 	ScDBData*	pData;
406 
407 	aLocalDbCol.SearchName( rStrName, nAt );
408 	pData = (ScDBData*)(aLocalDbCol.At( nAt ));
409 
410 	if ( pData )
411 	{
412 		SCCOL nColStart = 0;
413 		SCROW nRowStart = 0;
414 		SCCOL nColEnd	 = 0;
415 		SCROW nRowEnd	 = 0;
416 		SCTAB nTab		 = 0;
417 
418 		pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
419 		theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
420 							  ScAddress( nColEnd,	nRowEnd,   nTab ) );
421 		theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
422 		aEdAssign.SetText( theArea );
423 		aBtnAdd.SetText( aStrModify );
424 		aBtnHeader.Check( pData->HasHeader() );
425 		aBtnDoSize.Check( pData->IsDoSize() );
426 		aBtnKeepFmt.Check( pData->IsKeepFmt() );
427 		aBtnStripData.Check( pData->IsStripData() );
428 		SetInfoStrings( pData );
429 	}
430 
431 	aBtnAdd.SetText( aStrModify );
432 	aBtnAdd.Enable();
433 	aBtnRemove.Enable();
434 	aBtnHeader.Enable();
435 	aBtnDoSize.Enable();
436 	aBtnKeepFmt.Enable();
437 	aBtnStripData.Enable();
438 	aFTSource.Enable();
439 	aFTOperations.Enable();
440 }
441 
442 //------------------------------------------------------------------------
443 
444 
445 sal_Bool ScDbNameDlg::IsRefInputMode() const
446 {
447 	return bRefInputMode;
448 }
449 
450 //------------------------------------------------------------------------
451 // Handler:
452 // ========
453 
454 IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
455 {
456 	AddBtnHdl( 0 );
457 
458 	// Der View die Aenderungen und die Remove-Liste uebergeben:
459 	// beide werden nur als Referenz uebergeben, so dass an dieser
460 	// Stelle keine Speicherleichen entstehen koennen:
461 	if ( pViewData )
462 		pViewData->GetView()->
463 			NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
464 
465 	Close();
466 	return 0;
467 }
468 
469 //------------------------------------------------------------------------
470 
471 IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
472 {
473 	Close();
474 	return 0;
475 }
476 IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
477 
478 //------------------------------------------------------------------------
479 
480 IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
481 {
482 	String	aNewName = aEdName.GetText();
483 	String	aNewArea = aEdAssign.GetText();
484 
485 	aNewName.EraseLeadingChars( ' ' );
486 	aNewName.EraseTrailingChars( ' ' );
487 
488 	if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
489 	{
490 		if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
491 		{
492 			//	weil jetzt editiert werden kann, muss erst geparst werden
493 			ScRange aTmpRange;
494 			String aText = aEdAssign.GetText();
495 			if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
496 			{
497 				theCurArea = aTmpRange;
498 				ScAddress aStart = theCurArea.aStart;
499 				ScAddress aEnd   = theCurArea.aEnd;
500 
501 				ScDBData* pOldEntry = NULL;
502 				sal_uInt16 nFoundAt = 0;
503 				if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
504 					pOldEntry = aLocalDbCol[nFoundAt];
505 				if (pOldEntry)
506 				{
507 					//	Bereich veraendern
508 
509 					pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
510 														aEnd.Col(), aEnd.Row() );
511 					pOldEntry->SetByRow( sal_True );
512 					pOldEntry->SetHeader( aBtnHeader.IsChecked() );
513 					pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
514 					pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
515 					pOldEntry->SetStripData( aBtnStripData.IsChecked() );
516 				}
517 				else
518 				{
519 					//	neuen Bereich einfuegen
520 
521 					ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
522 														aStart.Col(), aStart.Row(),
523 														aEnd.Col(), aEnd.Row(),
524 														sal_True, aBtnHeader.IsChecked() );
525 					pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
526 					pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
527 					pNewEntry->SetStripData( aBtnStripData.IsChecked() );
528 
529 					if ( !aLocalDbCol.Insert( pNewEntry ) )
530 						delete pNewEntry;
531 				}
532 
533 				UpdateNames();
534 
535 				aEdName.SetText( EMPTY_STRING );
536 				aEdName.GrabFocus();
537 				aBtnAdd.SetText( aStrAdd );
538 				aBtnAdd.Disable();
539 				aBtnRemove.Disable();
540 				aEdAssign.SetText( EMPTY_STRING );
541 				aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
542 				aBtnDoSize.Check( sal_False );
543 				aBtnKeepFmt.Check( sal_False );
544 				aBtnStripData.Check( sal_False );
545 				SetInfoStrings( NULL );		// leer
546 				theCurArea = ScRange();
547 				bSaved=sal_True;
548 				pSaveObj->Save();
549 				NameModifyHdl( 0 );
550 			}
551 			else
552 			{
553 				ERRORBOX( aStrInvalid );
554 				aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
555 				aEdAssign.GrabFocus();
556 			}
557 		}
558 		else
559 		{
560 			ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
561 			aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
562 			aEdName.GrabFocus();
563 		}
564 	}
565 	return 0;
566 }
567 
568 //------------------------------------------------------------------------
569 
570 IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
571 {
572 	sal_uInt16		 nRemoveAt = 0;
573 	const String aStrEntry = aEdName.GetText();
574 
575 	if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
576 	{
577 		String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
578 		String aMsg		  = aStrDelMsg.GetToken( 0, '#' );
579 
580 		aMsg += aStrEntry;
581 		aMsg += aStrDelMsg.GetToken( 1, '#' );
582 
583 		if ( RET_YES == QUERYBOX(aMsg) )
584 		{
585 			ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
586 
587 			if ( pEntry )
588 			{
589                 SCTAB nTab;
590                 SCCOL nColStart, nColEnd;
591                 SCROW nRowStart, nRowEnd;
592                 pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
593 				aRemoveList.Insert(
594 					new ScRange( ScAddress( nColStart, nRowStart, nTab ),
595 								 ScAddress( nColEnd,   nRowEnd,   nTab ) ) );
596 			}
597 			aLocalDbCol.AtFree( nRemoveAt );
598 
599 			UpdateNames();
600 
601 			aEdName.SetText( EMPTY_STRING );
602 			aEdName.GrabFocus();
603 			aBtnAdd.SetText( aStrAdd );
604 			aBtnAdd.Disable();
605 			aBtnRemove.Disable();
606 			aEdAssign.SetText( EMPTY_STRING );
607 			theCurArea = ScRange();
608 			aBtnHeader.Check( sal_True );		// Default: mit Spaltenkoepfen
609 			aBtnDoSize.Check( sal_False );
610 			aBtnKeepFmt.Check( sal_False );
611 			aBtnStripData.Check( sal_False );
612 			SetInfoStrings( NULL );		// leer
613 			bSaved=sal_False;
614 			pSaveObj->Restore();
615 			NameModifyHdl( 0 );
616 		}
617 	}
618 	return 0;
619 }
620 
621 //------------------------------------------------------------------------
622 
623 IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
624 {
625 	String	theName		= aEdName.GetText();
626 	sal_Bool	bNameFound  = (COMBOBOX_ENTRY_NOTFOUND
627 						   != aEdName.GetEntryPos( theName ));
628 
629 	if ( theName.Len() == 0 )
630 	{
631 		if ( aBtnAdd.GetText() != aStrAdd )
632 			aBtnAdd.SetText( aStrAdd );
633 		aBtnAdd		.Disable();
634 		aBtnRemove	.Disable();
635         aFlAssign   .Disable();
636 		aBtnHeader	.Disable();
637 		aBtnDoSize	.Disable();
638 		aBtnKeepFmt	.Disable();
639 		aBtnStripData.Disable();
640 		aFTSource	.Disable();
641 		aFTOperations.Disable();
642 		aEdAssign	.Disable();
643 		aRbAssign	.Disable();
644 		//bSaved=sal_False;
645 		//pSaveObj->Restore();
646 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
647 		//SFX_APPWINDOW->Disable(sal_False);		//! allgemeine Methode im ScAnyRefDlg
648 		bRefInputMode = sal_False;
649 	}
650 	else
651 	{
652 		if ( bNameFound )
653 		{
654 			if ( aBtnAdd.GetText() != aStrModify )
655 				aBtnAdd.SetText( aStrModify );
656 
657 			if(!bSaved)
658 			{
659 				bSaved=sal_True;
660 				pSaveObj->Save();
661 			}
662 			UpdateDBData( theName );
663 		}
664 		else
665 		{
666 			if ( aBtnAdd.GetText() != aStrAdd )
667 				aBtnAdd.SetText( aStrAdd );
668 
669 			bSaved=sal_False;
670 			pSaveObj->Restore();
671 
672 			if ( aEdAssign.GetText().Len() > 0 )
673 			{
674 				aBtnAdd.Enable();
675 				aBtnHeader.Enable();
676 				aBtnDoSize.Enable();
677 				aBtnKeepFmt.Enable();
678 				aBtnStripData.Enable();
679 				aFTSource.Enable();
680 				aFTOperations.Enable();
681 			}
682 			else
683 			{
684 				aBtnAdd.Disable();
685 				aBtnHeader.Disable();
686 				aBtnDoSize.Disable();
687 				aBtnKeepFmt.Disable();
688 				aBtnStripData.Disable();
689 				aFTSource.Disable();
690 				aFTOperations.Disable();
691 			}
692 			aBtnRemove.Disable();
693 		}
694 
695         aFlAssign.Enable();
696 		aEdAssign.Enable();
697 		aRbAssign.Enable();
698 
699 		//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
700 		//SFX_APPWINDOW->Enable();
701 		bRefInputMode = sal_True;
702 	}
703 	return 0;
704 }
705 
706 //------------------------------------------------------------------------
707 
708 IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
709 {
710 	//	hier parsen fuer Save() etc.
711 
712 	ScRange aTmpRange;
713 	String aText = aEdAssign.GetText();
714 	if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
715 		theCurArea = aTmpRange;
716 
717 	return 0;
718 }
719 
720 
721