LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/cctrl - swlbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 67 1.5 %
Date: 2013-07-09 Functions: 2 19 10.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <osl/diagnose.h>
      21             : #include <unotools/charclass.hxx>
      22             : #include <swtypes.hxx>
      23             : #include <swlbox.hxx>
      24             : 
      25             : using namespace nsSwComboBoxStyle;
      26             : 
      27             : 
      28             : //     Description: ListboxElement
      29           0 : SwBoxEntry::SwBoxEntry() :
      30             :     bModified(sal_False),
      31             :     bNew(sal_False),
      32           0 :     nId(LISTBOX_APPEND)
      33             : {
      34           0 : }
      35             : 
      36           0 : SwBoxEntry::SwBoxEntry(const String& aNam, sal_uInt16 nIdx) :
      37             :     bModified(sal_False),
      38             :     bNew(sal_False),
      39             :     aName(aNam),
      40           0 :     nId(nIdx)
      41             : {
      42           0 : }
      43             : 
      44           0 : SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
      45             :     bModified(rOld.bModified),
      46             :     bNew(rOld.bNew),
      47             :     aName(rOld.aName),
      48           0 :     nId(rOld.nId)
      49             : {
      50           0 : }
      51             : 
      52           0 : SwComboBox::SwComboBox(Window* pParent, sal_uInt16 nStyleBits) :
      53             :     ComboBox(pParent),
      54           0 :     nStyle(nStyleBits)
      55             : {
      56           0 :     Init();
      57           0 : }
      58             : 
      59           0 : SwComboBox::SwComboBox(Window* pParent, const ResId& rId, sal_uInt16 nStyleBits) :
      60             :     ComboBox(pParent, rId),
      61           0 :     nStyle(nStyleBits)
      62             : {
      63           0 :     Init();
      64           0 : }
      65             : 
      66           0 : void SwComboBox::Init()
      67             : {
      68             :     // create administration for the resource's Stringlist
      69           0 :     sal_uInt16 nSize = GetEntryCount();
      70           0 :     for( sal_uInt16 i=0; i < nSize; ++i )
      71             :     {
      72           0 :         SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
      73           0 :         aEntryLst.push_back(pTmp);
      74             :     }
      75           0 : }
      76             : 
      77             : // Basic class Dtor
      78           0 : SwComboBox::~SwComboBox()
      79             : {
      80           0 : }
      81             : 
      82           0 : void SwComboBox::InsertEntry(const SwBoxEntry& rEntry)
      83             : {
      84           0 :     InsertSorted(new SwBoxEntry(rEntry));
      85           0 : }
      86             : 
      87           0 : void SwComboBox::RemoveEntry(sal_uInt16 nPos)
      88             : {
      89           0 :     if(nPos >= aEntryLst.size())
      90           0 :         return;
      91             : 
      92             :     // Remove old element
      93           0 :     SwBoxEntry* pEntry = &aEntryLst[nPos];
      94           0 :     ComboBox::RemoveEntry(nPos);
      95             : 
      96             :     // Don't add new entries to the list
      97           0 :     if(pEntry->bNew)
      98             :     {
      99           0 :         aEntryLst.erase(aEntryLst.begin() + nPos);
     100             :     }
     101             :     else
     102             :     {
     103             :         // add to DelEntryLst
     104             :         aDelEntryLst.transfer(aDelEntryLst.end(),
     105           0 :                 aEntryLst.begin() + nPos, aEntryLst);
     106             :     }
     107             : }
     108             : 
     109           0 : sal_uInt16 SwComboBox::GetEntryPos(const SwBoxEntry& rEntry) const
     110             : {
     111           0 :     return ComboBox::GetEntryPos(rEntry.aName);
     112             : }
     113             : 
     114           0 : const SwBoxEntry& SwComboBox::GetEntry(sal_uInt16 nPos) const
     115             : {
     116           0 :     if(nPos < aEntryLst.size())
     117           0 :         return aEntryLst[nPos];
     118             : 
     119           0 :     return aDefault;
     120             : }
     121             : 
     122           0 : sal_uInt16 SwComboBox::GetRemovedCount() const
     123             : {
     124           0 :     return aDelEntryLst.size();
     125             : }
     126             : 
     127           0 : const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_uInt16 nPos) const
     128             : {
     129           0 :     if(nPos < aDelEntryLst.size())
     130           0 :         return aDelEntryLst[nPos];
     131             : 
     132           0 :     return aDefault;
     133             : }
     134             : 
     135           0 : void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
     136             : {
     137           0 :     ComboBox::InsertEntry(pEntry->aName);
     138           0 :     sal_uInt16 nPos = ComboBox::GetEntryPos(pEntry->aName);
     139           0 :     aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
     140           0 : }
     141             : 
     142           0 : void SwComboBox::KeyInput( const KeyEvent& rKEvt )
     143             : {
     144           0 :     sal_uInt16 nChar = rKEvt.GetCharCode();
     145             : 
     146           0 :     if(nStyle & CBS_FILENAME)
     147             :     {
     148             : #if defined UNX
     149           0 :         if(nChar == '/' || nChar == ' ' )
     150           0 :             return;
     151             : #else
     152             :         if(nChar == ':' || nChar == '\\' || nChar == '.' || nChar == ' ')
     153             :             return;
     154             : #endif
     155             :     }
     156           0 :     ComboBox::KeyInput(rKEvt);
     157             : }
     158             : 
     159             : // Convert text according to option
     160           0 : OUString SwComboBox::GetText() const
     161             : {
     162           0 :     OUString aTxt( ComboBox::GetText() );
     163             : 
     164           0 :     if(nStyle & CBS_LOWER)
     165           0 :         aTxt = GetAppCharClass().lowercase( aTxt );
     166           0 :     else if( nStyle & CBS_UPPER )
     167           0 :         aTxt = GetAppCharClass().uppercase( aTxt );
     168             : 
     169           0 :     return aTxt;
     170          99 : }
     171             : 
     172             : 
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10