xref: /aoo41x/main/sc/source/ui/miscdlgs/crnrdlg.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // System - Includes ---------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir // INCLUDE -------------------------------------------------------------------
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include "reffact.hxx"
34cdf0e10cSrcweir #include "document.hxx"
35cdf0e10cSrcweir #include "scresid.hxx"
36cdf0e10cSrcweir #include "globstr.hrc"
37cdf0e10cSrcweir #include "crnrdlg.hrc"
38cdf0e10cSrcweir #include "docsh.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #define _CRNRDLG_CXX
41cdf0e10cSrcweir #include "crnrdlg.hxx"
42cdf0e10cSrcweir #undef _CRNRDLG_CXX
43cdf0e10cSrcweir #include <vcl/msgbox.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //============================================================================
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
49cdf0e10cSrcweir #define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
50cdf0e10cSrcweir 
51cdf0e10cSrcweir const sal_uLong nEntryDataCol = 0;
52cdf0e10cSrcweir const sal_uLong nEntryDataRow = 1;
53cdf0e10cSrcweir const sal_uLong nEntryDataDelim = 2;
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir //============================================================================
57cdf0e10cSrcweir //	class ScColRowNameRangesDlg
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir /*************************************************************************
61cdf0e10cSrcweir #*	Member:		ScColRowNameRangesDlg						Datum:04.09.97
62cdf0e10cSrcweir #*------------------------------------------------------------------------
63cdf0e10cSrcweir #*
64cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
65cdf0e10cSrcweir #*
66cdf0e10cSrcweir #*  Funktion:	Konstruktor der Klasse ScColRowNameRangesDlg.
67cdf0e10cSrcweir #*				Initialisieren der Klassen- Mitglieder,
68cdf0e10cSrcweir #*				Uebernahme der Range- Angaben und Aufruf
69cdf0e10cSrcweir #*				der eigentlichen Initialisierungsroutine
70cdf0e10cSrcweir #*
71cdf0e10cSrcweir #*  Input:		Sfx- Verknuepfungen
72cdf0e10cSrcweir #*				Parent- Window
73cdf0e10cSrcweir #*				SCViewData
74cdf0e10cSrcweir #*
75cdf0e10cSrcweir #*	Output:		---
76cdf0e10cSrcweir #*
77cdf0e10cSrcweir #************************************************************************/
78cdf0e10cSrcweir 
ScColRowNameRangesDlg(SfxBindings * pB,SfxChildWindow * pCW,Window * pParent,ScViewData * ptrViewData)79cdf0e10cSrcweir ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
80cdf0e10cSrcweir 								SfxChildWindow* pCW,
81cdf0e10cSrcweir 								Window* pParent,
82cdf0e10cSrcweir 								ScViewData*	ptrViewData )
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	:	ScAnyRefDlg	( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
85cdf0e10cSrcweir 		//
86cdf0e10cSrcweir         aFlAssign       ( this, ScResId( FL_ASSIGN ) ),
87cdf0e10cSrcweir 		aLbRange		( this, ScResId( LB_RANGE ) ),
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         aEdAssign       ( this, this, ScResId( ED_AREA ) ),
90cdf0e10cSrcweir 		aRbAssign		( this, ScResId( RB_AREA ), &aEdAssign, this ),
91cdf0e10cSrcweir 		aBtnColHead		( this, ScResId( BTN_COLHEAD ) ),
92cdf0e10cSrcweir 		aBtnRowHead		( this, ScResId( BTN_ROWHEAD ) ),
93cdf0e10cSrcweir 		aFtAssign2		( this, ScResId( FT_DATA_LABEL ) ),
94cdf0e10cSrcweir         aEdAssign2      ( this, this, ScResId( ED_DATA ) ),
95cdf0e10cSrcweir 		aRbAssign2		( this, ScResId( RB_DATA ), &aEdAssign2, this ),
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		aBtnOk			( this, ScResId( BTN_OK ) ),
98cdf0e10cSrcweir 		aBtnCancel		( this, ScResId( BTN_CANCEL ) ),
99cdf0e10cSrcweir 		aBtnHelp		( this, ScResId( BTN_HELP ) ),
100cdf0e10cSrcweir 		aBtnAdd			( this, ScResId( BTN_ADD ) ),
101cdf0e10cSrcweir 		aBtnRemove		( this, ScResId( BTN_REMOVE ) ),
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 		pViewData		( ptrViewData ),
104cdf0e10cSrcweir 		pDoc			( ptrViewData->GetDocument() ),
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 		pEdActive		( NULL ),
107cdf0e10cSrcweir 		bDlgLostFocus	( sal_False )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	xColNameRanges = pDoc->GetColNameRanges()->Clone();
110cdf0e10cSrcweir 	xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
111cdf0e10cSrcweir 	Init();
112cdf0e10cSrcweir 	FreeResource();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	aRbAssign.SetAccessibleRelationMemberOf(&aEdAssign);
115cdf0e10cSrcweir 	aRbAssign2.SetAccessibleRelationMemberOf(&aEdAssign);
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir /*************************************************************************
120cdf0e10cSrcweir #*	Member:		~ScColRowNameRangesDlg						Datum:04.09.97
121cdf0e10cSrcweir #*------------------------------------------------------------------------
122cdf0e10cSrcweir #*
123cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
124cdf0e10cSrcweir #*
125cdf0e10cSrcweir #*  Funktion:	Destruktor der Klasse
126cdf0e10cSrcweir #*
127cdf0e10cSrcweir #*  Input:		---
128cdf0e10cSrcweir #*
129cdf0e10cSrcweir #*	Output:		---
130cdf0e10cSrcweir #*
131cdf0e10cSrcweir #************************************************************************/
132cdf0e10cSrcweir 
~ScColRowNameRangesDlg()133cdf0e10cSrcweir __EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir #*	Member:		Init										Datum:04.09.97
140cdf0e10cSrcweir #*------------------------------------------------------------------------
141cdf0e10cSrcweir #*
142cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
143cdf0e10cSrcweir #*
144cdf0e10cSrcweir #*  Funktion:	Initialisierungs- Routine:
145cdf0e10cSrcweir #*				Umlenken der Event- Handler und einstellen der
146cdf0e10cSrcweir #*				Startparameter.
147cdf0e10cSrcweir #*
148cdf0e10cSrcweir #*  Input:		---
149cdf0e10cSrcweir #*
150cdf0e10cSrcweir #*	Output:		---
151cdf0e10cSrcweir #*
152cdf0e10cSrcweir #************************************************************************/
153cdf0e10cSrcweir 
Init()154cdf0e10cSrcweir void ScColRowNameRangesDlg::Init()
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	SCCOL	nStartCol 	= 0;
157cdf0e10cSrcweir 	SCROW	nStartRow 	= 0;
158cdf0e10cSrcweir 	SCTAB	nStartTab 	= 0;
159cdf0e10cSrcweir 	SCCOL	nEndCol 	= 0;
160cdf0e10cSrcweir 	SCROW	nEndRow		= 0;
161cdf0e10cSrcweir 	SCTAB	nEndTab 	= 0;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	aBtnOk.SetClickHdl		( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
164cdf0e10cSrcweir 	aBtnCancel.SetClickHdl	( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
165cdf0e10cSrcweir 	aBtnAdd.SetClickHdl		( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
166cdf0e10cSrcweir 	aBtnRemove.SetClickHdl	( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
167cdf0e10cSrcweir 	aLbRange.SetSelectHdl	( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
168cdf0e10cSrcweir 	aEdAssign.SetModifyHdl	( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
169cdf0e10cSrcweir 	aBtnColHead.SetClickHdl	( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
170cdf0e10cSrcweir 	aBtnRowHead.SetClickHdl	( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
171cdf0e10cSrcweir 	aEdAssign2.SetModifyHdl	( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
172cdf0e10cSrcweir 
173cdf0e10cSrcweir     Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
174cdf0e10cSrcweir     aEdAssign.SetGetFocusHdl( aLink );
175cdf0e10cSrcweir     aRbAssign.SetGetFocusHdl( aLink );
176cdf0e10cSrcweir     aEdAssign2.SetGetFocusHdl( aLink );
177cdf0e10cSrcweir     aRbAssign2.SetGetFocusHdl( aLink );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
180cdf0e10cSrcweir     aEdAssign.SetLoseFocusHdl( aLink );
181cdf0e10cSrcweir     aRbAssign.SetLoseFocusHdl( aLink );
182cdf0e10cSrcweir     aEdAssign2.SetLoseFocusHdl( aLink );
183cdf0e10cSrcweir     aRbAssign2.SetLoseFocusHdl( aLink );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	pEdActive = &aEdAssign;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	UpdateNames();
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	if ( pViewData && pDoc )
190cdf0e10cSrcweir 	{
191cdf0e10cSrcweir 		pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
192cdf0e10cSrcweir 								  nEndCol,	 nEndRow,  nEndTab );
193cdf0e10cSrcweir 		SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
194cdf0e10cSrcweir 							  ScAddress( nEndCol,   nEndRow,   nEndTab ) ) );
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 	else
197cdf0e10cSrcweir 	{
198cdf0e10cSrcweir 		aBtnColHead.Check( sal_True );
199cdf0e10cSrcweir 		aBtnRowHead.Check( sal_False );
200cdf0e10cSrcweir 		aEdAssign.SetText( EMPTY_STRING );
201cdf0e10cSrcweir 		aEdAssign2.SetText( EMPTY_STRING );
202cdf0e10cSrcweir 	}
203cdf0e10cSrcweir 
204cdf0e10cSrcweir     aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
205cdf0e10cSrcweir     aBtnColHead.Enable();
206cdf0e10cSrcweir 	aBtnRowHead.Enable();
207cdf0e10cSrcweir 	aEdAssign.Enable();
208cdf0e10cSrcweir 	aEdAssign.GrabFocus();
209cdf0e10cSrcweir     aRbAssign.Enable();
210cdf0e10cSrcweir 	//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
211cdf0e10cSrcweir 	//SFX_APPWINDOW->Enable();		// Ref-Feld hat Focus
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	Range1SelectHdl( 0 );
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 
217cdf0e10cSrcweir /*************************************************************************
218cdf0e10cSrcweir #*	Member:		SetColRowData								Datum:04.09.97
219cdf0e10cSrcweir #*------------------------------------------------------------------------
220cdf0e10cSrcweir #*
221cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
222cdf0e10cSrcweir #*
223cdf0e10cSrcweir #*  Funktion:	zugehoerigen Datenbereich eines Beschriftungsbereiches
224cdf0e10cSrcweir #*				auf default Werte setzen und beide Referenz-Edit-Felder
225cdf0e10cSrcweir #*				fuellen.
226cdf0e10cSrcweir #*
227cdf0e10cSrcweir #*  Input:		Einstellbereich fuer Labels
228cdf0e10cSrcweir #*
229cdf0e10cSrcweir #*	Output:		---
230cdf0e10cSrcweir #*
231cdf0e10cSrcweir #************************************************************************/
232cdf0e10cSrcweir 
SetColRowData(const ScRange & rLabelRange,sal_Bool bRef)233cdf0e10cSrcweir void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,sal_Bool bRef)
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	theCurData = theCurArea = rLabelRange;
236cdf0e10cSrcweir 	sal_Bool bValid = sal_True;
237cdf0e10cSrcweir 	SCCOL nCol1 = theCurArea.aStart.Col();
238cdf0e10cSrcweir 	SCCOL nCol2 = theCurArea.aEnd.Col();
239cdf0e10cSrcweir 	SCROW nRow1 = theCurArea.aStart.Row();
240cdf0e10cSrcweir 	SCROW nRow2 = theCurArea.aEnd.Row();
241cdf0e10cSrcweir 	if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
242cdf0e10cSrcweir 	{	// Spaltenkoepfe und Grenzfall gesamte Tabelle
243cdf0e10cSrcweir 		aBtnColHead.Check( sal_True );
244cdf0e10cSrcweir 		aBtnRowHead.Check( sal_False );
245cdf0e10cSrcweir 		if ( nRow2 == MAXROW  )
246cdf0e10cSrcweir 		{
247cdf0e10cSrcweir 			if ( nRow1 == 0 )
248cdf0e10cSrcweir 				bValid = sal_False;		// Grenzfall gesamte Tabelle
249cdf0e10cSrcweir 			else
250cdf0e10cSrcweir 			{	// Head unten, Data oben
251cdf0e10cSrcweir 				theCurData.aStart.SetRow( 0 );
252cdf0e10cSrcweir 				theCurData.aEnd.SetRow( nRow1 - 1 );
253cdf0e10cSrcweir 			}
254cdf0e10cSrcweir 		}
255cdf0e10cSrcweir 		else
256cdf0e10cSrcweir 		{	// Head oben, Data unten
257cdf0e10cSrcweir 			theCurData.aStart.SetRow( nRow2 + 1 );
258cdf0e10cSrcweir 			theCurData.aEnd.SetRow( MAXROW );
259cdf0e10cSrcweir 		}
260cdf0e10cSrcweir 	}
261cdf0e10cSrcweir 	else
262cdf0e10cSrcweir 	{	// Zeilenkoepfe
263cdf0e10cSrcweir 		aBtnRowHead.Check( sal_True );
264cdf0e10cSrcweir 		aBtnColHead.Check( sal_False );
265cdf0e10cSrcweir 		if ( nCol2 == MAXCOL )
266cdf0e10cSrcweir 		{	// Head rechts, Data links
267cdf0e10cSrcweir 			theCurData.aStart.SetCol( 0 );
268cdf0e10cSrcweir 			theCurData.aEnd.SetCol( nCol2 - 1 );
269cdf0e10cSrcweir 		}
270cdf0e10cSrcweir 		else
271cdf0e10cSrcweir 		{	// Head links, Data rechts
272cdf0e10cSrcweir 			theCurData.aStart.SetCol( nCol2 + 1 );
273cdf0e10cSrcweir 			theCurData.aEnd.SetCol( MAXCOL );
274cdf0e10cSrcweir 		}
275cdf0e10cSrcweir 	}
276cdf0e10cSrcweir 	if ( bValid )
277cdf0e10cSrcweir 	{
278cdf0e10cSrcweir         const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
279cdf0e10cSrcweir 		String aStr;
280cdf0e10cSrcweir 		theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 		if(bRef)
283cdf0e10cSrcweir 			aEdAssign.SetRefString( aStr );
284cdf0e10cSrcweir 		else
285cdf0e10cSrcweir 			aEdAssign.SetText( aStr );
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 		aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
288cdf0e10cSrcweir 		theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 		if(bRef)
291cdf0e10cSrcweir 			aEdAssign2.SetRefString( aStr );
292cdf0e10cSrcweir 		else
293cdf0e10cSrcweir 			aEdAssign2.SetText( aStr );
294cdf0e10cSrcweir 	}
295cdf0e10cSrcweir 	else
296cdf0e10cSrcweir 	{
297cdf0e10cSrcweir 		theCurData = theCurArea = ScRange();
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 		if(bRef)
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			aEdAssign.SetRefString( EMPTY_STRING );
302cdf0e10cSrcweir 			aEdAssign2.SetRefString( EMPTY_STRING );
303cdf0e10cSrcweir 		}
304cdf0e10cSrcweir 		else
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			aEdAssign.SetText( EMPTY_STRING );
307cdf0e10cSrcweir 			aEdAssign2.SetText( EMPTY_STRING );
308cdf0e10cSrcweir 		}
309cdf0e10cSrcweir 
310cdf0e10cSrcweir 		aBtnColHead.Disable();
311cdf0e10cSrcweir 		aBtnRowHead.Disable();
312cdf0e10cSrcweir 		aEdAssign2.Disable();
313cdf0e10cSrcweir         aRbAssign2.Disable();
314cdf0e10cSrcweir 	}
315cdf0e10cSrcweir }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 
318cdf0e10cSrcweir /*************************************************************************
319cdf0e10cSrcweir #*	Member:		AdjustColRowData							Datum:04.09.97
320cdf0e10cSrcweir #*------------------------------------------------------------------------
321cdf0e10cSrcweir #*
322cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
323cdf0e10cSrcweir #*
324cdf0e10cSrcweir #*  Funktion:	zugehoerigen Datenbereich eines Beschriftungsbereiches
325cdf0e10cSrcweir #*				anpassen und Data-Referenz-Edit-Feld fuellen.
326cdf0e10cSrcweir #*
327cdf0e10cSrcweir #*  Input:		Bereich fuer Labels
328cdf0e10cSrcweir #*
329cdf0e10cSrcweir #*	Output:		---
330cdf0e10cSrcweir #*
331cdf0e10cSrcweir #************************************************************************/
332cdf0e10cSrcweir 
AdjustColRowData(const ScRange & rDataRange,sal_Bool bRef)333cdf0e10cSrcweir void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,sal_Bool bRef)
334cdf0e10cSrcweir {
335cdf0e10cSrcweir 	theCurData = rDataRange;
336cdf0e10cSrcweir 	if ( aBtnColHead.IsChecked() )
337cdf0e10cSrcweir 	{	// Datenbereich gleiche Spalten wie Koepfe
338cdf0e10cSrcweir 		theCurData.aStart.SetCol( theCurArea.aStart.Col() );
339cdf0e10cSrcweir 		theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
340cdf0e10cSrcweir 		if ( theCurData.Intersects( theCurArea ) )
341cdf0e10cSrcweir 		{
342cdf0e10cSrcweir 			SCROW nRow1 = theCurArea.aStart.Row();
343cdf0e10cSrcweir 			SCROW nRow2 = theCurArea.aEnd.Row();
344cdf0e10cSrcweir 			if ( nRow1 > 0
345cdf0e10cSrcweir 			  && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
346cdf0e10cSrcweir 			{	// Data oben
347cdf0e10cSrcweir 				theCurData.aEnd.SetRow( nRow1 - 1 );
348cdf0e10cSrcweir 				if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
349cdf0e10cSrcweir 					theCurData.aStart.SetRow( theCurData.aEnd.Row() );
350cdf0e10cSrcweir 			}
351cdf0e10cSrcweir 			else
352cdf0e10cSrcweir 			{	// Data unten
353cdf0e10cSrcweir 				theCurData.aStart.SetRow( nRow2 + 1 );
354cdf0e10cSrcweir 				if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
355cdf0e10cSrcweir 					theCurData.aEnd.SetRow( theCurData.aStart.Row() );
356cdf0e10cSrcweir 			}
357cdf0e10cSrcweir 		}
358cdf0e10cSrcweir 	}
359cdf0e10cSrcweir 	else
360cdf0e10cSrcweir 	{	// Datenbereich gleiche Zeilen wie Koepfe
361cdf0e10cSrcweir 		theCurData.aStart.SetRow( theCurArea.aStart.Row() );
362cdf0e10cSrcweir 		theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
363cdf0e10cSrcweir 		if ( theCurData.Intersects( theCurArea ) )
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir 			SCCOL nCol1 = theCurArea.aStart.Col();
366cdf0e10cSrcweir 			SCCOL nCol2 = theCurArea.aEnd.Col();
367cdf0e10cSrcweir 			if ( nCol1 > 0
368cdf0e10cSrcweir 			  && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
369cdf0e10cSrcweir 			{	// Data links
370cdf0e10cSrcweir 				theCurData.aEnd.SetCol( nCol1 - 1 );
371cdf0e10cSrcweir 				if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
372cdf0e10cSrcweir 					theCurData.aStart.SetCol( theCurData.aEnd.Col() );
373cdf0e10cSrcweir 			}
374cdf0e10cSrcweir 			else
375cdf0e10cSrcweir 			{	// Data rechts
376cdf0e10cSrcweir 				theCurData.aStart.SetCol( nCol2 + 1 );
377cdf0e10cSrcweir 				if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
378cdf0e10cSrcweir 					theCurData.aEnd.SetCol( theCurData.aStart.Col() );
379cdf0e10cSrcweir 			}
380cdf0e10cSrcweir 		}
381cdf0e10cSrcweir 	}
382cdf0e10cSrcweir 	String aStr;
383cdf0e10cSrcweir 	theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 	if(bRef)
386cdf0e10cSrcweir 		aEdAssign2.SetRefString( aStr );
387cdf0e10cSrcweir 	else
388cdf0e10cSrcweir 		aEdAssign2.SetText( aStr );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir 	aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
391cdf0e10cSrcweir }
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir /*************************************************************************
395cdf0e10cSrcweir #*	Member:		SetReference								Datum:04.09.97
396cdf0e10cSrcweir #*------------------------------------------------------------------------
397cdf0e10cSrcweir #*
398cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
399cdf0e10cSrcweir #*
400cdf0e10cSrcweir #*  Funktion:	Uebergabe eines mit der Maus selektierten Tabellen-
401cdf0e10cSrcweir #*				bereiches, der dann als neue Selektion im Referenz-
402cdf0e10cSrcweir #*				Fenster angezeigt wird.
403cdf0e10cSrcweir #*
404cdf0e10cSrcweir #*  Input:		Bereich fuer Labels
405cdf0e10cSrcweir #*				Dokumentklasse
406cdf0e10cSrcweir #*
407cdf0e10cSrcweir #*	Output:		---
408cdf0e10cSrcweir #*
409cdf0e10cSrcweir #************************************************************************/
410cdf0e10cSrcweir 
SetReference(const ScRange & rRef,ScDocument *)411cdf0e10cSrcweir void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir 	if ( pEdActive )
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir 		if ( rRef.aStart != rRef.aEnd )
416cdf0e10cSrcweir 			RefInputStart( pEdActive );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 		String aRefStr;
419cdf0e10cSrcweir 		if ( pEdActive == &aEdAssign )
420cdf0e10cSrcweir 			SetColRowData( rRef, sal_True );
421cdf0e10cSrcweir 		else
422cdf0e10cSrcweir 			AdjustColRowData( rRef, sal_True );
423cdf0e10cSrcweir 		aBtnColHead.Enable();
424cdf0e10cSrcweir 		aBtnRowHead.Enable();
425cdf0e10cSrcweir 		aBtnAdd.Enable();
426cdf0e10cSrcweir 		aBtnRemove.Disable();
427cdf0e10cSrcweir 	}
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
431cdf0e10cSrcweir /*************************************************************************
432cdf0e10cSrcweir #*	Member:		Close										Datum:04.09.97
433cdf0e10cSrcweir #*------------------------------------------------------------------------
434cdf0e10cSrcweir #*
435cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
436cdf0e10cSrcweir #*
437cdf0e10cSrcweir #*  Funktion:	Schliessen des Fensters
438cdf0e10cSrcweir #*
439cdf0e10cSrcweir #*  Input:		---
440cdf0e10cSrcweir #*
441cdf0e10cSrcweir #*	Output:		---
442cdf0e10cSrcweir #*
443cdf0e10cSrcweir #************************************************************************/
444cdf0e10cSrcweir 
Close()445cdf0e10cSrcweir sal_Bool __EXPORT ScColRowNameRangesDlg::Close()
446cdf0e10cSrcweir {
447cdf0e10cSrcweir 	return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir 
451cdf0e10cSrcweir /*************************************************************************
452cdf0e10cSrcweir #*	Member:		SetActive									Datum:04.09.97
453cdf0e10cSrcweir #*------------------------------------------------------------------------
454cdf0e10cSrcweir #*
455cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
456cdf0e10cSrcweir #*
457cdf0e10cSrcweir #*  Funktion:	Aktivieren des Fensters
458cdf0e10cSrcweir #*
459cdf0e10cSrcweir #*  Input:		---
460cdf0e10cSrcweir #*
461cdf0e10cSrcweir #*	Output:		---
462cdf0e10cSrcweir #*
463cdf0e10cSrcweir #************************************************************************/
464cdf0e10cSrcweir 
SetActive()465cdf0e10cSrcweir void ScColRowNameRangesDlg::SetActive()
466cdf0e10cSrcweir {
467cdf0e10cSrcweir     if ( bDlgLostFocus )
468cdf0e10cSrcweir     {
469cdf0e10cSrcweir         bDlgLostFocus = sal_False;
470cdf0e10cSrcweir         if( pEdActive )
471cdf0e10cSrcweir             pEdActive->GrabFocus();
472cdf0e10cSrcweir     }
473cdf0e10cSrcweir     else
474cdf0e10cSrcweir         GrabFocus();
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     if( pEdActive == &aEdAssign )
477cdf0e10cSrcweir         Range1DataModifyHdl( 0 );
478cdf0e10cSrcweir     else if( pEdActive == &aEdAssign2 )
479cdf0e10cSrcweir         Range2DataModifyHdl( 0 );
480cdf0e10cSrcweir 
481cdf0e10cSrcweir     RefInputDone();
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 
485cdf0e10cSrcweir /*************************************************************************
486cdf0e10cSrcweir #*	Member:		UpdateNames									Datum:04.09.97
487cdf0e10cSrcweir #*------------------------------------------------------------------------
488cdf0e10cSrcweir #*
489cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
490cdf0e10cSrcweir #*
491cdf0e10cSrcweir #*  Funktion:	Aktualisieren der Namen
492cdf0e10cSrcweir #*
493cdf0e10cSrcweir #*  Input:		---
494cdf0e10cSrcweir #*
495cdf0e10cSrcweir #*	Output:		---
496cdf0e10cSrcweir #*
497cdf0e10cSrcweir #************************************************************************/
498cdf0e10cSrcweir 
UpdateNames()499cdf0e10cSrcweir void ScColRowNameRangesDlg::UpdateNames()
500cdf0e10cSrcweir {
501cdf0e10cSrcweir 	aLbRange.SetUpdateMode( sal_False );
502cdf0e10cSrcweir 	//-----------------------------------------------------------
503cdf0e10cSrcweir 	aLbRange.Clear();
504cdf0e10cSrcweir     aRangeMap.clear();
505cdf0e10cSrcweir 	aEdAssign.SetText( EMPTY_STRING );
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 	sal_uLong nCount, j;
508cdf0e10cSrcweir 	sal_uInt16 nPos; //@008 Hilfsvariable q eingefuegt
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	SCCOL nCol1;	//@008 04.09.97
511cdf0e10cSrcweir 	SCROW nRow1;	//Erweiterung fuer Bereichsnamen
512cdf0e10cSrcweir 	SCTAB nTab1;
513cdf0e10cSrcweir 	SCCOL nCol2;
514cdf0e10cSrcweir 	SCROW nRow2;
515cdf0e10cSrcweir 	SCTAB nTab2;
516cdf0e10cSrcweir 	String rString;
517cdf0e10cSrcweir 	String strShow;
518cdf0e10cSrcweir     const ScAddress::Details aDetails(pDoc->GetAddressConvention());
519cdf0e10cSrcweir 
520cdf0e10cSrcweir 	String aString;
521cdf0e10cSrcweir 	String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
522cdf0e10cSrcweir 	aString = strDelim;
523cdf0e10cSrcweir 	aString += ScGlobal::GetRscString( STR_COLUMN );
524cdf0e10cSrcweir 	aString += strDelim;
525cdf0e10cSrcweir 	nPos = aLbRange.InsertEntry( aString );
526cdf0e10cSrcweir 	aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
527cdf0e10cSrcweir 	if ( (nCount = xColNameRanges->Count()) > 0 )
528cdf0e10cSrcweir 	{
529cdf0e10cSrcweir 		ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
530cdf0e10cSrcweir 			nCount, pDoc );
531cdf0e10cSrcweir 		for ( j=0; j < nCount; j++ )
532cdf0e10cSrcweir 		{
533cdf0e10cSrcweir             const ScRange aRange(ppSortArray[j]->GetRange(0));
534cdf0e10cSrcweir 			aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 			//@008 Hole Bereichsparameter aus Dok
537cdf0e10cSrcweir 			ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
538cdf0e10cSrcweir 											nCol2, nRow2, nTab2 );
539cdf0e10cSrcweir 			SCCOL q=nCol1+3;
540cdf0e10cSrcweir 			if(q>nCol2) q=nCol2;
541cdf0e10cSrcweir 			//@008 Baue String zusammen
542cdf0e10cSrcweir 			strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
543cdf0e10cSrcweir 			if(pDoc!=NULL)
544cdf0e10cSrcweir 			{
545cdf0e10cSrcweir 				pDoc->GetString(nCol1, nRow1, nTab1,rString);
546cdf0e10cSrcweir 				strShow	+=rString;
547cdf0e10cSrcweir 				for(SCCOL i=nCol1+1;i<=q;i++)
548cdf0e10cSrcweir 				{
549cdf0e10cSrcweir 					strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
550cdf0e10cSrcweir 					pDoc->GetString(i, nRow1, nTab1,rString);
551cdf0e10cSrcweir 					strShow	+= rString;
552cdf0e10cSrcweir 				}
553cdf0e10cSrcweir 			}
554cdf0e10cSrcweir 			if(q<nCol2) // Zu lang? Ergaenzen um ",..."
555cdf0e10cSrcweir 			{
556cdf0e10cSrcweir 				strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
557cdf0e10cSrcweir 			}
558cdf0e10cSrcweir 			strShow += ']';
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 			//@008 String einfuegen in Listbox
561cdf0e10cSrcweir 			String aInsStr = aString;
562cdf0e10cSrcweir 			aInsStr += strShow;
563cdf0e10cSrcweir 			nPos = aLbRange.InsertEntry( aInsStr );
564cdf0e10cSrcweir             aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
565cdf0e10cSrcweir 			aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
566cdf0e10cSrcweir 		}
567cdf0e10cSrcweir 		delete [] ppSortArray;
568cdf0e10cSrcweir 	}
569cdf0e10cSrcweir 	aString = strDelim;
570cdf0e10cSrcweir 	aString += ScGlobal::GetRscString( STR_ROW );
571cdf0e10cSrcweir 	aString += strDelim;
572cdf0e10cSrcweir 	nPos = aLbRange.InsertEntry( aString );
573cdf0e10cSrcweir 	aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
574cdf0e10cSrcweir 	if ( (nCount = xRowNameRanges->Count()) > 0 )
575cdf0e10cSrcweir 	{
576cdf0e10cSrcweir 		ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
577cdf0e10cSrcweir 			nCount, pDoc );
578cdf0e10cSrcweir 		for ( j=0; j < nCount; j++ )
579cdf0e10cSrcweir 		{
580cdf0e10cSrcweir             const ScRange aRange(ppSortArray[j]->GetRange(0));
581cdf0e10cSrcweir 			aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 			//@008 Ab hier baue String fuer Zeilen
584cdf0e10cSrcweir 			ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
585cdf0e10cSrcweir 											nCol2, nRow2, nTab2 );
586cdf0e10cSrcweir 			SCROW q=nRow1+3;
587cdf0e10cSrcweir 			if(q>nRow2) q=nRow2;
588cdf0e10cSrcweir 			strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
589cdf0e10cSrcweir 			if(pDoc!=NULL)
590cdf0e10cSrcweir 			{
591cdf0e10cSrcweir 				pDoc->GetString(nCol1, nRow1, nTab1,rString);
592cdf0e10cSrcweir 				strShow	+= rString;
593cdf0e10cSrcweir 				for(SCROW i=nRow1+1;i<=q;i++)
594cdf0e10cSrcweir 				{
595cdf0e10cSrcweir 					strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
596cdf0e10cSrcweir 					pDoc->GetString(nCol1, i, nTab1,rString);
597cdf0e10cSrcweir 					strShow	+= rString;
598cdf0e10cSrcweir 				}
599cdf0e10cSrcweir 			}
600cdf0e10cSrcweir 			if(q<nRow2)
601cdf0e10cSrcweir 			{
602cdf0e10cSrcweir 				strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
603cdf0e10cSrcweir 			}
604cdf0e10cSrcweir 			strShow += ']';
605cdf0e10cSrcweir 
606cdf0e10cSrcweir 			String aInsStr = aString;
607cdf0e10cSrcweir 			aInsStr += strShow;
608cdf0e10cSrcweir 			nPos = aLbRange.InsertEntry( aInsStr );
609cdf0e10cSrcweir             aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
610cdf0e10cSrcweir 			aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
611cdf0e10cSrcweir 		}
612cdf0e10cSrcweir 		delete [] ppSortArray;
613cdf0e10cSrcweir 	}
614cdf0e10cSrcweir 	//-----------------------------------------------------------
615cdf0e10cSrcweir 	aLbRange.SetUpdateMode( sal_True );
616cdf0e10cSrcweir 	aLbRange.Invalidate();
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 
620cdf0e10cSrcweir /*************************************************************************
621cdf0e10cSrcweir #*	Member:		UpdateRangeData								Datum:04.09.97
622cdf0e10cSrcweir #*------------------------------------------------------------------------
623cdf0e10cSrcweir #*
624cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
625cdf0e10cSrcweir #*
626cdf0e10cSrcweir #*  Funktion:	Aktualisieren der Bereichsdaten
627cdf0e10cSrcweir #*
628cdf0e10cSrcweir #*  Input:		Bereichs-String
629cdf0e10cSrcweir #*				Flag fuer Spalten
630cdf0e10cSrcweir #*
631cdf0e10cSrcweir #*	Output:		---
632cdf0e10cSrcweir #*
633cdf0e10cSrcweir #************************************************************************/
634cdf0e10cSrcweir 
UpdateRangeData(const ScRange & rRange,sal_Bool bColName)635cdf0e10cSrcweir void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, sal_Bool bColName )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir     ScRangePair* pPair = NULL;
638cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
639cdf0e10cSrcweir     if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
640cdf0e10cSrcweir 		bFound = sal_True;
641cdf0e10cSrcweir     else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
642cdf0e10cSrcweir 		bFound = sal_True;
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	if ( bFound )
645cdf0e10cSrcweir 	{
646cdf0e10cSrcweir         const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
647cdf0e10cSrcweir 		String aStr;
648cdf0e10cSrcweir 		theCurArea = rRange;
649cdf0e10cSrcweir 		theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
650cdf0e10cSrcweir 		aEdAssign.SetText( aStr );
651cdf0e10cSrcweir 		aBtnAdd.Disable();
652cdf0e10cSrcweir 		aBtnRemove.Enable();
653cdf0e10cSrcweir 		aBtnColHead.Check( bColName );
654cdf0e10cSrcweir 		aBtnRowHead.Check( !bColName );
655cdf0e10cSrcweir 		theCurData = pPair->GetRange(1);
656cdf0e10cSrcweir 		theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
657cdf0e10cSrcweir 		aEdAssign2.SetText( aStr );
658cdf0e10cSrcweir 	}
659cdf0e10cSrcweir 	else
660cdf0e10cSrcweir 	{
661cdf0e10cSrcweir 		aBtnAdd.Enable();
662cdf0e10cSrcweir 		aBtnRemove.Disable();
663cdf0e10cSrcweir 	}
664cdf0e10cSrcweir 	aBtnColHead.Enable();
665cdf0e10cSrcweir 	aBtnRowHead.Enable();
666cdf0e10cSrcweir 	aEdAssign2.Enable();
667cdf0e10cSrcweir     aRbAssign2.Enable();
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
670cdf0e10cSrcweir 
671cdf0e10cSrcweir /*************************************************************************
672cdf0e10cSrcweir #*	Member:		IsRefInputMode								Datum:04.09.97
673cdf0e10cSrcweir #*------------------------------------------------------------------------
674cdf0e10cSrcweir #*
675cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
676cdf0e10cSrcweir #*
677cdf0e10cSrcweir #*  Funktion:	Abfragefunktion fuer Referenz- Input- Mode.
678cdf0e10cSrcweir #*
679cdf0e10cSrcweir #*  Input:		Bereichs-String
680cdf0e10cSrcweir #*				Flag fuer Spalten
681cdf0e10cSrcweir #*
682cdf0e10cSrcweir #*	Output:		true, wenn Referenz- Input- Mode
683cdf0e10cSrcweir #*
684cdf0e10cSrcweir #************************************************************************/
685cdf0e10cSrcweir 
IsRefInputMode() const686cdf0e10cSrcweir sal_Bool ScColRowNameRangesDlg::IsRefInputMode() const
687cdf0e10cSrcweir {
688cdf0e10cSrcweir 	return (pEdActive != NULL);
689cdf0e10cSrcweir }
690cdf0e10cSrcweir 
691cdf0e10cSrcweir //------------------------------------------------------------------------
692cdf0e10cSrcweir // Handler:
693cdf0e10cSrcweir // ========
694cdf0e10cSrcweir 
695cdf0e10cSrcweir /*************************************************************************
696cdf0e10cSrcweir #*	Handler:	OkBtnHdl									Datum:04.09.97
697cdf0e10cSrcweir #*------------------------------------------------------------------------
698cdf0e10cSrcweir #*
699cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
700cdf0e10cSrcweir #*
701cdf0e10cSrcweir #*  Funktion:   Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
702cdf0e10cSrcweir #*				Hinzufuegen- Button ausloesen, und die neu einge-
703cdf0e10cSrcweir #*				stellten Bereiche ans Dokument uebergeben.
704cdf0e10cSrcweir #*				Fensterschliessen- Anweisung ausloesen.
705cdf0e10cSrcweir #*  Input:		---
706cdf0e10cSrcweir #*
707cdf0e10cSrcweir #*	Output:		---
708cdf0e10cSrcweir #*
709cdf0e10cSrcweir #************************************************************************/
710cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,OkBtnHdl,void *,EMPTYARG)711cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
712cdf0e10cSrcweir {
713cdf0e10cSrcweir 	AddBtnHdl( 0 );
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 	// die RangeLists den Refs am Doc zuweisen
716cdf0e10cSrcweir 	pDoc->GetColNameRangesRef() = xColNameRanges;
717cdf0e10cSrcweir 	pDoc->GetRowNameRangesRef() = xRowNameRanges;
718cdf0e10cSrcweir 	// geaenderte Datenbereiche muessen sich auswirken
719cdf0e10cSrcweir 	pDoc->CompileColRowNameFormula();
720cdf0e10cSrcweir 	ScDocShell* pDocShell = pViewData->GetDocShell();
721cdf0e10cSrcweir 	pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
722cdf0e10cSrcweir 	pDocShell->SetDocumentModified();
723cdf0e10cSrcweir 
724cdf0e10cSrcweir 	Close();
725cdf0e10cSrcweir 	return 0;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 
729cdf0e10cSrcweir /*************************************************************************
730cdf0e10cSrcweir #*	Handler:	CancelBtnHdl								Datum:04.09.97
731cdf0e10cSrcweir #*------------------------------------------------------------------------
732cdf0e10cSrcweir #*
733cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
734cdf0e10cSrcweir #*
735cdf0e10cSrcweir #*  Funktion:	Fensterschliessen- Anweisung ausloesen.
736cdf0e10cSrcweir #*
737cdf0e10cSrcweir #*  Input:		---
738cdf0e10cSrcweir #*
739cdf0e10cSrcweir #*	Output:		---
740cdf0e10cSrcweir #*
741cdf0e10cSrcweir #************************************************************************/
742cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(ScColRowNameRangesDlg,CancelBtnHdl,void *,EMPTYARG)743cdf0e10cSrcweir IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
744cdf0e10cSrcweir {
745cdf0e10cSrcweir 	Close();
746cdf0e10cSrcweir 	return 0;
747cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(ScColRowNameRangesDlg,CancelBtnHdl,void *,EMPTYARG)748cdf0e10cSrcweir IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
749cdf0e10cSrcweir 
750cdf0e10cSrcweir 
751cdf0e10cSrcweir /*************************************************************************
752cdf0e10cSrcweir #*	Handler:	AddBtnHdl									Datum:04.09.97
753cdf0e10cSrcweir #*------------------------------------------------------------------------
754cdf0e10cSrcweir #*
755cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
756cdf0e10cSrcweir #*
757cdf0e10cSrcweir #*  Funktion:	Nach betaetigen des Hinzufuegen- Buttons, werden
758cdf0e10cSrcweir #*				die Bereichsangaben eingestellt und in der
759cdf0e10cSrcweir #*				Listbox dargestellt.
760cdf0e10cSrcweir #*
761cdf0e10cSrcweir #*  Input:		---
762cdf0e10cSrcweir #*
763cdf0e10cSrcweir #*	Output:		---
764cdf0e10cSrcweir #*
765cdf0e10cSrcweir #************************************************************************/
766cdf0e10cSrcweir 
767cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
768cdf0e10cSrcweir {
769cdf0e10cSrcweir 	String aNewArea( aEdAssign.GetText() );
770cdf0e10cSrcweir 	String aNewData( aEdAssign2.GetText() );
771cdf0e10cSrcweir 
772cdf0e10cSrcweir 	if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
773cdf0e10cSrcweir 	{
774cdf0e10cSrcweir         const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
775cdf0e10cSrcweir 		ScRange aRange1, aRange2;
776cdf0e10cSrcweir 		sal_Bool bOk1;
777cdf0e10cSrcweir         if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != sal_False
778cdf0e10cSrcweir 		  && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
779cdf0e10cSrcweir 		{
780cdf0e10cSrcweir 			theCurArea = aRange1;
781cdf0e10cSrcweir 			AdjustColRowData( aRange2 );
782cdf0e10cSrcweir 			ScRangePair* pPair;
783cdf0e10cSrcweir             if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
784cdf0e10cSrcweir 			{
785cdf0e10cSrcweir 				xColNameRanges->Remove( pPair );
786cdf0e10cSrcweir 				delete pPair;
787cdf0e10cSrcweir 			}
788cdf0e10cSrcweir             if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
789cdf0e10cSrcweir 			{
790cdf0e10cSrcweir 				xRowNameRanges->Remove( pPair );
791cdf0e10cSrcweir 				delete pPair;
792cdf0e10cSrcweir 			}
793cdf0e10cSrcweir 			if ( aBtnColHead.IsChecked() )
794cdf0e10cSrcweir 				xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
795cdf0e10cSrcweir 			else
796cdf0e10cSrcweir 				xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
797cdf0e10cSrcweir 
798cdf0e10cSrcweir 			UpdateNames();
799cdf0e10cSrcweir 
800cdf0e10cSrcweir 			aEdAssign.GrabFocus();
801cdf0e10cSrcweir 			aBtnAdd.Disable();
802cdf0e10cSrcweir 			aBtnRemove.Disable();
803cdf0e10cSrcweir 			aEdAssign.SetText( EMPTY_STRING );
804cdf0e10cSrcweir 			aBtnColHead.Check( sal_True );
805cdf0e10cSrcweir 			aBtnRowHead.Check( sal_False );
806cdf0e10cSrcweir 			aEdAssign2.SetText( EMPTY_STRING );
807cdf0e10cSrcweir 			theCurArea = ScRange();
808cdf0e10cSrcweir 			theCurData = theCurArea;
809cdf0e10cSrcweir 			Range1SelectHdl( 0 );
810cdf0e10cSrcweir 		}
811cdf0e10cSrcweir 		else
812cdf0e10cSrcweir 		{
813cdf0e10cSrcweir 			ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
814cdf0e10cSrcweir 			if ( !bOk1 )
815cdf0e10cSrcweir 				aEdAssign.GrabFocus();
816cdf0e10cSrcweir 			else
817cdf0e10cSrcweir 				aEdAssign2.GrabFocus();
818cdf0e10cSrcweir 		}
819cdf0e10cSrcweir 	}
820cdf0e10cSrcweir 	return 0;
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 
824cdf0e10cSrcweir /*************************************************************************
825cdf0e10cSrcweir #*	Handler:	RemoveBtnHdl								Datum:04.09.97
826cdf0e10cSrcweir #*------------------------------------------------------------------------
827cdf0e10cSrcweir #*
828cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
829cdf0e10cSrcweir #*
830cdf0e10cSrcweir #*  Funktion:	Nach betaetigen des Loeschen- Buttons, wird
831cdf0e10cSrcweir #*				die markierte Bereichsangabe geloescht.
832cdf0e10cSrcweir #*
833cdf0e10cSrcweir #*  Input:		---
834cdf0e10cSrcweir #*
835cdf0e10cSrcweir #*	Output:		---
836cdf0e10cSrcweir #*
837cdf0e10cSrcweir #************************************************************************/
838cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,RemoveBtnHdl,void *,EMPTYARG)839cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	String aRangeStr = aLbRange.GetSelectEntry();
842cdf0e10cSrcweir 	sal_uInt16 nSelectPos = aLbRange.GetSelectEntryPos();
843cdf0e10cSrcweir 	sal_Bool bColName =
844cdf0e10cSrcweir 		((sal_uLong)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
845cdf0e10cSrcweir     NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
846cdf0e10cSrcweir     if (itr == aRangeMap.end())
847cdf0e10cSrcweir         return 0;
848cdf0e10cSrcweir     const ScRange& rRange = itr->second;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir     ScRangePair* pPair = NULL;
851cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
852cdf0e10cSrcweir     if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
853cdf0e10cSrcweir 		bFound = sal_True;
854cdf0e10cSrcweir     else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
855cdf0e10cSrcweir 		bFound = sal_True;
856cdf0e10cSrcweir 	if ( bFound )
857cdf0e10cSrcweir 	{
858cdf0e10cSrcweir 		String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
859cdf0e10cSrcweir 		String aMsg		  = aStrDelMsg.GetToken( 0, '#' );
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 		aMsg += aRangeStr;
862cdf0e10cSrcweir 		aMsg += aStrDelMsg.GetToken( 1, '#' );
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 		if ( RET_YES == QUERYBOX(aMsg) )
865cdf0e10cSrcweir 		{
866cdf0e10cSrcweir 			if ( bColName )
867cdf0e10cSrcweir 				xColNameRanges->Remove( pPair );
868cdf0e10cSrcweir 			else
869cdf0e10cSrcweir 				xRowNameRanges->Remove( pPair );
870cdf0e10cSrcweir 			delete pPair;
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 			UpdateNames();
873cdf0e10cSrcweir 			sal_uInt16 nCnt = aLbRange.GetEntryCount();
874cdf0e10cSrcweir 			if ( nSelectPos >= nCnt )
875cdf0e10cSrcweir 			{
876cdf0e10cSrcweir 				if ( nCnt )
877cdf0e10cSrcweir 					nSelectPos = nCnt - 1;
878cdf0e10cSrcweir 				else
879cdf0e10cSrcweir 					nSelectPos = 0;
880cdf0e10cSrcweir 			}
881cdf0e10cSrcweir 			aLbRange.SelectEntryPos( nSelectPos );
882cdf0e10cSrcweir 			if ( nSelectPos &&
883cdf0e10cSrcweir 					(sal_uLong)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
884cdf0e10cSrcweir 				aLbRange.SelectEntryPos( --nSelectPos );	// ---Zeile---
885cdf0e10cSrcweir 
886cdf0e10cSrcweir 			aLbRange.GrabFocus();
887cdf0e10cSrcweir 			aBtnAdd.Disable();
888cdf0e10cSrcweir 			aBtnRemove.Disable();
889cdf0e10cSrcweir 			aEdAssign.SetText( EMPTY_STRING );
890cdf0e10cSrcweir 			theCurArea = theCurData = ScRange();
891cdf0e10cSrcweir 			aBtnColHead.Check( sal_True );
892cdf0e10cSrcweir 			aBtnRowHead.Check( sal_False );
893cdf0e10cSrcweir 			aEdAssign2.SetText( EMPTY_STRING );
894cdf0e10cSrcweir 			Range1SelectHdl( 0 );
895cdf0e10cSrcweir 		}
896cdf0e10cSrcweir 	}
897cdf0e10cSrcweir 	return 0;
898cdf0e10cSrcweir }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir 
901cdf0e10cSrcweir /*************************************************************************
902cdf0e10cSrcweir #*	Handler:	Range1SelectHdl								Datum:04.09.97
903cdf0e10cSrcweir #*------------------------------------------------------------------------
904cdf0e10cSrcweir #*
905cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
906cdf0e10cSrcweir #*
907cdf0e10cSrcweir #*  Funktion:	Wenn Zeile in Listbox ausgewaehlt wird,
908cdf0e10cSrcweir #*				werden die Eingabefelder entsprechend
909cdf0e10cSrcweir #*				eingestellt.
910cdf0e10cSrcweir #*
911cdf0e10cSrcweir #*  Input:		---
912cdf0e10cSrcweir #*
913cdf0e10cSrcweir #*	Output:		---
914cdf0e10cSrcweir #*
915cdf0e10cSrcweir #************************************************************************/
916cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,Range1SelectHdl,void *,EMPTYARG)917cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir 	sal_uInt16 nSelectPos = aLbRange.GetSelectEntryPos();
920cdf0e10cSrcweir 	sal_uInt16 nCnt = aLbRange.GetEntryCount();
921cdf0e10cSrcweir 	sal_uInt16 nMoves = 0;
922cdf0e10cSrcweir 	while ( nSelectPos < nCnt
923cdf0e10cSrcweir 			&& (sal_uLong)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
924cdf0e10cSrcweir 	{	// skip Delimiter
925cdf0e10cSrcweir 		++nMoves;
926cdf0e10cSrcweir 		aLbRange.SelectEntryPos( ++nSelectPos );
927cdf0e10cSrcweir 	}
928cdf0e10cSrcweir 	String aRangeStr = aLbRange.GetSelectEntry();
929cdf0e10cSrcweir 	if ( nMoves )
930cdf0e10cSrcweir 	{
931cdf0e10cSrcweir 		if ( nSelectPos > 1 && nSelectPos >= nCnt )
932cdf0e10cSrcweir 		{	// am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
933cdf0e10cSrcweir 			// wenn davor Eintraege existieren
934cdf0e10cSrcweir 			nSelectPos = nCnt - 2;
935cdf0e10cSrcweir 			aLbRange.SelectEntryPos( nSelectPos );
936cdf0e10cSrcweir 			aRangeStr = aLbRange.GetSelectEntry();
937cdf0e10cSrcweir 		}
938cdf0e10cSrcweir 		else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
939cdf0e10cSrcweir 				&& aRangeStr == aEdAssign.GetText() )
940cdf0e10cSrcweir 		{	// nach oben wandern statt nach unten auf die vorherige Position
941cdf0e10cSrcweir 			nSelectPos -= 2;
942cdf0e10cSrcweir 			aLbRange.SelectEntryPos( nSelectPos );
943cdf0e10cSrcweir 			aRangeStr = aLbRange.GetSelectEntry();
944cdf0e10cSrcweir 		}
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir     NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
947cdf0e10cSrcweir     if ( itr != aRangeMap.end() )
948cdf0e10cSrcweir 	{
949cdf0e10cSrcweir 		sal_Bool bColName =
950cdf0e10cSrcweir 			((sal_uLong)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
951cdf0e10cSrcweir 		UpdateRangeData( itr->second, bColName );
952cdf0e10cSrcweir 		aBtnAdd.Disable();
953cdf0e10cSrcweir 		aBtnRemove.Enable();
954cdf0e10cSrcweir 	}
955cdf0e10cSrcweir 	else
956cdf0e10cSrcweir 	{
957cdf0e10cSrcweir 		if ( aEdAssign.GetText().Len() > 0 )
958cdf0e10cSrcweir 		{
959cdf0e10cSrcweir 			if ( aEdAssign2.GetText().Len() > 0 )
960cdf0e10cSrcweir 				aBtnAdd.Enable();
961cdf0e10cSrcweir 			else
962cdf0e10cSrcweir 				aBtnAdd.Disable();
963cdf0e10cSrcweir 			aBtnColHead.Enable();
964cdf0e10cSrcweir 			aBtnRowHead.Enable();
965cdf0e10cSrcweir 			aEdAssign2.Enable();
966cdf0e10cSrcweir             aRbAssign2.Enable();
967cdf0e10cSrcweir 		}
968cdf0e10cSrcweir 		else
969cdf0e10cSrcweir 		{
970cdf0e10cSrcweir 			aBtnAdd.Disable();
971cdf0e10cSrcweir 			aBtnColHead.Disable();
972cdf0e10cSrcweir 			aBtnRowHead.Disable();
973cdf0e10cSrcweir 			aEdAssign2.Disable();
974cdf0e10cSrcweir             aRbAssign2.Disable();
975cdf0e10cSrcweir 		}
976cdf0e10cSrcweir 		aBtnRemove.Disable();
977cdf0e10cSrcweir 		aEdAssign.GrabFocus();
978cdf0e10cSrcweir 	}
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 	aEdAssign.Enable();
981cdf0e10cSrcweir 	aRbAssign.Enable();
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	//@BugID 54702 Enablen/Disablen nur noch in Basisklasse
984cdf0e10cSrcweir 	//SFX_APPWINDOW->Enable();
985cdf0e10cSrcweir 	return 0;
986cdf0e10cSrcweir }
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 
989cdf0e10cSrcweir /*************************************************************************
990cdf0e10cSrcweir #*	Handler:	Range1DataModifyHdl							Datum:04.09.97
991cdf0e10cSrcweir #*------------------------------------------------------------------------
992cdf0e10cSrcweir #*
993cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
994cdf0e10cSrcweir #*
995cdf0e10cSrcweir #*  Funktion:	Wird ausgeloest, wenn in der Tabelle, der Label-
996cdf0e10cSrcweir #*				Bereich geaendert wurde.
997cdf0e10cSrcweir #*
998cdf0e10cSrcweir #*  Input:		---
999cdf0e10cSrcweir #*
1000cdf0e10cSrcweir #*	Output:		---
1001cdf0e10cSrcweir #*
1002cdf0e10cSrcweir #************************************************************************/
1003cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,Range1DataModifyHdl,void *,EMPTYARG)1004cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
1005cdf0e10cSrcweir {
1006cdf0e10cSrcweir 	String aNewArea( aEdAssign.GetText() );
1007cdf0e10cSrcweir 	sal_Bool bValid = sal_False;
1008cdf0e10cSrcweir 	if ( aNewArea.Len() > 0 )
1009cdf0e10cSrcweir 	{
1010cdf0e10cSrcweir 		ScRange aRange;
1011cdf0e10cSrcweir 		if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
1012cdf0e10cSrcweir 		{
1013cdf0e10cSrcweir 			SetColRowData( aRange );
1014cdf0e10cSrcweir 			bValid = sal_True;
1015cdf0e10cSrcweir 		}
1016cdf0e10cSrcweir 	}
1017cdf0e10cSrcweir 	if ( bValid )
1018cdf0e10cSrcweir 	{
1019cdf0e10cSrcweir 		aBtnAdd.Enable();
1020cdf0e10cSrcweir 		aBtnColHead.Enable();
1021cdf0e10cSrcweir 		aBtnRowHead.Enable();
1022cdf0e10cSrcweir 		aEdAssign2.Enable();
1023cdf0e10cSrcweir         aRbAssign2.Enable();
1024cdf0e10cSrcweir 	}
1025cdf0e10cSrcweir 	else
1026cdf0e10cSrcweir 	{
1027cdf0e10cSrcweir 		aBtnAdd.Disable();
1028cdf0e10cSrcweir 		aBtnColHead.Disable();
1029cdf0e10cSrcweir 		aBtnRowHead.Disable();
1030cdf0e10cSrcweir 		aEdAssign2.Disable();
1031cdf0e10cSrcweir         aRbAssign2.Disable();
1032cdf0e10cSrcweir 	}
1033cdf0e10cSrcweir 	aBtnRemove.Disable();
1034cdf0e10cSrcweir 	return 0;
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir /*************************************************************************
1039cdf0e10cSrcweir #*	Handler:	Range2DataModifyHdl							Datum:04.09.97
1040cdf0e10cSrcweir #*------------------------------------------------------------------------
1041cdf0e10cSrcweir #*
1042cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
1043cdf0e10cSrcweir #*
1044cdf0e10cSrcweir #*  Funktion:	Wird ausgeloest, wenn in der Tabelle, der Daten-
1045cdf0e10cSrcweir #*				Bereich geaendert wurde
1046cdf0e10cSrcweir #*
1047cdf0e10cSrcweir #*  Input:		---
1048cdf0e10cSrcweir #*
1049cdf0e10cSrcweir #*	Output:		---
1050cdf0e10cSrcweir #*
1051cdf0e10cSrcweir #************************************************************************/
1052cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,Range2DataModifyHdl,void *,EMPTYARG)1053cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
1054cdf0e10cSrcweir {
1055cdf0e10cSrcweir 	String aNewData( aEdAssign2.GetText() );
1056cdf0e10cSrcweir 	if ( aNewData.Len() > 0 )
1057cdf0e10cSrcweir 	{
1058cdf0e10cSrcweir 		ScRange aRange;
1059cdf0e10cSrcweir 		if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
1060cdf0e10cSrcweir 		{
1061cdf0e10cSrcweir 			AdjustColRowData( aRange );
1062cdf0e10cSrcweir 			aBtnAdd.Enable();
1063cdf0e10cSrcweir 		}
1064cdf0e10cSrcweir 		else
1065cdf0e10cSrcweir 			aBtnAdd.Disable();
1066cdf0e10cSrcweir 	}
1067cdf0e10cSrcweir 	else
1068cdf0e10cSrcweir 	{
1069cdf0e10cSrcweir 		aBtnAdd.Disable();
1070cdf0e10cSrcweir 	}
1071cdf0e10cSrcweir 	return 0;
1072cdf0e10cSrcweir }
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir /*************************************************************************
1076cdf0e10cSrcweir #*	Handler:	ColClickHdl									Datum:04.09.97
1077cdf0e10cSrcweir #*------------------------------------------------------------------------
1078cdf0e10cSrcweir #*
1079cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
1080cdf0e10cSrcweir #*
1081cdf0e10cSrcweir #*  Funktion:	Radiobutton fuer Spalten wurde betaetigt,
1082cdf0e10cSrcweir #*				die entsprechenden Einstellungen werden
1083cdf0e10cSrcweir #*				vorgenommen
1084cdf0e10cSrcweir #*
1085cdf0e10cSrcweir #*  Input:		---
1086cdf0e10cSrcweir #*
1087cdf0e10cSrcweir #*	Output:		---
1088cdf0e10cSrcweir #*
1089cdf0e10cSrcweir #************************************************************************/
1090cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,ColClickHdl,void *,EMPTYARG)1091cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir 	if ( !aBtnColHead.GetSavedValue() )
1094cdf0e10cSrcweir 	{
1095cdf0e10cSrcweir 		aBtnColHead.Check( sal_True );
1096cdf0e10cSrcweir 		aBtnRowHead.Check( sal_False );
1097cdf0e10cSrcweir 		if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
1098cdf0e10cSrcweir 		{
1099cdf0e10cSrcweir 			theCurArea.aEnd.SetRow( MAXROW - 1 );
1100cdf0e10cSrcweir 			String aStr;
1101cdf0e10cSrcweir 			theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
1102cdf0e10cSrcweir 			aEdAssign.SetText( aStr );
1103cdf0e10cSrcweir 		}
1104cdf0e10cSrcweir 		ScRange aRange( theCurData );
1105cdf0e10cSrcweir 		aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
1106cdf0e10cSrcweir 		aRange.aEnd.SetRow( MAXROW );
1107cdf0e10cSrcweir 		AdjustColRowData( aRange );
1108cdf0e10cSrcweir 	}
1109cdf0e10cSrcweir 	return 0;
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir /*************************************************************************
1114cdf0e10cSrcweir #*	Handler:	RowClickHdl									Datum:04.09.97
1115cdf0e10cSrcweir #*------------------------------------------------------------------------
1116cdf0e10cSrcweir #*
1117cdf0e10cSrcweir #*  Klasse:		ScColRowNameRangesDlg
1118cdf0e10cSrcweir #*
1119cdf0e10cSrcweir #*  Funktion:	Radiobutton fuer Zeilen wurde betaetigt,
1120cdf0e10cSrcweir #*				die entsprechenden Einstellungen werden
1121cdf0e10cSrcweir #*				vorgenommen
1122cdf0e10cSrcweir #*
1123cdf0e10cSrcweir #*  Input:		---
1124cdf0e10cSrcweir #*
1125cdf0e10cSrcweir #*	Output:		---
1126cdf0e10cSrcweir #*
1127cdf0e10cSrcweir #************************************************************************/
1128cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,RowClickHdl,void *,EMPTYARG)1129cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
1130cdf0e10cSrcweir {
1131cdf0e10cSrcweir 	if ( !aBtnRowHead.GetSavedValue() )
1132cdf0e10cSrcweir 	{
1133cdf0e10cSrcweir 		aBtnRowHead.Check( sal_True );
1134cdf0e10cSrcweir 		aBtnColHead.Check( sal_False );
1135cdf0e10cSrcweir 		if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
1136cdf0e10cSrcweir 		{
1137cdf0e10cSrcweir 			theCurArea.aEnd.SetCol( MAXCOL - 1 );
1138cdf0e10cSrcweir 			String aStr;
1139cdf0e10cSrcweir 			theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
1140cdf0e10cSrcweir 			aEdAssign.SetText( aStr );
1141cdf0e10cSrcweir 		}
1142cdf0e10cSrcweir 		ScRange aRange( theCurData );
1143cdf0e10cSrcweir 		aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
1144cdf0e10cSrcweir 		aRange.aEnd.SetCol( MAXCOL );
1145cdf0e10cSrcweir 		AdjustColRowData( aRange );
1146cdf0e10cSrcweir 	}
1147cdf0e10cSrcweir 	return 0;
1148cdf0e10cSrcweir }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,GetFocusHdl,Control *,pCtrl)1151cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
1152cdf0e10cSrcweir {
1153cdf0e10cSrcweir     if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
1154cdf0e10cSrcweir         pEdActive = &aEdAssign;
1155cdf0e10cSrcweir     else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
1156cdf0e10cSrcweir         pEdActive = &aEdAssign2;
1157cdf0e10cSrcweir     else
1158cdf0e10cSrcweir         pEdActive = NULL;
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir     if( pEdActive )
1161cdf0e10cSrcweir         pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
1162cdf0e10cSrcweir 
1163cdf0e10cSrcweir 	return 0;
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir 
IMPL_LINK(ScColRowNameRangesDlg,LoseFocusHdl,Control *,EMPTYARG)1167cdf0e10cSrcweir IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
1168cdf0e10cSrcweir {
1169cdf0e10cSrcweir 	bDlgLostFocus = !IsActive();
1170cdf0e10cSrcweir 	return 0;
1171cdf0e10cSrcweir }
1172