Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/drawinglayer/source/processor2d/linegeometryextractor2d.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 <drawinglayer/processor2d/linegeometryextractor2d.hxx>
21
#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
22
#include <drawinglayer/primitive2d/PolygonHairlinePrimitive2D.hxx>
23
#include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
24
#include <drawinglayer/primitive2d/transformprimitive2d.hxx>
25
26
27
namespace drawinglayer::processor2d
28
{
29
        LineGeometryExtractor2D::LineGeometryExtractor2D(const geometry::ViewInformation2D& rViewInformation)
30
0
        :   BaseProcessor2D(rViewInformation),
31
0
            mbInLineGeometry(false)
32
0
        {
33
0
        }
34
35
        LineGeometryExtractor2D::~LineGeometryExtractor2D()
36
0
        {
37
0
        }
38
39
        void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
40
0
        {
41
0
            switch(rCandidate.getPrimitive2DID())
42
0
            {
43
0
                case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D :
44
0
                case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D :
45
0
                {
46
                    // enter a line geometry group (with or without LineEnds)
47
0
                    bool bOldState(mbInLineGeometry);
48
0
                    mbInLineGeometry = true;
49
0
                    process(rCandidate);
50
0
                    mbInLineGeometry = bOldState;
51
0
                    break;
52
0
                }
53
0
                case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
54
0
                {
55
0
                    if(mbInLineGeometry)
56
0
                    {
57
                        // extract hairline line geometry in world coordinates
58
0
                        const primitive2d::PolygonHairlinePrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate));
59
0
                        basegfx::B2DPolygon aLocalPolygon(rPolygonCandidate.getB2DPolygon());
60
0
                        aLocalPolygon.transform(getViewInformation2D().getObjectTransformation());
61
0
                        maExtractedHairlines.push_back(aLocalPolygon);
62
0
                    }
63
0
                    break;
64
0
                }
65
0
                case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
66
0
                {
67
0
                    if(mbInLineGeometry)
68
0
                    {
69
                        // extract filled line geometry (line with width)
70
0
                        const primitive2d::PolyPolygonColorPrimitive2D& rPolygonCandidate(static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate));
71
0
                        basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
72
0
                        aLocalPolyPolygon.transform(getViewInformation2D().getObjectTransformation());
73
0
                        maExtractedLineFills.push_back(aLocalPolyPolygon);
74
0
                    }
75
0
                    break;
76
0
                }
77
0
                case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
78
0
                {
79
                    // remember current transformation and ViewInformation
80
0
                    const primitive2d::TransformPrimitive2D& rTransformCandidate(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
81
0
                    const geometry::ViewInformation2D aLastViewInformation2D(getViewInformation2D());
82
83
                    // create new transformations for CurrentTransformation and for local ViewInformation2D
84
0
                    geometry::ViewInformation2D aViewInformation2D(getViewInformation2D());
85
0
                    aViewInformation2D.setObjectTransformation(getViewInformation2D().getObjectTransformation() * rTransformCandidate.getTransformation());
86
0
                    setViewInformation2D(aViewInformation2D);
87
88
                    // process content
89
0
                    process(rTransformCandidate.getChildren());
90
91
                    // restore transformations
92
0
                    setViewInformation2D(aLastViewInformation2D);
93
94
0
                    break;
95
0
                }
96
0
                case PRIMITIVE2D_ID_SCENEPRIMITIVE2D :
97
0
                case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
98
0
                case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
99
0
                case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
100
0
                case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
101
0
                case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
102
0
                case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
103
0
                {
104
                    // ignorable primitives
105
0
                    break;
106
0
                }
107
0
                default :
108
0
                {
109
                    // process recursively
110
0
                    process(rCandidate);
111
0
                    break;
112
0
                }
113
0
            }
114
0
        }
115
116
} // end of namespace
117
118
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */