1efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5efeef26fSAndrew Rist * distributed with this work for additional information 6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14efeef26fSAndrew Rist * software distributed under the License is distributed on an 15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17efeef26fSAndrew Rist * specific language governing permissions and limitations 18efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20efeef26fSAndrew Rist *************************************************************/ 21efeef26fSAndrew Rist 22efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #include <unotools/charclass.hxx> 30cdf0e10cSrcweir #include <swtypes.hxx> 31cdf0e10cSrcweir #include <swlbox.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir using namespace nsSwComboBoxStyle; 34cdf0e10cSrcweir 35cdf0e10cSrcweir 36cdf0e10cSrcweir SV_IMPL_PTRARR(SwEntryLst, SwBoxEntry*) 37cdf0e10cSrcweir 38cdf0e10cSrcweir /*-------------------------------------------------------------------- 39cdf0e10cSrcweir Beschreibung: Ein ListboxElement 40cdf0e10cSrcweir --------------------------------------------------------------------*/ 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir SwBoxEntry::SwBoxEntry() : 44cdf0e10cSrcweir bModified(sal_False), 45cdf0e10cSrcweir bNew(sal_False), 46cdf0e10cSrcweir nId(LISTBOX_APPEND) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir } 49cdf0e10cSrcweir 50cdf0e10cSrcweir 51cdf0e10cSrcweir SwBoxEntry::SwBoxEntry(const String& aNam, sal_uInt16 nIdx) : 52cdf0e10cSrcweir bModified(sal_False), 53cdf0e10cSrcweir bNew(sal_False), 54cdf0e10cSrcweir aName(aNam), 55cdf0e10cSrcweir nId(nIdx) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir } 58cdf0e10cSrcweir 59cdf0e10cSrcweir 60cdf0e10cSrcweir SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) : 61cdf0e10cSrcweir bModified(rOld.bModified), 62cdf0e10cSrcweir bNew(rOld.bNew), 63cdf0e10cSrcweir aName(rOld.aName), 64cdf0e10cSrcweir nId(rOld.nId) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir 67cdf0e10cSrcweir } 68cdf0e10cSrcweir 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir SwComboBox::SwComboBox(Window* pParent, const ResId& rId, sal_uInt16 nStyleBits ): 72cdf0e10cSrcweir ComboBox(pParent, rId), 73cdf0e10cSrcweir nStyle(nStyleBits) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir // Verwaltung fuer die Stringlist aus der Resource aufbauen 76cdf0e10cSrcweir sal_uInt16 nSize = GetEntryCount(); 77cdf0e10cSrcweir for( sal_uInt16 i=0; i < nSize; ++i ) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir const SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i); 80cdf0e10cSrcweir aEntryLst.Insert(pTmp, aEntryLst.Count() ); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir /*-------------------------------------------------------------------- 85cdf0e10cSrcweir Beschreibung: Basisklasse Dtor 86cdf0e10cSrcweir --------------------------------------------------------------------*/ 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir SwComboBox::~SwComboBox() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir // das erledigen die Listen doch schon selbst im DTOR! 92cdf0e10cSrcweir // aEntryLst.DeleteAndDestroy(0, aEntryLst.Count()); 93cdf0e10cSrcweir // aDelEntryLst.DeleteAndDestroy(0, aDelEntryLst.Count()); 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir /*-------------------------------------------------------------------- 97cdf0e10cSrcweir Beschreibung: Eintrag in die ComboBox aufnehmen 98cdf0e10cSrcweir --------------------------------------------------------------------*/ 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir void SwComboBox::InsertEntry(const SwBoxEntry& rEntry) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir InsertSorted(new SwBoxEntry(rEntry)); 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir /*-------------------------------------------------------------------- 107cdf0e10cSrcweir Beschreibung: Eintrag aus der Liste loeschen 108cdf0e10cSrcweir --------------------------------------------------------------------*/ 109cdf0e10cSrcweir 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SwComboBox::RemoveEntry(sal_uInt16 nPos) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if(nPos >= aEntryLst.Count()) 114cdf0e10cSrcweir return; 115cdf0e10cSrcweir 116cdf0e10cSrcweir // Altes Element austragen 117cdf0e10cSrcweir SwBoxEntry* pEntry = aEntryLst[nPos]; 118cdf0e10cSrcweir aEntryLst.Remove(nPos, 1); 119cdf0e10cSrcweir ComboBox::RemoveEntry(nPos); 120cdf0e10cSrcweir 121cdf0e10cSrcweir // keine neuen Eintraege in die Liste mit aufnehmen 122cdf0e10cSrcweir if(pEntry->bNew) 123cdf0e10cSrcweir return; 124cdf0e10cSrcweir 125cdf0e10cSrcweir // in DeleteListe eintragen 126cdf0e10cSrcweir aDelEntryLst.C40_INSERT(SwBoxEntry, pEntry, aDelEntryLst.Count()); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir 131cdf0e10cSrcweir /*-------------------------------------------------------------------- 132cdf0e10cSrcweir Beschreibung: Position by Name 133cdf0e10cSrcweir --------------------------------------------------------------------*/ 134cdf0e10cSrcweir 135cdf0e10cSrcweir sal_uInt16 SwComboBox::GetEntryPos(const SwBoxEntry& rEntry) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir return ComboBox::GetEntryPos(rEntry.aName); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir /*-------------------------------------------------------------------- 141cdf0e10cSrcweir Beschreibung: Rund um die Entries 142cdf0e10cSrcweir --------------------------------------------------------------------*/ 143cdf0e10cSrcweir 144cdf0e10cSrcweir 145cdf0e10cSrcweir const SwBoxEntry& SwComboBox::GetEntry(sal_uInt16 nPos) const 146cdf0e10cSrcweir { 147cdf0e10cSrcweir if(nPos < aEntryLst.Count()) 148cdf0e10cSrcweir return *aEntryLst[nPos]; 149cdf0e10cSrcweir 150cdf0e10cSrcweir return aDefault; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir /*-------------------------------------------------------------------- 154cdf0e10cSrcweir Beschreibung: geloeschte Eintraege 155cdf0e10cSrcweir --------------------------------------------------------------------*/ 156cdf0e10cSrcweir 157cdf0e10cSrcweir 158cdf0e10cSrcweir sal_uInt16 SwComboBox::GetRemovedCount() const 159cdf0e10cSrcweir { 160cdf0e10cSrcweir return aDelEntryLst.Count(); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir 164cdf0e10cSrcweir const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_uInt16 nPos) const 165cdf0e10cSrcweir { 166cdf0e10cSrcweir if(nPos < aDelEntryLst.Count()) 167cdf0e10cSrcweir return *aDelEntryLst[nPos]; 168cdf0e10cSrcweir 169cdf0e10cSrcweir return aDefault; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir /*-------------------------------------------------------------------- 173cdf0e10cSrcweir Beschreibung: Sortiert einfuegen 174cdf0e10cSrcweir --------------------------------------------------------------------*/ 175cdf0e10cSrcweir 176cdf0e10cSrcweir 177cdf0e10cSrcweir void SwComboBox::InsertSorted(SwBoxEntry* pEntry) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir ComboBox::InsertEntry(pEntry->aName); 180cdf0e10cSrcweir sal_uInt16 nPos = ComboBox::GetEntryPos(pEntry->aName); 181cdf0e10cSrcweir aEntryLst.C40_INSERT(SwBoxEntry, pEntry, nPos); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir 185cdf0e10cSrcweir /*-------------------------------------------------------------------- 186cdf0e10cSrcweir Beschreibung: Je nach Option bestimmte Zeichen ausblenden 187cdf0e10cSrcweir --------------------------------------------------------------------*/ 188cdf0e10cSrcweir 189cdf0e10cSrcweir 190cdf0e10cSrcweir void SwComboBox::KeyInput( const KeyEvent& rKEvt ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir sal_uInt16 nChar = rKEvt.GetCharCode(); 193cdf0e10cSrcweir 194cdf0e10cSrcweir if(nStyle & CBS_FILENAME) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir #if defined UNX 197cdf0e10cSrcweir if(nChar == '/' || nChar == ' ' ) 198cdf0e10cSrcweir return; 199cdf0e10cSrcweir #else 200cdf0e10cSrcweir if(nChar == ':' || nChar == '\\' || nChar == '.' || nChar == ' ') 201cdf0e10cSrcweir return; 202cdf0e10cSrcweir #endif 203cdf0e10cSrcweir } 204cdf0e10cSrcweir ComboBox::KeyInput(rKEvt); 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir 209cdf0e10cSrcweir /*-------------------------------------------------------------------- 210cdf0e10cSrcweir Beschreibung: Text nach Option konvertieren 211cdf0e10cSrcweir --------------------------------------------------------------------*/ 212cdf0e10cSrcweir 213cdf0e10cSrcweir 214cdf0e10cSrcweir String SwComboBox::GetText() const 215cdf0e10cSrcweir { 216cdf0e10cSrcweir String aTxt( ComboBox::GetText() ); 217cdf0e10cSrcweir 218cdf0e10cSrcweir if(nStyle & CBS_LOWER) 219cdf0e10cSrcweir GetAppCharClass().toLower( aTxt ); 220cdf0e10cSrcweir else if( nStyle & CBS_UPPER ) 221cdf0e10cSrcweir GetAppCharClass().toUpper( aTxt ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir return aTxt; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226*ca62e2c2SSteve Yin //IAccessibility2 Impplementaton 2009----- 227*ca62e2c2SSteve Yin void SwComboBox::SetText( const XubString& rStr ) 228*ca62e2c2SSteve Yin { 229*ca62e2c2SSteve Yin ComboBox::SetText(rStr); 230*ca62e2c2SSteve Yin // MT: CallEventListeners stay protected for now. Probably not needed at all, as the implementation of VCLXAccessibelEdit/ComboBox should do it on text changed nowadays anyway. Verify. 231*ca62e2c2SSteve Yin // CallEventListeners( VCLEVENT_EDIT_MODIFY ); 232*ca62e2c2SSteve Yin } 233*ca62e2c2SSteve Yin //-----IAccessibility2 Impplementaton 2009 234