LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - ContextList.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 34 0.0 %
Date: 2014-04-14 Functions: 0 6 0.0 %
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             : #include "ContextList.hxx"
      20             : #include "Context.hxx"
      21             : 
      22             : using ::rtl::OUString;
      23             : 
      24             : namespace sfx2 { namespace sidebar {
      25             : 
      26             : 
      27           0 : ContextList::ContextList (void)
      28           0 :     : maEntries()
      29             : {
      30           0 : }
      31             : 
      32             : 
      33             : 
      34             : 
      35           0 : ContextList::~ContextList (void)
      36             : {
      37           0 : }
      38             : 
      39             : 
      40             : 
      41             : 
      42           0 : const ContextList::Entry* ContextList::GetMatch (const Context& rContext) const
      43             : {
      44           0 :     const ::std::vector<Entry>::const_iterator iEntry = FindBestMatch(rContext);
      45           0 :     if (iEntry != maEntries.end())
      46           0 :         return &*iEntry;
      47             :     else
      48           0 :         return NULL;
      49             : }
      50             : 
      51             : 
      52             : 
      53             : 
      54           0 : ContextList::Entry* ContextList::GetMatch (const Context& rContext)
      55             : {
      56           0 :     const ::std::vector<Entry>::const_iterator iEntry = FindBestMatch(rContext);
      57           0 :     if (iEntry != maEntries.end())
      58           0 :         return const_cast<Entry*>(&*iEntry);
      59             :     else
      60           0 :         return NULL;
      61             : }
      62             : 
      63             : 
      64             : 
      65             : 
      66           0 : ::std::vector<ContextList::Entry>::const_iterator ContextList::FindBestMatch (const Context& rContext) const
      67             : {
      68           0 :     sal_Int32 nBestMatch (Context::NoMatch);
      69           0 :     ::std::vector<Entry>::const_iterator iBestMatch (maEntries.end());
      70             : 
      71           0 :     for (::std::vector<Entry>::const_iterator
      72           0 :              iEntry(maEntries.begin()),
      73           0 :              iEnd(maEntries.end());
      74             :          iEntry!=iEnd;
      75             :          ++iEntry)
      76             :     {
      77           0 :         const sal_Int32 nMatch (rContext.EvaluateMatch(iEntry->maContext));
      78           0 :         if (nMatch < nBestMatch)
      79             :         {
      80           0 :             nBestMatch = nMatch;
      81           0 :             iBestMatch = iEntry;
      82             :         }
      83           0 :         if (nBestMatch == Context::OptimalMatch)
      84           0 :             return iEntry;
      85             :     }
      86             : 
      87           0 :     return iBestMatch;
      88             : }
      89             : 
      90             : 
      91             : 
      92             : 
      93           0 : void ContextList::AddContextDescription (
      94             :     const Context& rContext,
      95             :     const bool bIsInitiallyVisible,
      96             :     const OUString& rsMenuCommand)
      97             : {
      98           0 :     maEntries.push_back(Entry());
      99           0 :     maEntries.back().maContext = rContext;
     100           0 :     maEntries.back().mbIsInitiallyVisible = bIsInitiallyVisible;
     101           0 :     maEntries.back().msMenuCommand = rsMenuCommand;
     102           0 : }
     103             : 
     104             : 
     105             : 
     106             : 
     107             : } } // end of namespace sfx2::sidebar
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10