LCOV - code coverage report
Current view: top level - xmloff/source/style - impastp3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 61 68.9 %
Date: 2012-08-25 Functions: 3 4 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 32 60 53.3 %

           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 "impastpl.hxx"
      30                 :            : #include <xmloff/xmlprmap.hxx>
      31                 :            : 
      32                 :            : using namespace std;
      33                 :            : 
      34                 :            : using ::rtl::OUString;
      35                 :            : 
      36                 :            : //#############################################################################
      37                 :            : //
      38                 :            : // Class SvXMLAutoStylePoolParent_Impl
      39                 :            : //
      40                 :            : 
      41                 :            : ///////////////////////////////////////////////////////////////////////////////
      42                 :            : //
      43                 :            : // dtor class SvXMLAutoStylePoolParent_Impl
      44                 :            : //
      45                 :            : 
      46                 :        738 : SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl()
      47                 :            : {
      48         [ +  + ]:        984 :     for( size_t i = maPropertiesList.size(); i > 0;  )
      49         [ +  - ]:        246 :         delete maPropertiesList[ --i ];
      50                 :        738 :     maPropertiesList.clear();
      51                 :        738 : }
      52                 :            : 
      53                 :            : ///////////////////////////////////////////////////////////////////////////////
      54                 :            : //
      55                 :            : // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
      56                 :            : // if not added, yet.
      57                 :            : //
      58                 :            : 
      59                 :        302 : sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek )
      60                 :            : {
      61                 :        302 :     sal_Bool bAdded = sal_False;
      62                 :        302 :     SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0;
      63                 :        302 :     size_t i = 0;
      64                 :        302 :     sal_Int32 nProperties = rProperties.size();
      65                 :        302 :     size_t nCount = maPropertiesList.size();
      66                 :            : 
      67         [ +  + ]:        719 :     for( i = 0; i < nCount; i++ )
      68                 :            :     {
      69                 :        563 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
      70         [ +  + ]:        563 :         if( nProperties > (sal_Int32)pIS->GetProperties().size() )
      71                 :            :         {
      72                 :        279 :             continue;
      73                 :            :         }
      74         [ +  + ]:        284 :         else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
      75                 :            :         {
      76                 :         90 :             break;
      77                 :            :         }
      78 [ +  - ][ +  - ]:        194 :         else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
         [ +  - ][ +  + ]
                 [ +  + ]
      79                 :            :         {
      80                 :         56 :             pProperties = pIS;
      81                 :         56 :             break;
      82                 :            :         }
      83                 :            :     }
      84                 :            : 
      85         [ +  + ]:        302 :     if( !pProperties )
      86                 :            :     {
      87 [ +  - ][ +  - ]:        246 :         pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
      88                 :        246 :         SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
      89         [ +  - ]:        246 :         ::std::advance( it, i );
      90         [ +  - ]:        246 :         maPropertiesList.insert( it, pProperties );
      91                 :        246 :         bAdded = sal_True;
      92                 :            :     }
      93                 :            : 
      94                 :        302 :     rName = pProperties->GetName();
      95                 :            : 
      96                 :        302 :     return bAdded;
      97                 :            : }
      98                 :            : 
      99                 :            : ///////////////////////////////////////////////////////////////////////////////
     100                 :            : //
     101                 :            : // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) with a given name.
     102                 :            : // If the name exists already, nothing is done. If a style with a different name and
     103                 :            : // the same properties exists, a new one is added (like with bDontSeek).
     104                 :            : //
     105                 :            : 
     106                 :          0 : sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName )
     107                 :            : {
     108                 :          0 :     sal_Bool bAdded = sal_False;
     109                 :          0 :     size_t i = 0;
     110                 :          0 :     sal_Int32 nProperties = rProperties.size();
     111                 :          0 :     size_t nCount = maPropertiesList.size();
     112                 :            : 
     113         [ #  # ]:          0 :     for( i = 0; i < nCount; i++ )
     114                 :            :     {
     115                 :          0 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
     116         [ #  # ]:          0 :         if( nProperties > (sal_Int32)pIS->GetProperties().size() )
     117                 :            :         {
     118                 :          0 :             continue;
     119                 :            :         }
     120         [ #  # ]:          0 :         else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
     121                 :            :         {
     122                 :          0 :             break;
     123                 :            :         }
     124                 :            :     }
     125                 :            : 
     126 [ #  # ][ #  # ]:          0 :     if(rFamilyData.mpNameList->find(rName) == rFamilyData.mpNameList->end())
     127                 :            :     {
     128                 :            :         SvXMLAutoStylePoolPropertiesP_Impl* pProperties =
     129 [ #  # ][ #  # ]:          0 :                 new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
     130                 :            :         // ignore the generated name
     131                 :          0 :         pProperties->SetName( rName );
     132                 :          0 :         SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
     133         [ #  # ]:          0 :         ::std::advance( it, i );
     134         [ #  # ]:          0 :         maPropertiesList.insert( it, pProperties );
     135                 :          0 :         bAdded = sal_True;
     136                 :            :     }
     137                 :            : 
     138                 :          0 :     return bAdded;
     139                 :            : }
     140                 :            : 
     141                 :            : ///////////////////////////////////////////////////////////////////////////////
     142                 :            : //
     143                 :            : // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
     144                 :            : //
     145                 :            : 
     146                 :        266 : OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties ) const
     147                 :            : {
     148                 :        266 :     OUString sName;
     149                 :        266 :     vector< XMLPropertyState>::size_type nItems = rProperties.size();
     150                 :        266 :     size_t nCount = maPropertiesList.size();
     151         [ +  + ]:        431 :     for( size_t i = 0; i < nCount; i++ )
     152                 :            :     {
     153                 :        408 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
     154         [ +  + ]:        408 :         if( nItems > pIS->GetProperties().size() )
     155                 :            :         {
     156                 :        100 :             continue;
     157                 :            :         }
     158         [ +  + ]:        308 :         else if( nItems < pIS->GetProperties().size() )
     159                 :            :         {
     160                 :          6 :             break;
     161                 :            :         }
     162 [ +  - ][ +  - ]:        302 :         else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
                 [ +  + ]
     163                 :            :         {
     164                 :        237 :             sName = pIS->GetName();
     165                 :        237 :             break;
     166                 :            :         }
     167                 :            :     }
     168                 :            : 
     169                 :        266 :     return sName;
     170                 :            : }
     171                 :            : 
     172                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10