LCOV - code coverage report
Current view: top level - writerfilter/source/dmapper - FontTable.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 102 52.0 %
Date: 2012-08-25 Functions: 13 27 48.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 103 46.6 %

           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 <FontTable.hxx>
      21                 :            : #include <doctok/resourceids.hxx>
      22                 :            : #include <ooxml/resourceids.hxx>
      23                 :            : #include <vector>
      24                 :            : #include <stdio.h>
      25                 :            : #include <rtl/tencinfo.h>
      26                 :            : 
      27                 :            : #include "dmapperLoggers.hxx"
      28                 :            : 
      29                 :            : namespace writerfilter {
      30                 :            : namespace dmapper
      31                 :            : {
      32                 :            : 
      33         [ +  - ]:        368 : struct FontTable_Impl
      34                 :            : {
      35                 :            :     std::vector< FontEntry::Pointer_t > aFontEntries;
      36                 :            :     FontEntry::Pointer_t pCurrentEntry;
      37         [ +  - ]:        368 :     FontTable_Impl() {}
      38                 :            : };
      39                 :            : 
      40                 :        368 : FontTable::FontTable()
      41                 :            : : LoggedProperties(dmapper_logger, "FontTable")
      42                 :            : , LoggedTable(dmapper_logger, "FontTable")
      43                 :            : , LoggedStream(dmapper_logger, "FontTable")
      44 [ +  - ][ +  - ]:        368 : , m_pImpl( new FontTable_Impl )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      45                 :            : {
      46                 :        368 : }
      47                 :            : 
      48 [ +  - ][ +  - ]:        368 : FontTable::~FontTable()
      49                 :            : {
      50 [ +  - ][ +  - ]:        368 :     delete m_pImpl;
      51         [ -  + ]:        736 : }
      52                 :            : 
      53                 :       3341 : void FontTable::lcl_attribute(Id Name, Value & val)
      54                 :            : {
      55                 :            :     OSL_ENSURE( m_pImpl->pCurrentEntry, "current entry has to be set here");
      56         [ +  - ]:       3341 :     if(!m_pImpl->pCurrentEntry)
      57                 :       3341 :         return ;
      58         [ +  - ]:       3341 :     int nIntValue = val.getInt();
      59         [ +  - ]:       3341 :     OUString sValue = val.getString();
      60   [ -  -  -  -  :       3341 :     switch(Name)
          -  -  -  -  -  
          -  -  +  +  +  
                      - ]
      61                 :            :     {
      62                 :            :         case NS_rtf::LN_CBFFNM1:
      63                 :          0 :             m_pImpl->pCurrentEntry->sFontName1 = sValue;
      64                 :          0 :         break;
      65                 :            :         case NS_rtf::LN_PRQ:
      66                 :          0 :             m_pImpl->pCurrentEntry->nPitchRequest = static_cast<sal_Int16>( nIntValue );
      67                 :          0 :         break;
      68                 :            :         case NS_rtf::LN_FTRUETYPE:
      69                 :          0 :             m_pImpl->pCurrentEntry->bTrueType = nIntValue == 1 ? true : false;
      70                 :          0 :         break;
      71                 :            :         case NS_rtf::LN_UNUSED1_3: //unused
      72                 :            :         case NS_rtf::LN_FF: //unused
      73                 :            :         case NS_rtf::LN_UNUSED1_7: //unused
      74                 :          0 :         break;
      75                 :            :         case NS_rtf::LN_WWEIGHT:
      76                 :          0 :             m_pImpl->pCurrentEntry->nBaseWeight = nIntValue;
      77                 :          0 :         break;
      78                 :            :         case NS_rtf::LN_CHS:
      79                 :          0 :             m_pImpl->pCurrentEntry->nTextEncoding = nIntValue;
      80                 :          0 :         break;
      81                 :            :         case NS_rtf::LN_IXCHSZALT:
      82                 :          0 :         break;
      83                 :            :         case NS_rtf::LN_PANOSE:
      84                 :          0 :             m_pImpl->pCurrentEntry->sPanose += sValue;
      85                 :          0 :         break;
      86                 :            :         case NS_rtf::LN_FS:
      87                 :          0 :             m_pImpl->pCurrentEntry->sFontSignature += sValue;
      88                 :          0 :         break;
      89                 :            :         case NS_rtf::LN_F:
      90                 :          0 :         break;
      91                 :            :         case NS_rtf::LN_ALTFONTNAME:
      92                 :          0 :             m_pImpl->pCurrentEntry->sAlternativeFont = sValue;
      93                 :          0 :         break;
      94                 :            :         case NS_rtf::LN_XSZFFN:
      95                 :            :         case NS_ooxml::LN_CT_Font_name:
      96                 :       2203 :             m_pImpl->pCurrentEntry->sFontName = sValue;
      97                 :       2203 :         break;
      98                 :            :         case NS_ooxml::LN_CT_Charset_val:
      99                 :            :             // w:characterSet has higher priority, set only if that one is not set
     100         [ +  + ]:        877 :             if( m_pImpl->pCurrentEntry->nTextEncoding == RTL_TEXTENCODING_DONTKNOW )
     101         [ +  - ]:        616 :                 m_pImpl->pCurrentEntry->nTextEncoding = rtl_getTextEncodingFromWindowsCharset( nIntValue );
     102                 :        877 :         break;
     103                 :            :         case NS_ooxml::LN_CT_Charset_characterSet:
     104                 :            :         {
     105                 :        261 :             OString tmp;
     106                 :        261 :             sValue.convertToString( &tmp, RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS );
     107         [ +  - ]:        261 :             m_pImpl->pCurrentEntry->nTextEncoding = rtl_getTextEncodingFromMimeCharset( tmp.getStr() );
     108                 :        261 :         break;
     109                 :            :         }
     110                 :            :         default:
     111                 :            :         {
     112                 :            :             //----> debug
     113         [ #  # ]:          0 :             int nVal = val.getInt();
     114                 :          0 :             ++nVal;
     115                 :            :             //<---- debug
     116                 :            :         }
     117                 :       3341 :     }
     118                 :            : }
     119                 :            : 
     120                 :       5170 : void FontTable::lcl_sprm(Sprm& rSprm)
     121                 :            : {
     122                 :            :     OSL_ENSURE( m_pImpl->pCurrentEntry, "current entry has to be set here");
     123         [ +  - ]:       5170 :     if(!m_pImpl->pCurrentEntry)
     124                 :       5170 :         return ;
     125         [ +  - ]:       5170 :     sal_uInt32 nSprmId = rSprm.getId();
     126                 :            : 
     127 [ +  - ][ +  - ]:       5170 :     Value::Pointer_t pValue = rSprm.getValue();
     128         [ +  - ]:       5170 :     sal_Int32 nIntValue = pValue->getInt();
     129                 :            :     (void)nIntValue;
     130         [ +  - ]:       5170 :     OUString sStringValue = pValue->getString();
     131         [ +  + ]:       5170 :     switch(nSprmId)
     132                 :            :     {
     133                 :            :         case NS_ooxml::LN_CT_Font_charset:
     134         [ +  - ]:        877 :             resolveSprm( rSprm );
     135                 :        877 :             break;
     136         [ +  - ]:       5170 :     }
     137                 :            : }
     138                 :            : 
     139                 :        877 : void FontTable::resolveSprm(Sprm & r_Sprm)
     140                 :            : {
     141         [ +  - ]:        877 :     writerfilter::Reference<Properties>::Pointer_t pProperties = r_Sprm.getProps();
     142         [ +  - ]:        877 :     if( pProperties.get())
     143 [ +  - ][ +  - ]:        877 :         pProperties->resolve(*this);
     144                 :        877 : }
     145                 :            : 
     146                 :       2203 : void FontTable::lcl_entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref)
     147                 :            : {
     148                 :            :     //create a new font entry
     149                 :            :     OSL_ENSURE( !m_pImpl->pCurrentEntry, "current entry has to be NULL here");
     150                 :       2203 :     m_pImpl->pCurrentEntry.reset(new FontEntry);
     151                 :       2203 :     ref->resolve(*this);
     152                 :            :     //append it to the table
     153                 :       2203 :     m_pImpl->aFontEntries.push_back( m_pImpl->pCurrentEntry );
     154                 :       2203 :     m_pImpl->pCurrentEntry.reset();
     155                 :       2203 : }
     156                 :            : 
     157                 :          0 : void FontTable::lcl_startSectionGroup()
     158                 :            : {
     159                 :          0 : }
     160                 :            : 
     161                 :          0 : void FontTable::lcl_endSectionGroup()
     162                 :            : {
     163                 :          0 : }
     164                 :            : 
     165                 :          0 : void FontTable::lcl_startParagraphGroup()
     166                 :            : {
     167                 :          0 : }
     168                 :            : 
     169                 :          0 : void FontTable::lcl_endParagraphGroup()
     170                 :            : {
     171                 :          0 : }
     172                 :            : 
     173                 :          0 : void FontTable::lcl_startCharacterGroup()
     174                 :            : {
     175                 :          0 : }
     176                 :            : 
     177                 :          0 : void FontTable::lcl_endCharacterGroup()
     178                 :            : {
     179                 :          0 : }
     180                 :            : 
     181                 :          0 : void FontTable::lcl_text(const sal_uInt8*, size_t )
     182                 :            : {
     183                 :          0 : }
     184                 :            : 
     185                 :          0 : void FontTable::lcl_utext(const sal_uInt8* , size_t)
     186                 :            : {
     187                 :          0 : }
     188                 :            : 
     189                 :          0 : void FontTable::lcl_props(writerfilter::Reference<Properties>::Pointer_t)
     190                 :            : {
     191                 :          0 : }
     192                 :            : 
     193                 :          0 : void FontTable::lcl_table(Id, writerfilter::Reference<Table>::Pointer_t)
     194                 :            : {
     195                 :          0 : }
     196                 :            : 
     197                 :          0 : void FontTable::lcl_substream(Id, ::writerfilter::Reference<Stream>::Pointer_t)
     198                 :            : {
     199                 :          0 : }
     200                 :            : 
     201                 :          0 : void FontTable::lcl_info(const string& )
     202                 :            : {
     203                 :          0 : }
     204                 :            : 
     205                 :          0 : void FontTable::lcl_startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > )
     206                 :            : {
     207                 :          0 : }
     208                 :            : 
     209                 :          0 : void FontTable::lcl_endShape( )
     210                 :            : {
     211                 :          0 : }
     212                 :            : 
     213                 :      14259 : const FontEntry::Pointer_t FontTable::getFontEntry(sal_uInt32 nIndex)
     214                 :            : {
     215                 :      14259 :     return (m_pImpl->aFontEntries.size() > nIndex)
     216                 :      14259 :         ?   m_pImpl->aFontEntries[nIndex]
     217         [ +  - ]:      28518 :         :   FontEntry::Pointer_t();
     218                 :            : }
     219                 :            : 
     220                 :      14591 : sal_uInt32 FontTable::size()
     221                 :            : {
     222                 :      14591 :     return m_pImpl->aFontEntries.size();
     223                 :            : }
     224                 :            : 
     225                 :            : }//namespace dmapper
     226 [ +  - ][ +  - ]:         60 : }//namespace writerfilter
     227                 :            : 
     228                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10