Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <svx/svdhlpln.hxx>
31 : :
32 : : #include <vcl/outdev.hxx>
33 : : #include <vcl/window.hxx>
34 : : #include <tools/poly.hxx>
35 : : #include <vcl/lineinfo.hxx>
36 : :
37 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
38 : :
39 : 0 : Pointer SdrHelpLine::GetPointer() const
40 : : {
41 [ # # # ]: 0 : switch (eKind) {
42 : 0 : case SDRHELPLINE_VERTICAL : return Pointer(POINTER_ESIZE);
43 : 0 : case SDRHELPLINE_HORIZONTAL: return Pointer(POINTER_SSIZE);
44 : 0 : default : return Pointer(POINTER_MOVE);
45 : : } // switch
46 : : }
47 : :
48 : 0 : bool SdrHelpLine::IsHit(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
49 : : {
50 [ # # ]: 0 : Size a1Pix(rOut.PixelToLogic(Size(1,1)));
51 [ # # ][ # # ]: 0 : bool bXHit=rPnt.X()>=aPos.X()-nTolLog && rPnt.X()<=aPos.X()+nTolLog+a1Pix.Width();
52 [ # # ][ # # ]: 0 : bool bYHit=rPnt.Y()>=aPos.Y()-nTolLog && rPnt.Y()<=aPos.Y()+nTolLog+a1Pix.Height();
53 [ # # # # ]: 0 : switch (eKind) {
54 : 0 : case SDRHELPLINE_VERTICAL : return bXHit;
55 : 0 : case SDRHELPLINE_HORIZONTAL: return bYHit;
56 : : case SDRHELPLINE_POINT: {
57 [ # # ][ # # ]: 0 : if (bXHit || bYHit) {
58 [ # # ]: 0 : Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
59 : 0 : return rPnt.X()>=aPos.X()-aRad.Width() && rPnt.X()<=aPos.X()+aRad.Width()+a1Pix.Width() &&
60 [ # # ][ # # ]: 0 : rPnt.Y()>=aPos.Y()-aRad.Height() && rPnt.Y()<=aPos.Y()+aRad.Height()+a1Pix.Height();
[ # # # # ]
61 : : }
62 : 0 : } break;
63 : : } // switch
64 : 0 : return sal_False;
65 : : }
66 : :
67 : 0 : Rectangle SdrHelpLine::GetBoundRect(const OutputDevice& rOut) const
68 : : {
69 [ # # ]: 0 : Rectangle aRet(aPos,aPos);
70 : 0 : Point aOfs(rOut.GetMapMode().GetOrigin());
71 [ # # ]: 0 : Size aSiz(rOut.GetOutputSize());
72 [ # # # # ]: 0 : switch (eKind) {
73 : 0 : case SDRHELPLINE_VERTICAL : aRet.Top()=-aOfs.Y(); aRet.Bottom()=-aOfs.Y()+aSiz.Height(); break;
74 : 0 : case SDRHELPLINE_HORIZONTAL: aRet.Left()=-aOfs.X(); aRet.Right()=-aOfs.X()+aSiz.Width(); break;
75 : : case SDRHELPLINE_POINT : {
76 [ # # ]: 0 : Size aRad(rOut.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE,SDRHELPLINE_POINT_PIXELSIZE)));
77 : 0 : aRet.Left() -=aRad.Width();
78 : 0 : aRet.Right() +=aRad.Width();
79 : 0 : aRet.Top() -=aRad.Height();
80 : 0 : aRet.Bottom()+=aRad.Height();
81 : 0 : } break;
82 : : } // switch
83 : 0 : return aRet;
84 : : }
85 : :
86 : 5153 : void SdrHelpLineList::Clear()
87 : : {
88 : 5153 : sal_uInt16 nAnz=GetCount();
89 [ - + ]: 5153 : for (sal_uInt16 i=0; i<nAnz; i++) {
90 : 0 : delete GetObject(i);
91 : : }
92 : 5153 : aList.clear();
93 : 5153 : }
94 : :
95 : 1095 : void SdrHelpLineList::operator=(const SdrHelpLineList& rSrcList)
96 : : {
97 : 1095 : Clear();
98 : 1095 : sal_uInt16 nAnz=rSrcList.GetCount();
99 [ - + ]: 1095 : for (sal_uInt16 i=0; i<nAnz; i++) {
100 : 0 : Insert(rSrcList[i]);
101 : : }
102 : 1095 : }
103 : :
104 : 405 : bool SdrHelpLineList::operator==(const SdrHelpLineList& rSrcList) const
105 : : {
106 : 405 : bool bEqual = false;
107 : 405 : sal_uInt16 nAnz=GetCount();
108 [ + - ]: 405 : if (nAnz==rSrcList.GetCount()) {
109 : 405 : bEqual = true;
110 [ - + ][ # # ]: 405 : for (sal_uInt16 i=0; i<nAnz && bEqual; i++) {
[ - + ]
111 [ # # ]: 0 : if (*GetObject(i)!=*rSrcList.GetObject(i)) {
112 : 0 : bEqual = false;
113 : : }
114 : : }
115 : : }
116 : 405 : return bEqual;
117 : : }
118 : :
119 : 0 : sal_uInt16 SdrHelpLineList::HitTest(const Point& rPnt, sal_uInt16 nTolLog, const OutputDevice& rOut) const
120 : : {
121 : 0 : sal_uInt16 nAnz=GetCount();
122 [ # # ]: 0 : for (sal_uInt16 i=nAnz; i>0;) {
123 : 0 : i--;
124 [ # # ]: 0 : if (GetObject(i)->IsHit(rPnt,nTolLog,rOut)) return i;
125 : : }
126 : 0 : return SDRHELPLINE_NOTFOUND;
127 : : }
128 : :
129 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|