LCOV - code coverage report
Current view: top level - sw/source/uibase/cctrl - swlbox.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 52 1.9 %
Date: 2015-06-13 12:38:46 Functions: 2 17 11.8 %
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             : //     Description: ListboxElement
      26           0 : SwBoxEntry::SwBoxEntry() :
      27             :     bModified(false),
      28             :     bNew(false),
      29           0 :     nId(COMBOBOX_APPEND)
      30             : {
      31           0 : }
      32             : 
      33           0 : SwBoxEntry::SwBoxEntry(const OUString& aNam, sal_Int32 nIdx) :
      34             :     bModified(false),
      35             :     bNew(false),
      36             :     aName(aNam),
      37           0 :     nId(nIdx)
      38             : {
      39           0 : }
      40             : 
      41           0 : SwBoxEntry::SwBoxEntry(const SwBoxEntry& rOld) :
      42             :     bModified(rOld.bModified),
      43             :     bNew(rOld.bNew),
      44             :     aName(rOld.aName),
      45           0 :     nId(rOld.nId)
      46             : {
      47           0 : }
      48             : 
      49           0 : SwComboBox::SwComboBox(vcl::Window* pParent, WinBits nStyle)
      50           0 :     : ComboBox(pParent, nStyle)
      51             : {
      52           0 :     Init();
      53           0 : }
      54             : 
      55           0 : void SwComboBox::Init()
      56             : {
      57             :     // create administration for the resource's Stringlist
      58           0 :     sal_Int32 nSize = GetEntryCount();
      59           0 :     for( sal_Int32 i=0; i < nSize; ++i )
      60             :     {
      61           0 :         SwBoxEntry* pTmp = new SwBoxEntry(ComboBox::GetEntry(i), i);
      62           0 :         aEntryLst.push_back(pTmp);
      63             :     }
      64           0 : }
      65             : 
      66             : // Basic class Dtor
      67           0 : SwComboBox::~SwComboBox()
      68             : {
      69           0 : }
      70             : 
      71           0 : void SwComboBox::InsertSwEntry(const SwBoxEntry& rEntry)
      72             : {
      73           0 :     InsertSorted(new SwBoxEntry(rEntry));
      74           0 : }
      75             : 
      76           0 : sal_Int32 SwComboBox::InsertEntry(const OUString& rStr, sal_Int32)
      77             : {
      78           0 :     InsertSwEntry(SwBoxEntry(rStr));
      79           0 :     return 0;
      80             : }
      81             : 
      82           0 : void SwComboBox::RemoveEntryAt(sal_Int32 const nPos)
      83             : {
      84           0 :     if(nPos < 0 || static_cast<size_t>(nPos) >= aEntryLst.size())
      85           0 :         return;
      86             : 
      87             :     // Remove old element
      88           0 :     SwBoxEntry* pEntry = &aEntryLst[nPos];
      89           0 :     ComboBox::RemoveEntryAt(nPos);
      90             : 
      91             :     // Don't add new entries to the list
      92           0 :     if(pEntry->bNew)
      93             :     {
      94           0 :         aEntryLst.erase(aEntryLst.begin() + nPos);
      95             :     }
      96             :     else
      97             :     {
      98             :         // add to DelEntryLst
      99             :         aDelEntryLst.transfer(aDelEntryLst.end(),
     100           0 :                 aEntryLst.begin() + nPos, aEntryLst);
     101             :     }
     102             : }
     103             : 
     104           0 : sal_Int32 SwComboBox::GetSwEntryPos(const SwBoxEntry& rEntry) const
     105             : {
     106           0 :     return ComboBox::GetEntryPos(rEntry.aName);
     107             : }
     108             : 
     109           0 : const SwBoxEntry& SwComboBox::GetSwEntry(sal_Int32 const nPos) const
     110             : {
     111           0 :     if(0 <= nPos && static_cast<size_t>(nPos) < aEntryLst.size())
     112           0 :         return aEntryLst[nPos];
     113             : 
     114           0 :     return aDefault;
     115             : }
     116             : 
     117           0 : sal_Int32 SwComboBox::GetRemovedCount() const
     118             : {
     119           0 :     return static_cast<sal_Int32>(aDelEntryLst.size());
     120             : }
     121             : 
     122           0 : const SwBoxEntry& SwComboBox::GetRemovedEntry(sal_Int32 nPos) const
     123             : {
     124           0 :     if(0 <= nPos && static_cast<size_t>(nPos) < aDelEntryLst.size())
     125           0 :         return aDelEntryLst[nPos];
     126             : 
     127           0 :     return aDefault;
     128             : }
     129             : 
     130           0 : void SwComboBox::InsertSorted(SwBoxEntry* pEntry)
     131             : {
     132           0 :     ComboBox::InsertEntry(pEntry->aName);
     133           0 :     sal_Int32 nPos = ComboBox::GetEntryPos(pEntry->aName);
     134           0 :     aEntryLst.insert( aEntryLst.begin() + nPos, pEntry );
     135         177 : }
     136             : 
     137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11