1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "precompile.h"
24 /* ÀÌ ÇÔ¼ö´Â HWP ÆÄÀÏÀ» Çؼ®ÇÏ´Â ºÎºÐÀÌ´Ù. */
26 HWPFont::HWPFont(void)
28 for (int ii
= 0; ii
< NLanguage
; ii
++)
36 HWPFont::~HWPFont(void)
38 for (int ii
= 0; ii
< NLanguage
; ii
++)
41 delete[]fontnames
[ii
];
46 int HWPFont::AddFont(int lang
, const char *font
)
50 if (!(lang
>= 0 && lang
< NLanguage
))
52 nfonts
= nFonts
[lang
];
53 if (MAXFONTS
<= nfonts
)
55 strncpy(fontnames
[lang
] + FONTNAMELEN
* nfonts
, font
, FONTNAMELEN
- 1);
61 const char *HWPFont::GetFontName(int lang
, int id
)
63 if (!(lang
>= 0 && lang
< NLanguage
))
65 if (id
< 0 || nFonts
[lang
] <= id
)
67 return fontnames
[lang
] + id
* FONTNAMELEN
;
71 static char buffer
[FONTNAMELEN
];
73 bool HWPFont::Read(HWPFile
& hwpf
)
78 //printf("HWPFont::Read : lang = %d\n",NLanguage);
79 for(lang
= 0; lang
< NLanguage
; lang
++)
81 hwpf
.Read2b(&nfonts
, 1);
82 if (!(nfonts
> 0 && nfonts
< MAXFONTS
))
84 return !hwpf
.SetState(HWP_InvalidFileFormat
);
86 fontnames
[lang
] = new char[nfonts
* FONTNAMELEN
];
88 memset(fontnames
[lang
], 0, nfonts
* FONTNAMELEN
);
89 for (int jj
= 0; jj
< nfonts
; jj
++)
91 hwpf
.ReadBlock(buffer
, FONTNAMELEN
);
92 AddFont(lang
, buffer
);
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */