1*5900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5900e8ecSAndrew Rist * distributed with this work for additional information 6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an 15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 17*5900e8ecSAndrew Rist * specific language governing permissions and limitations 18*5900e8ecSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5900e8ecSAndrew Rist *************************************************************/ 21*5900e8ecSAndrew Rist 22*5900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir #include <tools/debug.hxx> 27cdf0e10cSrcweir #include <vcl/svapp.hxx> 28cdf0e10cSrcweir #include <svtools/svxbox.hxx> 29cdf0e10cSrcweir #include <unotools/charclass.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir // ----------------------------------------------------------------------- 32cdf0e10cSrcweir 33cdf0e10cSrcweir SV_IMPL_PTRARR(SvxEntryLst, SvxBoxEntry*) 34cdf0e10cSrcweir 35cdf0e10cSrcweir /*-------------------------------------------------------------------- 36cdf0e10cSrcweir Beschreibung: Ein ListboxElement 37cdf0e10cSrcweir --------------------------------------------------------------------*/ 38cdf0e10cSrcweir 39cdf0e10cSrcweir SvxBoxEntry::SvxBoxEntry() : 40cdf0e10cSrcweir nId(LISTBOX_ENTRY_NOTFOUND), 41cdf0e10cSrcweir bModified(sal_False), 42cdf0e10cSrcweir bNew(sal_False) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir } 45cdf0e10cSrcweir 46cdf0e10cSrcweir 47cdf0e10cSrcweir SvxBoxEntry::SvxBoxEntry(const String& aNam, sal_uInt16 nIdx) : 48cdf0e10cSrcweir aName(aNam), 49cdf0e10cSrcweir nId(nIdx), 50cdf0e10cSrcweir bModified(sal_False), 51cdf0e10cSrcweir bNew(sal_False) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir 56cdf0e10cSrcweir SvxBoxEntry::SvxBoxEntry(const SvxBoxEntry& rOld) : 57cdf0e10cSrcweir aName(rOld.aName), 58cdf0e10cSrcweir nId(rOld.nId), 59cdf0e10cSrcweir bModified(rOld.bModified), 60cdf0e10cSrcweir bNew(rOld.bNew) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir } 63cdf0e10cSrcweir 64cdf0e10cSrcweir /*-------------------------------------------------------------------- 65cdf0e10cSrcweir Beschreibung: 66cdf0e10cSrcweir --------------------------------------------------------------------*/ 67cdf0e10cSrcweir 68cdf0e10cSrcweir SvxListBox::SvxListBox(Window* pParent, WinBits nBits) : 69cdf0e10cSrcweir ListBox(pParent, nBits) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir InitListBox(); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir 75cdf0e10cSrcweir SvxListBox::SvxListBox(Window* pParent, const ResId& rId): 76cdf0e10cSrcweir ListBox(pParent, rId) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir InitListBox(); 79cdf0e10cSrcweir } 80cdf0e10cSrcweir 81cdf0e10cSrcweir /*-------------------------------------------------------------------- 82cdf0e10cSrcweir Beschreibung: Basisklasse Dtor 83cdf0e10cSrcweir --------------------------------------------------------------------*/ 84cdf0e10cSrcweir 85cdf0e10cSrcweir __EXPORT SvxListBox::~SvxListBox() 86cdf0e10cSrcweir { 87cdf0e10cSrcweir aEntryLst.DeleteAndDestroy(0, aEntryLst.Count()); 88cdf0e10cSrcweir aDelEntryLst.DeleteAndDestroy(0, aDelEntryLst.Count()); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir /*-------------------------------------------------------------------- 92cdf0e10cSrcweir Beschreibung: Evtl. Liste aus der Ressource beachten 93cdf0e10cSrcweir --------------------------------------------------------------------*/ 94cdf0e10cSrcweir 95cdf0e10cSrcweir void SvxListBox::InitListBox() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir // Verwaltung fuer die Stringlist aus der Resource aufbauen 98cdf0e10cSrcweir sal_uInt16 nSize = GetEntryCount(); 99cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 100cdf0e10cSrcweir { const SvxBoxEntry* pTmp = new SvxBoxEntry(ListBox::GetEntry(i), i); 101cdf0e10cSrcweir const SvxBoxEntry* &rpTmp = pTmp; 102cdf0e10cSrcweir aEntryLst.Insert(rpTmp, aEntryLst.Count()); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir /*-------------------------------------------------------------------- 107cdf0e10cSrcweir Beschreibung: neue Eintraege verwalten 108cdf0e10cSrcweir --------------------------------------------------------------------*/ 109cdf0e10cSrcweir 110cdf0e10cSrcweir void SvxListBox::InsertNewEntry(const SvxBoxEntry& rEntry) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir SvxBoxEntry* pNew = new SvxBoxEntry(rEntry); 113cdf0e10cSrcweir pNew->bNew = sal_True; 114cdf0e10cSrcweir InsertSorted(pNew); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir /*-------------------------------------------------------------------- 118cdf0e10cSrcweir Beschreibung: Eintrag in die ListBox aufnehmen 119cdf0e10cSrcweir --------------------------------------------------------------------*/ 120cdf0e10cSrcweir 121cdf0e10cSrcweir void SvxListBox::InsertEntry(const SvxBoxEntry& rEntry, sal_uInt16 nPos) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir if(nPos != LISTBOX_ENTRY_NOTFOUND) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir SvxBoxEntry* pEntry = new SvxBoxEntry(rEntry); 126cdf0e10cSrcweir ListBox::InsertEntry(pEntry->aName, nPos); 127cdf0e10cSrcweir //const SvxBoxEntry* &rpEntry = pEntry; 128cdf0e10cSrcweir aEntryLst.C40_INSERT(SvxBoxEntry, pEntry, nPos); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir else 131cdf0e10cSrcweir InsertSorted(new SvxBoxEntry(rEntry)); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir /*-------------------------------------------------------------------- 135cdf0e10cSrcweir Beschreibung: Eintrag aus der Liste loeschen 136cdf0e10cSrcweir --------------------------------------------------------------------*/ 137cdf0e10cSrcweir 138cdf0e10cSrcweir void SvxListBox::RemoveEntry(sal_uInt16 nPos) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir if(nPos >= aEntryLst.Count()) 141cdf0e10cSrcweir return; 142cdf0e10cSrcweir 143cdf0e10cSrcweir // Altes Element austragen 144cdf0e10cSrcweir SvxBoxEntry* pEntry = aEntryLst[nPos]; 145cdf0e10cSrcweir aEntryLst.Remove(nPos, 1); 146cdf0e10cSrcweir ListBox::RemoveEntry(nPos); 147cdf0e10cSrcweir 148cdf0e10cSrcweir // keine neuen Eintraege in die Liste mit aufnehmen 149cdf0e10cSrcweir if(pEntry->bNew) 150cdf0e10cSrcweir return; 151cdf0e10cSrcweir 152cdf0e10cSrcweir // in DeleteListe eintragen 153cdf0e10cSrcweir aDelEntryLst.C40_INSERT(SvxBoxEntry, pEntry, aDelEntryLst.Count()); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir /*-------------------------------------------------------------------- 157cdf0e10cSrcweir Beschreibung: Eintrag ueber konkretes Obkjekt loeschen 158cdf0e10cSrcweir --------------------------------------------------------------------*/ 159cdf0e10cSrcweir 160cdf0e10cSrcweir void SvxListBox::RemoveEntry(const SvxBoxEntry& rEntry) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir sal_uInt16 nPos = ListBox::GetEntryPos(rEntry.aName); 163cdf0e10cSrcweir RemoveEntry(nPos); 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir /*-------------------------------------------------------------------- 167cdf0e10cSrcweir Beschreibung: Listen loeschen und Anzeige loeschen 168cdf0e10cSrcweir --------------------------------------------------------------------*/ 169cdf0e10cSrcweir 170cdf0e10cSrcweir void SvxListBox::Clear() 171cdf0e10cSrcweir { 172cdf0e10cSrcweir ListBox::Clear(); 173cdf0e10cSrcweir aEntryLst.DeleteAndDestroy(0, aEntryLst.Count()); 174cdf0e10cSrcweir aDelEntryLst.DeleteAndDestroy(0, aDelEntryLst.Count()); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir /*-------------------------------------------------------------------- 178cdf0e10cSrcweir Beschreibung: Position by Name 179cdf0e10cSrcweir --------------------------------------------------------------------*/ 180cdf0e10cSrcweir 181cdf0e10cSrcweir sal_uInt16 SvxListBox::GetEntryPos(const SvxBoxEntry& rEntry) const 182cdf0e10cSrcweir { 183cdf0e10cSrcweir return ListBox::GetEntryPos(rEntry.aName); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir /*-------------------------------------------------------------------- 187cdf0e10cSrcweir Beschreibung: Rund um die Entries 188cdf0e10cSrcweir --------------------------------------------------------------------*/ 189cdf0e10cSrcweir 190cdf0e10cSrcweir const SvxBoxEntry& SvxListBox::GetSvxBoxEntry(sal_uInt16 nPos) const 191cdf0e10cSrcweir { 192cdf0e10cSrcweir if(nPos < aEntryLst.Count()) 193cdf0e10cSrcweir return *aEntryLst[nPos]; 194cdf0e10cSrcweir else 195cdf0e10cSrcweir return aDefault; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir /*-------------------------------------------------------------------- 199cdf0e10cSrcweir Beschreibung: aktullen Eintrag zurueckgeben 200cdf0e10cSrcweir --------------------------------------------------------------------*/ 201cdf0e10cSrcweir 202cdf0e10cSrcweir const SvxBoxEntry& SvxListBox::GetSelectSvxBoxEntry(sal_uInt16 nSelId) const 203cdf0e10cSrcweir { 204cdf0e10cSrcweir String aName(ListBox::GetSelectEntry(nSelId)); 205cdf0e10cSrcweir 206cdf0e10cSrcweir if(aName.Len() > 0) 207cdf0e10cSrcweir { 208cdf0e10cSrcweir for (sal_uInt16 i=0; i < aEntryLst.Count(); i++) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir if(aEntryLst[i]->aName == aName ) 211cdf0e10cSrcweir return *aEntryLst[i]; 212cdf0e10cSrcweir } 213cdf0e10cSrcweir } 214cdf0e10cSrcweir return aDefault; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir 217cdf0e10cSrcweir /*-------------------------------------------------------------------- 218cdf0e10cSrcweir Beschreibung: modifizierte Eintraege 219cdf0e10cSrcweir --------------------------------------------------------------------*/ 220cdf0e10cSrcweir 221cdf0e10cSrcweir sal_uInt16 SvxListBox::GetModifiedCount() const 222cdf0e10cSrcweir { 223cdf0e10cSrcweir sal_uInt16 nMod = 0; 224cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 225cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 226cdf0e10cSrcweir { if(aEntryLst[i]->bModified) 227cdf0e10cSrcweir nMod++; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir return nMod; 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir /*-------------------------------------------------------------------- 233cdf0e10cSrcweir Beschreibung: Modifizierte Eintraege behandeln 234cdf0e10cSrcweir --------------------------------------------------------------------*/ 235cdf0e10cSrcweir 236cdf0e10cSrcweir void SvxListBox::ModifyEntry(sal_uInt16 nPos, const String& rName) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir if(nPos >= aEntryLst.Count()) 239cdf0e10cSrcweir return; 240cdf0e10cSrcweir 241cdf0e10cSrcweir SvxBoxEntry* pEntry = aEntryLst[nPos]; 242cdf0e10cSrcweir aEntryLst.Remove(nPos, 1); 243cdf0e10cSrcweir aEntryLst[nPos]->aName = rName; 244cdf0e10cSrcweir aEntryLst[nPos]->bModified = sal_True; 245cdf0e10cSrcweir ListBox::RemoveEntry(nPos); 246cdf0e10cSrcweir 247cdf0e10cSrcweir InsertSorted(pEntry); 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir /*-------------------------------------------------------------------- 251cdf0e10cSrcweir Beschreibung: alle modifizierten Eintraege bahandeln 252cdf0e10cSrcweir --------------------------------------------------------------------*/ 253cdf0e10cSrcweir 254cdf0e10cSrcweir const SvxBoxEntry& SvxListBox::GetModifiedEntry(sal_uInt16 nPos) const 255cdf0e10cSrcweir { 256cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 257cdf0e10cSrcweir sal_uInt16 nMod = 0; 258cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 259cdf0e10cSrcweir { if(aEntryLst[i]->bModified) 260cdf0e10cSrcweir { if(nMod == nPos) 261cdf0e10cSrcweir return *aEntryLst[i]; 262cdf0e10cSrcweir nMod++; 263cdf0e10cSrcweir } 264cdf0e10cSrcweir } 265cdf0e10cSrcweir return aDefault; 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir /*-------------------------------------------------------------------- 269cdf0e10cSrcweir Beschreibung: geloeschte Eintraege 270cdf0e10cSrcweir --------------------------------------------------------------------*/ 271cdf0e10cSrcweir 272cdf0e10cSrcweir sal_uInt16 SvxListBox::GetRemovedCount() const 273cdf0e10cSrcweir { 274cdf0e10cSrcweir return aDelEntryLst.Count(); 275cdf0e10cSrcweir } 276cdf0e10cSrcweir 277cdf0e10cSrcweir 278cdf0e10cSrcweir const SvxBoxEntry& SvxListBox::GetRemovedEntry(sal_uInt16 nPos) const 279cdf0e10cSrcweir { 280cdf0e10cSrcweir if(nPos < aDelEntryLst.Count()) 281cdf0e10cSrcweir return *aDelEntryLst[nPos]; 282cdf0e10cSrcweir 283cdf0e10cSrcweir return aDefault; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir /*-------------------------------------------------------------------- 287cdf0e10cSrcweir Beschreibung: Neue Entries begutachten 288cdf0e10cSrcweir --------------------------------------------------------------------*/ 289cdf0e10cSrcweir 290cdf0e10cSrcweir sal_uInt16 SvxListBox::GetNewCount() const 291cdf0e10cSrcweir { 292cdf0e10cSrcweir sal_uInt16 nNew = 0; 293cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 294cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 295cdf0e10cSrcweir { if(aEntryLst[i]->bNew) 296cdf0e10cSrcweir nNew++; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir return nNew; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir /*-------------------------------------------------------------------- 302cdf0e10cSrcweir Beschreibung: Alle neuen Eintraege ueberpruefen 303cdf0e10cSrcweir --------------------------------------------------------------------*/ 304cdf0e10cSrcweir 305cdf0e10cSrcweir const SvxBoxEntry& SvxListBox::GetNewEntry(sal_uInt16 nPos) const 306cdf0e10cSrcweir { 307cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 308cdf0e10cSrcweir sal_uInt16 nNew = 0; 309cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 310cdf0e10cSrcweir { if(aEntryLst[i]->bNew) 311cdf0e10cSrcweir { if(nNew == nPos) 312cdf0e10cSrcweir return *aEntryLst[i]; 313cdf0e10cSrcweir nNew++; 314cdf0e10cSrcweir } 315cdf0e10cSrcweir } 316cdf0e10cSrcweir return aDefault; 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir /*-------------------------------------------------------------------- 320cdf0e10cSrcweir Beschreibung: Sortiert einfuegen 321cdf0e10cSrcweir --------------------------------------------------------------------*/ 322cdf0e10cSrcweir 323cdf0e10cSrcweir void SvxListBox::InsertSorted(SvxBoxEntry* pEntry) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir ListBox::InsertEntry(pEntry->aName); 326cdf0e10cSrcweir sal_uInt16 nPos = ListBox::GetEntryPos(pEntry->aName); 327cdf0e10cSrcweir aEntryLst.C40_INSERT(SvxBoxEntry, pEntry, nPos); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir /*-------------------------------------------------------------------- 331cdf0e10cSrcweir Beschreibung: ComboBoxen mit Verwaltungseinheit 332cdf0e10cSrcweir --------------------------------------------------------------------*/ 333cdf0e10cSrcweir 334cdf0e10cSrcweir SvxComboBox::SvxComboBox(Window* pParent, WinBits nBits, sal_uInt16 nStyleBits) : 335cdf0e10cSrcweir ComboBox(pParent, nBits), 336cdf0e10cSrcweir nStyle(nStyleBits) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir InitComboBox(); 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir 342cdf0e10cSrcweir SvxComboBox::SvxComboBox(Window* pParent, const ResId& rId, sal_uInt16 nStyleBits ): 343cdf0e10cSrcweir ComboBox(pParent, rId), 344cdf0e10cSrcweir nStyle(nStyleBits) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir InitComboBox(); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir /*-------------------------------------------------------------------- 350cdf0e10cSrcweir Beschreibung: Basisklasse Dtor 351cdf0e10cSrcweir --------------------------------------------------------------------*/ 352cdf0e10cSrcweir 353cdf0e10cSrcweir __EXPORT SvxComboBox::~SvxComboBox() 354cdf0e10cSrcweir { 355cdf0e10cSrcweir aEntryLst.DeleteAndDestroy(0, aEntryLst.Count()); 356cdf0e10cSrcweir aDelEntryLst.DeleteAndDestroy(0, aDelEntryLst.Count()); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir 359cdf0e10cSrcweir /*-------------------------------------------------------------------- 360cdf0e10cSrcweir Beschreibung: Evtl. Liste aus der Ressource beachten 361cdf0e10cSrcweir --------------------------------------------------------------------*/ 362cdf0e10cSrcweir 363cdf0e10cSrcweir void SvxComboBox::InitComboBox() 364cdf0e10cSrcweir { 365cdf0e10cSrcweir // Verwaltung fuer die Stringlist aus der Resource aufbauen 366cdf0e10cSrcweir sal_uInt16 nSize = GetEntryCount(); 367cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 368cdf0e10cSrcweir { const SvxBoxEntry* pTmp = new SvxBoxEntry(ComboBox::GetEntry(i), i); 369cdf0e10cSrcweir const SvxBoxEntry* &rpTmp = pTmp; 370cdf0e10cSrcweir aEntryLst.Insert(rpTmp, aEntryLst.Count()); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir /*-------------------------------------------------------------------- 375cdf0e10cSrcweir Beschreibung: neue Eintraege verwalten 376cdf0e10cSrcweir --------------------------------------------------------------------*/ 377cdf0e10cSrcweir 378cdf0e10cSrcweir void SvxComboBox::InsertNewEntry(const SvxBoxEntry& rEntry) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir SvxBoxEntry* pNew = new SvxBoxEntry(rEntry); 381cdf0e10cSrcweir pNew->bNew = sal_True; 382cdf0e10cSrcweir InsertSorted(pNew); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir /*-------------------------------------------------------------------- 386cdf0e10cSrcweir Beschreibung: Eintrag in die ComboBox aufnehmen 387cdf0e10cSrcweir --------------------------------------------------------------------*/ 388cdf0e10cSrcweir 389cdf0e10cSrcweir void SvxComboBox::InsertEntry(const SvxBoxEntry& rEntry) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir InsertSorted(new SvxBoxEntry(rEntry)); 392cdf0e10cSrcweir } 393cdf0e10cSrcweir 394cdf0e10cSrcweir /*-------------------------------------------------------------------- 395cdf0e10cSrcweir Beschreibung: Eintrag aus der Liste loeschen 396cdf0e10cSrcweir --------------------------------------------------------------------*/ 397cdf0e10cSrcweir 398cdf0e10cSrcweir void SvxComboBox::RemoveEntry(sal_uInt16 nPos) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir if(nPos >= aEntryLst.Count()) 401cdf0e10cSrcweir return; 402cdf0e10cSrcweir 403cdf0e10cSrcweir // Altes Element austragen 404cdf0e10cSrcweir SvxBoxEntry* pEntry = aEntryLst[nPos]; 405cdf0e10cSrcweir aEntryLst.Remove(nPos, 1); 406cdf0e10cSrcweir ComboBox::RemoveEntry(nPos); 407cdf0e10cSrcweir 408cdf0e10cSrcweir // keine neuen Eintraege in die Liste mit aufnehmen 409cdf0e10cSrcweir if(pEntry->bNew) 410cdf0e10cSrcweir return; 411cdf0e10cSrcweir 412cdf0e10cSrcweir // in DeleteListe eintragen 413cdf0e10cSrcweir aDelEntryLst.C40_INSERT(SvxBoxEntry, pEntry, aDelEntryLst.Count()); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir /*-------------------------------------------------------------------- 417cdf0e10cSrcweir Beschreibung: Eintrag ueber konkretes Obkjekt loeschen 418cdf0e10cSrcweir --------------------------------------------------------------------*/ 419cdf0e10cSrcweir 420cdf0e10cSrcweir void SvxComboBox::RemoveEntry(const SvxBoxEntry& rEntry) 421cdf0e10cSrcweir { 422cdf0e10cSrcweir sal_uInt16 nPos = ComboBox::GetEntryPos(rEntry.aName); 423cdf0e10cSrcweir RemoveEntry(nPos); 424cdf0e10cSrcweir } 425cdf0e10cSrcweir 426cdf0e10cSrcweir /*-------------------------------------------------------------------- 427cdf0e10cSrcweir Beschreibung: Listen loeschen und Anzeige loeschen 428cdf0e10cSrcweir --------------------------------------------------------------------*/ 429cdf0e10cSrcweir 430cdf0e10cSrcweir void SvxComboBox::Clear() 431cdf0e10cSrcweir { 432cdf0e10cSrcweir ComboBox::Clear(); 433cdf0e10cSrcweir aEntryLst.DeleteAndDestroy(0, aEntryLst.Count()); 434cdf0e10cSrcweir aDelEntryLst.DeleteAndDestroy(0, aDelEntryLst.Count()); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir 438cdf0e10cSrcweir /*-------------------------------------------------------------------- 439cdf0e10cSrcweir Beschreibung: Position by Name 440cdf0e10cSrcweir --------------------------------------------------------------------*/ 441cdf0e10cSrcweir 442cdf0e10cSrcweir sal_uInt16 SvxComboBox::GetEntryPos(const SvxBoxEntry& rEntry) const 443cdf0e10cSrcweir { 444cdf0e10cSrcweir return ComboBox::GetEntryPos(rEntry.aName); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir /*-------------------------------------------------------------------- 448cdf0e10cSrcweir Beschreibung: Rund um die Entries 449cdf0e10cSrcweir --------------------------------------------------------------------*/ 450cdf0e10cSrcweir 451cdf0e10cSrcweir const SvxBoxEntry& SvxComboBox::GetEntry(sal_uInt16 nPos) const 452cdf0e10cSrcweir { 453cdf0e10cSrcweir if(nPos < aEntryLst.Count()) 454cdf0e10cSrcweir return *aEntryLst[nPos]; 455cdf0e10cSrcweir else 456cdf0e10cSrcweir return aDefault; 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir /*-------------------------------------------------------------------- 460cdf0e10cSrcweir Beschreibung: modifizierte Eintraege 461cdf0e10cSrcweir --------------------------------------------------------------------*/ 462cdf0e10cSrcweir 463cdf0e10cSrcweir sal_uInt16 SvxComboBox::GetModifiedCount() const 464cdf0e10cSrcweir { 465cdf0e10cSrcweir sal_uInt16 nMod = 0; 466cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 467cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 468cdf0e10cSrcweir { if(aEntryLst[i]->bModified) 469cdf0e10cSrcweir nMod++; 470cdf0e10cSrcweir } 471cdf0e10cSrcweir return nMod; 472cdf0e10cSrcweir } 473cdf0e10cSrcweir 474cdf0e10cSrcweir /*-------------------------------------------------------------------- 475cdf0e10cSrcweir Beschreibung: Modifizierte Eintraege behandeln 476cdf0e10cSrcweir --------------------------------------------------------------------*/ 477cdf0e10cSrcweir 478cdf0e10cSrcweir void SvxComboBox::ModifyEntry(sal_uInt16 nPos, const String& rName) 479cdf0e10cSrcweir { 480cdf0e10cSrcweir if(nPos >= aEntryLst.Count()) 481cdf0e10cSrcweir return; 482cdf0e10cSrcweir 483cdf0e10cSrcweir SvxBoxEntry* pEntry = aEntryLst[nPos]; 484cdf0e10cSrcweir aEntryLst.Remove(nPos, 1); 485cdf0e10cSrcweir aEntryLst[nPos]->aName = rName; 486cdf0e10cSrcweir aEntryLst[nPos]->bModified = sal_True; 487cdf0e10cSrcweir ComboBox::RemoveEntry(nPos); 488cdf0e10cSrcweir 489cdf0e10cSrcweir InsertSorted(pEntry); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir /*-------------------------------------------------------------------- 493cdf0e10cSrcweir Beschreibung: alle modifizierten Eintraege bahandeln 494cdf0e10cSrcweir --------------------------------------------------------------------*/ 495cdf0e10cSrcweir 496cdf0e10cSrcweir const SvxBoxEntry& SvxComboBox::GetModifiedEntry(sal_uInt16 nPos) const 497cdf0e10cSrcweir { 498cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 499cdf0e10cSrcweir sal_uInt16 nMod = 0; 500cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 501cdf0e10cSrcweir { if(aEntryLst[i]->bModified) 502cdf0e10cSrcweir { if(nMod == nPos) 503cdf0e10cSrcweir return *aEntryLst[i]; 504cdf0e10cSrcweir nMod++; 505cdf0e10cSrcweir } 506cdf0e10cSrcweir } 507cdf0e10cSrcweir return aDefault; 508cdf0e10cSrcweir } 509cdf0e10cSrcweir 510cdf0e10cSrcweir /*-------------------------------------------------------------------- 511cdf0e10cSrcweir Beschreibung: geloeschte Eintraege 512cdf0e10cSrcweir --------------------------------------------------------------------*/ 513cdf0e10cSrcweir 514cdf0e10cSrcweir sal_uInt16 SvxComboBox::GetRemovedCount() const 515cdf0e10cSrcweir { 516cdf0e10cSrcweir return aDelEntryLst.Count(); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir 520cdf0e10cSrcweir const SvxBoxEntry& SvxComboBox::GetRemovedEntry(sal_uInt16 nPos) const 521cdf0e10cSrcweir { 522cdf0e10cSrcweir if(nPos < aDelEntryLst.Count()) 523cdf0e10cSrcweir return *aDelEntryLst[nPos]; 524cdf0e10cSrcweir 525cdf0e10cSrcweir return aDefault; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir /*-------------------------------------------------------------------- 529cdf0e10cSrcweir Beschreibung: Neue Entries begutachten 530cdf0e10cSrcweir --------------------------------------------------------------------*/ 531cdf0e10cSrcweir 532cdf0e10cSrcweir sal_uInt16 SvxComboBox::GetNewCount() const 533cdf0e10cSrcweir { 534cdf0e10cSrcweir sal_uInt16 nNew = 0; 535cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 536cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 537cdf0e10cSrcweir { if(aEntryLst[i]->bNew) 538cdf0e10cSrcweir nNew++; 539cdf0e10cSrcweir } 540cdf0e10cSrcweir return nNew; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir /*-------------------------------------------------------------------- 544cdf0e10cSrcweir Beschreibung: Alle neuen Eintraege ueberpruefen 545cdf0e10cSrcweir --------------------------------------------------------------------*/ 546cdf0e10cSrcweir 547cdf0e10cSrcweir const SvxBoxEntry& SvxComboBox::GetNewEntry(sal_uInt16 nPos) const 548cdf0e10cSrcweir { 549cdf0e10cSrcweir sal_uInt16 nSize = aEntryLst.Count(); 550cdf0e10cSrcweir sal_uInt16 nNew = 0; 551cdf0e10cSrcweir for(sal_uInt16 i=0; i < nSize; ++i) 552cdf0e10cSrcweir { if(aEntryLst[i]->bNew) 553cdf0e10cSrcweir { if(nNew == nPos) 554cdf0e10cSrcweir return *aEntryLst[i]; 555cdf0e10cSrcweir nNew++; 556cdf0e10cSrcweir } 557cdf0e10cSrcweir } 558cdf0e10cSrcweir return aDefault; 559cdf0e10cSrcweir } 560cdf0e10cSrcweir 561cdf0e10cSrcweir /*-------------------------------------------------------------------- 562cdf0e10cSrcweir Beschreibung: Sortiert einfuegen 563cdf0e10cSrcweir --------------------------------------------------------------------*/ 564cdf0e10cSrcweir 565cdf0e10cSrcweir void SvxComboBox::InsertSorted(SvxBoxEntry* pEntry) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir ComboBox::InsertEntry(pEntry->aName); 568cdf0e10cSrcweir sal_uInt16 nPos = ComboBox::GetEntryPos(pEntry->aName); 569cdf0e10cSrcweir aEntryLst.C40_INSERT(SvxBoxEntry, pEntry, nPos); 570cdf0e10cSrcweir } 571cdf0e10cSrcweir 572cdf0e10cSrcweir 573cdf0e10cSrcweir /*-------------------------------------------------------------------- 574cdf0e10cSrcweir Beschreibung: Je nach Option bestimmte Zeichen ausblenden 575cdf0e10cSrcweir --------------------------------------------------------------------*/ 576cdf0e10cSrcweir 577cdf0e10cSrcweir void __EXPORT SvxComboBox::KeyInput( const KeyEvent& rKEvt ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir sal_Unicode cChar = rKEvt.GetCharCode(); 580cdf0e10cSrcweir 581cdf0e10cSrcweir if(nStyle & SVX_CBS_FILENAME) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir #if defined UNX 584cdf0e10cSrcweir if( cChar == sal_Unicode( '/' ) || cChar == sal_Unicode( ' ' ) ) 585cdf0e10cSrcweir return; 586cdf0e10cSrcweir #else 587cdf0e10cSrcweir if( cChar == sal_Unicode( ':' ) || cChar == sal_Unicode( '\\' ) || 588cdf0e10cSrcweir cChar == sal_Unicode( '.' ) || cChar == sal_Unicode( ' ' ) ) 589cdf0e10cSrcweir return; 590cdf0e10cSrcweir #endif 591cdf0e10cSrcweir } 592cdf0e10cSrcweir ComboBox::KeyInput(rKEvt); 593cdf0e10cSrcweir } 594cdf0e10cSrcweir 595cdf0e10cSrcweir /*-------------------------------------------------------------------- 596cdf0e10cSrcweir Beschreibung: Text nach Option konvertieren 597cdf0e10cSrcweir --------------------------------------------------------------------*/ 598cdf0e10cSrcweir 599cdf0e10cSrcweir String SvxComboBox::GetText() const 600cdf0e10cSrcweir { 601cdf0e10cSrcweir String aTxt(ComboBox::GetText()); 602cdf0e10cSrcweir CharClass aCharClass( Application::GetSettings().GetLocale() ); 603cdf0e10cSrcweir 604cdf0e10cSrcweir if(nStyle & SVX_CBS_LOWER) 605cdf0e10cSrcweir return aCharClass.lower(aTxt); 606cdf0e10cSrcweir 607cdf0e10cSrcweir if(nStyle & SVX_CBS_UPPER) 608cdf0e10cSrcweir return aCharClass.upper(aTxt); 609cdf0e10cSrcweir 610cdf0e10cSrcweir return aTxt; 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir 614