LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/style - impastp3.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 42 61 68.9 %
Date: 2013-07-09 Functions: 3 4 75.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             : 
      20             : #include "impastpl.hxx"
      21             : #include <xmloff/xmlprmap.hxx>
      22             : 
      23             : using namespace std;
      24             : 
      25             : 
      26             : //#############################################################################
      27             : //
      28             : // Class SvXMLAutoStylePoolParent_Impl
      29             : //
      30             : 
      31             : ///////////////////////////////////////////////////////////////////////////////
      32             : //
      33             : // dtor class SvXMLAutoStylePoolParent_Impl
      34             : //
      35             : 
      36        1130 : SvXMLAutoStylePoolParentP_Impl::~SvXMLAutoStylePoolParentP_Impl()
      37             : {
      38        1340 :     for( size_t i = maPropertiesList.size(); i > 0;  )
      39         210 :         delete maPropertiesList[ --i ];
      40         565 :     maPropertiesList.clear();
      41         565 : }
      42             : 
      43             : ///////////////////////////////////////////////////////////////////////////////
      44             : //
      45             : // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) to list
      46             : // if not added, yet.
      47             : //
      48             : 
      49         246 : sal_Bool SvXMLAutoStylePoolParentP_Impl::Add( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, OUString& rName, bool bDontSeek )
      50             : {
      51         246 :     sal_Bool bAdded = sal_False;
      52         246 :     SvXMLAutoStylePoolPropertiesP_Impl *pProperties = 0;
      53         246 :     size_t i = 0;
      54         246 :     sal_Int32 nProperties = rProperties.size();
      55         246 :     size_t nCount = maPropertiesList.size();
      56             : 
      57         562 :     for( i = 0; i < nCount; i++ )
      58             :     {
      59         407 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
      60         407 :         if( nProperties > (sal_Int32)pIS->GetProperties().size() )
      61             :         {
      62         172 :             continue;
      63             :         }
      64         235 :         else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
      65             :         {
      66          55 :             break;
      67             :         }
      68         180 :         else if( !bDontSeek && rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
      69             :         {
      70          36 :             pProperties = pIS;
      71          36 :             break;
      72             :         }
      73             :     }
      74             : 
      75         246 :     if( !pProperties )
      76             :     {
      77         210 :         pProperties = new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
      78         210 :         SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
      79         210 :         ::std::advance( it, i );
      80         210 :         maPropertiesList.insert( it, pProperties );
      81         210 :         bAdded = sal_True;
      82             :     }
      83             : 
      84         246 :     rName = pProperties->GetName();
      85             : 
      86         246 :     return bAdded;
      87             : }
      88             : 
      89             : ///////////////////////////////////////////////////////////////////////////////
      90             : //
      91             : // Adds a array of XMLPropertyState ( vector< XMLPropertyState > ) with a given name.
      92             : // If the name exists already, nothing is done. If a style with a different name and
      93             : // the same properties exists, a new one is added (like with bDontSeek).
      94             : //
      95             : 
      96           0 : sal_Bool SvXMLAutoStylePoolParentP_Impl::AddNamed( XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties, const OUString& rName )
      97             : {
      98           0 :     sal_Bool bAdded = sal_False;
      99           0 :     size_t i = 0;
     100           0 :     sal_Int32 nProperties = rProperties.size();
     101           0 :     size_t nCount = maPropertiesList.size();
     102             : 
     103           0 :     for( i = 0; i < nCount; i++ )
     104             :     {
     105           0 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
     106           0 :         if( nProperties > (sal_Int32)pIS->GetProperties().size() )
     107             :         {
     108           0 :             continue;
     109             :         }
     110           0 :         else if( nProperties < (sal_Int32)pIS->GetProperties().size() )
     111             :         {
     112           0 :             break;
     113             :         }
     114             :     }
     115             : 
     116           0 :     if(rFamilyData.mpNameList->find(rName) == rFamilyData.mpNameList->end())
     117             :     {
     118             :         SvXMLAutoStylePoolPropertiesP_Impl* pProperties =
     119           0 :                 new SvXMLAutoStylePoolPropertiesP_Impl( rFamilyData, rProperties );
     120             :         // ignore the generated name
     121           0 :         pProperties->SetName( rName );
     122           0 :         SvXMLAutoStylePoolPropertiesPList_Impl::iterator it = maPropertiesList.begin();
     123           0 :         ::std::advance( it, i );
     124           0 :         maPropertiesList.insert( it, pProperties );
     125           0 :         bAdded = sal_True;
     126             :     }
     127             : 
     128           0 :     return bAdded;
     129             : }
     130             : 
     131             : ///////////////////////////////////////////////////////////////////////////////
     132             : //
     133             : // Search for a array of XMLPropertyState ( vector< XMLPropertyState > ) in list
     134             : //
     135             : 
     136         168 : OUString SvXMLAutoStylePoolParentP_Impl::Find( const XMLFamilyData_Impl& rFamilyData, const vector< XMLPropertyState >& rProperties ) const
     137             : {
     138         168 :     OUString sName;
     139         168 :     vector< XMLPropertyState>::size_type nItems = rProperties.size();
     140         168 :     size_t nCount = maPropertiesList.size();
     141         261 :     for( size_t i = 0; i < nCount; i++ )
     142             :     {
     143         242 :         SvXMLAutoStylePoolPropertiesP_Impl *pIS = maPropertiesList[ i ];
     144         242 :         if( nItems > pIS->GetProperties().size() )
     145             :         {
     146          57 :             continue;
     147             :         }
     148         185 :         else if( nItems < pIS->GetProperties().size() )
     149             :         {
     150           4 :             break;
     151             :         }
     152         181 :         else if( rFamilyData.mxMapper->Equals( pIS->GetProperties(), rProperties ) )
     153             :         {
     154         145 :             sName = pIS->GetName();
     155         145 :             break;
     156             :         }
     157             :     }
     158             : 
     159         168 :     return sName;
     160             : }
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10