fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / hwpfilter / source / hutil.cxx
blob2faf89897a81137894912ddb7c8917443147f972
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
22 #include <ctype.h>
23 #include "hwpfile.h"
24 #include "hbox.h"
25 #include "hutil.h"
27 static char *get_one_roman(int num, char one, char five, char ten, char *str)
29 static const char *one_strs[] =
31 "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"
34 strcpy(str, one_strs[num]);
35 while (*str)
37 switch (*str)
39 case 'i':
40 *str = one;
41 break;
42 case 'v':
43 *str = five;
44 break;
45 case 'x':
46 *str = ten;
48 str++;
50 return str;
54 void num2roman(int num, char *buf)
56 char *pt;
58 pt = get_one_roman((num / 100) % 10, 'c', 'd', 'm', buf);
59 pt = get_one_roman((num / 10) % 10, 'x', 'l', 'c', pt);
60 get_one_roman(num % 10, 'i', 'v', 'x', pt);
64 void str2hstr(const char *c, hchar * i)
66 hchar ch;
68 while( 0 != (ch = *c++))
70 if (ch & 0x80)
72 if (*c > 32)
74 *i++ = (ch << 8) | *c;
75 c++;
78 else
79 *i++ = ch;
81 *i = 0;
85 int hstrlen(const hchar * s)
87 int n = 0;
89 while (*s++)
90 n++;
91 return n;
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */