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