1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libodfgen
3 * Version: MPL 2.0 / LGPLv2.1+
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 * Alternatively, the contents of this file may be used under the terms
10 * of the GNU Lesser General Public License Version 2.1 or later
11 * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
12 * applicable instead of those above.
13 *
14 * For further information visit http://libwpd.sourceforge.net
15 */
16
17 #include "FilterInternal.hxx"
18
19 #include "DocumentElement.hxx"
20
21 #include <cstdarg>
22 #include <cstdio>
23
doubleToString(const double value)24 librevenge::RVNGString libodfgen::doubleToString(const double value)
25 {
26 std::unique_ptr<librevenge::RVNGProperty> prop(librevenge::RVNGPropertyFactory::newDoubleProp(value));
27 librevenge::RVNGString retVal = prop->getStr();
28 return retVal;
29 }
30
getInchValue(librevenge::RVNGProperty const & prop,double & value)31 bool libodfgen::getInchValue(librevenge::RVNGProperty const &prop, double &value)
32 {
33 value=prop.getDouble();
34 switch (prop.getUnit())
35 {
36 case librevenge::RVNG_GENERIC: // assume inch
37 case librevenge::RVNG_INCH:
38 return true;
39 case librevenge::RVNG_POINT:
40 value /= 72.;
41 return true;
42 case librevenge::RVNG_TWIP:
43 value /= 1440.;
44 return true;
45 case librevenge::RVNG_PERCENT:
46 case librevenge::RVNG_UNIT_ERROR:
47 default:
48 {
49 static bool first=true;
50 if (first)
51 {
52 ODFGEN_DEBUG_MSG(("libodfgen::getInchValue: call with no double value\n"));
53 first=false;
54 }
55 break;
56 }
57 }
58 return false;
59 }
60
61 namespace libodfgen
62 {
63
debugPrint(const char * format,...)64 void debugPrint(const char *format, ...)
65 {
66 va_list args;
67 va_start(args, format);
68 std::vfprintf(stderr, format, args);
69 va_end(args);
70 }
71
72 }
73 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
74