1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hfont.cpp,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 /* $Id: hfont.cpp,v 1.4 2008-06-04 09:56:49 vg Exp $ */
33 #include "precompile.h"
37 /* ÀÌ ÇÔ¼ö´Â HWP ÆÄÀÏÀ» Çؼ®ÇÏ´Â ºÎºÐÀÌ´Ù. */
39 HWPFont::HWPFont(void)
41 for (int ii
= 0; ii
< NLanguage
; ii
++)
49 HWPFont::~HWPFont(void)
51 for (int ii
= 0; ii
< NLanguage
; ii
++)
54 delete[]fontnames
[ii
];
59 int HWPFont::AddFont(int lang
, const char *font
)
63 if (!(lang
>= 0 && lang
< NLanguage
))
65 nfonts
= nFonts
[lang
];
66 if (MAXFONTS
<= nfonts
)
68 strncpy(fontnames
[lang
] + FONTNAMELEN
* nfonts
, font
, FONTNAMELEN
- 1);
74 const char *HWPFont::GetFontName(int lang
, int id
)
76 if (!(lang
>= 0 && lang
< NLanguage
))
78 if (id
< 0 || nFonts
[lang
] <= id
)
80 return fontnames
[lang
] + id
* FONTNAMELEN
;
84 static char buffer
[FONTNAMELEN
];
86 bool HWPFont::Read(HWPFile
& hwpf
)
91 //printf("HWPFont::Read : lang = %d\n",NLanguage);
92 for(lang
= 0; lang
< NLanguage
; lang
++)
94 hwpf
.Read2b(&nfonts
, 1);
95 if (!(nfonts
> 0 && nfonts
< MAXFONTS
))
97 return !hwpf
.SetState(HWP_InvalidFileFormat
);
99 fontnames
[lang
] = new char[nfonts
* FONTNAMELEN
];
101 memset(fontnames
[lang
], 0, nfonts
* FONTNAMELEN
);
102 for (int jj
= 0; jj
< nfonts
; jj
++)
104 hwpf
.ReadBlock(buffer
, FONTNAMELEN
);
105 AddFont(lang
, buffer
);
109 return !hwpf
.State();