LCOV - code coverage report
Current view: top level - vcl/source/gdi - metric.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 72 56.9 %
Date: 2015-06-13 12:38:46 Functions: 13 19 68.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     2226433 : ImplFontMetric::ImplFontMetric()
      29             : :   mnAscent( 0 ),
      30             :     mnDescent( 0 ),
      31             :     mnIntLeading( 0 ),
      32             :     mnExtLeading( 0 ),
      33             :     mnLineHeight( 0 ),
      34             :     mnSlant( 0 ),
      35             :     mnMiscFlags( 0 ),
      36     2226433 :     mnRefCount( 1 )
      37     2226433 : {}
      38             : 
      39     1836856 : inline void ImplFontMetric::AddReference()
      40             : {
      41             :     // TODO: disable refcounting on the default maps?
      42     1836856 :     ++mnRefCount;
      43     1836856 : }
      44             : 
      45     4059404 : inline void ImplFontMetric::DeReference()
      46             : {
      47             :     // TODO: disable refcounting on the default maps?
      48     4059404 :     if( --mnRefCount <= 0 )
      49     2222548 :         delete this;
      50     4059404 : }
      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     2226433 : FontInfo::FontInfo()
      73     2226433 : :   mpImplMetric( new ImplFontMetric )
      74     2226433 : {}
      75             : 
      76     1810316 : FontInfo::FontInfo( const FontInfo& rInfo )
      77     1810316 : :  Font( rInfo )
      78             : {
      79     1810316 :     mpImplMetric = rInfo.mpImplMetric;
      80     1810316 :     mpImplMetric->AddReference();
      81     1810316 : }
      82             : 
      83     8065728 : FontInfo::~FontInfo()
      84             : {
      85     4032864 :     mpImplMetric->DeReference();
      86     4032864 : }
      87             : 
      88       26540 : FontInfo& FontInfo::operator=( const FontInfo& rInfo )
      89             : {
      90       26540 :     Font::operator=( rInfo );
      91             : 
      92       26540 :     if( mpImplMetric != rInfo.mpImplMetric )
      93             :     {
      94       26540 :         mpImplMetric->DeReference();
      95       26540 :         mpImplMetric = rInfo.mpImplMetric;
      96       26540 :         mpImplMetric->AddReference();
      97             :     }
      98             : 
      99       26540 :     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      319117 : FontType FontInfo::GetType() const
     114             : {
     115      319117 :     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      553865 : long FontMetric::GetAscent() const
     125             : {
     126      553865 :     return mpImplMetric->GetAscent();
     127             : }
     128             : 
     129      504365 : long FontMetric::GetDescent() const
     130             : {
     131      504365 :     return mpImplMetric->GetDescent();
     132             : }
     133             : 
     134      779662 : long FontMetric::GetIntLeading() const
     135             : {
     136      779662 :     return mpImplMetric->GetIntLeading();
     137             : }
     138             : 
     139       26734 : long FontMetric::GetExtLeading() const
     140             : {
     141       26734 :     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        5762 : FontMetric& FontMetric::operator =( const FontMetric& rMetric )
     155             : {
     156        5762 :     vcl::FontInfo::operator=( rMetric );
     157        5762 :     return *this;
     158             : }
     159             : 
     160           0 : bool FontMetric::operator==( const FontMetric& rMetric ) const
     161             : {
     162           0 :     return vcl::FontInfo::operator==( rMetric );
     163             : }
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11