LibreOffice Module svx (master) 1
svdhlpln.cxx
Go to the documentation of this file.
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
28{
29 switch (eKind) {
30 case SdrHelpLineKind::Vertical : return PointerStyle::ESize;
31 case SdrHelpLineKind::Horizontal: return PointerStyle::SSize;
32 default : return PointerStyle::Move;
33 } // switch
34}
35
36bool SdrHelpLine::IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
37{
38 Size a1Pix(rOut.PixelToLogic(Size(1,1)));
39 bool bXHit=rPnt.X()>=aPos.X()-nTolLog && rPnt.X()<=aPos.X()+nTolLog+a1Pix.Width();
40 bool bYHit=rPnt.Y()>=aPos.Y()-nTolLog && rPnt.Y()<=aPos.Y()+nTolLog+a1Pix.Height();
41 switch (eKind) {
42 case SdrHelpLineKind::Vertical : return bXHit;
43 case SdrHelpLineKind::Horizontal: return bYHit;
45 if (bXHit || bYHit) {
47 return rPnt.X()>=aPos.X()-aRad.Width() && rPnt.X()<=aPos.X()+aRad.Width()+a1Pix.Width() &&
48 rPnt.Y()>=aPos.Y()-aRad.Height() && rPnt.Y()<=aPos.Y()+aRad.Height()+a1Pix.Height();
49 }
50 } break;
51 } // switch
52 return false;
53}
54
56{
58 Point aOfs(rOut.GetMapMode().GetOrigin());
59 Size aSiz(rOut.GetOutputSize());
60 switch (eKind) {
61 case SdrHelpLineKind::Vertical : aRet.SetTop(-aOfs.Y() ); aRet.SetBottom(-aOfs.Y()+aSiz.Height() ); break;
62 case SdrHelpLineKind::Horizontal: aRet.SetLeft(-aOfs.X() ); aRet.SetRight(-aOfs.X()+aSiz.Width() ); break;
65 aRet.AdjustLeft( -(aRad.Width()) );
66 aRet.AdjustRight(aRad.Width() );
67 aRet.AdjustTop( -(aRad.Height()) );
68 aRet.AdjustBottom(aRad.Height() );
69 } break;
70 } // switch
71 return aRet;
72}
73
75{
76 aList.clear();
77 sal_uInt16 nCount=rSrcList.GetCount();
78 for (sal_uInt16 i=0; i<nCount; i++) {
79 Insert(rSrcList[i]);
80 }
81 return *this;
82}
83
85{
86 bool bEqual = false;
87 sal_uInt16 nCount=GetCount();
88 if (nCount==rSrcList.GetCount()) {
89 bEqual = true;
90 for (sal_uInt16 i=0; i<nCount && bEqual; i++) {
91 if (*aList[i]!=*rSrcList.aList[i]) {
92 bEqual = false;
93 }
94 }
95 }
96 return bEqual;
97}
98
99sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
100{
101 sal_uInt16 nCount=GetCount();
102 for (sal_uInt16 i=nCount; i>0;) {
103 i--;
104 if (aList[i]->IsHit(rPnt,nTolLog,rOut)) return i;
105 }
107}
108
109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const Point & GetOrigin() const
Size GetOutputSize() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
const MapMode & GetMapMode() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
void Insert(const SdrHelpLine &rHL)
Definition: svdhlpln.hxx:71
sal_uInt16 GetCount() const
Definition: svdhlpln.hxx:70
bool operator==(const SdrHelpLineList &rCmp) const
Definition: svdhlpln.cxx:84
SdrHelpLineList & operator=(const SdrHelpLineList &rSrcList)
Definition: svdhlpln.cxx:74
sal_uInt16 HitTest(const Point &rPnt, sal_uInt16 nTolLog, const OutputDevice &rOut) const
Definition: svdhlpln.cxx:99
std::vector< std::unique_ptr< SdrHelpLine > > aList
Definition: svdhlpln.hxx:62
PointerStyle GetPointer() const
Definition: svdhlpln.cxx:27
tools::Rectangle GetBoundRect(const OutputDevice &rOut) const
Definition: svdhlpln.cxx:55
Point aPos
Definition: svdhlpln.hxx:39
bool IsHit(const Point &rPnt, sal_uInt16 nTolLog, const OutputDevice &rOut) const
Definition: svdhlpln.cxx:36
SdrHelpLineKind eKind
Definition: svdhlpln.hxx:40
constexpr tools::Long Height() const
constexpr tools::Long Width() const
constexpr void SetLeft(tools::Long v)
constexpr void SetTop(tools::Long v)
constexpr void SetRight(tools::Long v)
tools::Long AdjustTop(tools::Long nVertMoveDelta)
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
constexpr void SetBottom(tools::Long v)
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
int nCount
int i
PointerStyle
#define SDRHELPLINE_POINT_PIXELSIZE
Definition: svdhlpln.hxx:36
#define SDRHELPLINE_NOTFOUND
Definition: svdhlpln.hxx:59