LCOV - code coverage report
Current view: top level - configmgr/source - setnode.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 38 76.3 %
Date: 2012-08-25 Functions: 12 16 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 38 34.2 %

           Branch data     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 "sal/config.h"
      21                 :            : 
      22                 :            : #include <algorithm>
      23                 :            : #include <functional>
      24                 :            : #include <vector>
      25                 :            : 
      26                 :            : #include "rtl/ref.hxx"
      27                 :            : #include "rtl/ustring.hxx"
      28                 :            : 
      29                 :            : #include "data.hxx"
      30                 :            : #include "node.hxx"
      31                 :            : #include "nodemap.hxx"
      32                 :            : #include "setnode.hxx"
      33                 :            : 
      34                 :            : namespace configmgr {
      35                 :            : 
      36                 :            : namespace {
      37                 :            : 
      38                 :            : // Work around some compilers' failure to accept
      39                 :            : // std::binder1st(std::ptr_fun(&Data::equalTemplateNames), ...):
      40                 :            : class EqualTemplateNames:
      41                 :            :     public std::unary_function< rtl::OUString const &, bool >
      42                 :            : {
      43                 :            : public:
      44                 :          0 :     inline explicit EqualTemplateNames(rtl::OUString const & shortName):
      45                 :          0 :         shortName_(shortName) {}
      46                 :            : 
      47                 :          0 :     inline bool operator ()(rtl::OUString const & longName) const
      48                 :          0 :     { return Data::equalTemplateNames(shortName_, longName); }
      49                 :            : 
      50                 :            : private:
      51                 :            :     rtl::OUString const & shortName_;
      52                 :            : };
      53                 :            : 
      54                 :            : }
      55                 :            : 
      56                 :      75424 : SetNode::SetNode(
      57                 :            :     int layer, rtl::OUString const & defaultTemplateName,
      58                 :            :     rtl::OUString const & templateName):
      59                 :            :     Node(layer), defaultTemplateName_(defaultTemplateName),
      60 [ +  - ][ +  - ]:      75424 :     templateName_(templateName), mandatory_(Data::NO_LAYER)
      61                 :      75424 : {}
      62                 :            : 
      63                 :      57125 : rtl::Reference< Node > SetNode::clone(bool keepTemplateName) const {
      64         [ +  - ]:      57125 :     return new SetNode(*this, keepTemplateName);
      65                 :            : }
      66                 :            : 
      67                 :    6607013 : NodeMap & SetNode::getMembers() {
      68                 :    6607013 :     return members_;
      69                 :            : }
      70                 :            : 
      71                 :      21705 : rtl::OUString SetNode::getTemplateName() const {
      72                 :      21705 :     return templateName_;
      73                 :            : }
      74                 :            : 
      75                 :      31359 : void SetNode::setMandatory(int layer) {
      76                 :      31359 :     mandatory_ = layer;
      77                 :      31359 : }
      78                 :            : 
      79                 :      17781 : int SetNode::getMandatory() const {
      80                 :      17781 :     return mandatory_;
      81                 :            : }
      82                 :            : 
      83                 :    2520275 : rtl::OUString const & SetNode::getDefaultTemplateName() const {
      84                 :    2520275 :     return defaultTemplateName_;
      85                 :            : }
      86                 :            : 
      87                 :          0 : std::vector< rtl::OUString > & SetNode::getAdditionalTemplateNames() {
      88                 :          0 :     return additionalTemplateNames_;
      89                 :            : }
      90                 :            : 
      91                 :    2521829 : bool SetNode::isValidTemplate(rtl::OUString const & templateName) const {
      92         [ +  - ]:    2521829 :     return Data::equalTemplateNames(templateName, defaultTemplateName_) ||
      93                 :            :         (std::find_if(
      94                 :            :             additionalTemplateNames_.begin(),
      95 [ -  + ][ #  # ]:    2521829 :             additionalTemplateNames_.end(), EqualTemplateNames(templateName)) !=
      96 [ -  + ][ #  # ]:    5043658 :          additionalTemplateNames_.end());
         [ #  # ][ #  # ]
         [ -  + ][ -  + ]
           [ #  #  #  # ]
      97                 :            : }
      98                 :            : 
      99                 :      57125 : SetNode::SetNode(SetNode const & other, bool keepTemplateName):
     100                 :            :     Node(other), defaultTemplateName_(other.defaultTemplateName_),
     101                 :            :     additionalTemplateNames_(other.additionalTemplateNames_),
     102 [ +  - ][ +  - ]:      57125 :     mandatory_(other.mandatory_)
     103                 :            : {
     104         [ +  - ]:      57125 :     cloneNodeMap(other.members_, &members_);
     105         [ +  - ]:      57125 :     if (keepTemplateName) {
     106                 :      57125 :         templateName_ = other.templateName_;
     107                 :            :     }
     108                 :      57125 : }
     109                 :            : 
     110         [ -  + ]:     261850 : SetNode::~SetNode() {}
     111                 :            : 
     112                 :    5222927 : Node::Kind SetNode::kind() const {
     113                 :    5222927 :     return KIND_SET;
     114                 :            : }
     115                 :            : 
     116                 :          0 : void SetNode::clear() {
     117                 :          0 :     members_.clear();
     118                 :          0 : }
     119                 :            : 
     120                 :            : }
     121                 :            : 
     122                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10