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