LCOV - code coverage report
Current view: top level - vcl/source/gdi - metric.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 42 73 57.5 %
Date: 2014-11-03 Functions: 15 21 71.4 %
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 <impfont.hxx>
      21             : #include <vcl/metric.hxx>
      22             : 
      23             : #include <vector>
      24             : #include <set>
      25             : 
      26             : #include <cstdio>
      27             : 
      28     2319772 : ImplFontMetric::ImplFontMetric()
      29             : :   mnAscent( 0 ),
      30             :     mnDescent( 0 ),
      31             :     mnIntLeading( 0 ),
      32             :     mnExtLeading( 0 ),
      33             :     mnLineHeight( 0 ),
      34             :     mnSlant( 0 ),
      35             :     mnMiscFlags( 0 ),
      36     2319772 :     mnRefCount( 1 )
      37     2319772 : {}
      38             : 
      39     1887333 : inline void ImplFontMetric::AddReference()
      40             : {
      41             :     // TODO: disable refcounting on the default maps?
      42     1887333 :     ++mnRefCount;
      43     1887333 : }
      44             : 
      45     4206673 : inline void ImplFontMetric::DeReference()
      46             : {
      47             :     // TODO: disable refcounting on the default maps?
      48     4206673 :     if( --mnRefCount <= 0 )
      49     2319340 :         delete this;
      50     4206673 : }
      51             : 
      52           0 : bool ImplFontMetric::operator==( const ImplFontMetric& r ) const
      53             : {
      54           0 :     if( mnMiscFlags  != r.mnMiscFlags )
      55           0 :         return false;
      56           0 :     if( mnAscent     != r.mnAscent )
      57           0 :         return false;
      58           0 :     if( mnDescent    != r.mnDescent )
      59           0 :         return false;
      60           0 :     if( mnIntLeading != r.mnIntLeading )
      61           0 :         return false;
      62           0 :     if( mnExtLeading != r.mnExtLeading )
      63           0 :         return false;
      64           0 :     if( mnSlant      != r.mnSlant )
      65           0 :         return false;
      66             : 
      67           0 :     return true;
      68             : }
      69             : 
      70             : namespace vcl {
      71             : 
      72     2319772 : FontInfo::FontInfo()
      73     2319772 : :   mpImplMetric( new ImplFontMetric )
      74     2319772 : {}
      75             : 
      76     1841972 : FontInfo::FontInfo( const FontInfo& rInfo )
      77     1841972 : :  Font( rInfo )
      78             : {
      79     1841972 :     mpImplMetric = rInfo.mpImplMetric;
      80     1841972 :     mpImplMetric->AddReference();
      81     1841972 : }
      82             : 
      83     8322624 : FontInfo::~FontInfo()
      84             : {
      85     4161312 :     mpImplMetric->DeReference();
      86     4161312 : }
      87             : 
      88       45361 : FontInfo& FontInfo::operator=( const FontInfo& rInfo )
      89             : {
      90       45361 :     Font::operator=( rInfo );
      91             : 
      92       45361 :     if( mpImplMetric != rInfo.mpImplMetric )
      93             :     {
      94       45361 :         mpImplMetric->DeReference();
      95       45361 :         mpImplMetric = rInfo.mpImplMetric;
      96       45361 :         mpImplMetric->AddReference();
      97             :     }
      98             : 
      99       45361 :     return *this;
     100             : }
     101             : 
     102           0 : bool FontInfo::operator==( const FontInfo& rInfo ) const
     103             : {
     104           0 :     if( !Font::operator==( rInfo ) )
     105           0 :         return false;
     106           0 :     if( mpImplMetric == rInfo.mpImplMetric )
     107           0 :         return true;
     108           0 :     if( *mpImplMetric == *rInfo.mpImplMetric  )
     109           0 :         return true;
     110           0 :     return false;
     111             : }
     112             : 
     113      327828 : FontType FontInfo::GetType() const
     114             : {
     115      327828 :     return (mpImplMetric->IsScalable() ? TYPE_SCALABLE : TYPE_RASTER);
     116             : }
     117             : 
     118             : }
     119             : 
     120           0 : FontMetric::FontMetric( const FontMetric& rMetric ):
     121           0 :     vcl::FontInfo( rMetric )
     122           0 : {}
     123             : 
     124      534054 : long FontMetric::GetAscent() const
     125             : {
     126      534054 :     return mpImplMetric->GetAscent();
     127             : }
     128             : 
     129      447225 : long FontMetric::GetDescent() const
     130             : {
     131      447225 :     return mpImplMetric->GetDescent();
     132             : }
     133             : 
     134      733821 : long FontMetric::GetIntLeading() const
     135             : {
     136      733821 :     return mpImplMetric->GetIntLeading();
     137             : }
     138             : 
     139       47949 : long FontMetric::GetExtLeading() const
     140             : {
     141       47949 :     return mpImplMetric->GetExtLeading();
     142             : }
     143             : 
     144           0 : long FontMetric::GetLineHeight() const
     145             : {
     146           0 :     return mpImplMetric->GetLineHeight();
     147             : }
     148             : 
     149           0 : long FontMetric::GetSlant() const
     150             : {
     151           0 :     return mpImplMetric->GetSlant();
     152             : }
     153             : 
     154        3187 : FontMetric& FontMetric::operator =( const FontMetric& rMetric )
     155             : {
     156        3187 :     vcl::FontInfo::operator=( rMetric );
     157        3187 :     return *this;
     158             : }
     159             : 
     160           0 : bool FontMetric::operator==( const FontMetric& rMetric ) const
     161             : {
     162           0 :     return vcl::FontInfo::operator==( rMetric );
     163        1233 : }
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10