summaryrefslogtreecommitdiff
path: root/sc/source/ui/dbgui/dbnamdlg.cxx
blob: 3f417a63f31ce36a91735aee88e7b76e11053cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
/*************************************************************************
 *
 *  $RCSfile: dbnamdlg.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: nn $ $Date: 2000-10-23 14:58:48 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

// System - Includes ---------------------------------------------------------

#ifdef PCH
#include "ui_pch.hxx"
#endif

#pragma hdrstop

#ifndef PCH
#include <segmentc.hxx>
#endif

// INCLUDE -------------------------------------------------------------------

#include <vcl/msgbox.hxx>

#include "reffact.hxx"
#include "document.hxx"
#include "scresid.hxx"
#include "globstr.hrc"
#include "dbnamdlg.hrc"
#include "rangenam.hxx"		// IsNameValid

#define _DBNAMDLG_CXX
#include "dbnamdlg.hxx"
#undef _DBNAMDLG_CXX


//============================================================================

#define ABS_SREF		  SCA_VALID \
                        | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
#define ABS_DREF		  ABS_SREF \
                        | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
#define ABS_SREF3D		ABS_SREF | SCA_TAB_3D
#define ABS_DREF3D		ABS_DREF | SCA_TAB_3D

//----------------------------------------------------------------------------

class DBSaveData;

static DBSaveData* pSaveObj = NULL;

#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()

SEG_EOFGLOBALS()


//============================================================================
//	class DBSaveData

class DBSaveData
{
public:
    DBSaveData( Edit& rEd, CheckBox& rHdr, CheckBox& rSize, CheckBox& rFmt,
                            CheckBox& rStrip, ScRange& rArea )
        : bHeader(FALSE), bSize(FALSE), bFormat(FALSE), bDirty(FALSE),
          rEdAssign(rEd),
          rBtnHeader(rHdr), rBtnSize(rSize), rBtnFormat(rFmt), rBtnStrip(rStrip),
          rCurArea(rArea) {}

    void Clear();
    void Save();
    void Restore();

private:
    Edit&		rEdAssign;
    CheckBox&	rBtnHeader;
    CheckBox&	rBtnSize;
    CheckBox&	rBtnFormat;
    CheckBox&	rBtnStrip;
    ScRange&	rCurArea;
    String		aStr;
    ScRange		aArea;
    BOOL		bHeader:1;
    BOOL		bSize:1;
    BOOL		bFormat:1;
    BOOL		bStrip:1;
    BOOL		bDirty:1;
};



//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_0f)

void DBSaveData::Clear()
{
    aStr.Erase();
    aArea = ScRange();
    bHeader = bSize = bFormat = bStrip = bDirty = FALSE;
}


//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_10)

void DBSaveData::Save()
{
    aArea   = rCurArea;
    aStr    = rEdAssign.GetText();
    bHeader = rBtnHeader.IsChecked();
    bSize   = rBtnSize.IsChecked();
    bFormat = rBtnFormat.IsChecked();
    bStrip	= rBtnStrip.IsChecked();
    bDirty  = TRUE;
}


//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_11)

void DBSaveData::Restore()
{
    if ( bDirty )
    {
        rCurArea = aArea;
        rEdAssign.SetText( aStr );
        rBtnHeader.Check ( bHeader );
        rBtnSize.Check   ( bSize );
        rBtnFormat.Check ( bFormat );
        rBtnStrip.Check  ( bStrip );
        bDirty = FALSE;
    }
}


//============================================================================
//	class ScDbNameDlg

//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_01)

ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
                          ScViewData*	ptrViewData )

    :	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_DBNAMES ),
        //
        aGbName			( this, ScResId( GB_NAME ) ),
        aEdName			( this, ScResId( ED_NAME ) ),

        aGbAssign		( this, ScResId( GB_ASSIGN ) ),
        aEdAssign		( this, ScResId( ED_DBAREA ) ),
        aRbAssign		( this, ScResId( RB_DBAREA ), &aEdAssign ),
        aGbOptions		( this, ScResId( GB_OPTIONS ) ),
        aBtnHeader		( this, ScResId( BTN_HEADER ) ),
        aBtnDoSize		( this, ScResId( BTN_SIZE ) ),
        aBtnKeepFmt		( this, ScResId( BTN_FORMAT ) ),
        aBtnStripData	( this, ScResId( BTN_STRIPDATA ) ),
        aFTSource		( this, ScResId( FT_SOURCE ) ),
        aFTOperations	( this, ScResId( FT_OPERATIONS ) ),

        aBtnOk			( this, ScResId( BTN_OK ) ),
        aBtnCancel		( this, ScResId( BTN_CANCEL ) ),
        aBtnAdd			( this, ScResId( BTN_ADD ) ),
        aBtnRemove		( this, ScResId( BTN_REMOVE ) ),
        aBtnHelp		( this, ScResId( BTN_HELP ) ),
        aBtnMore		( this, ScResId( BTN_MORE ) ),

        aStrAdd			( ScResId( STR_ADD ) ),
        aStrModify		( ScResId( STR_MODIFY ) ),
        aStrNoName		( ScGlobal::GetRscString(STR_DB_NONAME) ),
        aStrInvalid		( ScResId( STR_DB_INVALID ) ),
        //
        pViewData		( ptrViewData ),
        pDoc			( ptrViewData->GetDocument() ),
        aLocalDbCol		( *(pDoc->GetDBCollection()) ),
        bRefInputMode	( FALSE )
{
    // WB_NOLABEL can't be set in resource...
    aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
    aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );

    //	damit die Strings in der Resource bei den FixedTexten bleiben koennen:
    aStrSource		= aFTSource.GetText();
    aStrOperations	= aFTOperations.GetText();

    pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
                        aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
    Init();
    FreeResource();
}


//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_02)

__EXPORT ScDbNameDlg::~ScDbNameDlg()
{
    DELETEZ( pSaveObj );

    ScRange* pEntry = (ScRange*)aRemoveList.First();
    while ( pEntry )
    {
        delete aRemoveList.Remove( pEntry );
        pEntry = (ScRange*)aRemoveList.Next();
    }
}


//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_03)

void ScDbNameDlg::Init()
{
    aBtnHeader.Check( TRUE );		// Default: mit Spaltenkoepfen

    aBtnMore.AddWindow( &aGbOptions );
    aBtnMore.AddWindow( &aBtnHeader );
    aBtnMore.AddWindow( &aBtnDoSize );
    aBtnMore.AddWindow( &aBtnKeepFmt );
    aBtnMore.AddWindow( &aBtnStripData );
    aBtnMore.AddWindow( &aFTSource );
    aBtnMore.AddWindow( &aFTOperations );

    String	theAreaStr;
    USHORT	nStartCol 	= 0;
    USHORT	nStartRow 	= 0;
    USHORT	nStartTab 	= 0;
    USHORT	nEndCol 	= 0;
    USHORT	nEndRow		= 0;
    USHORT	nEndTab 	= 0;

    aBtnOk.SetClickHdl		( LINK( this, ScDbNameDlg, OkBtnHdl ) );
    aBtnCancel.SetClickHdl	( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
    aBtnAdd.SetClickHdl		( LINK( this, ScDbNameDlg, AddBtnHdl ) );
    aBtnRemove.SetClickHdl	( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
    aEdName.SetModifyHdl	( LINK( this, ScDbNameDlg, NameModifyHdl ) );
    aEdAssign.SetModifyHdl	( LINK( this, ScDbNameDlg, AssModifyHdl ) );
    UpdateNames();

    if ( pViewData && pDoc )
    {
        ScDBCollection*	pDBColl	= pDoc->GetDBCollection();
        ScDBData*		pDBData = NULL;

        pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
                                  nEndCol,	 nEndRow,  nEndTab );

        theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
                              ScAddress( nEndCol,   nEndRow,   nEndTab ) );

        theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc );

        if ( pDBColl )
        {
            // Feststellen, ob definierter DB-Bereich markiert wurde:
            pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, TRUE );
            if ( pDBData )
            {
                String		theDbName;
                ScAddress&	rStart = theCurArea.aStart;
                ScAddress&	rEnd   = theCurArea.aEnd;
                USHORT		nCol1, nCol2, nRow1, nRow2, nTab;

                pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );

                if (   (rStart.Tab() == nTab)
                    && (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
                    && (rEnd.Col()   == nCol2) && (rEnd.Row()   == nRow2 ) )
                {
                    pDBData->GetName( theDbName );
                    if ( theDbName != aStrNoName )
                        aEdName.SetText( theDbName );
                    else
                        aEdName.SetText( EMPTY_STRING );
                    aBtnHeader.Check( pDBData->HasHeader() );
                    aBtnDoSize.Check( pDBData->IsDoSize() );
                    aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
                    aBtnStripData.Check( pDBData->IsStripData() );
                    SetInfoStrings( pDBData );
                }
            }
        }
    }

    aEdAssign.SetText( theAreaStr );
    aEdName.GrabFocus();
    bSaved=TRUE;
    pSaveObj->Save();
    NameModifyHdl( 0 );
}

#pragma SEG_FUNCDEF(dbnamdlg_14)

void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
{
    String aSource = aStrSource;
    if (pDBData)
    {
        aSource += ' ';
        aSource += pDBData->GetSourceString();
    }
    aFTSource.SetText( aSource );

    String aOper = aStrOperations;
    if (pDBData)
    {
        aOper += ' ';
        aOper += pDBData->GetOperations();
    }
    aFTOperations.SetText( aOper );
}

//----------------------------------------------------------------------------
// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
//  neue Selektion im Referenz-Fenster angezeigt wird.
#pragma SEG_FUNCDEF(dbnamdlg_04)

void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDoc )
{
    if ( aEdAssign.IsEnabled() )
    {
        if ( rRef.aStart != rRef.aEnd )
            RefInputStart( &aEdAssign );

        theCurArea = rRef;

        String aRefStr;
        theCurArea.Format( aRefStr, ABS_DREF3D, pDoc );
        aEdAssign.SetRefString( aRefStr );
        aBtnHeader.Enable();
        aBtnDoSize.Enable();
        aBtnKeepFmt.Enable();
        aBtnStripData.Enable();
        aFTSource.Enable();
        aFTOperations.Enable();
        aBtnAdd.Enable();
        bSaved=TRUE;
        pSaveObj->Save();
    }
}


//----------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_05)

BOOL __EXPORT ScDbNameDlg::Close()
{
    return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_06)

void ScDbNameDlg::SetActive()
{
    aEdAssign.GrabFocus();

    //	kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
    //	(nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
    //	(der ausgewaehlte DB-Name hat sich auch nicht veraendert)

    RefInputDone();
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_07)

void ScDbNameDlg::UpdateNames()
{
    USHORT	nNameCount = aLocalDbCol.GetCount();

    aEdName.SetUpdateMode( FALSE );
    //-----------------------------------------------------------
    aEdName.Clear();
    aEdAssign.SetText( EMPTY_STRING );

    if ( nNameCount > 0 )
    {
        ScDBData*	pDbData = NULL;
        String		aString;

        for ( USHORT i=0; i<nNameCount; i++ )
        {
            pDbData = (ScDBData*)(aLocalDbCol.At( i ));
            if ( pDbData )
            {
                pDbData->GetName( aString );
                if ( aString != aStrNoName )
                    aEdName.InsertEntry( aString );
            }
        }
    }
    else
    {
        aBtnAdd.SetText( aStrAdd );
        aBtnAdd.Disable();
        aBtnRemove.Disable();
    }
    //-----------------------------------------------------------
    aEdName.SetUpdateMode( TRUE );
    aEdName.Invalidate();
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_0e)

void ScDbNameDlg::UpdateDBData( const String& rStrName )
{
    String		theArea;
    USHORT 		nAt;
    ScDBData*	pData;

    aLocalDbCol.SearchName( rStrName, nAt );
    pData = (ScDBData*)(aLocalDbCol.At( nAt ));

    if ( pData )
    {
        USHORT nColStart = 0;
        USHORT nRowStart = 0;
        USHORT nColEnd	 = 0;
        USHORT nRowEnd	 = 0;
        USHORT nTab		 = 0;

        pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
        theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
                              ScAddress( nColEnd,	nRowEnd,   nTab ) );
        theCurArea.Format( theArea, ABS_DREF3D, pDoc );
        aEdAssign.SetText( theArea );
        aBtnAdd.SetText( aStrModify );
        aBtnHeader.Check( pData->HasHeader() );
        aBtnDoSize.Check( pData->IsDoSize() );
        aBtnKeepFmt.Check( pData->IsKeepFmt() );
        aBtnStripData.Check( pData->IsStripData() );
        SetInfoStrings( pData );
    }

    aBtnAdd.SetText( aStrModify );
    aBtnAdd.Enable();
    aBtnRemove.Enable();
    aBtnHeader.Enable();
    aBtnDoSize.Enable();
    aBtnKeepFmt.Enable();
    aBtnStripData.Enable();
    aFTSource.Enable();
    aFTOperations.Enable();
}

//------------------------------------------------------------------------

#pragma SEG_FUNCDEF(dbnamdlg_12)

BOOL ScDbNameDlg::IsRefInputMode() const
{
    return bRefInputMode;
}

//------------------------------------------------------------------------
// Handler:
// ========
#pragma SEG_FUNCDEF(dbnamdlg_08)

IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
{
    AddBtnHdl( 0 );

    // Der View die Aenderungen und die Remove-Liste uebergeben:
    // beide werden nur als Referenz uebergeben, so dass an dieser
    // Stelle keine Speicherleichen entstehen koennen:
    if ( pViewData )
        pViewData->GetView()->
            NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );

    Close();
    return 0;
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_0d)

IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
{
    Close();
    return 0;
}
IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_09)

IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
{
    String	aNewName = aEdName.GetText();
    String	aNewArea = aEdAssign.GetText();

    aNewName.EraseLeadingChars( ' ' );
    aNewName.EraseTrailingChars( ' ' );

    if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
    {
        if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
        {
            //	weil jetzt editiert werden kann, muss erst geparst werden
            ScRange aTmpRange;
            String aText = aEdAssign.GetText();
            if ( aTmpRange.ParseAny( aText, pDoc ) & SCA_VALID )
            {
                theCurArea = aTmpRange;
                ScAddress aStart = theCurArea.aStart;
                ScAddress aEnd   = theCurArea.aEnd;

                ScDBData* pOldEntry = NULL;
                USHORT nFoundAt = 0;
                if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
                    pOldEntry = aLocalDbCol[nFoundAt];
                if (pOldEntry)
                {
                    //	Bereich veraendern

                    pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
                                                        aEnd.Col(), aEnd.Row() );
                    pOldEntry->SetByRow( TRUE );
                    pOldEntry->SetHeader( aBtnHeader.IsChecked() );
                    pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
                    pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
                    pOldEntry->SetStripData( aBtnStripData.IsChecked() );
                }
                else
                {
                    //	neuen Bereich einfuegen

                    ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
                                                        aStart.Col(), aStart.Row(),
                                                        aEnd.Col(), aEnd.Row(),
                                                        TRUE, aBtnHeader.IsChecked() );
                    pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
                    pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
                    pNewEntry->SetStripData( aBtnStripData.IsChecked() );

                    if ( !aLocalDbCol.Insert( pNewEntry ) )
                        delete pNewEntry;
                }

                UpdateNames();

                aEdName.SetText( EMPTY_STRING );
                aEdName.GrabFocus();
                aBtnAdd.SetText( aStrAdd );
                aBtnAdd.Disable();
                aBtnRemove.Disable();
                aEdAssign.SetText( EMPTY_STRING );
                aBtnHeader.Check( TRUE );		// Default: mit Spaltenkoepfen
                aBtnDoSize.Check( FALSE );
                aBtnKeepFmt.Check( FALSE );
                aBtnStripData.Check( FALSE );
                SetInfoStrings( NULL );		// leer
                theCurArea = ScRange();
                bSaved=TRUE;
                pSaveObj->Save();
                NameModifyHdl( 0 );
            }
            else
            {
                ERRORBOX( aStrInvalid );
                aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
                aEdAssign.GrabFocus();
            }
        }
        else
        {
            ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
            aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
            aEdName.GrabFocus();
        }
    }
    return 0;
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_0a)

IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
{
    USHORT		 nRemoveAt = 0;
    const String aStrEntry = aEdName.GetText();

    if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
    {
        String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
        String aMsg		  = aStrDelMsg.GetToken( 0, '#' );

        aMsg += aStrEntry;
        aMsg += aStrDelMsg.GetToken( 1, '#' );

        if ( RET_YES == QUERYBOX(aMsg) )
        {
            ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);

            if ( pEntry )
            {
                USHORT nTab, nColStart, nRowStart, nColEnd, nRowEnd;
                pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
                aRemoveList.Insert(
                    new ScRange( ScAddress( nColStart, nRowStart, nTab ),
                                 ScAddress( nColEnd,   nRowEnd,   nTab ) ) );
            }
            aLocalDbCol.AtFree( nRemoveAt );

            UpdateNames();

            aEdName.SetText( EMPTY_STRING );
            aEdName.GrabFocus();
            aBtnAdd.SetText( aStrAdd );
            aBtnAdd.Disable();
            aBtnRemove.Disable();
            aEdAssign.SetText( EMPTY_STRING );
            theCurArea = ScRange();
            aBtnHeader.Check( TRUE );		// Default: mit Spaltenkoepfen
            aBtnDoSize.Check( FALSE );
            aBtnKeepFmt.Check( FALSE );
            aBtnStripData.Check( FALSE );
            SetInfoStrings( NULL );		// leer
            bSaved=FALSE;
            pSaveObj->Restore();
            NameModifyHdl( 0 );
        }
    }
    return 0;
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_0c)

IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
{
    String	theName		= aEdName.GetText();
    BOOL	bNameFound  = (COMBOBOX_ENTRY_NOTFOUND
                           != aEdName.GetEntryPos( theName ));

    if ( theName.Len() == 0 )
    {
        if ( aBtnAdd.GetText() != aStrAdd )
            aBtnAdd.SetText( aStrAdd );
        aBtnAdd		.Disable();
        aBtnRemove	.Disable();
        aGbAssign	.Disable();
        aBtnHeader	.Disable();
        aBtnDoSize	.Disable();
        aBtnKeepFmt	.Disable();
        aBtnStripData.Disable();
        aFTSource	.Disable();
        aFTOperations.Disable();
        aEdAssign	.Disable();
        aRbAssign	.Disable();
        //bSaved=FALSE;
        //pSaveObj->Restore();
        //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
        //SFX_APPWINDOW->Disable(FALSE);		//! allgemeine Methode im ScAnyRefDlg
        bRefInputMode = FALSE;
    }
    else
    {
        if ( bNameFound )
        {
            if ( aBtnAdd.GetText() != aStrModify )
                aBtnAdd.SetText( aStrModify );

            if(!bSaved)
            {
                bSaved=TRUE;
                pSaveObj->Save();
            }
            UpdateDBData( theName );
        }
        else
        {
            if ( aBtnAdd.GetText() != aStrAdd )
                aBtnAdd.SetText( aStrAdd );

            bSaved=FALSE;
            pSaveObj->Restore();

            if ( aEdAssign.GetText().Len() > 0 )
            {
                aBtnAdd.Enable();
                aBtnHeader.Enable();
                aBtnDoSize.Enable();
                aBtnKeepFmt.Enable();
                aBtnStripData.Enable();
                aFTSource.Enable();
                aFTOperations.Enable();
            }
            else
            {
                aBtnAdd.Disable();
                aBtnHeader.Disable();
                aBtnDoSize.Disable();
                aBtnKeepFmt.Disable();
                aBtnStripData.Disable();
                aFTSource.Disable();
                aFTOperations.Disable();
            }
            aBtnRemove.Disable();
        }

        aGbAssign.Enable();
        aEdAssign.Enable();
        aRbAssign.Enable();

        //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
        //SFX_APPWINDOW->Enable();
        bRefInputMode = TRUE;
    }
    return 0;
}

//------------------------------------------------------------------------
#pragma SEG_FUNCDEF(dbnamdlg_13)

IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
{
    //	hier parsen fuer Save() etc.

    ScRange aTmpRange;
    String aText = aEdAssign.GetText();
    if ( aTmpRange.ParseAny( aText, pDoc ) & SCA_VALID )
        theCurArea = aTmpRange;

    return 0;
}

/*----------------------------------------------------------------------------

    $Log: not supported by cvs2svn $
    Revision 1.1.1.1  2000/09/18 16:44:54  hr
    initial import
    
    Revision 1.54  2000/09/17 14:08:56  willem.vandorp
    OpenOffice header added.
    
    Revision 1.53  2000/08/31 16:38:20  willem.vandorp
    Header and footer replaced
    
    Revision 1.52  2000/02/11 12:22:54  hr
    #70473# changes for unicode ( patched by automated patchtool )
    
    Revision 1.51  1999/06/09 16:09:04  NN
    Sfx-appwin removed
    

      Rev 1.50   09 Jun 1999 18:09:04   NN
   Sfx-appwin removed

      Rev 1.49   10 Dec 1998 20:09:18   ANK
   #51738# Umstellung auf ScRefEdit zum Anzeigen von Referenzen

      Rev 1.48   12 Aug 1998 19:47:34   ANK
   #54702# IsRefInputMode ueberarbeitet

      Rev 1.47   06 Aug 1998 21:19:48   ANK
   #54702# Enablen/Disablen der Applikation nur noch in ScAnyRefDlg

      Rev 1.46   01 Jul 1998 15:00:12   ANK
   MUSS-Aenderung wg. Autocomplete

      Rev 1.45   15 Mar 1998 14:23:20   NN
   App-Fenster disablen mit bChild=FALSE

      Rev 1.44   05 Dec 1997 19:56:22   ANK
   Includes geaendert

      Rev 1.43   03 Sep 1997 15:23:42   RG
   change header

      Rev 1.42   12 Jun 1997 13:16:18   NN
   #40646# STR_DB_NONAME statt SCSTR_NONAME fuer DB-Bereiche

      Rev 1.41   04 Mar 1997 18:47:48   NN
   37186# nur gueltige Namen (wie Bereichsnamen) zulassen

      Rev 1.40   23 Feb 1997 22:49:22   NN
   Button 'Importierte Daten nicht speichern'

      Rev 1.39   13 Feb 1997 22:46:16   NN
   neue Optionen einstellbar

      Rev 1.38   17 Jan 1997 15:10:44   NN
   #35110# Bereich kann auch im Edit eingegeben werden

      Rev 1.37   18 Dec 1996 14:22:32   ER
   AddBtnHdl: Index eines geaenderten Bereiches erhalten

      Rev 1.36   13 Nov 1996 20:11:16   NN
   #33143# AutoHide nur bei Bereichsreferenz

      Rev 1.35   29 Oct 1996 14:03:34   NN
   ueberall ScResId statt ResId

      Rev 1.34   22 Oct 1996 15:29:58   RJ
   Buttons fuer Referenzeingabe

      Rev 1.33   08 Oct 1996 15:00:02   RJ
   Einklappen des Fensters bei Referenzeingabe

      Rev 1.32   15 Aug 1996 12:20:26   NN
   #30362# SetReference: ggf. Add-Button enablen

      Rev 1.31   18 Jul 1996 16:51:54   NN
   Parameter bStartOnly bei IsDBAtCursor

      Rev 1.30   10 Jun 1996 16:28:48   NN
   #28513# Restore statt Save im RemoveButtonHdl

      Rev 1.29   07 Jun 1996 14:23:42   NN
   #28451# kein NameModifyHdl in SetActive

      Rev 1.28   05 Jun 1996 19:19:00   NN
   kein Show im ctor (Position wird von aussen gesetzt)

      Rev 1.27   26 Apr 1996 12:02:40   NN
   SfxModelessDialog statt ModelessDialog

      Rev 1.26   25 Apr 1996 18:08:34   NN
   SetReference aufgeteilt in SetReference und AddRefEntry

      Rev 1.25   29 Jan 1996 15:12:22   MO
   neuer Link

      Rev 1.24   27 Nov 1995 16:39:50   MO
   RangeUtil/Area/Tripel gegen Address/Range ersetzt

      Rev 1.23   14 Nov 1995 18:05:36   MO
   Disable-Enable-Logik, DBName ueberpruefen

      Rev 1.22   09 Nov 1995 10:20:14   JN
   weitere Verbesseungen Modeless Dialoge

      Rev 1.21   08 Nov 1995 13:05:48   MO
   301-Aenderungen

      Rev 1.20   08 Nov 1995 10:45:48   JN
   Umstellung auf SfxChildWindow

      Rev 1.19   26 Oct 1995 11:29:44   MO
   Nachfrage beim Loeschen von Eintraegen

      Rev 1.18   14 Sep 1995 12:37:24   MO
   FixedInfos

      Rev 1.17   31 Jul 1995 08:58:00   MO
   CancelBtnHdl

      Rev 1.16   25 Apr 1995 17:01:30   MO
   Knopfflackern beseitigt

      Rev 1.15   20 Apr 1995 10:34:06   MO
   Show() im Ctor

      Rev 1.14   18 Apr 1995 16:55:00   MO
   Flackern bei SetText() an Buttons unterbunden

      Rev 1.13   24 Mar 1995 15:37:50   MO
   Mauseingabe von Referenzen korrigiert

      Rev 1.12   29 Jan 1995 13:17:42   NN
   include dbfunc statt tabview

      Rev 1.11   27 Jan 1995 18:39:50   MO
   __EXECUTE durch __EXPORT ersetzt

      Rev 1.10   26 Jan 1995 18:28:00   TRI
   __EXPORT bei virtuellen Methoden eingebaut

      Rev 1.9   23 Jan 1995 16:44:34   MO
   * unbenannt-DB-Bereich wird ignoriert
   * NotifyClose nicht mehr im Close() sondern im Ok-Handler
     damit ist wieder Abbrechen moeglich

      Rev 1.8   19 Jan 1995 17:12:14   TRI
   __EXPORT vor verschiedene LinkHandler gesetzt

      Rev 1.7   19 Jan 1995 11:36:20   MO
   Uebergabe der Veraenderungen an die View in der Close()-Methode.
   Dabei werden nur Referenzen weitergereicht, so dass im Dialog
   keine Speicherleichen entstehen.

      Rev 1.6   18 Jan 1995 13:56:26   TRI
   Pragmas zur Segementierung eingebaut

      Rev 1.5   12 Jan 1995 14:45:56   MO
   * Verwendung von ScRangeUtil
   * Enable/Disable-Logik ueberarbeitet
   * Erkennung von DB-Bereichen

      Rev 1.4   04 Jan 1995 19:28:00   MO
   Verwendung von DbUiUtil

      Rev 1.3   04 Jan 1995 13:09:46   MO
   Hinzufuegen/Loeschen-Knoepfe: Enable/Diable-Fehler beseitigt

      Rev 1.2   23 Dec 1994 12:26:52   MO
   Bereichseingabe nur noch mit der Maus moeglich

      Rev 1.1   23 Dec 1994 09:27:58   MO
   Korrigierte Version. Zusammen mit namedlg und den
   Collections auf einen lauffaehhigen Stand gebracht.

----------------------------------------------------------------------------*/

#pragma SEG_EOFMODULE