xref: /AOO41X/main/toolkit/workben/layout/tpsort.cxx (revision b0724fc6948542b2496e16ea247f985ee5987cfe)
1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #if !TEST_LAYOUT
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_sc.hxx"
27cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #undef SC_DLLIMPLEMENTATION
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <vcl/msgbox.hxx>
34cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
35cdf0e10cSrcweir #include <svtools/collatorres.hxx>
36cdf0e10cSrcweir #include <unotools/collatorwrapper.hxx>
37cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
38cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "scitems.hxx"
41cdf0e10cSrcweir #include "uiitems.hxx"
42cdf0e10cSrcweir #include "viewdata.hxx"
43cdf0e10cSrcweir #include "document.hxx"
44cdf0e10cSrcweir #include "global.hxx"
45cdf0e10cSrcweir #include "dbcolect.hxx"
46cdf0e10cSrcweir #include "userlist.hxx"
47cdf0e10cSrcweir #include "rangeutl.hxx"
48cdf0e10cSrcweir #include "scresid.hxx"
49cdf0e10cSrcweir #include "sc.hrc"       // -> Slot IDs
50cdf0e10cSrcweir #include "globstr.hrc"
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #include "sortdlg.hxx"
53cdf0e10cSrcweir #include "sortdlg.hrc"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir #define _TPSORT_CXX
56cdf0e10cSrcweir #include "tpsort.hxx"
57cdf0e10cSrcweir #undef _TPSORT_CXX
58cdf0e10cSrcweir 
59cdf0e10cSrcweir using namespace com::sun::star;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
62cdf0e10cSrcweir 
63cdf0e10cSrcweir static USHORT pSortRanges[] =
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 	SID_SORT,
66cdf0e10cSrcweir 	SID_SORT,
67cdf0e10cSrcweir 	0
68cdf0e10cSrcweir };
69cdf0e10cSrcweir 
70cdf0e10cSrcweir // -----------------------------------------------------------------------
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /*
73cdf0e10cSrcweir  * Da sich Einstellungen auf der zweiten TabPage (Optionen) auf
74cdf0e10cSrcweir  * die erste TabPage auswirken, muss es die Moeglichkeit geben,
75cdf0e10cSrcweir  * dies der jeweils anderen Seite mitzuteilen.
76cdf0e10cSrcweir  *
77cdf0e10cSrcweir  * Im Moment wird dieses Problem ueber zwei Datenmember des TabDialoges
78cdf0e10cSrcweir  * geloest. Wird eine Seite Aktiviert/Deaktiviert, so gleicht sie diese
79cdf0e10cSrcweir  * Datenmember mit dem eigenen Zustand ab (->Activate()/Deactivate()).
80cdf0e10cSrcweir  *
81cdf0e10cSrcweir  * 31.01.95:
82cdf0e10cSrcweir  * Die Klasse SfxTabPage bietet mittlerweile ein Verfahren an:
83cdf0e10cSrcweir  *
84cdf0e10cSrcweir  * virtual BOOL HasExchangeSupport() const; -> return TRUE;
85cdf0e10cSrcweir  * virtual void ActivatePage(const SfxItemSet &);
86cdf0e10cSrcweir  * virtual int	DeactivatePage(SfxItemSet * = 0);
87cdf0e10cSrcweir  *
88cdf0e10cSrcweir  * muss noch geaendert werden!
89cdf0e10cSrcweir  */
90cdf0e10cSrcweir 
91cdf0e10cSrcweir //========================================================================
92cdf0e10cSrcweir //========================================================================
93cdf0e10cSrcweir // Sortierkriterien-Tabpage:
94cdf0e10cSrcweir 
ScTabPageSortFields(Window * pParent,const SfxItemSet & rArgSet)95cdf0e10cSrcweir ScTabPageSortFields::ScTabPageSortFields( Window*			pParent,
96cdf0e10cSrcweir 										  const SfxItemSet& rArgSet )
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	:	SfxTabPage		( pParent,
99cdf0e10cSrcweir 						  ScResId( RID_SCPAGE_SORT_FIELDS ),
100cdf0e10cSrcweir 						  rArgSet ),
101cdf0e10cSrcweir 		//
102cdf0e10cSrcweir         aFlSort1        ( this, ScResId( FL_SORT1  ) ),
103cdf0e10cSrcweir 		aLbSort1		( this, ScResId( LB_SORT1  ) ),
104cdf0e10cSrcweir         aBtnUp1         ( this, ScResId( BTN_UP1   ) ),
105cdf0e10cSrcweir 		aBtnDown1		( this, ScResId( BTN_DOWN1 ) ),
106cdf0e10cSrcweir 		//
107cdf0e10cSrcweir         aFlSort2        ( this, ScResId( FL_SORT2  ) ),
108cdf0e10cSrcweir 		aLbSort2		( this, ScResId( LB_SORT2  ) ),
109cdf0e10cSrcweir         aBtnUp2         ( this, ScResId( BTN_UP2   ) ),
110cdf0e10cSrcweir 		aBtnDown2		( this, ScResId( BTN_DOWN2 ) ),
111cdf0e10cSrcweir 		//
112cdf0e10cSrcweir         aFlSort3        ( this, ScResId( FL_SORT3  ) ),
113cdf0e10cSrcweir 		aLbSort3		( this, ScResId( LB_SORT3  ) ),
114cdf0e10cSrcweir         aBtnUp3         ( this, ScResId( BTN_UP3   ) ),
115cdf0e10cSrcweir 		aBtnDown3		( this, ScResId( BTN_DOWN3 ) ),
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		aStrUndefined	( ScResId( SCSTR_UNDEFINED ) ),
118cdf0e10cSrcweir 		aStrColumn		( ScResId( SCSTR_COLUMN ) ),
119cdf0e10cSrcweir 		aStrRow 		( ScResId( SCSTR_ROW ) ),
120cdf0e10cSrcweir 		//
121cdf0e10cSrcweir #if !TEST_LAYOUT
122cdf0e10cSrcweir 		nWhichSort		( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
123cdf0e10cSrcweir #else /* TEST_LAYOUT */
124cdf0e10cSrcweir 		nWhichSort		( 0 ),
125cdf0e10cSrcweir #endif /* TEST_LAYOUT */
126cdf0e10cSrcweir 		pDlg			( (ScSortDlg*)(GetParent()->GetParent()) ),
127cdf0e10cSrcweir 		pViewData		( NULL ),
128cdf0e10cSrcweir #if !TEST_LAYOUT
129cdf0e10cSrcweir 		rSortData		( ((const ScSortItem&)
130cdf0e10cSrcweir 						   rArgSet.Get( nWhichSort )).
131cdf0e10cSrcweir 								GetSortData() ),
132cdf0e10cSrcweir #else /* TEST_LAYOUT */
133cdf0e10cSrcweir 		rSortData		( *new ScSortParam() ),
134cdf0e10cSrcweir #endif /* TEST_LAYOUT */
135cdf0e10cSrcweir 		nFieldCount 	( 0 ),
136cdf0e10cSrcweir 		bHasHeader		( FALSE ),
137cdf0e10cSrcweir 		bSortByRows 	( FALSE )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir 	Init();
140cdf0e10cSrcweir 	FreeResource();
141cdf0e10cSrcweir 	SetExchangeSupport();
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // -----------------------------------------------------------------------
145cdf0e10cSrcweir 
~ScTabPageSortFields()146cdf0e10cSrcweir __EXPORT ScTabPageSortFields::~ScTabPageSortFields()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir // -----------------------------------------------------------------------
151cdf0e10cSrcweir 
Init()152cdf0e10cSrcweir void ScTabPageSortFields::Init()
153cdf0e10cSrcweir {
154cdf0e10cSrcweir #if !TEST_LAYOUT
155cdf0e10cSrcweir 	const ScSortItem& rSortItem = (const ScSortItem&)
156cdf0e10cSrcweir 								  GetItemSet().Get( nWhichSort );
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	pViewData = rSortItem.GetViewData();
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	DBG_ASSERT( pViewData, "ViewData not found!" );
161cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	nFieldArr[0] = 0;
164cdf0e10cSrcweir     nFirstCol = 0;
165cdf0e10cSrcweir     nFirstRow = 0;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	aLbSort1.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
168cdf0e10cSrcweir 	aLbSort2.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
169cdf0e10cSrcweir 	aLbSort3.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
170cdf0e10cSrcweir 	aLbSort1.Clear();
171cdf0e10cSrcweir 	aLbSort2.Clear();
172cdf0e10cSrcweir 	aLbSort3.Clear();
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 	aSortLbArr[0]		= &aLbSort1;
175cdf0e10cSrcweir 	aSortLbArr[1]		= &aLbSort2;
176cdf0e10cSrcweir 	aSortLbArr[2]		= &aLbSort3;
177cdf0e10cSrcweir 	aDirBtnArr[0][0]	= &aBtnUp1;
178cdf0e10cSrcweir 	aDirBtnArr[0][1]	= &aBtnDown1;
179cdf0e10cSrcweir 	aDirBtnArr[1][0]	= &aBtnUp2;
180cdf0e10cSrcweir 	aDirBtnArr[1][1]	= &aBtnDown2;
181cdf0e10cSrcweir 	aDirBtnArr[2][0]	= &aBtnUp3;
182cdf0e10cSrcweir 	aDirBtnArr[2][1]	= &aBtnDown3;
183cdf0e10cSrcweir     aFlArr[0]           = &aFlSort1;
184cdf0e10cSrcweir     aFlArr[1]           = &aFlSort2;
185cdf0e10cSrcweir     aFlArr[2]           = &aFlSort3;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir //------------------------------------------------------------------------
189cdf0e10cSrcweir 
GetRanges()190cdf0e10cSrcweir USHORT* __EXPORT ScTabPageSortFields::GetRanges()
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	return pSortRanges;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir // -----------------------------------------------------------------------
196cdf0e10cSrcweir 
Create(Window * pParent,const SfxItemSet & rArgSet)197cdf0e10cSrcweir SfxTabPage* __EXPORT ScTabPageSortFields::Create( Window*	pParent,
198cdf0e10cSrcweir 										 const SfxItemSet&	rArgSet )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir 	return ( new ScTabPageSortFields( pParent, rArgSet ) );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir // -----------------------------------------------------------------------
204cdf0e10cSrcweir 
Reset(const SfxItemSet &)205cdf0e10cSrcweir void __EXPORT ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	bSortByRows = rSortData.bByRow;
208cdf0e10cSrcweir 	bHasHeader	= rSortData.bHasHeader;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	if ( aLbSort1.GetEntryCount() == 0 )
211cdf0e10cSrcweir 		FillFieldLists();
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	// Selektieren der ListBoxen:
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	if ( rSortData.bDoSort[0] )
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir 		for ( USHORT i=0; i<3; i++ )
218cdf0e10cSrcweir 		{
219cdf0e10cSrcweir 			if ( rSortData.bDoSort[i] )
220cdf0e10cSrcweir 			{
221cdf0e10cSrcweir 				aSortLbArr[i]->SelectEntryPos(
222cdf0e10cSrcweir 					 GetFieldSelPos( rSortData.nField[i] ) );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 				(rSortData.bAscending[i])
225cdf0e10cSrcweir 					? aDirBtnArr[i][0]->Check() 	// Up
226cdf0e10cSrcweir 					: aDirBtnArr[i][1]->Check();	// Down
227cdf0e10cSrcweir 			}
228cdf0e10cSrcweir 			else
229cdf0e10cSrcweir 			{
230cdf0e10cSrcweir 				aSortLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
231cdf0e10cSrcweir 				aDirBtnArr[i][0]->Check();			// Up
232cdf0e10cSrcweir 			}
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 		EnableField( 1 );
236cdf0e10cSrcweir 		EnableField( 2 );
237cdf0e10cSrcweir 		EnableField( 3 );
238cdf0e10cSrcweir 		if ( aLbSort1.GetSelectEntryPos() == 0 )
239cdf0e10cSrcweir 			DisableField( 2 );
240cdf0e10cSrcweir 		if ( aLbSort2.GetSelectEntryPos() == 0 )
241cdf0e10cSrcweir 			DisableField( 3 );
242cdf0e10cSrcweir 	}
243cdf0e10cSrcweir 	else
244cdf0e10cSrcweir 	{
245cdf0e10cSrcweir 		aLbSort1.SelectEntryPos( 1 );
246cdf0e10cSrcweir 		aLbSort2.SelectEntryPos( 0 );
247cdf0e10cSrcweir 		aLbSort3.SelectEntryPos( 0 );
248cdf0e10cSrcweir 		aBtnUp1.Check();
249cdf0e10cSrcweir 		aBtnUp2.Check();
250cdf0e10cSrcweir 		aBtnUp3.Check();
251cdf0e10cSrcweir 		EnableField ( 1 );
252cdf0e10cSrcweir 		EnableField ( 2 );
253cdf0e10cSrcweir 		DisableField( 3 );
254cdf0e10cSrcweir 	}
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 	if ( pDlg )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir 		pDlg->SetByRows ( bSortByRows );
259cdf0e10cSrcweir 		pDlg->SetHeaders( bHasHeader );
260cdf0e10cSrcweir 	}
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir // -----------------------------------------------------------------------
264cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rArgSet)265cdf0e10cSrcweir BOOL __EXPORT ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir 	ScSortParam theSortData = rSortData;
268cdf0e10cSrcweir 	if (pDlg)
269cdf0e10cSrcweir 	{
270cdf0e10cSrcweir 		const SfxItemSet* pExample = pDlg->GetExampleSet();
271cdf0e10cSrcweir 		const SfxPoolItem* pItem;
272cdf0e10cSrcweir 		if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
273cdf0e10cSrcweir 			theSortData = ((const ScSortItem*)pItem)->GetSortData();
274cdf0e10cSrcweir 	}
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	USHORT	nSort1Pos = aLbSort1.GetSelectEntryPos();
277cdf0e10cSrcweir 	USHORT	nSort2Pos = aLbSort2.GetSelectEntryPos();
278cdf0e10cSrcweir 	USHORT	nSort3Pos = aLbSort3.GetSelectEntryPos();
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	DBG_ASSERT(    (nSort1Pos <= SC_MAXFIELDS)
281cdf0e10cSrcweir 				&& (nSort2Pos <= SC_MAXFIELDS)
282cdf0e10cSrcweir 				&& (nSort3Pos <= SC_MAXFIELDS),
283cdf0e10cSrcweir 				"Array-Range Fehler!" );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	if ( nSort1Pos == LISTBOX_ENTRY_NOTFOUND ) nSort1Pos = 0;
286cdf0e10cSrcweir 	if ( nSort2Pos == LISTBOX_ENTRY_NOTFOUND ) nSort2Pos = 0;
287cdf0e10cSrcweir 	if ( nSort3Pos == LISTBOX_ENTRY_NOTFOUND ) nSort3Pos = 0;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	if ( nSort1Pos > 0 )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir 		theSortData.bDoSort[0] = (nSort1Pos > 0);
292cdf0e10cSrcweir 		theSortData.bDoSort[1] = (nSort2Pos > 0);
293cdf0e10cSrcweir 		theSortData.bDoSort[2] = (nSort3Pos > 0);
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 		// wenn auf Optionen-Seite "OK" gewaehlt wurde und
296cdf0e10cSrcweir 		// dabei die Sortierrichtung umgestellt wurde, so
297cdf0e10cSrcweir 		// wird das erste Feld der jeweiligen Richtung als
298cdf0e10cSrcweir 		// Sortierkriterium gewaehlt (steht in nFieldArr[0]):
299cdf0e10cSrcweir 		if ( bSortByRows != pDlg->GetByRows() )
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir 			theSortData.nField[0] =
302cdf0e10cSrcweir 			theSortData.nField[1] =
303cdf0e10cSrcweir             theSortData.nField[2] = ( bSortByRows ?
304cdf0e10cSrcweir                     static_cast<SCCOLROW>(nFirstRow) :
305cdf0e10cSrcweir                     static_cast<SCCOLROW>(nFirstCol) );
306cdf0e10cSrcweir 		}
307cdf0e10cSrcweir 		else
308cdf0e10cSrcweir 		{
309cdf0e10cSrcweir 			theSortData.nField[0] = nFieldArr[nSort1Pos];
310cdf0e10cSrcweir 			theSortData.nField[1] = nFieldArr[nSort2Pos];
311cdf0e10cSrcweir 			theSortData.nField[2] = nFieldArr[nSort3Pos];
312cdf0e10cSrcweir 		}
313cdf0e10cSrcweir 
314cdf0e10cSrcweir 		theSortData.bAscending[0] = aBtnUp1.IsChecked();
315cdf0e10cSrcweir 		theSortData.bAscending[1] = aBtnUp2.IsChecked();
316cdf0e10cSrcweir 		theSortData.bAscending[2] = aBtnUp3.IsChecked();
317cdf0e10cSrcweir 		//	bHasHeader ist in ScTabPageSortOptions::FillItemSet, wo es hingehoert
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir 	else
320cdf0e10cSrcweir 	{
321cdf0e10cSrcweir 		theSortData.bDoSort[0] =
322cdf0e10cSrcweir 		theSortData.bDoSort[1] =
323cdf0e10cSrcweir 		theSortData.bDoSort[2] = FALSE;
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	rArgSet.Put( ScSortItem( SCITEM_SORTDATA, NULL, &theSortData ) );
327cdf0e10cSrcweir 
328cdf0e10cSrcweir 	return TRUE;
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir // -----------------------------------------------------------------------
332cdf0e10cSrcweir 
333cdf0e10cSrcweir // fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
334cdf0e10cSrcweir // void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet )
335cdf0e10cSrcweir 
ActivatePage()336cdf0e10cSrcweir void __EXPORT ScTabPageSortFields::ActivatePage()
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	if ( pDlg )
339cdf0e10cSrcweir 	{
340cdf0e10cSrcweir 		if (   bHasHeader  != pDlg->GetHeaders()
341cdf0e10cSrcweir 			|| bSortByRows != pDlg->GetByRows()   )
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			USHORT	nCurSel1 = aLbSort1.GetSelectEntryPos();
344cdf0e10cSrcweir 			USHORT	nCurSel2 = aLbSort2.GetSelectEntryPos();
345cdf0e10cSrcweir 			USHORT	nCurSel3 = aLbSort3.GetSelectEntryPos();
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 			bHasHeader	= pDlg->GetHeaders();
348cdf0e10cSrcweir 			bSortByRows = pDlg->GetByRows();
349cdf0e10cSrcweir 			FillFieldLists();
350cdf0e10cSrcweir 			aLbSort1.SelectEntryPos( nCurSel1 );
351cdf0e10cSrcweir 			aLbSort2.SelectEntryPos( nCurSel2 );
352cdf0e10cSrcweir 			aLbSort3.SelectEntryPos( nCurSel3 );
353cdf0e10cSrcweir 		}
354cdf0e10cSrcweir 	}
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir // -----------------------------------------------------------------------
358cdf0e10cSrcweir 
DeactivatePage(SfxItemSet * pSetP)359cdf0e10cSrcweir int __EXPORT ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	if ( pDlg )
362cdf0e10cSrcweir 	{
363cdf0e10cSrcweir 		if ( bHasHeader != pDlg->GetHeaders() )
364cdf0e10cSrcweir 			pDlg->SetHeaders( bHasHeader );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		if ( bSortByRows != pDlg->GetByRows() )
367cdf0e10cSrcweir 			pDlg->SetByRows( bSortByRows );
368cdf0e10cSrcweir 	}
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     if ( pSetP )
371cdf0e10cSrcweir         FillItemSet( *pSetP );
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	return SfxTabPage::LEAVE_PAGE;
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir // -----------------------------------------------------------------------
377cdf0e10cSrcweir 
DisableField(USHORT nField)378cdf0e10cSrcweir void ScTabPageSortFields::DisableField( USHORT nField )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	nField--;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     if ( nField<=2 )
383cdf0e10cSrcweir 	{
384cdf0e10cSrcweir 		aSortLbArr[nField]	 ->Disable();
385cdf0e10cSrcweir 		aDirBtnArr[nField][0]->Disable();
386cdf0e10cSrcweir 		aDirBtnArr[nField][1]->Disable();
387cdf0e10cSrcweir         aFlArr[nField]       ->Disable();
388cdf0e10cSrcweir 	}
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir // -----------------------------------------------------------------------
392cdf0e10cSrcweir 
EnableField(USHORT nField)393cdf0e10cSrcweir void ScTabPageSortFields::EnableField( USHORT nField )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir 	nField--;
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     if ( nField<=2 )
398cdf0e10cSrcweir 	{
399cdf0e10cSrcweir 		aSortLbArr[nField]	 ->Enable();
400cdf0e10cSrcweir 		aDirBtnArr[nField][0]->Enable();
401cdf0e10cSrcweir 		aDirBtnArr[nField][1]->Enable();
402cdf0e10cSrcweir         aFlArr[nField]       ->Enable();
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // -----------------------------------------------------------------------
407cdf0e10cSrcweir 
FillFieldLists()408cdf0e10cSrcweir void ScTabPageSortFields::FillFieldLists()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	if ( pViewData )
411cdf0e10cSrcweir 	{
412cdf0e10cSrcweir 		ScDocument* pDoc = pViewData->GetDocument();
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 		if ( pDoc )
415cdf0e10cSrcweir 		{
416cdf0e10cSrcweir 			aLbSort1.Clear();
417cdf0e10cSrcweir 			aLbSort2.Clear();
418cdf0e10cSrcweir 			aLbSort3.Clear();
419cdf0e10cSrcweir 			aLbSort1.InsertEntry( aStrUndefined, 0 );
420cdf0e10cSrcweir 			aLbSort2.InsertEntry( aStrUndefined, 0 );
421cdf0e10cSrcweir 			aLbSort3.InsertEntry( aStrUndefined, 0 );
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 			SCCOL	nFirstSortCol	= rSortData.nCol1;
424cdf0e10cSrcweir 			SCROW	nFirstSortRow	= rSortData.nRow1;
425cdf0e10cSrcweir 			SCTAB	nTab		= pViewData->GetTabNo();
426cdf0e10cSrcweir 			USHORT	i			= 1;
427cdf0e10cSrcweir 
428cdf0e10cSrcweir 			if ( bSortByRows )
429cdf0e10cSrcweir 			{
430cdf0e10cSrcweir 				String	aFieldName;
431cdf0e10cSrcweir 				SCCOL	nMaxCol = rSortData.nCol2;
432cdf0e10cSrcweir 				SCCOL	col;
433cdf0e10cSrcweir 
434cdf0e10cSrcweir 				for ( col=nFirstSortCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
435cdf0e10cSrcweir 				{
436cdf0e10cSrcweir 					pDoc->GetString( col, nFirstSortRow, nTab, aFieldName );
437cdf0e10cSrcweir 					if ( !bHasHeader || (aFieldName.Len() == 0) )
438cdf0e10cSrcweir 					{
439cdf0e10cSrcweir 						aFieldName	= aStrColumn;
440cdf0e10cSrcweir 						aFieldName += ' ';
441cdf0e10cSrcweir 						aFieldName += ColToAlpha( col );
442cdf0e10cSrcweir 					}
443cdf0e10cSrcweir 					nFieldArr[i] = col;
444cdf0e10cSrcweir 					aLbSort1.InsertEntry( aFieldName, i );
445cdf0e10cSrcweir 					aLbSort2.InsertEntry( aFieldName, i );
446cdf0e10cSrcweir 					aLbSort3.InsertEntry( aFieldName, i );
447cdf0e10cSrcweir 					i++;
448cdf0e10cSrcweir 				}
449cdf0e10cSrcweir 			}
450cdf0e10cSrcweir 			else
451cdf0e10cSrcweir 			{
452cdf0e10cSrcweir 				String	aFieldName;
453cdf0e10cSrcweir 				SCROW	nMaxRow = rSortData.nRow2;
454cdf0e10cSrcweir 				SCROW	row;
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 				for ( row=nFirstSortRow; row<=nMaxRow && i<SC_MAXFIELDS; row++ )
457cdf0e10cSrcweir 				{
458cdf0e10cSrcweir 					pDoc->GetString( nFirstSortCol, row, nTab, aFieldName );
459cdf0e10cSrcweir 					if ( !bHasHeader || (aFieldName.Len() == 0) )
460cdf0e10cSrcweir 					{
461cdf0e10cSrcweir 						aFieldName	= aStrRow;
462cdf0e10cSrcweir 						aFieldName += ' ';
463cdf0e10cSrcweir 						aFieldName += String::CreateFromInt32( row+1 );
464cdf0e10cSrcweir 					}
465cdf0e10cSrcweir 					nFieldArr[i] = row;
466cdf0e10cSrcweir 					aLbSort1.InsertEntry( aFieldName, i );
467cdf0e10cSrcweir 					aLbSort2.InsertEntry( aFieldName, i );
468cdf0e10cSrcweir 					aLbSort3.InsertEntry( aFieldName, i );
469cdf0e10cSrcweir 					i++;
470cdf0e10cSrcweir 				}
471cdf0e10cSrcweir 			}
472cdf0e10cSrcweir 			nFieldCount = i;
473cdf0e10cSrcweir 		}
474cdf0e10cSrcweir 	}
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir //------------------------------------------------------------------------
478cdf0e10cSrcweir 
GetFieldSelPos(SCCOLROW nField)479cdf0e10cSrcweir USHORT ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir 	USHORT	nFieldPos	= 0;
482cdf0e10cSrcweir 	BOOL	bFound		= FALSE;
483cdf0e10cSrcweir 
484cdf0e10cSrcweir 	for ( USHORT n=1; n<nFieldCount && !bFound; n++ )
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		if ( nFieldArr[n] == nField )
487cdf0e10cSrcweir 		{
488cdf0e10cSrcweir 			nFieldPos = n;
489cdf0e10cSrcweir 			bFound = TRUE;
490cdf0e10cSrcweir 		}
491cdf0e10cSrcweir 	}
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	return nFieldPos;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
496cdf0e10cSrcweir // -----------------------------------------------------------------------
497cdf0e10cSrcweir // Handler:
498cdf0e10cSrcweir //---------
499cdf0e10cSrcweir 
IMPL_LINK(ScTabPageSortFields,SelectHdl,ListBox *,pLb)500cdf0e10cSrcweir IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	String aSelEntry = pLb->GetSelectEntry();
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 	if ( pLb == &aLbSort1 )
505cdf0e10cSrcweir 	{
506cdf0e10cSrcweir 		if ( aSelEntry == aStrUndefined )
507cdf0e10cSrcweir 		{
508cdf0e10cSrcweir 			aLbSort2.SelectEntryPos( 0 );
509cdf0e10cSrcweir 			aLbSort3.SelectEntryPos( 0 );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir             if ( aFlSort2.IsEnabled() )
512cdf0e10cSrcweir 				DisableField( 2 );
513cdf0e10cSrcweir 
514cdf0e10cSrcweir             if ( aFlSort3.IsEnabled() )
515cdf0e10cSrcweir 				DisableField( 3 );
516cdf0e10cSrcweir 		}
517cdf0e10cSrcweir 		else
518cdf0e10cSrcweir 		{
519cdf0e10cSrcweir             if ( !aFlSort2.IsEnabled() )
520cdf0e10cSrcweir 				EnableField( 2 );
521cdf0e10cSrcweir 		}
522cdf0e10cSrcweir 	}
523cdf0e10cSrcweir 	else if ( pLb == &aLbSort2 )
524cdf0e10cSrcweir 	{
525cdf0e10cSrcweir 		if ( aSelEntry == aStrUndefined )
526cdf0e10cSrcweir 		{
527cdf0e10cSrcweir 			aLbSort3.SelectEntryPos( 0 );
528cdf0e10cSrcweir             if ( aFlSort3.IsEnabled() )
529cdf0e10cSrcweir 				DisableField( 3 );
530cdf0e10cSrcweir 		}
531cdf0e10cSrcweir 		else
532cdf0e10cSrcweir 		{
533cdf0e10cSrcweir             if ( !aFlSort3.IsEnabled() )
534cdf0e10cSrcweir 				EnableField( 3 );
535cdf0e10cSrcweir 		}
536cdf0e10cSrcweir 	}
537cdf0e10cSrcweir 	return 0;
538cdf0e10cSrcweir }
539cdf0e10cSrcweir 
540cdf0e10cSrcweir //========================================================================
541cdf0e10cSrcweir // Sortieroptionen-Tabpage:
542cdf0e10cSrcweir //========================================================================
543cdf0e10cSrcweir 
544cdf0e10cSrcweir #include <layout/layout-pre.hxx>
545cdf0e10cSrcweir 
546cdf0e10cSrcweir #if ENABLE_LAYOUT
547cdf0e10cSrcweir #undef ScResId
548cdf0e10cSrcweir #define ScResId(x) #x
549cdf0e10cSrcweir #undef SfxTabPage
550cdf0e10cSrcweir #define SfxTabPage( parent, id, args ) SfxTabPage( parent, "sort-options.xml", id, &args )
551cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
552cdf0e10cSrcweir 
ScTabPageSortOptions(Window * pParent,const SfxItemSet & rArgSet)553cdf0e10cSrcweir ScTabPageSortOptions::ScTabPageSortOptions( Window* 			pParent,
554cdf0e10cSrcweir 											const SfxItemSet&	rArgSet )
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 	:	SfxTabPage		( pParent,
557cdf0e10cSrcweir 						  ScResId( RID_SCPAGE_SORT_OPTIONS ),
558cdf0e10cSrcweir 						  rArgSet ),
559cdf0e10cSrcweir 		//
560cdf0e10cSrcweir 		aBtnCase		( this, ScResId( BTN_CASESENSITIVE ) ),
561cdf0e10cSrcweir 		aBtnHeader		( this, ScResId( BTN_LABEL ) ),
562cdf0e10cSrcweir 		aBtnFormats 	( this, ScResId( BTN_FORMATS ) ),
563cdf0e10cSrcweir 		aBtnCopyResult	( this, ScResId( BTN_COPYRESULT ) ),
564cdf0e10cSrcweir 		aBtnNaturalSort	( this, ScResId( BTN_NATURALSORT ) ),
565cdf0e10cSrcweir 		aLbOutPos		( this, ScResId( LB_OUTAREA ) ),
566cdf0e10cSrcweir 		aEdOutPos		( this, ScResId( ED_OUTAREA ) ),
567cdf0e10cSrcweir 		aBtnSortUser	( this, ScResId( BTN_SORT_USER ) ),
568cdf0e10cSrcweir 		aLbSortUser 	( this, ScResId( LB_SORT_USER ) ),
569cdf0e10cSrcweir         aFtLanguage     ( this, ScResId( FT_LANGUAGE ) ),
570cdf0e10cSrcweir 		aLbLanguage		( this, ScResId( LB_LANGUAGE ) ),
571cdf0e10cSrcweir         aFtAlgorithm    ( this, ScResId( FT_ALGORITHM ) ),
572cdf0e10cSrcweir 		aLbAlgorithm	( this, ScResId( LB_ALGORITHM ) ),
573cdf0e10cSrcweir 		aLineDirection	( this, ScResId( FL_DIRECTION ) ),
574cdf0e10cSrcweir 		aBtnTopDown 	( this, ScResId( BTN_TOP_DOWN ) ),
575cdf0e10cSrcweir 		aBtnLeftRight	( this, ScResId( BTN_LEFT_RIGHT ) ),
576cdf0e10cSrcweir // 		aFtAreaLabel	( this, ScResId( FT_AREA_LABEL ) ),
577cdf0e10cSrcweir //		aFtArea 		( this, ScResId( FT_AREA ) ),
578cdf0e10cSrcweir 		//
579cdf0e10cSrcweir #if ENABLE_LAYOUT
580cdf0e10cSrcweir #undef this
581cdf0e10cSrcweir #undef ScResId
582cdf0e10cSrcweir #define ScResId(x) this, #x
583cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
584cdf0e10cSrcweir 		aStrRowLabel	( ScResId( STR_ROW_LABEL ) ),
585cdf0e10cSrcweir 		aStrColLabel	( ScResId( STR_COL_LABEL ) ),
586cdf0e10cSrcweir 		aStrUndefined	( ScResId( SCSTR_UNDEFINED ) ),
587cdf0e10cSrcweir 		aStrNoName		( ScGlobal::GetRscString(STR_DB_NONAME) ),
588cdf0e10cSrcweir 		//
589cdf0e10cSrcweir #if !TEST_LAYOUT
590cdf0e10cSrcweir 		nWhichSort		( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
591cdf0e10cSrcweir 		rSortData		( ((const ScSortItem&)
592cdf0e10cSrcweir 						  rArgSet.Get( nWhichSort )).GetSortData() ),
593cdf0e10cSrcweir #else /* TEST_LAYOUT */
594cdf0e10cSrcweir 		nWhichSort		( 0 ),
595cdf0e10cSrcweir 		rSortData		( *new ScSortParam() ),
596cdf0e10cSrcweir #endif /* TEST_LAYOUT */
597cdf0e10cSrcweir 		pViewData		( NULL ),
598cdf0e10cSrcweir 		pDoc			( NULL ),
599cdf0e10cSrcweir 		pDlg			( (ScSortDlg*)(GetParent() ? GetParent()->GetParent() : 0 ) ),
600cdf0e10cSrcweir 		pColRes			( NULL ),
601cdf0e10cSrcweir 		pColWrap		( NULL )
602cdf0e10cSrcweir {
603cdf0e10cSrcweir #if TEST_LAYOUT
604cdf0e10cSrcweir     (void) rArgSet;
605cdf0e10cSrcweir #endif /* TEST_LAYOUT */
606cdf0e10cSrcweir 	Init();
607cdf0e10cSrcweir 	FreeResource();
608cdf0e10cSrcweir 	SetExchangeSupport();
609cdf0e10cSrcweir }
610cdf0e10cSrcweir 
611cdf0e10cSrcweir // -----------------------------------------------------------------------
612cdf0e10cSrcweir 
~ScTabPageSortOptions()613cdf0e10cSrcweir __EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
614cdf0e10cSrcweir {
615cdf0e10cSrcweir #if !TEST_LAYOUT
616cdf0e10cSrcweir 	USHORT nEntries = aLbOutPos.GetEntryCount();
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 	for ( USHORT i=1; i<nEntries; i++ )
619cdf0e10cSrcweir 		delete (String*)aLbOutPos.GetEntryData( i );
620cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
621cdf0e10cSrcweir 
622cdf0e10cSrcweir 	delete pColRes;
623cdf0e10cSrcweir 	delete pColWrap;		//! not if from document
624cdf0e10cSrcweir }
625cdf0e10cSrcweir 
626cdf0e10cSrcweir // -----------------------------------------------------------------------
627cdf0e10cSrcweir 
Init()628cdf0e10cSrcweir void ScTabPageSortOptions::Init()
629cdf0e10cSrcweir {
630cdf0e10cSrcweir // 	aStrAreaLabel = aFtAreaLabel.GetText();
631cdf0e10cSrcweir // 	aStrAreaLabel.Append( (sal_Unicode) ' ' );
632cdf0e10cSrcweir 
633cdf0e10cSrcweir 	//	CollatorRessource has user-visible names for sort algorithms
634cdf0e10cSrcweir 	pColRes = new CollatorRessource();
635cdf0e10cSrcweir 
636cdf0e10cSrcweir 	//!	use CollatorWrapper from document?
637cdf0e10cSrcweir 	pColWrap = new CollatorWrapper( comphelper::getProcessServiceFactory() );
638cdf0e10cSrcweir 
639cdf0e10cSrcweir #if !TEST_LAYOUT
640cdf0e10cSrcweir 	const ScSortItem&	rSortItem = (const ScSortItem&)
641cdf0e10cSrcweir 									GetItemSet().Get( nWhichSort );
642cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	aLbOutPos.SetSelectHdl	  ( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
645cdf0e10cSrcweir 	aBtnCopyResult.SetClickHdl( LINK( this, ScTabPageSortOptions, EnableHdl ) );
646cdf0e10cSrcweir 	aBtnSortUser.SetClickHdl  ( LINK( this, ScTabPageSortOptions, EnableHdl ) );
647cdf0e10cSrcweir 	aBtnTopDown.SetClickHdl	  ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
648cdf0e10cSrcweir 	aBtnLeftRight.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
649cdf0e10cSrcweir 	aLbLanguage.SetSelectHdl  ( LINK( this, ScTabPageSortOptions, FillAlgorHdl ) );
650cdf0e10cSrcweir 
651cdf0e10cSrcweir #if !TEST_LAYOUT
652cdf0e10cSrcweir 	pViewData = rSortItem.GetViewData();
653cdf0e10cSrcweir #endif /* TEST_LAYOUT */
654cdf0e10cSrcweir 	pDoc	  = pViewData ? pViewData->GetDocument() : NULL;
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 	DBG_ASSERT( pViewData, "ViewData not found! :-/" );
657cdf0e10cSrcweir 
658cdf0e10cSrcweir #if !TEST_LAYOUT
659cdf0e10cSrcweir 	if ( pViewData && pDoc )
660cdf0e10cSrcweir 	{
661cdf0e10cSrcweir 		String			theArea;
662cdf0e10cSrcweir 		ScDBCollection* pDBColl 	= pDoc->GetDBCollection();
663cdf0e10cSrcweir 		String			theDbArea;
664cdf0e10cSrcweir 		String			theDbName	= aStrNoName;
665cdf0e10cSrcweir 		const SCTAB	nCurTab		= pViewData->GetTabNo();
666cdf0e10cSrcweir         const ScAddress::Convention eConv = pDoc->GetAddressConvention();
667cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 		aLbOutPos.Clear();
670cdf0e10cSrcweir 		aLbOutPos.InsertEntry( aStrUndefined, 0 );
671cdf0e10cSrcweir 		aLbOutPos.Disable();
672cdf0e10cSrcweir 
673cdf0e10cSrcweir #if !TEST_LAYOUT
674cdf0e10cSrcweir 		ScAreaNameIterator aIter( pDoc );
675cdf0e10cSrcweir 		String aName;
676cdf0e10cSrcweir 		ScRange aRange;
677cdf0e10cSrcweir 		String aRefStr;
678cdf0e10cSrcweir 		while ( aIter.Next( aName, aRange ) )
679cdf0e10cSrcweir 		{
680cdf0e10cSrcweir 			USHORT nInsert = aLbOutPos.InsertEntry( aName );
681cdf0e10cSrcweir 
682cdf0e10cSrcweir 			aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv );
683cdf0e10cSrcweir 			aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
684cdf0e10cSrcweir 		}
685cdf0e10cSrcweir #endif /* !TEST_LAYOUT */
686cdf0e10cSrcweir 
687cdf0e10cSrcweir 		aLbOutPos.SelectEntryPos( 0 );
688cdf0e10cSrcweir 		aEdOutPos.SetText( EMPTY_STRING );
689cdf0e10cSrcweir 
690cdf0e10cSrcweir #if !TEST_LAYOUT
691cdf0e10cSrcweir 		/*
692cdf0e10cSrcweir 		 * Ueberpruefen, ob es sich bei dem uebergebenen
693cdf0e10cSrcweir 		 * Bereich um einen Datenbankbereich handelt:
694cdf0e10cSrcweir 		 */
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 		ScAddress aScAddress( rSortData.nCol1, rSortData.nRow1, nCurTab );
697cdf0e10cSrcweir 		ScRange( aScAddress,
698cdf0e10cSrcweir 				 ScAddress( rSortData.nCol2, rSortData.nRow2, nCurTab )
699cdf0e10cSrcweir 			   ).Format( theArea, SCR_ABS, pDoc, eConv );
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		if ( pDBColl )
702cdf0e10cSrcweir 		{
703cdf0e10cSrcweir 			ScDBData* pDBData
704cdf0e10cSrcweir 					= pDBColl->GetDBAtArea( nCurTab,
705cdf0e10cSrcweir 											rSortData.nCol1, rSortData.nRow1,
706cdf0e10cSrcweir 											rSortData.nCol2, rSortData.nRow2 );
707cdf0e10cSrcweir 			if ( pDBData )
708cdf0e10cSrcweir 			{
709cdf0e10cSrcweir 				pDBData->GetName( theDbName );
710cdf0e10cSrcweir 				aBtnHeader.Check( pDBData->HasHeader() );
711cdf0e10cSrcweir 			}
712cdf0e10cSrcweir 		}
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 		theArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
715cdf0e10cSrcweir 		theArea += theDbName;
716cdf0e10cSrcweir 		theArea += ')';
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 		//aFtArea.SetText( theArea );
719cdf0e10cSrcweir 		//theArea.Insert( aStrAreaLabel, 0 );
720cdf0e10cSrcweir 		//aFtAreaLabel.SetText( theArea );
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 		aBtnHeader.SetText( aStrColLabel );
723cdf0e10cSrcweir 	}
724cdf0e10cSrcweir #endif /* TEST_LAYOUT */
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	FillUserSortListBox();
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 	//	get available languages
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     aLbLanguage.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE );
731cdf0e10cSrcweir 	aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM );
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
734cdf0e10cSrcweir //------------------------------------------------------------------------
735cdf0e10cSrcweir 
GetRanges()736cdf0e10cSrcweir USHORT* __EXPORT ScTabPageSortOptions::GetRanges()
737cdf0e10cSrcweir {
738cdf0e10cSrcweir 	return pSortRanges;
739cdf0e10cSrcweir }
740cdf0e10cSrcweir 
741cdf0e10cSrcweir // -----------------------------------------------------------------------
742cdf0e10cSrcweir 
743cdf0e10cSrcweir #if ENABLE_LAYOUT
744cdf0e10cSrcweir #undef SfxTabPage
745cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
Create(Window * pParent,const SfxItemSet & rArgSet)746cdf0e10cSrcweir SfxTabPage* __EXPORT ScTabPageSortOptions::Create(
747cdf0e10cSrcweir 											Window*				pParent,
748cdf0e10cSrcweir 											const SfxItemSet&	rArgSet )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	return ( new ScTabPageSortOptions( pParent, rArgSet ) );
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir // -----------------------------------------------------------------------
754cdf0e10cSrcweir 
Reset(const SfxItemSet &)755cdf0e10cSrcweir void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
756cdf0e10cSrcweir {
757cdf0e10cSrcweir 	if ( rSortData.bUserDef )
758cdf0e10cSrcweir 	{
759cdf0e10cSrcweir 		aBtnSortUser.Check( TRUE );
760cdf0e10cSrcweir 		aLbSortUser.Enable();
761cdf0e10cSrcweir 		aLbSortUser.SelectEntryPos( rSortData.nUserIndex );
762cdf0e10cSrcweir 	}
763cdf0e10cSrcweir 	else
764cdf0e10cSrcweir 	{
765cdf0e10cSrcweir 		aBtnSortUser.Check( FALSE );
766cdf0e10cSrcweir 		aLbSortUser.Disable();
767cdf0e10cSrcweir 		aLbSortUser.SelectEntryPos( 0 );
768cdf0e10cSrcweir 	}
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	aBtnCase.Check			( rSortData.bCaseSens );
771cdf0e10cSrcweir 	aBtnFormats.Check		( rSortData.bIncludePattern );
772cdf0e10cSrcweir 	aBtnHeader.Check		( rSortData.bHasHeader );
773cdf0e10cSrcweir 	aBtnNaturalSort.Check	( rSortData.bNaturalSort );
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	if ( rSortData.bByRow )
776cdf0e10cSrcweir 	{
777cdf0e10cSrcweir 		aBtnTopDown.Check();
778cdf0e10cSrcweir 		aBtnHeader.SetText( aStrColLabel );
779cdf0e10cSrcweir 	}
780cdf0e10cSrcweir 	else
781cdf0e10cSrcweir 	{
782cdf0e10cSrcweir 		aBtnLeftRight.Check();
783cdf0e10cSrcweir 		aBtnHeader.SetText( aStrRowLabel );
784cdf0e10cSrcweir 	}
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	LanguageType eLang = MsLangId::convertLocaleToLanguage( rSortData.aCollatorLocale );
787cdf0e10cSrcweir 	if ( eLang == LANGUAGE_DONTKNOW )
788cdf0e10cSrcweir 		eLang = LANGUAGE_SYSTEM;
789cdf0e10cSrcweir 	aLbLanguage.SelectLanguage( eLang );
790cdf0e10cSrcweir 	FillAlgorHdl( &aLbLanguage );				// get algorithms, select default
791cdf0e10cSrcweir 	if ( rSortData.aCollatorAlgorithm.Len() )
792cdf0e10cSrcweir 		aLbAlgorithm.SelectEntry( pColRes->GetTranslation( rSortData.aCollatorAlgorithm ) );
793cdf0e10cSrcweir 
794cdf0e10cSrcweir 	if ( pDoc && !rSortData.bInplace )
795cdf0e10cSrcweir 	{
796cdf0e10cSrcweir 		String aStr;
797cdf0e10cSrcweir 		USHORT nFormat = (rSortData.nDestTab != pViewData->GetTabNo())
798cdf0e10cSrcweir 							? SCR_ABS_3D
799cdf0e10cSrcweir 							: SCR_ABS;
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 		theOutPos.Set( rSortData.nDestCol,
802cdf0e10cSrcweir 					   rSortData.nDestRow,
803cdf0e10cSrcweir 					   rSortData.nDestTab );
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 		theOutPos.Format( aStr, nFormat, pDoc, pDoc->GetAddressConvention() );
806cdf0e10cSrcweir 		aBtnCopyResult.Check();
807cdf0e10cSrcweir 		aLbOutPos.Enable();
808cdf0e10cSrcweir 		aEdOutPos.Enable();
809cdf0e10cSrcweir 		aEdOutPos.SetText( aStr );
810cdf0e10cSrcweir 		EdOutPosModHdl( &aEdOutPos );
811cdf0e10cSrcweir 		aEdOutPos.GrabFocus();
812cdf0e10cSrcweir 		aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
813cdf0e10cSrcweir 	}
814cdf0e10cSrcweir 	else
815cdf0e10cSrcweir 	{
816cdf0e10cSrcweir 		aBtnCopyResult.Check( FALSE );
817cdf0e10cSrcweir 		aLbOutPos.Disable();
818cdf0e10cSrcweir 		aEdOutPos.Disable();
819cdf0e10cSrcweir 		aEdOutPos.SetText( EMPTY_STRING );
820cdf0e10cSrcweir 	}
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823cdf0e10cSrcweir // -----------------------------------------------------------------------
824cdf0e10cSrcweir 
FillItemSet(SfxItemSet & rArgSet)825cdf0e10cSrcweir BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
826cdf0e10cSrcweir {
827cdf0e10cSrcweir 	ScSortParam theSortData = rSortData;
828cdf0e10cSrcweir 	if (pDlg)
829cdf0e10cSrcweir 	{
830cdf0e10cSrcweir 		const SfxItemSet* pExample = pDlg->GetExampleSet();
831cdf0e10cSrcweir 		const SfxPoolItem* pItem;
832cdf0e10cSrcweir 		if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
833cdf0e10cSrcweir 			theSortData = ((const ScSortItem*)pItem)->GetSortData();
834cdf0e10cSrcweir 	}
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 	theSortData.bByRow			= aBtnTopDown.IsChecked();
837cdf0e10cSrcweir 	theSortData.bHasHeader		= aBtnHeader.IsChecked();
838cdf0e10cSrcweir 	theSortData.bCaseSens		= aBtnCase.IsChecked();
839cdf0e10cSrcweir 	theSortData.bNaturalSort	= aBtnNaturalSort.IsChecked();
840cdf0e10cSrcweir 	theSortData.bIncludePattern = aBtnFormats.IsChecked();
841cdf0e10cSrcweir 	theSortData.bInplace		= !aBtnCopyResult.IsChecked();
842cdf0e10cSrcweir 	theSortData.nDestCol		= theOutPos.Col();
843cdf0e10cSrcweir 	theSortData.nDestRow		= theOutPos.Row();
844cdf0e10cSrcweir 	theSortData.nDestTab		= theOutPos.Tab();
845cdf0e10cSrcweir 	theSortData.bUserDef		= aBtnSortUser.IsChecked();
846cdf0e10cSrcweir 	theSortData.nUserIndex		= (aBtnSortUser.IsChecked())
847cdf0e10cSrcweir 									? aLbSortUser.GetSelectEntryPos()
848cdf0e10cSrcweir 									: 0;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 	// get locale
851cdf0e10cSrcweir 	LanguageType eLang = aLbLanguage.GetSelectLanguage();
852cdf0e10cSrcweir     theSortData.aCollatorLocale = MsLangId::convertLanguageToLocale( eLang, false );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir 	// get algorithm
855cdf0e10cSrcweir 	String sAlg;
856cdf0e10cSrcweir 	if ( eLang != LANGUAGE_SYSTEM )
857cdf0e10cSrcweir 	{
858cdf0e10cSrcweir         uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms(
859cdf0e10cSrcweir                 theSortData.aCollatorLocale );
860cdf0e10cSrcweir 		USHORT nSel = aLbAlgorithm.GetSelectEntryPos();
861cdf0e10cSrcweir 		if ( nSel < aAlgos.getLength() )
862cdf0e10cSrcweir 			sAlg = aAlgos[nSel];
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir 	theSortData.aCollatorAlgorithm = sAlg;
865cdf0e10cSrcweir 
866cdf0e10cSrcweir #if !TEST_LAYOUT
867cdf0e10cSrcweir 	rArgSet.Put( ScSortItem( SCITEM_SORTDATA, &theSortData ) );
868cdf0e10cSrcweir #endif /* TEST_LAYOUT */
869cdf0e10cSrcweir 	return TRUE;
870cdf0e10cSrcweir }
871cdf0e10cSrcweir 
872cdf0e10cSrcweir // -----------------------------------------------------------------------
873cdf0e10cSrcweir 
874cdf0e10cSrcweir // fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
875cdf0e10cSrcweir // void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet )
ActivatePage()876cdf0e10cSrcweir void __EXPORT ScTabPageSortOptions::ActivatePage()
877cdf0e10cSrcweir {
878cdf0e10cSrcweir 	if ( pDlg )
879cdf0e10cSrcweir 	{
880cdf0e10cSrcweir 		if ( aBtnHeader.IsChecked() != pDlg->GetHeaders() )
881cdf0e10cSrcweir 		{
882cdf0e10cSrcweir 			aBtnHeader.Check( pDlg->GetHeaders() );
883cdf0e10cSrcweir 		}
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 		if ( aBtnTopDown.IsChecked() != pDlg->GetByRows() )
886cdf0e10cSrcweir 		{
887cdf0e10cSrcweir 			aBtnTopDown.Check( pDlg->GetByRows() );
888cdf0e10cSrcweir 			aBtnLeftRight.Check( !pDlg->GetByRows() );
889cdf0e10cSrcweir 		}
890cdf0e10cSrcweir 
891cdf0e10cSrcweir 		aBtnHeader.SetText( (pDlg->GetByRows())
892cdf0e10cSrcweir 							? aStrColLabel
893cdf0e10cSrcweir 							: aStrRowLabel );
894cdf0e10cSrcweir 	}
895cdf0e10cSrcweir }
896cdf0e10cSrcweir 
897cdf0e10cSrcweir // -----------------------------------------------------------------------
898cdf0e10cSrcweir 
DeactivatePage(SfxItemSet * pSetP)899cdf0e10cSrcweir int __EXPORT ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
900cdf0e10cSrcweir {
901cdf0e10cSrcweir 	BOOL bPosInputOk = TRUE;
902cdf0e10cSrcweir 
903cdf0e10cSrcweir 	if ( aBtnCopyResult.IsChecked() )
904cdf0e10cSrcweir 	{
905cdf0e10cSrcweir 		String		thePosStr = aEdOutPos.GetText();
906cdf0e10cSrcweir 		ScAddress	thePos;
907cdf0e10cSrcweir 		xub_StrLen	nColonPos = thePosStr.Search( ':' );
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 		if ( STRING_NOTFOUND != nColonPos )
910cdf0e10cSrcweir 			thePosStr.Erase( nColonPos );
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 		if ( pViewData )
913cdf0e10cSrcweir 		{
914cdf0e10cSrcweir 			//	visible table is default for input without table
915cdf0e10cSrcweir 			//	must be changed to GetRefTabNo when sorting has RefInput!
916cdf0e10cSrcweir 			thePos.SetTab( pViewData->GetTabNo() );
917cdf0e10cSrcweir 		}
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 		USHORT nResult = thePos.Parse( thePosStr, pDoc, pDoc->GetAddressConvention() );
920cdf0e10cSrcweir 
921cdf0e10cSrcweir 		bPosInputOk = ( SCA_VALID == (nResult & SCA_VALID) );
922cdf0e10cSrcweir 
923cdf0e10cSrcweir 		if ( !bPosInputOk )
924cdf0e10cSrcweir 		{
925cdf0e10cSrcweir #if !ENABLE_LAYOUT
926cdf0e10cSrcweir 			ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
927cdf0e10cSrcweir 					 ScGlobal::GetRscString( STR_INVALID_TABREF )
928cdf0e10cSrcweir 					).Execute();
929cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
930cdf0e10cSrcweir 			aEdOutPos.GrabFocus();
931cdf0e10cSrcweir 			aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
932cdf0e10cSrcweir 			theOutPos.Set(0,0,0);
933cdf0e10cSrcweir 		}
934cdf0e10cSrcweir 		else
935cdf0e10cSrcweir 		{
936cdf0e10cSrcweir 			aEdOutPos.SetText( thePosStr );
937cdf0e10cSrcweir 			theOutPos = thePos;
938cdf0e10cSrcweir 		}
939cdf0e10cSrcweir 	}
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	if ( pDlg && bPosInputOk )
942cdf0e10cSrcweir 	{
943cdf0e10cSrcweir 		pDlg->SetHeaders( aBtnHeader.IsChecked() );
944cdf0e10cSrcweir 		pDlg->SetByRows ( aBtnTopDown.IsChecked() );
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir 
947cdf0e10cSrcweir     if ( pSetP && bPosInputOk )
948cdf0e10cSrcweir         FillItemSet( *pSetP );
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 	return bPosInputOk ? SfxTabPage::LEAVE_PAGE : SfxTabPage::KEEP_PAGE;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir // -----------------------------------------------------------------------
954cdf0e10cSrcweir 
FillUserSortListBox()955cdf0e10cSrcweir void ScTabPageSortOptions::FillUserSortListBox()
956cdf0e10cSrcweir {
957cdf0e10cSrcweir 	ScUserList* pUserLists = ScGlobal::GetUserList();
958cdf0e10cSrcweir 
959cdf0e10cSrcweir 	aLbSortUser.Clear();
960cdf0e10cSrcweir 	if ( pUserLists )
961cdf0e10cSrcweir 	{
962cdf0e10cSrcweir 		USHORT nCount = pUserLists->GetCount();
963cdf0e10cSrcweir 		if ( nCount > 0 )
964cdf0e10cSrcweir 			for ( USHORT i=0; i<nCount; i++ )
965cdf0e10cSrcweir 				aLbSortUser.InsertEntry( (*pUserLists)[i]->GetString() );
966cdf0e10cSrcweir 	}
967cdf0e10cSrcweir }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir // -----------------------------------------------------------------------
970cdf0e10cSrcweir // Handler:
971cdf0e10cSrcweir 
IMPL_LINK(ScTabPageSortOptions,EnableHdl,CheckBox *,pBox)972cdf0e10cSrcweir IMPL_LINK( ScTabPageSortOptions, EnableHdl, CheckBox *, pBox )
973cdf0e10cSrcweir {
974cdf0e10cSrcweir 	if ( pBox == &aBtnCopyResult )
975cdf0e10cSrcweir 	{
976cdf0e10cSrcweir 		if ( pBox->IsChecked() )
977cdf0e10cSrcweir 		{
978cdf0e10cSrcweir 			aLbOutPos.Enable();
979cdf0e10cSrcweir 			aEdOutPos.Enable();
980cdf0e10cSrcweir 			aEdOutPos.GrabFocus();
981cdf0e10cSrcweir 		}
982cdf0e10cSrcweir 		else
983cdf0e10cSrcweir 		{
984cdf0e10cSrcweir 			aLbOutPos.Disable();
985cdf0e10cSrcweir 			aEdOutPos.Disable();
986cdf0e10cSrcweir 		}
987cdf0e10cSrcweir 	}
988cdf0e10cSrcweir 	else if ( pBox == &aBtnSortUser )
989cdf0e10cSrcweir 	{
990cdf0e10cSrcweir 		if ( pBox->IsChecked() )
991cdf0e10cSrcweir 		{
992cdf0e10cSrcweir 			aLbSortUser.Enable();
993cdf0e10cSrcweir 			aLbSortUser.GrabFocus();
994cdf0e10cSrcweir 		}
995cdf0e10cSrcweir 		else
996cdf0e10cSrcweir 			aLbSortUser.Disable();
997cdf0e10cSrcweir 	}
998cdf0e10cSrcweir 	return 0;
999cdf0e10cSrcweir }
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir // -----------------------------------------------------------------------
1002cdf0e10cSrcweir 
IMPL_LINK(ScTabPageSortOptions,SelOutPosHdl,ListBox *,pLb)1003cdf0e10cSrcweir IMPL_LINK( ScTabPageSortOptions, SelOutPosHdl, ListBox *, pLb )
1004cdf0e10cSrcweir {
1005cdf0e10cSrcweir 	if ( pLb == &aLbOutPos )
1006cdf0e10cSrcweir 	{
1007cdf0e10cSrcweir 		String	aString;
1008cdf0e10cSrcweir 		USHORT	nSelPos = aLbOutPos.GetSelectEntryPos();
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir 		if ( nSelPos > 0 )
1011cdf0e10cSrcweir 			aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 		aEdOutPos.SetText( aString );
1014cdf0e10cSrcweir 	}
1015cdf0e10cSrcweir 	return 0;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir // -----------------------------------------------------------------------
1019cdf0e10cSrcweir 
IMPL_LINK(ScTabPageSortOptions,SortDirHdl,RadioButton *,pBtn)1020cdf0e10cSrcweir IMPL_LINK( ScTabPageSortOptions, SortDirHdl, RadioButton *, pBtn )
1021cdf0e10cSrcweir {
1022cdf0e10cSrcweir 	if ( pBtn == &aBtnTopDown )
1023cdf0e10cSrcweir 	{
1024cdf0e10cSrcweir 		aBtnHeader.SetText( aStrColLabel );
1025cdf0e10cSrcweir 	}
1026cdf0e10cSrcweir 	else if ( pBtn == &aBtnLeftRight )
1027cdf0e10cSrcweir 	{
1028cdf0e10cSrcweir 		aBtnHeader.SetText( aStrRowLabel );
1029cdf0e10cSrcweir 	}
1030cdf0e10cSrcweir 	return 0;
1031cdf0e10cSrcweir }
1032cdf0e10cSrcweir 
1033cdf0e10cSrcweir // -----------------------------------------------------------------------
1034cdf0e10cSrcweir 
EdOutPosModHdl(Edit * pEd)1035cdf0e10cSrcweir void __EXPORT ScTabPageSortOptions::EdOutPosModHdl( Edit* pEd )
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir 	if ( pEd == &aEdOutPos )
1038cdf0e10cSrcweir 	{
1039cdf0e10cSrcweir 		String	theCurPosStr = aEdOutPos.GetText();
1040cdf0e10cSrcweir 		USHORT	nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir 		if ( SCA_VALID == (nResult & SCA_VALID) )
1043cdf0e10cSrcweir 		{
1044cdf0e10cSrcweir 			String*	pStr	= NULL;
1045cdf0e10cSrcweir 			BOOL	bFound	= FALSE;
1046cdf0e10cSrcweir 			USHORT	i		= 0;
1047cdf0e10cSrcweir 			USHORT	nCount	= aLbOutPos.GetEntryCount();
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 			for ( i=2; i<nCount && !bFound; i++ )
1050cdf0e10cSrcweir 			{
1051cdf0e10cSrcweir 				pStr = (String*)aLbOutPos.GetEntryData( i );
1052cdf0e10cSrcweir 				bFound = (theCurPosStr == *pStr);
1053cdf0e10cSrcweir 			}
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir 			if ( bFound )
1056cdf0e10cSrcweir 				aLbOutPos.SelectEntryPos( --i );
1057cdf0e10cSrcweir 			else
1058cdf0e10cSrcweir 				aLbOutPos.SelectEntryPos( 0 );
1059cdf0e10cSrcweir 		}
1060cdf0e10cSrcweir 	}
1061cdf0e10cSrcweir }
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir // -----------------------------------------------------------------------
1064cdf0e10cSrcweir 
IMPL_LINK(ScTabPageSortOptions,FillAlgorHdl,void *,EMPTYARG)1065cdf0e10cSrcweir IMPL_LINK( ScTabPageSortOptions, FillAlgorHdl, void *, EMPTYARG )
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir 	aLbAlgorithm.SetUpdateMode( FALSE );
1068cdf0e10cSrcweir 	aLbAlgorithm.Clear();
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir 	LanguageType eLang = aLbLanguage.GetSelectLanguage();
1071cdf0e10cSrcweir 	if ( eLang == LANGUAGE_SYSTEM )
1072cdf0e10cSrcweir 	{
1073cdf0e10cSrcweir 		//	for LANGUAGE_SYSTEM no algorithm can be selected because
1074cdf0e10cSrcweir 		//	it wouldn't necessarily exist for other languages
1075cdf0e10cSrcweir 		//	-> leave list box empty if LANGUAGE_SYSTEM is selected
1076cdf0e10cSrcweir         aFtAlgorithm.Enable( FALSE );           // nothing to select
1077cdf0e10cSrcweir 		aLbAlgorithm.Enable( FALSE );			// nothing to select
1078cdf0e10cSrcweir 	}
1079cdf0e10cSrcweir 	else
1080cdf0e10cSrcweir 	{
1081cdf0e10cSrcweir 		lang::Locale aLocale( MsLangId::convertLanguageToLocale( eLang ));
1082cdf0e10cSrcweir 		uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms( aLocale );
1083cdf0e10cSrcweir 
1084cdf0e10cSrcweir 		long nCount = aAlgos.getLength();
1085cdf0e10cSrcweir 		const rtl::OUString* pArray = aAlgos.getConstArray();
1086cdf0e10cSrcweir 		for (long i=0; i<nCount; i++)
1087cdf0e10cSrcweir 		{
1088cdf0e10cSrcweir 			String sAlg = pArray[i];
1089cdf0e10cSrcweir 			String sUser = pColRes->GetTranslation( sAlg );
1090cdf0e10cSrcweir 			aLbAlgorithm.InsertEntry( sUser, LISTBOX_APPEND );
1091cdf0e10cSrcweir 		}
1092cdf0e10cSrcweir 		aLbAlgorithm.SelectEntryPos( 0 );		// first entry is default
1093cdf0e10cSrcweir         aFtAlgorithm.Enable( nCount > 1 );      // enable only if there is a choice
1094cdf0e10cSrcweir 		aLbAlgorithm.Enable( nCount > 1 );		// enable only if there is a choice
1095cdf0e10cSrcweir 	}
1096cdf0e10cSrcweir 
1097cdf0e10cSrcweir 	aLbAlgorithm.SetUpdateMode( TRUE );
1098cdf0e10cSrcweir 	return 0;
1099cdf0e10cSrcweir }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir 
1102