Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/tools/emfpfont.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
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
 * This file incorporates work covered by the following license notice:
10
 *
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 .
18
 */
19
20
#include <sal/log.hxx>
21
#include <rtl/ustrbuf.hxx>
22
#include "emfpfont.hxx"
23
24
namespace emfplushelper
25
{
26
    static OUString FontStyleToString(sal_uInt32 style)
27
0
    {
28
0
        OUStringBuffer sStyle;
29
30
0
        if (style & FontStyleBold)
31
0
            sStyle = "\n\t\t\tFontStyleBold";
32
33
0
        if (style & FontStyleItalic)
34
0
            sStyle.append("\n\t\t\tFontStyleItalic");
35
36
0
        if (style & FontStyleUnderline)
37
0
            sStyle.append("\n\t\t\tFontStyleUnderline");
38
39
0
        if (style & FontStyleStrikeout)
40
0
            sStyle.append("\n\t\t\tFontStyleStrikeout");
41
42
0
        return sStyle.makeStringAndClear();
43
0
    }
44
45
    void EMFPFont::Read(SvMemoryStream &s)
46
0
    {
47
0
        sal_uInt32 header;
48
0
        sal_uInt32 reserved;
49
0
        sal_uInt32 length;
50
0
        s.ReadUInt32(header).ReadFloat(emSize).ReadUInt32(sizeUnit).ReadInt32(fontFlags).ReadUInt32(reserved).ReadUInt32(length);
51
0
        SAL_WARN_IF((header >> 12) != 0xdbc01, "drawinglayer.emf", "Invalid header - not 0xdbc01");
52
0
        SAL_INFO("drawinglayer.emf", "EMF+\tHeader: 0x" << std::hex << (header >> 12));
53
0
        SAL_INFO("drawinglayer.emf", "EMF+\tVersion: 0x" << (header & 0x1fff));
54
0
        SAL_INFO("drawinglayer.emf", "EMF+\tSize: " << std::dec << emSize);
55
0
        SAL_INFO("drawinglayer.emf", "EMF+\tUnit: " << UnitTypeToString(sizeUnit) << " (0x" << std::hex << sizeUnit << ")" << std::dec);
56
0
        SAL_INFO("drawinglayer.emf", "EMF+\tFlags: " << FontStyleToString(fontFlags) << " (0x" << std::hex << fontFlags << ")");
57
0
        SAL_INFO("drawinglayer.emf", "EMF+\tReserved: 0x" << reserved << std::dec);
58
0
        SAL_INFO("drawinglayer.emf", "EMF+\tLength: " << length);
59
60
0
        if (length <= 0 || length >= 0x4000)
61
0
            return;
62
63
0
        rtl_uString *pStr = rtl_uString_alloc(length);
64
0
        sal_Unicode *chars = pStr->buffer;
65
66
0
        for (sal_uInt32 i = 0; i < length; ++i)
67
0
        {
68
0
            s.ReadUtf16(chars[i]);
69
0
        }
70
71
0
        family = OUString(pStr, SAL_NO_ACQUIRE);
72
0
        SAL_INFO("drawinglayer.emf", "EMF+\tFamily: " << family);
73
0
    }
74
}
75
76
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */