LCOV - code coverage report
Current view: top level - drawinglayer/source/attribute - fontattribute.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 62 82 75.6 %
Date: 2012-08-25 Functions: 28 31 90.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 50 28.0 %

           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 <drawinglayer/attribute/fontattribute.hxx>
      21                 :            : #include <tools/string.hxx>
      22                 :            : 
      23                 :            : //////////////////////////////////////////////////////////////////////////////
      24                 :            : 
      25                 :            : namespace drawinglayer
      26                 :            : {
      27                 :            :     namespace attribute
      28                 :            :     {
      29         [ +  - ]:      23167 :         class ImpFontAttribute
      30                 :            :         {
      31                 :            :         public:
      32                 :            :             // refcounter
      33                 :            :             sal_uInt32                              mnRefCount;
      34                 :            : 
      35                 :            :             /// core data
      36                 :            :             String                                      maFamilyName;       // Font Family Name
      37                 :            :             String                                      maStyleName;        // Font Style Name
      38                 :            :             sal_uInt16                                  mnWeight;           // Font weight
      39                 :            : 
      40                 :            :             /// bitfield
      41                 :            :             unsigned                                    mbSymbol : 1;       // Symbol Font Flag
      42                 :            :             unsigned                                    mbVertical : 1;     // Vertical Text Flag
      43                 :            :             unsigned                                    mbItalic : 1;       // Italic Flag
      44                 :            :             unsigned                                    mbOutline : 1;      // Outline Flag
      45                 :            :             unsigned                                    mbRTL : 1;          // RTL Flag
      46                 :            :             unsigned                                    mbBiDiStrong : 1;   // BiDi Flag
      47                 :            :             unsigned                                    mbMonospaced : 1;
      48                 :            : 
      49                 :      23172 :             ImpFontAttribute(
      50                 :            :                 const String& rFamilyName,
      51                 :            :                 const String& rStyleName,
      52                 :            :                 sal_uInt16 nWeight,
      53                 :            :                 bool bSymbol,
      54                 :            :                 bool bVertical,
      55                 :            :                 bool bItalic,
      56                 :            :                 bool bMonospaced,
      57                 :            :                 bool bOutline,
      58                 :            :                 bool bRTL,
      59                 :            :                 bool bBiDiStrong)
      60                 :            :             :   mnRefCount(0),
      61                 :            :                 maFamilyName(rFamilyName),
      62                 :            :                 maStyleName(rStyleName),
      63                 :            :                 mnWeight(nWeight),
      64                 :            :                 mbSymbol(bSymbol),
      65                 :            :                 mbVertical(bVertical),
      66                 :            :                 mbItalic(bItalic),
      67                 :            :                 mbOutline(bOutline),
      68                 :            :                 mbRTL(bRTL),
      69                 :            :                 mbBiDiStrong(bBiDiStrong),
      70         [ +  - ]:      23172 :                 mbMonospaced(bMonospaced)
      71                 :            :             {
      72                 :      23172 :             }
      73                 :            : 
      74                 :            :             // data read access
      75                 :      43234 :             const String& getFamilyName() const { return maFamilyName; }
      76                 :      43234 :             const String& getStyleName() const { return maStyleName; }
      77                 :      43234 :             sal_uInt16 getWeight() const { return mnWeight; }
      78                 :      43234 :             bool getSymbol() const { return mbSymbol; }
      79                 :      43234 :             bool getVertical() const { return mbVertical; }
      80                 :      43234 :             bool getItalic() const { return mbItalic; }
      81                 :      42705 :             bool getOutline() const { return mbOutline; }
      82                 :      37136 :             bool getRTL() const { return mbRTL; }
      83                 :       2018 :             bool getBiDiStrong() const { return mbBiDiStrong; }
      84                 :      42123 :             bool getMonospaced() const { return mbMonospaced; }
      85                 :            : 
      86                 :          0 :             bool operator==(const ImpFontAttribute& rCompare) const
      87                 :            :             {
      88                 :          0 :                 return (getFamilyName() == rCompare.getFamilyName()
      89                 :          0 :                     && getStyleName() == rCompare.getStyleName()
      90                 :          0 :                     && getWeight() == rCompare.getWeight()
      91                 :          0 :                     && getSymbol() == rCompare.getSymbol()
      92                 :          0 :                     && getVertical() == rCompare.getVertical()
      93                 :          0 :                     && getItalic() == rCompare.getItalic()
      94                 :          0 :                     && getOutline() == rCompare.getOutline()
      95                 :          0 :                     && getRTL() == rCompare.getRTL()
      96                 :          0 :                     && getBiDiStrong() == rCompare.getBiDiStrong()
      97 [ #  # ][ #  #  :          0 :                     && getMonospaced() == rCompare.getMonospaced());
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                      # ]
      98                 :            :             }
      99                 :            : 
     100                 :       2992 :             static ImpFontAttribute* get_global_default()
     101                 :            :             {
     102                 :            :                 static ImpFontAttribute* pDefault = 0;
     103                 :            : 
     104         [ +  + ]:       2992 :                 if(!pDefault)
     105                 :            :                 {
     106                 :            :                     pDefault = new ImpFontAttribute(
     107                 :            :                         String(), String(),
     108                 :            :                         0,
     109 [ +  - ][ +  - ]:          5 :                         false, false, false, false, false, false, false);
         [ +  - ][ +  - ]
     110                 :            : 
     111                 :            :                     // never delete; start with RefCount 1, not 0
     112                 :          5 :                     pDefault->mnRefCount++;
     113                 :            :                 }
     114                 :            : 
     115                 :       2992 :                 return pDefault;
     116                 :            :             }
     117                 :            :         };
     118                 :            : 
     119                 :      23167 :         FontAttribute::FontAttribute(
     120                 :            :             const String& rFamilyName,
     121                 :            :             const String& rStyleName,
     122                 :            :             sal_uInt16 nWeight,
     123                 :            :             bool bSymbol,
     124                 :            :             bool bVertical,
     125                 :            :             bool bItalic,
     126                 :            :             bool bMonospaced,
     127                 :            :             bool bOutline,
     128                 :            :             bool bRTL,
     129                 :            :             bool bBiDiStrong)
     130                 :            :         :   mpFontAttribute(new ImpFontAttribute(
     131         [ +  - ]:      23167 :                 rFamilyName, rStyleName, nWeight, bSymbol, bVertical, bItalic, bMonospaced, bOutline, bRTL, bBiDiStrong))
     132                 :            :         {
     133                 :      23167 :         }
     134                 :            : 
     135                 :       2992 :         FontAttribute::FontAttribute()
     136                 :       2992 :         :   mpFontAttribute(ImpFontAttribute::get_global_default())
     137                 :            :         {
     138                 :       2992 :             mpFontAttribute->mnRefCount++;
     139                 :       2992 :         }
     140                 :            : 
     141                 :      23955 :         FontAttribute::FontAttribute(const FontAttribute& rCandidate)
     142                 :      23955 :         :   mpFontAttribute(rCandidate.mpFontAttribute)
     143                 :            :         {
     144                 :      23955 :             mpFontAttribute->mnRefCount++;
     145                 :      23955 :         }
     146                 :            : 
     147                 :      50114 :         FontAttribute::~FontAttribute()
     148                 :            :         {
     149         [ +  + ]:      50114 :             if(mpFontAttribute->mnRefCount)
     150                 :            :             {
     151                 :      26947 :                 mpFontAttribute->mnRefCount--;
     152                 :            :             }
     153                 :            :             else
     154                 :            :             {
     155         [ +  - ]:      23167 :                 delete mpFontAttribute;
     156                 :            :             }
     157                 :      50114 :         }
     158                 :            : 
     159                 :          0 :         bool FontAttribute::isDefault() const
     160                 :            :         {
     161                 :          0 :             return mpFontAttribute == ImpFontAttribute::get_global_default();
     162                 :            :         }
     163                 :            : 
     164                 :       2992 :         FontAttribute& FontAttribute::operator=(const FontAttribute& rCandidate)
     165                 :            :         {
     166         [ +  - ]:       2992 :             if(rCandidate.mpFontAttribute != mpFontAttribute)
     167                 :            :             {
     168         [ +  - ]:       2992 :                 if(mpFontAttribute->mnRefCount)
     169                 :            :                 {
     170                 :       2992 :                     mpFontAttribute->mnRefCount--;
     171                 :            :                 }
     172                 :            :                 else
     173                 :            :                 {
     174         [ #  # ]:          0 :                     delete mpFontAttribute;
     175                 :            :                 }
     176                 :            : 
     177                 :       2992 :                 mpFontAttribute = rCandidate.mpFontAttribute;
     178                 :       2992 :                 mpFontAttribute->mnRefCount++;
     179                 :            :             }
     180                 :            : 
     181                 :       2992 :             return *this;
     182                 :            :         }
     183                 :            : 
     184                 :          0 :         bool FontAttribute::operator==(const FontAttribute& rCandidate) const
     185                 :            :         {
     186         [ #  # ]:          0 :             if(rCandidate.mpFontAttribute == mpFontAttribute)
     187                 :            :             {
     188                 :          0 :                 return true;
     189                 :            :             }
     190                 :            : 
     191         [ #  # ]:          0 :             if(rCandidate.isDefault() != isDefault())
     192                 :            :             {
     193                 :          0 :                 return false;
     194                 :            :             }
     195                 :            : 
     196                 :          0 :             return (*rCandidate.mpFontAttribute == *mpFontAttribute);
     197                 :            :         }
     198                 :            : 
     199                 :      43234 :         const String& FontAttribute::getFamilyName() const
     200                 :            :         {
     201                 :      43234 :             return mpFontAttribute->getFamilyName();
     202                 :            :         }
     203                 :            : 
     204                 :      43234 :         const String& FontAttribute::getStyleName() const
     205                 :            :         {
     206                 :      43234 :             return mpFontAttribute->getStyleName();
     207                 :            :         }
     208                 :            : 
     209                 :      43234 :         sal_uInt16 FontAttribute::getWeight() const
     210                 :            :         {
     211                 :      43234 :             return mpFontAttribute->getWeight();
     212                 :            :         }
     213                 :            : 
     214                 :      43234 :         bool FontAttribute::getSymbol() const
     215                 :            :         {
     216                 :      43234 :             return mpFontAttribute->getSymbol();
     217                 :            :         }
     218                 :            : 
     219                 :      43234 :         bool FontAttribute::getVertical() const
     220                 :            :         {
     221                 :      43234 :             return mpFontAttribute->getVertical();
     222                 :            :         }
     223                 :            : 
     224                 :      43234 :         bool FontAttribute::getItalic() const
     225                 :            :         {
     226                 :      43234 :             return mpFontAttribute->getItalic();
     227                 :            :         }
     228                 :            : 
     229                 :      42705 :         bool FontAttribute::getOutline() const
     230                 :            :         {
     231                 :      42705 :             return mpFontAttribute->getOutline();
     232                 :            :         }
     233                 :            : 
     234                 :      37136 :         bool FontAttribute::getRTL() const
     235                 :            :         {
     236                 :      37136 :             return mpFontAttribute->getRTL();
     237                 :            :         }
     238                 :            : 
     239                 :       2018 :         bool FontAttribute::getBiDiStrong() const
     240                 :            :         {
     241                 :       2018 :             return mpFontAttribute->getBiDiStrong();
     242                 :            :         }
     243                 :            : 
     244                 :      42123 :         bool FontAttribute::getMonospaced() const
     245                 :            :         {
     246                 :      42123 :             return mpFontAttribute->getMonospaced();
     247                 :            :         }
     248                 :            : 
     249                 :            : 
     250                 :            :     } // end of namespace attribute
     251                 :            : } // end of namespace drawinglayer
     252                 :            : 
     253                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10