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 <sal/log.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include "emfpfont.hxx"
24 namespace emfplushelper
26 static OUString
FontStyleToString(sal_uInt32 style
)
28 OUStringBuffer sStyle
;
30 if (style
& FontStyleBold
)
31 sStyle
= "\n\t\t\tFontStyleBold";
33 if (style
& FontStyleItalic
)
34 sStyle
.append("\n\t\t\tFontStyleItalic");
36 if (style
& FontStyleUnderline
)
37 sStyle
.append("\n\t\t\tFontStyleUnderline");
39 if (style
& FontStyleStrikeout
)
40 sStyle
.append("\n\t\t\tFontStyleStrikeout");
42 return sStyle
.makeStringAndClear();
45 void EMFPFont::Read(SvMemoryStream
&s
)
50 s
.ReadUInt32(header
).ReadFloat(emSize
).ReadUInt32(sizeUnit
).ReadInt32(fontFlags
).ReadUInt32(reserved
).ReadUInt32(length
);
51 SAL_WARN_IF((header
>> 12) != 0xdbc01, "drawinglayer.emf", "Invalid header - not 0xdbc01");
52 SAL_INFO("drawinglayer.emf", "EMF+\tHeader: 0x" << std::hex
<< (header
>> 12));
53 SAL_INFO("drawinglayer.emf", "EMF+\tVersion: 0x" << (header
& 0x1fff));
54 SAL_INFO("drawinglayer.emf", "EMF+\tSize: " << std::dec
<< emSize
);
55 SAL_INFO("drawinglayer.emf", "EMF+\tUnit: " << UnitTypeToString(sizeUnit
) << " (0x" << std::hex
<< sizeUnit
<< ")" << std::dec
);
56 SAL_INFO("drawinglayer.emf", "EMF+\tFlags: " << FontStyleToString(fontFlags
) << " (0x" << std::hex
<< fontFlags
<< ")");
57 SAL_INFO("drawinglayer.emf", "EMF+\tReserved: 0x" << reserved
<< std::dec
);
58 SAL_INFO("drawinglayer.emf", "EMF+\tLength: " << length
);
60 if (length
<= 0 || length
>= 0x4000)
63 rtl_uString
*pStr
= rtl_uString_alloc(length
);
64 sal_Unicode
*chars
= pStr
->buffer
;
66 for (sal_uInt32 i
= 0; i
< length
; ++i
)
68 s
.ReadUtf16(chars
[i
]);
71 family
= OUString(pStr
, SAL_NO_ACQUIRE
);
72 SAL_INFO("drawinglayer.emf", "EMF+\tFamily: " << family
);
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */