LCOV - code coverage report
Current view: top level - hwpfilter/source - hfont.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 38 0.0 %
Date: 2014-04-14 Functions: 0 5 0.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 "precompile.h"
      21             : #include "hwplib.h"
      22             : #include "hwpfile.h"
      23             : #include "hfont.h"
      24             : /* ÀÌ ÇÔ¼ö´Â HWP ÆÄÀÏÀ» Çؼ®ÇÏ´Â ºÎºÐÀÌ´Ù. */
      25             : 
      26           0 : HWPFont::HWPFont(void)
      27             : {
      28           0 :     for (int ii = 0; ii < NLanguage; ii++)
      29             :     {
      30           0 :         nFonts[ii] = 0;
      31           0 :         fontnames[ii] = NULL;
      32             :     }
      33           0 : }
      34             : 
      35             : 
      36           0 : HWPFont::~HWPFont(void)
      37             : {
      38           0 :     for (int ii = 0; ii < NLanguage; ii++)
      39             :     {
      40           0 :         nFonts[ii] = 0;
      41           0 :         delete[]fontnames[ii];
      42             :     }
      43           0 : }
      44             : 
      45             : 
      46           0 : int HWPFont::AddFont(int lang, const char *font)
      47             : {
      48             :     int nfonts;
      49             : 
      50           0 :     if (!(lang >= 0 && lang < NLanguage))
      51           0 :         return 0;
      52           0 :     nfonts = nFonts[lang];
      53           0 :     if (MAXFONTS <= nfonts)
      54           0 :         return 0;
      55           0 :     strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1);
      56           0 :     nFonts[lang]++;
      57           0 :     return nfonts;
      58             : }
      59             : 
      60             : 
      61           0 : const char *HWPFont::GetFontName(int lang, int id)
      62             : {
      63           0 :     if (!(lang >= 0 && lang < NLanguage))
      64           0 :         return 0;
      65           0 :     if (id < 0 || nFonts[lang] <= id)
      66           0 :         return 0;
      67           0 :     return fontnames[lang] + id * FONTNAMELEN;
      68             : }
      69             : 
      70             : 
      71             : static char buffer[FONTNAMELEN];
      72             : 
      73           0 : bool HWPFont::Read(HWPFile & hwpf)
      74             : {
      75           0 :     int lang = 0;
      76           0 :     short nfonts = 0;
      77             : 
      78             : //printf("HWPFont::Read : lang = %d\n",NLanguage);
      79           0 :     for(lang = 0; lang < NLanguage; lang++)
      80             :     {
      81           0 :         hwpf.Read2b(&nfonts, 1);
      82           0 :         if (!(nfonts > 0 && nfonts < MAXFONTS))
      83             :         {
      84           0 :             return !hwpf.SetState(HWP_InvalidFileFormat);
      85             :         }
      86           0 :         fontnames[lang] = new char[nfonts * FONTNAMELEN];
      87             : 
      88           0 :         memset(fontnames[lang], 0, nfonts * FONTNAMELEN);
      89           0 :         for (int jj = 0; jj < nfonts; jj++)
      90             :         {
      91           0 :             hwpf.ReadBlock(buffer, FONTNAMELEN);
      92           0 :             AddFont(lang, buffer);
      93             :         }
      94             :     }
      95             : 
      96           0 :     return !hwpf.State();
      97             : }
      98             : 
      99             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10