LCOV - code coverage report
Current view: top level - sd/inc - customshowlist.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 15 32 46.9 %
Date: 2014-11-03 Functions: 7 15 46.7 %
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             : #ifndef INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
      21             : #define INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
      22             : 
      23             : #include <vector>
      24             : 
      25             : class SdCustomShow;
      26             : 
      27           6 : class SdCustomShowList
      28             : {
      29             : private:
      30             :     std::vector<SdCustomShow*> mShows;
      31             :    sal_uInt16 mnCurPos;
      32             : public:
      33           6 :     SdCustomShowList()
      34           6 :         : mShows(), mnCurPos(0)
      35             :     {
      36           6 :     }
      37             : 
      38           0 :     bool empty() const {return mShows.empty();}
      39             : 
      40          58 :     size_t size() const {return mShows.size();}
      41             : 
      42          32 :     SdCustomShow* &operator[](size_t i) {return mShows[i];}
      43             : 
      44           0 :     std::vector<SdCustomShow*>::iterator begin() {return mShows.begin();}
      45             : 
      46           0 :     void erase(std::vector<SdCustomShow*>::iterator it) {mShows.erase(it);}
      47             : 
      48           6 :     void push_back(SdCustomShow* p) {mShows.push_back(p);}
      49             : 
      50           0 :     sal_uInt16 GetCurPos() const { return mnCurPos; }
      51           0 :     void Seek(sal_uInt16 nNewPos) { mnCurPos = nNewPos; }
      52             : 
      53           6 :     SdCustomShow* First()
      54             :     {
      55           6 :         if( mShows.empty() )
      56           4 :             return NULL;
      57           2 :         mnCurPos = 0;
      58           2 :         return mShows[mnCurPos];
      59             :     }
      60           2 :     SdCustomShow* Next()
      61             :     {
      62           2 :         ++mnCurPos;
      63           2 :         return mnCurPos >= mShows.size() ? NULL : mShows[mnCurPos];
      64             :     }
      65           0 :     void Last()
      66             :     {
      67           0 :         if( !mShows.empty() )
      68           0 :             mnCurPos = mShows.size() - 1;
      69           0 :     }
      70           0 :     SdCustomShow* GetCurObject()
      71             :     {
      72           0 :         return mShows.empty() ? NULL : mShows[mnCurPos];
      73             :     }
      74           0 :     SdCustomShow* Remove(SdCustomShow* p)
      75             :     {
      76           0 :         std::vector<SdCustomShow*>::iterator it = std::find(mShows.begin(), mShows.end(), p);
      77           0 :         if( it == mShows.end() )
      78           0 :             return NULL;
      79           0 :         mShows.erase(it);
      80           0 :         return p;
      81             :     }
      82             : };
      83             : 
      84             : #endif // INCLUDED_SD_INC_CUSTOMSHOWLIST_HXX
      85             : 
      86             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10