Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/svdraw/svdhlpln.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 <svx/svdhlpln.hxx>
22
23
#include <vcl/outdev.hxx>
24
#include <vcl/ptrstyle.hxx>
25
26
27
PointerStyle SdrHelpLine::GetPointer() const
28
0
{
29
0
    switch (m_eKind) {
30
0
        case SdrHelpLineKind::Vertical  : return PointerStyle::ESize;
31
0
        case SdrHelpLineKind::Horizontal: return PointerStyle::SSize;
32
0
        default                    : return PointerStyle::Move;
33
0
    } // switch
34
0
}
35
36
bool SdrHelpLine::IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
37
0
{
38
0
    Size a1Pix(rOut.PixelToLogic(Size(1,1)));
39
0
    bool bXHit=rPnt.X()>=m_aPos.X()-nTolLog && rPnt.X()<=m_aPos.X()+nTolLog+a1Pix.Width();
40
0
    bool bYHit=rPnt.Y()>=m_aPos.Y()-nTolLog && rPnt.Y()<=m_aPos.Y()+nTolLog+a1Pix.Height();
41
0
    switch (m_eKind) {
42
0
        case SdrHelpLineKind::Vertical  : return bXHit;
43
0
        case SdrHelpLineKind::Horizontal: return bYHit;
44
0
        case SdrHelpLineKind::Point: {
45
0
            if (bXHit || bYHit) {
46
0
                Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
47
0
                return rPnt.X()>=m_aPos.X()-aRad.Width() && rPnt.X()<=m_aPos.X()+aRad.Width()+a1Pix.Width() &&
48
0
                       rPnt.Y()>=m_aPos.Y()-aRad.Height() && rPnt.Y()<=m_aPos.Y()+aRad.Height()+a1Pix.Height();
49
0
            }
50
0
        } break;
51
0
    } // switch
52
0
    return false;
53
0
}
54
55
tools::Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
56
0
{
57
0
    tools::Rectangle aRet(m_aPos,m_aPos);
58
0
    Point aOfs(rOut.GetMapMode().GetOrigin());
59
0
    Size aSiz(rOut.GetOutputSize());
60
0
    switch (m_eKind) {
61
0
        case SdrHelpLineKind::Vertical  : aRet.SetTop(-aOfs.Y() ); aRet.SetBottom(-aOfs.Y()+aSiz.Height() ); break;
62
0
        case SdrHelpLineKind::Horizontal: aRet.SetLeft(-aOfs.X() ); aRet.SetRight(-aOfs.X()+aSiz.Width() );  break;
63
0
        case SdrHelpLineKind::Point     : {
64
0
            Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
65
0
            aRet.AdjustLeft( -(aRad.Width()) );
66
0
            aRet.AdjustRight(aRad.Width() );
67
0
            aRet.AdjustTop( -(aRad.Height()) );
68
0
            aRet.AdjustBottom(aRad.Height() );
69
0
        } break;
70
0
    } // switch
71
0
    return aRet;
72
0
}
73
74
SdrHelpLineList& SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
75
15
{
76
15
    m_aList.clear();
77
15
    sal_uInt16 nCount=rSrcList.GetCount();
78
15
    for (sal_uInt16 i=0; i<nCount; i++) {
79
0
        Insert(rSrcList[i]);
80
0
    }
81
15
    return *this;
82
15
}
83
84
bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
85
0
{
86
0
    bool bEqual = false;
87
0
    sal_uInt16 nCount=GetCount();
88
0
    if (nCount==rSrcList.GetCount()) {
89
0
        bEqual = true;
90
0
        for (sal_uInt16 i=0; i<nCount && bEqual; i++) {
91
0
            if (*m_aList[i]!=*rSrcList.m_aList[i]) {
92
0
                bEqual = false;
93
0
            }
94
0
        }
95
0
    }
96
0
    return bEqual;
97
0
}
98
99
sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
100
0
{
101
0
    sal_uInt16 nCount=GetCount();
102
0
    for (sal_uInt16 i=nCount; i>0;) {
103
0
        i--;
104
0
        if (m_aList[i]->IsHit(rPnt,nTolLog,rOut)) return i;
105
0
    }
106
0
    return SDRHELPLINE_NOTFOUND;
107
0
}
108
109
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */