Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/tools/emfpcustomlinecap.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 "emfpcustomlinecap.hxx"
22
#include "emfppath.hxx"
23
#include <basegfx/matrix/b2dhommatrixtools.hxx>
24
25
using namespace ::com::sun::star;
26
using namespace ::basegfx;
27
28
namespace emfplushelper
29
{
30
    const sal_uInt32 EmfPlusCustomLineCapDataTypeDefault = 0x00000000;
31
    const sal_uInt32 EmfPlusCustomLineCapDataTypeAdjustableArrow = 0x00000001;
32
    const sal_uInt32 EmfPlusCustomLineCapDataFillPath = 0x00000001;
33
    const sal_uInt32 EmfPlusCustomLineCapDataLinePath = 0x00000002;
34
35
    EMFPCustomLineCap::EMFPCustomLineCap()
36
0
        : EMFPObject()
37
0
        , type(0)
38
0
        , strokeStartCap(0)
39
0
        , strokeEndCap(0)
40
0
        , strokeJoin(0)
41
0
        , miterLimit(0.0)
42
0
        , widthScale(0.0)
43
0
        , mbIsFilled(false)
44
0
    {
45
0
    }
46
47
    void EMFPCustomLineCap::ReadPath(SvStream& s, EmfPlusHelperData const & rR, bool bFill)
48
0
    {
49
0
        sal_Int32 pathLength(0);
50
0
        s.ReadInt32(pathLength);
51
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tpath length: " << pathLength);
52
0
        sal_uInt32 pathHeader(0);
53
0
        sal_Int32 pathPoints(0), pathFlags(0);
54
0
        s.ReadUInt32(pathHeader).ReadInt32(pathPoints).ReadInt32(pathFlags);
55
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tpath (custom cap line path)");
56
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec);
57
58
0
        EMFPPath path(pathPoints);
59
0
        path.Read(s, pathFlags);
60
0
        polygon = path.GetPolygon(rR, false);
61
        // rotate polygon by 180 degrees
62
0
        polygon.transform(basegfx::utils::createRotateB2DHomMatrix(M_PI));
63
0
        mbIsFilled = bFill;
64
0
    }
65
66
    void EMFPCustomLineCap::Read(SvStream& s, EmfPlusHelperData const & rR)
67
0
    {
68
0
        sal_uInt32 header(0);
69
0
        s.ReadUInt32(header).ReadUInt32(type);
70
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tcustom cap");
71
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\theader: 0x" << std::hex << header << " type: " << type << std::dec);
72
73
0
        if (type == EmfPlusCustomLineCapDataTypeDefault)
74
0
        {
75
0
            sal_uInt32 customLineCapDataFlags(0), baseCap(0);
76
0
            float baseInset(0);
77
0
            float fillHotSpotX(0), fillHotSpotY(0), strokeHotSpotX(0), strokeHotSpotY(0);
78
79
0
            s.ReadUInt32(customLineCapDataFlags).ReadUInt32(baseCap).ReadFloat(baseInset)
80
0
                .ReadUInt32(strokeStartCap).ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin)
81
0
                .ReadFloat(miterLimit).ReadFloat(widthScale)
82
0
                .ReadFloat(fillHotSpotX).ReadFloat(fillHotSpotY).ReadFloat(strokeHotSpotX).ReadFloat(strokeHotSpotY);
83
84
0
            SAL_INFO("drawinglayer.emf", "EMF+\t\tcustomLineCapDataFlags: 0x" << std::hex << customLineCapDataFlags);
85
0
            SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseCap: 0x" << std::hex << baseCap);
86
0
            SAL_INFO("drawinglayer.emf", "EMF+\t\tbaseInset: " << baseInset);
87
88
0
            if (customLineCapDataFlags & EmfPlusCustomLineCapDataFillPath)
89
0
            {
90
0
                ReadPath(s, rR, true);
91
0
            }
92
93
0
            if (customLineCapDataFlags & EmfPlusCustomLineCapDataLinePath)
94
0
            {
95
0
                ReadPath(s, rR, false);
96
0
            }
97
0
        }
98
0
        else if (type == EmfPlusCustomLineCapDataTypeAdjustableArrow)
99
0
        {
100
            // TODO only reads the data, does not use them [I've had
101
            // no test document to be able to implement it]
102
103
0
            sal_Int32 fillState(0);
104
0
            float width(0), height(0), middleInset(0), unusedHotSpot(0);
105
106
0
            s.ReadFloat(width).ReadFloat(height).ReadFloat(middleInset).ReadInt32(fillState).ReadUInt32(strokeStartCap)
107
0
                .ReadUInt32(strokeEndCap).ReadUInt32(strokeJoin).ReadFloat(miterLimit).ReadFloat(widthScale)
108
0
                .ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot).ReadFloat(unusedHotSpot);
109
110
0
            SAL_INFO("drawinglayer.emf", "EMF+\t\tTODO - actually read EmfPlusCustomLineCapArrowData object (section 2.2.2.12)");
111
0
        }
112
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeStartCap: 0x" << std::hex << strokeStartCap);
113
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeEndCap: 0x" << std::hex << strokeEndCap);
114
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tstrokeJoin: 0x" << std::hex << strokeJoin);
115
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\tmiterLimit: " << miterLimit);
116
0
        SAL_INFO("drawinglayer.emf", "EMF+\t\twidthScale: " << widthScale);
117
0
    }
118
}
119
120
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */