LCOV - code coverage report
Current view: top level - sw/source/ui/cctrl - swlbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 59 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 64 0.0 %

           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 <osl/diagnose.h>
      30                 :            : #include <unotools/charclass.hxx>
      31                 :            : #include <swtypes.hxx>
      32                 :            : #include <swlbox.hxx>
      33                 :            : 
      34                 :            : using namespace nsSwComboBoxStyle;
      35                 :            : 
      36                 :            : 
      37                 :            : //     Description: ListboxElement
      38                 :          0 : SwBoxEntry::SwBoxEntry() :
      39                 :            :     bModified(sal_False),
      40                 :            :     bNew(sal_False),
      41                 :          0 :     nId(LISTBOX_APPEND)
      42                 :            : {
      43                 :          0 : }
      44                 :            : 
      45                 :          0 : SwBoxEntry::SwBoxEntry(const String& aNam, sal_uInt16 nIdx) :
      46                 :            :     bModified(sal_False),
      47                 :            :     bNew(sal_False),
      48                 :            :     aName(aNam),
      49                 :          0 :     nId(nIdx)
      50                 :            : {
      51                 :          0 : }
      52                 :            : 
      53                 :          0 : SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
      54                 :            :     bModified(rOld.bModified),
      55                 :            :     bNew(rOld.bNew),
      56                 :            :     aName(rOld.aName),
      57                 :          0 :     nId(rOld.nId)
      58                 :            : {
      59                 :          0 : }
      60                 :            : 
      61                 :          0 : SwComboBox::SwComboBox(Window* pParent, const ResId& rId, sal_uInt16 nStyleBits ):
      62                 :            :     ComboBox(pParent, rId),
      63 [ #  # ][ #  # ]:          0 :     nStyle(nStyleBits)
                 [ #  # ]
      64                 :            : {
      65                 :            :     // create administration for the resource's Stringlist
      66         [ #  # ]:          0 :     sal_uInt16 nSize = GetEntryCount();
      67         [ #  # ]:          0 :     for( sal_uInt16 i=0; i < nSize; ++i )
      68                 :            :     {
      69 [ #  # ][ #  # ]:          0 :         SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
         [ #  # ][ #  # ]
      70         [ #  # ]:          0 :         aEntryLst.push_back(pTmp);
      71                 :            :     }
      72                 :          0 : }
      73                 :            : 
      74                 :            : // Basic class Dtor
      75 [ #  # ][ #  # ]:          0 : SwComboBox::~SwComboBox()
                 [ #  # ]
      76                 :            : {
      77         [ #  # ]:          0 : }
      78                 :            : 
      79                 :          0 : void SwComboBox::InsertEntry(const SwBoxEntry& rEntry)
      80                 :            : {
      81         [ #  # ]:          0 :     InsertSorted(new SwBoxEntry(rEntry));
      82                 :          0 : }
      83                 :            : 
      84                 :          0 : void SwComboBox::RemoveEntry(sal_uInt16 nPos)
      85                 :            : {
      86         [ #  # ]:          0 :     if(nPos >= aEntryLst.size())
      87                 :          0 :         return;
      88                 :            : 
      89                 :            :     // Remove old element
      90                 :          0 :     SwBoxEntry* pEntry = &aEntryLst[nPos];
      91                 :          0 :     ComboBox::RemoveEntry(nPos);
      92                 :            : 
      93                 :            :     // Don't add new entries to the list
      94         [ #  # ]:          0 :     if(pEntry->bNew)
      95                 :            :     {
      96                 :          0 :         aEntryLst.erase(aEntryLst.begin() + nPos);
      97                 :            :     }
      98                 :            :     else
      99                 :            :     {
     100                 :            :         // add to DelEntryLst
     101                 :            :         aDelEntryLst.transfer(aDelEntryLst.end(),
     102                 :          0 :                 aEntryLst.begin() + nPos, aEntryLst);
     103                 :            :     }
     104                 :            : }
     105                 :            : 
     106                 :          0 : sal_uInt16 SwComboBox::GetEntryPos(const SwBoxEntry& rEntry) const
     107                 :            : {
     108                 :          0 :     return ComboBox::GetEntryPos(rEntry.aName);
     109                 :            : }
     110                 :            : 
     111                 :          0 : const SwBoxEntry& SwComboBox::GetEntry(sal_uInt16 nPos) const
     112                 :            : {
     113         [ #  # ]:          0 :     if(nPos < aEntryLst.size())
     114                 :          0 :         return aEntryLst[nPos];
     115                 :            : 
     116                 :          0 :     return aDefault;
     117                 :            : }
     118                 :            : 
     119                 :          0 : sal_uInt16 SwComboBox::GetRemovedCount() const
     120                 :            : {
     121                 :          0 :     return aDelEntryLst.size();
     122                 :            : }
     123                 :            : 
     124                 :          0 : const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_uInt16 nPos) const
     125                 :            : {
     126         [ #  # ]:          0 :     if(nPos < aDelEntryLst.size())
     127                 :          0 :         return aDelEntryLst[nPos];
     128                 :            : 
     129                 :          0 :     return aDefault;
     130                 :            : }
     131                 :            : 
     132                 :          0 : void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
     133                 :            : {
     134                 :          0 :     ComboBox::InsertEntry(pEntry->aName);
     135                 :          0 :     sal_uInt16 nPos = ComboBox::GetEntryPos(pEntry->aName);
     136                 :          0 :     aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
     137                 :          0 : }
     138                 :            : 
     139                 :          0 : void SwComboBox::KeyInput( const KeyEvent& rKEvt )
     140                 :            : {
     141                 :          0 :     sal_uInt16 nChar = rKEvt.GetCharCode();
     142                 :            : 
     143         [ #  # ]:          0 :     if(nStyle & CBS_FILENAME)
     144                 :            :     {
     145                 :            : #if defined UNX
     146 [ #  # ][ #  # ]:          0 :         if(nChar == '/' || nChar == ' ' )
     147                 :          0 :             return;
     148                 :            : #else
     149                 :            :         if(nChar == ':' || nChar == '\\' || nChar == '.' || nChar == ' ')
     150                 :            :             return;
     151                 :            : #endif
     152                 :            :     }
     153                 :          0 :     ComboBox::KeyInput(rKEvt);
     154                 :            : }
     155                 :            : 
     156                 :            : // Convert text according to option
     157                 :          0 : String SwComboBox::GetText() const
     158                 :            : {
     159                 :          0 :     String aTxt( ComboBox::GetText() );
     160                 :            : 
     161         [ #  # ]:          0 :     if(nStyle & CBS_LOWER)
     162 [ #  # ][ #  # ]:          0 :         aTxt = GetAppCharClass().lowercase( aTxt );
         [ #  # ][ #  # ]
     163         [ #  # ]:          0 :     else if( nStyle & CBS_UPPER )
     164 [ #  # ][ #  # ]:          0 :         aTxt = GetAppCharClass().uppercase( aTxt );
         [ #  # ][ #  # ]
     165                 :            : 
     166                 :          0 :     return aTxt;
     167                 :            : }
     168                 :            : 
     169                 :            : 
     170                 :            : 
     171                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10