Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/sdr/contact/viewcontactofsdrcircobj.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
21
#include <sdr/contact/viewcontactofsdrcircobj.hxx>
22
#include <svx/svdocirc.hxx>
23
#include <svx/sdangitm.hxx>
24
#include <sdr/primitive2d/sdrattributecreator.hxx>
25
#include <sdr/primitive2d/sdrellipseprimitive2d.hxx>
26
#include <svl/itemset.hxx>
27
#include <basegfx/matrix/b2dhommatrixtools.hxx>
28
#include <vcl/canvastools.hxx>
29
30
31
namespace sdr::contact
32
{
33
        ViewContactOfSdrCircObj::ViewContactOfSdrCircObj(SdrCircObj& rCircObj)
34
15.3k
        :   ViewContactOfSdrRectObj(rCircObj)
35
15.3k
        {
36
15.3k
        }
37
38
        ViewContactOfSdrCircObj::~ViewContactOfSdrCircObj()
39
15.3k
        {
40
15.3k
        }
41
42
        void ViewContactOfSdrCircObj::createViewIndependentPrimitive2DSequence(drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const
43
0
        {
44
0
            const SfxItemSet& rItemSet = GetCircObj().GetMergedItemSet();
45
0
            const drawinglayer::attribute::SdrLineFillEffectsTextAttribute aAttribute(
46
0
                drawinglayer::primitive2d::createNewSdrLineFillEffectsTextAttribute(
47
0
                    rItemSet,
48
0
                    GetCircObj().getText(0),
49
0
                    false));
50
51
            // take unrotated snap rect (direct model data) for position and size
52
0
            const basegfx::B2DRange aObjectRange = vcl::unotools::b2DRectangleFromRectangle(GetCircObj().GetGeoRect());
53
0
            const GeoStat& rGeoStat(GetCircObj().GetGeoStat());
54
55
            // fill object matrix
56
0
            const basegfx::B2DHomMatrix aObjectMatrix(
57
0
                basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
58
0
                    aObjectRange.getWidth(), aObjectRange.getHeight(),
59
0
                    -rGeoStat.mfTanShearAngle,
60
0
                    rGeoStat.m_nRotationAngle ? toRadians(36000_deg100 - rGeoStat.m_nRotationAngle) : 0.0,
61
0
                    aObjectRange.getMinX(), aObjectRange.getMinY()));
62
63
            // create primitive data
64
0
            const SdrObjKind nIdentifier(GetCircObj().GetObjIdentifier());
65
66
            // always create primitives to allow the decomposition of SdrEllipsePrimitive2D
67
            // or SdrEllipseSegmentPrimitive2D to create needed invisible elements for HitTest
68
            // and/or BoundRect
69
0
            if(SdrObjKind::CircleOrEllipse == nIdentifier)
70
0
            {
71
0
                const drawinglayer::primitive2d::Primitive2DReference xReference(
72
0
                    new drawinglayer::primitive2d::SdrEllipsePrimitive2D(
73
0
                        aObjectMatrix,
74
0
                        aAttribute));
75
76
0
                rVisitor.visit(xReference);
77
0
            }
78
0
            else
79
0
            {
80
0
                const auto nNewStart(rItemSet.Get(SDRATTR_CIRCSTARTANGLE).GetValue());
81
0
                const auto nNewEnd(rItemSet.Get(SDRATTR_CIRCENDANGLE).GetValue());
82
0
                const double fStart(toRadians((36000_deg100 - nNewEnd) % 36000_deg100));
83
0
                const double fEnd(toRadians((36000_deg100 - nNewStart) % 36000_deg100));
84
0
                const bool bCloseSegment(SdrObjKind::CircleArc != nIdentifier);
85
0
                const bool bCloseUsingCenter(SdrObjKind::CircleSection == nIdentifier);
86
87
0
                const drawinglayer::primitive2d::Primitive2DReference xReference(
88
0
                    new drawinglayer::primitive2d::SdrEllipseSegmentPrimitive2D(
89
0
                        aObjectMatrix,
90
0
                        aAttribute,
91
0
                        fStart,
92
0
                        fEnd,
93
0
                        bCloseSegment,
94
0
                        bCloseUsingCenter));
95
96
0
                rVisitor.visit(xReference);
97
0
            }
98
0
        }
99
100
} // end of namespace
101
102
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */