tdf#144694 In direct SQL dialog, activate options 'Run SQL command
[LibreOffice.git] / svx / source / svdraw / svdhlpln.cxx
blob58d0eb10c40036c7af3ce10b752debc6d4c0f9ff
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/svdhlpln.hxx>
23 #include <vcl/outdev.hxx>
24 #include <vcl/ptrstyle.hxx>
27 PointerStyle SdrHelpLine::GetPointer() const
29 switch (m_eKind) {
30 case SdrHelpLineKind::Vertical : return PointerStyle::ESize;
31 case SdrHelpLineKind::Horizontal: return PointerStyle::SSize;
32 default : return PointerStyle::Move;
33 } // switch
36 bool SdrHelpLine::IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
38 Size a1Pix(rOut.PixelToLogic(Size(1,1)));
39 bool bXHit=rPnt.X()>=m_aPos.X()-nTolLog && rPnt.X()<=m_aPos.X()+nTolLog+a1Pix.Width();
40 bool bYHit=rPnt.Y()>=m_aPos.Y()-nTolLog && rPnt.Y()<=m_aPos.Y()+nTolLog+a1Pix.Height();
41 switch (m_eKind) {
42 case SdrHelpLineKind::Vertical : return bXHit;
43 case SdrHelpLineKind::Horizontal: return bYHit;
44 case SdrHelpLineKind::Point: {
45 if (bXHit || bYHit) {
46 Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
47 return rPnt.X()>=m_aPos.X()-aRad.Width() && rPnt.X()<=m_aPos.X()+aRad.Width()+a1Pix.Width() &&
48 rPnt.Y()>=m_aPos.Y()-aRad.Height() && rPnt.Y()<=m_aPos.Y()+aRad.Height()+a1Pix.Height();
50 } break;
51 } // switch
52 return false;
55 tools::Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
57 tools::Rectangle aRet(m_aPos,m_aPos);
58 Point aOfs(rOut.GetMapMode().GetOrigin());
59 Size aSiz(rOut.GetOutputSize());
60 switch (m_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;
63 case SdrHelpLineKind::Point : {
64 Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
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;
74 SdrHelpLineList& SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
76 m_aList.clear();
77 sal_uInt16 nCount=rSrcList.GetCount();
78 for (sal_uInt16 i=0; i<nCount; i++) {
79 Insert(rSrcList[i]);
81 return *this;
84 bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
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 (*m_aList[i]!=*rSrcList.m_aList[i]) {
92 bEqual = false;
96 return bEqual;
99 sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
101 sal_uInt16 nCount=GetCount();
102 for (sal_uInt16 i=nCount; i>0;) {
103 i--;
104 if (m_aList[i]->IsHit(rPnt,nTolLog,rOut)) return i;
106 return SDRHELPLINE_NOTFOUND;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */