Bump for 3.6-28
[LibreOffice.git] / hwpfilter / source / hfont.cxx
blob12c8705ba17fbf5f3c831a06713db6bb76f1c628
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "precompile.h"
30 #include "hwplib.h"
31 #include "hwpfile.h"
32 #include "hfont.h"
33 /* ÀÌ ÇÔ¼ö´Â HWP ÆÄÀÏÀ» Çؼ®ÇÏ´Â ºÎºÐÀÌ´Ù. */
35 HWPFont::HWPFont(void)
37 for (int ii = 0; ii < NLanguage; ii++)
39 nFonts[ii] = 0;
40 fontnames[ii] = NULL;
45 HWPFont::~HWPFont(void)
47 for (int ii = 0; ii < NLanguage; ii++)
49 nFonts[ii] = 0;
50 delete[]fontnames[ii];
55 int HWPFont::AddFont(int lang, const char *font)
57 int nfonts;
59 if (!(lang >= 0 && lang < NLanguage))
60 return 0;
61 nfonts = nFonts[lang];
62 if (MAXFONTS <= nfonts)
63 return 0;
64 strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1);
65 nFonts[lang]++;
66 return nfonts;
70 const char *HWPFont::GetFontName(int lang, int id)
72 if (!(lang >= 0 && lang < NLanguage))
73 return 0;
74 if (id < 0 || nFonts[lang] <= id)
75 return 0;
76 return fontnames[lang] + id * FONTNAMELEN;
80 static char buffer[FONTNAMELEN];
82 bool HWPFont::Read(HWPFile & hwpf)
84 int lang = 0;
85 short nfonts = 0;
87 //printf("HWPFont::Read : lang = %d\n",NLanguage);
88 for(lang = 0; lang < NLanguage; lang++)
90 hwpf.Read2b(&nfonts, 1);
91 if (!(nfonts > 0 && nfonts < MAXFONTS))
93 return !hwpf.SetState(HWP_InvalidFileFormat);
95 fontnames[lang] = new char[nfonts * FONTNAMELEN];
97 memset(fontnames[lang], 0, nfonts * FONTNAMELEN);
98 for (int jj = 0; jj < nfonts; jj++)
100 hwpf.ReadBlock(buffer, FONTNAMELEN);
101 AddFont(lang, buffer);
105 return !hwpf.State();
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */