xref: /aoo41x/main/sw/source/ui/misc/srtdlg.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sw.hxx"
30*cdf0e10cSrcweir #ifdef SW_DLLIMPLEMENTATION
31*cdf0e10cSrcweir #undef SW_DLLIMPLEMENTATION
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "srtdlg.hxx"
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #ifndef _MSGBOX_HXX //autogen
37*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir #include <svl/intitem.hxx>
40*cdf0e10cSrcweir #include <svl/eitem.hxx>
41*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
42*cdf0e10cSrcweir #include <svx/svxids.hrc>
43*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
44*cdf0e10cSrcweir #include <svx/svxdlg.hxx>
45*cdf0e10cSrcweir #include <svx/dialogs.hrc>
46*cdf0e10cSrcweir #include <unotools/collatorwrapper.hxx>
47*cdf0e10cSrcweir #include <svtools/collatorres.hxx>
48*cdf0e10cSrcweir #include <swwait.hxx>
49*cdf0e10cSrcweir #include <view.hxx>
50*cdf0e10cSrcweir #include <cmdid.h>
51*cdf0e10cSrcweir #include <wrtsh.hxx>
52*cdf0e10cSrcweir #include <misc.hrc>
53*cdf0e10cSrcweir #include <srtdlg.hrc>
54*cdf0e10cSrcweir #include <swtable.hxx>
55*cdf0e10cSrcweir #include <node.hxx>
56*cdf0e10cSrcweir #include <tblsel.hxx>
57*cdf0e10cSrcweir #include <sfx2/request.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir // sw/inc/tblsel.hxx
60*cdf0e10cSrcweir SV_IMPL_PTRARR( _FndBoxes, _FndBox* )
61*cdf0e10cSrcweir SV_IMPL_PTRARR( _FndLines, _FndLine* )
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir static sal_Bool bCheck1 = sal_True;
64*cdf0e10cSrcweir static sal_Bool bCheck2 = sal_False;
65*cdf0e10cSrcweir static sal_Bool bCheck3 = sal_False;
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir static sal_uInt16 nCol1 = 1;
68*cdf0e10cSrcweir static sal_uInt16 nCol2 = 1;
69*cdf0e10cSrcweir static sal_uInt16 nCol3 = 1;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir static sal_uInt16 nType1 = 0;
72*cdf0e10cSrcweir static sal_uInt16 nType2 = 0;
73*cdf0e10cSrcweir static sal_uInt16 nType3 = 0;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir static sal_uInt16 nLang = LANGUAGE_NONE;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir static sal_Bool	  bAsc1	 = sal_True;
78*cdf0e10cSrcweir static sal_Bool	  bAsc2	 = sal_True;
79*cdf0e10cSrcweir static sal_Bool	  bAsc3	 = sal_True;
80*cdf0e10cSrcweir static sal_Bool	  bCol	 = sal_False;
81*cdf0e10cSrcweir static sal_Bool	  bCsSens= sal_False;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir static sal_Unicode	  cDeli	 = '\t';
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
86*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
87*cdf0e10cSrcweir using ::rtl::OUString;
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir void lcl_ClearLstBoxAndDelUserData( ListBox& rLstBox )
91*cdf0e10cSrcweir {
92*cdf0e10cSrcweir 	void* pDel;
93*cdf0e10cSrcweir 	for( sal_uInt16 n = 0, nEnd = rLstBox.GetEntryCount(); n < nEnd; ++n )
94*cdf0e10cSrcweir 		if( 0 != ( pDel = rLstBox.GetEntryData( n )) )
95*cdf0e10cSrcweir 			delete (String*)pDel;
96*cdf0e10cSrcweir 	rLstBox.Clear();
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir /*--------------------------------------------------------------------
100*cdf0e10cSrcweir 	 Beschreibung: 	Fuer Tabellenselektion sel. Zeilen und Spalten
101*cdf0e10cSrcweir 					feststellen
102*cdf0e10cSrcweir  --------------------------------------------------------------------*/
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir sal_Bool lcl_GetSelTbl( SwWrtShell &rSh, sal_uInt16& rX, sal_uInt16& rY )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir 	const SwTableNode* pTblNd = rSh.IsCrsrInTbl();
108*cdf0e10cSrcweir 	if( !pTblNd )
109*cdf0e10cSrcweir 		return sal_False;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	_FndBox aFndBox( 0, 0 );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	// suche alle Boxen / Lines
114*cdf0e10cSrcweir 	{
115*cdf0e10cSrcweir 		SwSelBoxes aSelBoxes;
116*cdf0e10cSrcweir 		::GetTblSel( rSh, aSelBoxes );
117*cdf0e10cSrcweir 		_FndPara aPara( aSelBoxes, &aFndBox );
118*cdf0e10cSrcweir 		const SwTable& rTbl = pTblNd->GetTable();
119*cdf0e10cSrcweir 		((SwTableLines&)rTbl.GetTabLines()).ForEach( &_FndLineCopyCol, &aPara );
120*cdf0e10cSrcweir 	}
121*cdf0e10cSrcweir 	rX = aFndBox.GetLines().Count();
122*cdf0e10cSrcweir 	if( !rX )
123*cdf0e10cSrcweir 		return sal_False;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	rY = aFndBox.GetLines()[0]->GetBoxes().Count();
126*cdf0e10cSrcweir 	return sal_True;
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir /*--------------------------------------------------------------------
130*cdf0e10cSrcweir 	 Beschreibung: Init-Liste
131*cdf0e10cSrcweir  --------------------------------------------------------------------*/
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir SwSortDlg::SwSortDlg(Window* pParent, SwWrtShell &rShell) :
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	SvxStandardDialog(pParent, SW_RES(DLG_SORTING)),
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir     aColLbl(this, 		SW_RES(FT_COL   )),
138*cdf0e10cSrcweir 	aTypLbl(this, 		SW_RES(FT_KEYTYP)),
139*cdf0e10cSrcweir 	aDirLbl(this, 		SW_RES(FT_DIR	)),
140*cdf0e10cSrcweir     aSortFL(this,      SW_RES(FL_SORT_2  )),
141*cdf0e10cSrcweir 
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     aKeyCB1(this,       SW_RES(CB_KEY1  )),
144*cdf0e10cSrcweir 	aColEdt1(this, 		SW_RES(ED_KEY1  )),
145*cdf0e10cSrcweir 	aTypDLB1(this, 		SW_RES(DLB_KEY1 )),
146*cdf0e10cSrcweir 	aSortUpRB(this, 	SW_RES(RB_UP    )),
147*cdf0e10cSrcweir 	aSortDnRB(this, 	SW_RES(RB_DN    )),
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     aKeyCB2(this,       SW_RES(CB_KEY2  )),
150*cdf0e10cSrcweir 	aColEdt2(this, 		SW_RES(ED_KEY2  )),
151*cdf0e10cSrcweir 	aTypDLB2(this, 		SW_RES(DLB_KEY2 )),
152*cdf0e10cSrcweir 	aSortUp2RB(this, 	SW_RES(RB_UP2    )),
153*cdf0e10cSrcweir 	aSortDn2RB(this, 	SW_RES(RB_DN2    )),
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     aKeyCB3(this,       SW_RES(CB_KEY3  )),
156*cdf0e10cSrcweir 	aColEdt3(this, 		SW_RES(ED_KEY3  )),
157*cdf0e10cSrcweir 	aTypDLB3(this, 		SW_RES(DLB_KEY3 )),
158*cdf0e10cSrcweir 	aSortUp3RB(this, 	SW_RES(RB_UP3    )),
159*cdf0e10cSrcweir 	aSortDn3RB(this, 	SW_RES(RB_DN3    )),
160*cdf0e10cSrcweir 	aDirFL(this,       SW_RES(FL_DIR   )),
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	aColumnRB(this, 	SW_RES(RB_COL   )),
163*cdf0e10cSrcweir 	aRowRB(this, 		SW_RES(RB_ROW   )),
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     aDelimFL(this,     SW_RES(FL_DELIM )),
166*cdf0e10cSrcweir     aDelimTabRB(this,   SW_RES(RB_TAB   )),
167*cdf0e10cSrcweir 	aDelimFreeRB(this, 	SW_RES(RB_TABCH )),
168*cdf0e10cSrcweir 	aDelimEdt(this, 	SW_RES(ED_TABCH )),
169*cdf0e10cSrcweir     aDelimPB(this,    	SW_RES( PB_DELIM)),
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     aLangFL(this,       SW_RES( FL_LANG )),
172*cdf0e10cSrcweir     aLangLB(this,     	SW_RES( LB_LANG )),
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir     aSortOptFL(this,    SW_RES( FL_SORT )),
175*cdf0e10cSrcweir     aCaseCB(this,     	SW_RES( CB_CASE )),
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir     aOkBtn(this,        SW_RES(BT_OK    )),
178*cdf0e10cSrcweir     aCancelBtn(this,    SW_RES(BT_CANCEL)),
179*cdf0e10cSrcweir     aHelpBtn(this,      SW_RES(BT_HELP  )),
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     aColTxt(            SW_RES(STR_COL)),
182*cdf0e10cSrcweir     aRowTxt(            SW_RES(STR_ROW)),
183*cdf0e10cSrcweir 	aNumericTxt(		SW_RES(STR_NUMERIC)),
184*cdf0e10cSrcweir     rSh(rShell),
185*cdf0e10cSrcweir     pColRes( 0 ),
186*cdf0e10cSrcweir 	nX( 99 ),
187*cdf0e10cSrcweir     nY( 99 )
188*cdf0e10cSrcweir {
189*cdf0e10cSrcweir 	aColEdt1.SetAccessibleName(aColLbl.GetText());
190*cdf0e10cSrcweir 	aColEdt2.SetAccessibleName(aColLbl.GetText());
191*cdf0e10cSrcweir 	aColEdt3.SetAccessibleName(aColLbl.GetText());
192*cdf0e10cSrcweir 	aTypDLB1.SetAccessibleName(aTypLbl.GetText());
193*cdf0e10cSrcweir 	aTypDLB2.SetAccessibleName(aTypLbl.GetText());
194*cdf0e10cSrcweir 	aTypDLB3.SetAccessibleName(aTypLbl.GetText());
195*cdf0e10cSrcweir 	aSortUpRB.SetAccessibleRelationMemberOf( &aKeyCB1 );
196*cdf0e10cSrcweir 	aSortDnRB.SetAccessibleRelationMemberOf( &aKeyCB1 );
197*cdf0e10cSrcweir 	aSortUp2RB.SetAccessibleRelationMemberOf( &aKeyCB2 );
198*cdf0e10cSrcweir 	aSortDn2RB.SetAccessibleRelationMemberOf( &aKeyCB2 );
199*cdf0e10cSrcweir 	aSortUp3RB.SetAccessibleRelationMemberOf( &aKeyCB3 );
200*cdf0e10cSrcweir 	aSortDn3RB.SetAccessibleRelationMemberOf( &aKeyCB3 );
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir 	aDelimEdt.SetMaxTextLen( 1 );
203*cdf0e10cSrcweir 	if(rSh.GetSelectionType() &
204*cdf0e10cSrcweir 			(nsSelectionType::SEL_TBL|nsSelectionType::SEL_TBL_CELLS) )
205*cdf0e10cSrcweir 	{
206*cdf0e10cSrcweir 		aColumnRB.Check(bCol);
207*cdf0e10cSrcweir 		aColLbl.SetText(bCol ? aRowTxt : aColTxt);
208*cdf0e10cSrcweir 		aRowRB.Check(!bCol);
209*cdf0e10cSrcweir 		aDelimTabRB.Enable(sal_False);
210*cdf0e10cSrcweir 		aDelimFreeRB.Enable(sal_False);
211*cdf0e10cSrcweir 		aDelimEdt.Enable(sal_False);
212*cdf0e10cSrcweir 	}
213*cdf0e10cSrcweir 	else
214*cdf0e10cSrcweir 	{
215*cdf0e10cSrcweir 		aColumnRB.Enable(sal_False);
216*cdf0e10cSrcweir 		aRowRB.Check(sal_True);
217*cdf0e10cSrcweir 		aColLbl.SetText(aColTxt);
218*cdf0e10cSrcweir 	}
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir 	// Initialisieren
221*cdf0e10cSrcweir 	Link aLk = LINK(this,SwSortDlg, CheckHdl);
222*cdf0e10cSrcweir 	aKeyCB1.SetClickHdl( aLk );
223*cdf0e10cSrcweir 	aKeyCB2.SetClickHdl( aLk );
224*cdf0e10cSrcweir 	aKeyCB3.SetClickHdl( aLk );
225*cdf0e10cSrcweir 	aColumnRB.SetClickHdl( aLk );
226*cdf0e10cSrcweir 	aRowRB.SetClickHdl( aLk );
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	aLk = LINK(this,SwSortDlg, DelimHdl);
229*cdf0e10cSrcweir 	aDelimFreeRB.SetClickHdl(aLk);
230*cdf0e10cSrcweir 	aDelimTabRB.SetClickHdl(aLk);
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 	aDelimPB.SetClickHdl( LINK( this, SwSortDlg, DelimCharHdl ));
233*cdf0e10cSrcweir 
234*cdf0e10cSrcweir 	aKeyCB1.Check(bCheck1);
235*cdf0e10cSrcweir 	aKeyCB2.Check(bCheck2);
236*cdf0e10cSrcweir 	aKeyCB3.Check(bCheck3);
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	aColEdt1.SetValue(nCol1);
239*cdf0e10cSrcweir 	aColEdt2.SetValue(nCol2);
240*cdf0e10cSrcweir 	aColEdt3.SetValue(nCol3);
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 	// first initialise the language, then select the
243*cdf0e10cSrcweir 	if( LANGUAGE_NONE == nLang || LANGUAGE_DONTKNOW == nLang )
244*cdf0e10cSrcweir 		nLang = (sal_uInt16)GetAppLanguage();
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     aLangLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, sal_True, sal_False);
247*cdf0e10cSrcweir 	aLangLB.SelectLanguage( nLang );
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	LanguageHdl( 0 );
250*cdf0e10cSrcweir 	aLangLB.SetSelectHdl( LINK( this, SwSortDlg, LanguageHdl ));
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	aSortUpRB.Check(bAsc1);
253*cdf0e10cSrcweir 	aSortDnRB.Check(!bAsc1);
254*cdf0e10cSrcweir 	aSortUp2RB.Check(bAsc2);
255*cdf0e10cSrcweir 	aSortDn2RB.Check(!bAsc2);
256*cdf0e10cSrcweir 	aSortUp3RB.Check(bAsc3);
257*cdf0e10cSrcweir 	aSortDn3RB.Check(!bAsc3);
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir 	aCaseCB.Check( bCsSens );
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 	aDelimTabRB.Check(cDeli == '\t');
262*cdf0e10cSrcweir 	if(!aDelimTabRB.IsChecked())
263*cdf0e10cSrcweir 	{
264*cdf0e10cSrcweir 		aDelimEdt.SetText(cDeli);
265*cdf0e10cSrcweir 		aDelimFreeRB.Check(sal_True);
266*cdf0e10cSrcweir 		DelimHdl(&aDelimFreeRB);
267*cdf0e10cSrcweir 	}
268*cdf0e10cSrcweir 	else
269*cdf0e10cSrcweir 		DelimHdl(&aDelimTabRB);
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir 	FreeResource();
272*cdf0e10cSrcweir 	if( ::lcl_GetSelTbl( rSh, nX, nY) )
273*cdf0e10cSrcweir 	{
274*cdf0e10cSrcweir 		sal_uInt16 nMax = aRowRB.IsChecked()? nY : nX;
275*cdf0e10cSrcweir 		aColEdt1.SetMax(nMax);
276*cdf0e10cSrcweir 		aColEdt2.SetMax(nMax);
277*cdf0e10cSrcweir 		aColEdt3.SetMax(nMax);
278*cdf0e10cSrcweir 	}
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 	aDelimEdt.SetAccessibleRelationLabeledBy(&aDelimFreeRB);
281*cdf0e10cSrcweir 	aDelimPB.SetAccessibleRelationLabeledBy(&aDelimFreeRB);
282*cdf0e10cSrcweir 	aDelimPB.SetAccessibleRelationMemberOf(&aDelimFL);
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir 	aColEdt1.SetAccessibleRelationMemberOf(&aKeyCB1);
285*cdf0e10cSrcweir 	aColEdt1.SetAccessibleRelationLabeledBy(&aColLbl);
286*cdf0e10cSrcweir 	aTypDLB1.SetAccessibleRelationMemberOf(&aKeyCB1);
287*cdf0e10cSrcweir 	aTypDLB1.SetAccessibleRelationLabeledBy(&aTypLbl);
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	aColEdt2.SetAccessibleRelationMemberOf(&aKeyCB2);
290*cdf0e10cSrcweir 	aColEdt2.SetAccessibleRelationLabeledBy(&aColLbl);
291*cdf0e10cSrcweir 	aTypDLB2.SetAccessibleRelationMemberOf(&aKeyCB2);
292*cdf0e10cSrcweir 	aTypDLB2.SetAccessibleRelationLabeledBy(&aTypLbl);
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 	aColEdt3.SetAccessibleRelationMemberOf(&aKeyCB3);
295*cdf0e10cSrcweir 	aColEdt3.SetAccessibleRelationLabeledBy(&aColLbl);
296*cdf0e10cSrcweir 	aTypDLB3.SetAccessibleRelationMemberOf(&aKeyCB3);
297*cdf0e10cSrcweir 	aTypDLB3.SetAccessibleRelationLabeledBy(&aTypLbl);
298*cdf0e10cSrcweir }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir SwSortDlg::~SwSortDlg()
301*cdf0e10cSrcweir {
302*cdf0e10cSrcweir 	::lcl_ClearLstBoxAndDelUserData( aTypDLB1 );
303*cdf0e10cSrcweir 	::lcl_ClearLstBoxAndDelUserData( aTypDLB2 );
304*cdf0e10cSrcweir 	::lcl_ClearLstBoxAndDelUserData( aTypDLB3 );
305*cdf0e10cSrcweir 	delete pColRes;
306*cdf0e10cSrcweir }
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir sal_Unicode	SwSortDlg::GetDelimChar() const
309*cdf0e10cSrcweir {
310*cdf0e10cSrcweir     sal_Unicode cRet = '\t';
311*cdf0e10cSrcweir 	if( !aDelimTabRB.IsChecked() )
312*cdf0e10cSrcweir 	{
313*cdf0e10cSrcweir 		String aTmp( aDelimEdt.GetText() );
314*cdf0e10cSrcweir 		if( aTmp.Len() )
315*cdf0e10cSrcweir             cRet = aTmp.GetChar( 0 );
316*cdf0e10cSrcweir 	}
317*cdf0e10cSrcweir     return cRet;
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir /*--------------------------------------------------------------------
321*cdf0e10cSrcweir 	Beschreibung: An die Core weiterreichen
322*cdf0e10cSrcweir  --------------------------------------------------------------------*/
323*cdf0e10cSrcweir void SwSortDlg::Apply()
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	// Alte Einstellung speichern
326*cdf0e10cSrcweir 	//
327*cdf0e10cSrcweir 	bCheck1 = aKeyCB1.IsChecked();
328*cdf0e10cSrcweir 	bCheck2 = aKeyCB2.IsChecked();
329*cdf0e10cSrcweir 	bCheck3 = aKeyCB3.IsChecked();
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 	nCol1 = (sal_uInt16)aColEdt1.GetValue();
332*cdf0e10cSrcweir 	nCol2 = (sal_uInt16)aColEdt2.GetValue();
333*cdf0e10cSrcweir 	nCol3 = (sal_uInt16)aColEdt3.GetValue();
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	nType1 = aTypDLB1.GetSelectEntryPos();
336*cdf0e10cSrcweir 	nType2 = aTypDLB2.GetSelectEntryPos();
337*cdf0e10cSrcweir 	nType3 = aTypDLB3.GetSelectEntryPos();
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 	bAsc1 = aSortUpRB.IsChecked();
340*cdf0e10cSrcweir 	bAsc2 = aSortUp2RB.IsChecked();
341*cdf0e10cSrcweir 	bAsc3 = aSortUp3RB.IsChecked();
342*cdf0e10cSrcweir 	bCol = aColumnRB.IsChecked();
343*cdf0e10cSrcweir 	nLang = aLangLB.GetSelectLanguage();
344*cdf0e10cSrcweir 	cDeli = GetDelimChar();
345*cdf0e10cSrcweir 	bCsSens = aCaseCB.IsChecked();
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir 	void* pUserData;
348*cdf0e10cSrcweir 	SwSortOptions aOptions;
349*cdf0e10cSrcweir 	if( bCheck1 )
350*cdf0e10cSrcweir 	{
351*cdf0e10cSrcweir 		String sEntry( aTypDLB1.GetSelectEntry() );
352*cdf0e10cSrcweir 		if( sEntry == aNumericTxt )
353*cdf0e10cSrcweir 			sEntry.Erase();
354*cdf0e10cSrcweir 		else if( 0 != (pUserData = aTypDLB1.GetEntryData(
355*cdf0e10cSrcweir 											aTypDLB1.GetSelectEntryPos())) )
356*cdf0e10cSrcweir 			sEntry = *(String*)pUserData;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 		SwSortKey *pKey = new SwSortKey( nCol1, sEntry,
359*cdf0e10cSrcweir 									bAsc1 ? SRT_ASCENDING : SRT_DESCENDING );
360*cdf0e10cSrcweir 		aOptions.aKeys.C40_INSERT(SwSortKey, pKey, aOptions.aKeys.Count());
361*cdf0e10cSrcweir 	}
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	if( bCheck2 )
364*cdf0e10cSrcweir 	{
365*cdf0e10cSrcweir 		String sEntry( aTypDLB2.GetSelectEntry() );
366*cdf0e10cSrcweir 		if( sEntry == aNumericTxt )
367*cdf0e10cSrcweir 			sEntry.Erase();
368*cdf0e10cSrcweir 		else if( 0 != (pUserData = aTypDLB2.GetEntryData(
369*cdf0e10cSrcweir 											aTypDLB2.GetSelectEntryPos())) )
370*cdf0e10cSrcweir 			sEntry = *(String*)pUserData;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 		SwSortKey *pKey = new SwSortKey( nCol2, sEntry,
373*cdf0e10cSrcweir 									bAsc2 ? SRT_ASCENDING : SRT_DESCENDING );
374*cdf0e10cSrcweir 		aOptions.aKeys.C40_INSERT( SwSortKey, pKey, aOptions.aKeys.Count() );
375*cdf0e10cSrcweir 	}
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	if( bCheck3 )
378*cdf0e10cSrcweir 	{
379*cdf0e10cSrcweir 		String sEntry( aTypDLB3.GetSelectEntry() );
380*cdf0e10cSrcweir 		if( sEntry == aNumericTxt )
381*cdf0e10cSrcweir 			sEntry.Erase();
382*cdf0e10cSrcweir 		else if( 0 != (pUserData = aTypDLB3.GetEntryData(
383*cdf0e10cSrcweir 											aTypDLB3.GetSelectEntryPos())) )
384*cdf0e10cSrcweir 			sEntry = *(String*)pUserData;
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir 		SwSortKey *pKey = new SwSortKey( nCol3, sEntry,
387*cdf0e10cSrcweir 									bAsc3 ? SRT_ASCENDING : SRT_DESCENDING );
388*cdf0e10cSrcweir 		aOptions.aKeys.C40_INSERT( SwSortKey, pKey, aOptions.aKeys.Count() );
389*cdf0e10cSrcweir 	}
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir 	aOptions.eDirection =  bCol ? SRT_COLUMNS : SRT_ROWS;
392*cdf0e10cSrcweir 	aOptions.cDeli = cDeli;
393*cdf0e10cSrcweir 	aOptions.nLanguage = nLang;
394*cdf0e10cSrcweir 	aOptions.bTable = rSh.IsTableMode();
395*cdf0e10cSrcweir 	aOptions.bIgnoreCase = !bCsSens;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir 	sal_Bool bRet;
398*cdf0e10cSrcweir 	{
399*cdf0e10cSrcweir 		SwWait aWait( *rSh.GetView().GetDocShell(), sal_True );
400*cdf0e10cSrcweir 		rSh.StartAllAction();
401*cdf0e10cSrcweir 		if( 0 != (bRet = rSh.Sort( aOptions )))
402*cdf0e10cSrcweir 			rSh.SetModified();
403*cdf0e10cSrcweir 		rSh.EndAllAction();
404*cdf0e10cSrcweir 	}
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir 	if( !bRet )
407*cdf0e10cSrcweir 		InfoBox( this->GetParent(), SW_RES(MSG_SRTERR)).Execute();
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir /* -----------------30.09.98 10:03-------------------
411*cdf0e10cSrcweir  *
412*cdf0e10cSrcweir  * --------------------------------------------------*/
413*cdf0e10cSrcweir IMPL_LINK( SwSortDlg, DelimHdl, RadioButton*, pButton )
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir 	sal_Bool bEnable = pButton == &aDelimFreeRB && aDelimFreeRB.IsEnabled();
416*cdf0e10cSrcweir 	aDelimEdt.Enable( bEnable );
417*cdf0e10cSrcweir 	aDelimPB.Enable( bEnable );
418*cdf0e10cSrcweir 	return 0;
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir IMPL_LINK( SwSortDlg, DelimCharHdl, PushButton*, EMPTYARG )
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir 	SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
424*cdf0e10cSrcweir 	if(pFact)
425*cdf0e10cSrcweir 	{
426*cdf0e10cSrcweir 		SfxAllItemSet aSet( rSh.GetAttrPool() );
427*cdf0e10cSrcweir 		aSet.Put( SfxInt32Item( SID_ATTR_CHAR, GetDelimChar() ) );
428*cdf0e10cSrcweir         SfxAbstractDialog* pMap = pFact->CreateSfxDialog( &aDelimPB, aSet,
429*cdf0e10cSrcweir 			rSh.GetView().GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
430*cdf0e10cSrcweir 		if( RET_OK == pMap->Execute() )
431*cdf0e10cSrcweir 		{
432*cdf0e10cSrcweir 			SFX_ITEMSET_ARG( pMap->GetOutputItemSet(), pItem, SfxInt32Item, SID_ATTR_CHAR, sal_False );
433*cdf0e10cSrcweir 			if ( pItem )
434*cdf0e10cSrcweir 				aDelimEdt.SetText( sal_Unicode ( pItem->GetValue() ) );
435*cdf0e10cSrcweir 		}
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir 		delete pMap;
438*cdf0e10cSrcweir 	}
439*cdf0e10cSrcweir 	return 0;
440*cdf0e10cSrcweir }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir IMPL_LINK( SwSortDlg, CheckHdl, CheckBox *, pCheck )
444*cdf0e10cSrcweir {
445*cdf0e10cSrcweir 	if( pCheck == ( CheckBox* ) &aRowRB)
446*cdf0e10cSrcweir 	{
447*cdf0e10cSrcweir 		aColLbl.SetText(aColTxt);
448*cdf0e10cSrcweir 		aColEdt1.SetMax(nY);
449*cdf0e10cSrcweir 		aColEdt2.SetMax(nY);
450*cdf0e10cSrcweir 		aColEdt3.SetMax(nY);
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 		aColEdt1.SetAccessibleName(aColTxt);
453*cdf0e10cSrcweir 		aColEdt2.SetAccessibleName(aColTxt);
454*cdf0e10cSrcweir 		aColEdt3.SetAccessibleName(aColTxt);
455*cdf0e10cSrcweir 	}
456*cdf0e10cSrcweir 	else if( pCheck == ( CheckBox* ) &aColumnRB)
457*cdf0e10cSrcweir 	{
458*cdf0e10cSrcweir 		aColLbl.SetText(aRowTxt);
459*cdf0e10cSrcweir 		aColEdt1.SetMax(nX);
460*cdf0e10cSrcweir 		aColEdt2.SetMax(nX);
461*cdf0e10cSrcweir 		aColEdt3.SetMax(nX);
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir 		aColEdt1.SetAccessibleName(aRowTxt);
464*cdf0e10cSrcweir 		aColEdt2.SetAccessibleName(aRowTxt);
465*cdf0e10cSrcweir 		aColEdt3.SetAccessibleName(aRowTxt);
466*cdf0e10cSrcweir 	}
467*cdf0e10cSrcweir 	else if(!aKeyCB1.IsChecked() &&
468*cdf0e10cSrcweir 				!aKeyCB2.IsChecked() &&
469*cdf0e10cSrcweir 					!aKeyCB3.IsChecked())
470*cdf0e10cSrcweir 		pCheck->Check(sal_True);
471*cdf0e10cSrcweir 	return 0;
472*cdf0e10cSrcweir }
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir IMPL_LINK( SwSortDlg, LanguageHdl, ListBox*, pLBox )
475*cdf0e10cSrcweir {
476*cdf0e10cSrcweir 	Locale aLcl( SvxCreateLocale( aLangLB.GetSelectLanguage() ) );
477*cdf0e10cSrcweir 	Sequence < OUString > aSeq(
478*cdf0e10cSrcweir 							GetAppCollator().listCollatorAlgorithms( aLcl ));
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	if( !pColRes )
481*cdf0e10cSrcweir 		pColRes = new CollatorRessource();
482*cdf0e10cSrcweir 
483*cdf0e10cSrcweir 	const sal_uInt16 nLstBoxCnt = 3;
484*cdf0e10cSrcweir 	ListBox* aLstArr[ nLstBoxCnt ] = { &aTypDLB1, &aTypDLB2, &aTypDLB3 };
485*cdf0e10cSrcweir 	sal_uInt16* aTypeArr[ nLstBoxCnt ] = { &nType1, &nType2, &nType3 };
486*cdf0e10cSrcweir 	String aOldStrArr[ nLstBoxCnt ];
487*cdf0e10cSrcweir 	sal_uInt16 n;
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir 	void* pUserData;
490*cdf0e10cSrcweir 	for( n = 0; n < nLstBoxCnt; ++n )
491*cdf0e10cSrcweir 	{
492*cdf0e10cSrcweir 		ListBox* pL = aLstArr[ n ];
493*cdf0e10cSrcweir 		if( 0 != (pUserData = pL->GetEntryData( pL->GetSelectEntryPos())) )
494*cdf0e10cSrcweir 			aOldStrArr[ n ] = *(String*)pUserData;
495*cdf0e10cSrcweir 		::lcl_ClearLstBoxAndDelUserData( *pL );
496*cdf0e10cSrcweir 	}
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir 	sal_uInt16 nInsPos;
499*cdf0e10cSrcweir 	String sAlg, sUINm;
500*cdf0e10cSrcweir 	for( long nCnt = 0, nEnd = aSeq.getLength(); nCnt <= nEnd; ++nCnt )
501*cdf0e10cSrcweir 	{
502*cdf0e10cSrcweir 		if( nCnt < nEnd )
503*cdf0e10cSrcweir 			sUINm = pColRes->GetTranslation( sAlg = aSeq[ nCnt ] );
504*cdf0e10cSrcweir 		else
505*cdf0e10cSrcweir 			sUINm = sAlg = aNumericTxt;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir 		for( n = 0; n < nLstBoxCnt; ++n )
508*cdf0e10cSrcweir 		{
509*cdf0e10cSrcweir 			ListBox* pL = aLstArr[ n ];
510*cdf0e10cSrcweir 			nInsPos = pL->InsertEntry( sUINm );
511*cdf0e10cSrcweir 			pL->SetEntryData( nInsPos, new String( sAlg ));
512*cdf0e10cSrcweir 			if( pLBox && sAlg == aOldStrArr[ n ] )
513*cdf0e10cSrcweir 				pL->SelectEntryPos( nInsPos );
514*cdf0e10cSrcweir 		}
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir 	for( n = 0; n < nLstBoxCnt; ++n )
518*cdf0e10cSrcweir 	{
519*cdf0e10cSrcweir 		ListBox* pL = aLstArr[ n ];
520*cdf0e10cSrcweir 		if( !pLBox )
521*cdf0e10cSrcweir 			pL->SelectEntryPos( *aTypeArr[n] );
522*cdf0e10cSrcweir 		else if( LISTBOX_ENTRY_NOTFOUND == pL->GetSelectEntryPos() )
523*cdf0e10cSrcweir 			pL->SelectEntryPos( 0 );
524*cdf0e10cSrcweir 	}
525*cdf0e10cSrcweir 	return 0;
526*cdf0e10cSrcweir }
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 
533