1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdhlpln.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svdhlpln.hxx>
35 #include <tools/color.hxx>
37 #include <vcl/outdev.hxx>
38 #include <vcl/window.hxx>
39 #include <tools/poly.hxx>
40 #include <vcl/lineinfo.hxx>
42 ////////////////////////////////////////////////////////////////////////////////////////////////////
44 Pointer
SdrHelpLine::GetPointer() const
47 case SDRHELPLINE_VERTICAL
: return Pointer(POINTER_ESIZE
);
48 case SDRHELPLINE_HORIZONTAL
: return Pointer(POINTER_SSIZE
);
49 default : return Pointer(POINTER_MOVE
);
53 FASTBOOL
SdrHelpLine::IsHit(const Point
& rPnt
, USHORT nTolLog
, const OutputDevice
& rOut
) const
55 Size
a1Pix(rOut
.PixelToLogic(Size(1,1)));
56 FASTBOOL bXHit
=rPnt
.X()>=aPos
.X()-nTolLog
&& rPnt
.X()<=aPos
.X()+nTolLog
+a1Pix
.Width();
57 FASTBOOL bYHit
=rPnt
.Y()>=aPos
.Y()-nTolLog
&& rPnt
.Y()<=aPos
.Y()+nTolLog
+a1Pix
.Height();
59 case SDRHELPLINE_VERTICAL
: return bXHit
;
60 case SDRHELPLINE_HORIZONTAL
: return bYHit
;
61 case SDRHELPLINE_POINT
: {
63 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
64 return rPnt
.X()>=aPos
.X()-aRad
.Width() && rPnt
.X()<=aPos
.X()+aRad
.Width()+a1Pix
.Width() &&
65 rPnt
.Y()>=aPos
.Y()-aRad
.Height() && rPnt
.Y()<=aPos
.Y()+aRad
.Height()+a1Pix
.Height();
72 Rectangle
SdrHelpLine::GetBoundRect(const OutputDevice
& rOut
) const
74 Rectangle
aRet(aPos
,aPos
);
75 Point
aOfs(rOut
.GetMapMode().GetOrigin());
76 Size
aSiz(rOut
.GetOutputSize());
78 case SDRHELPLINE_VERTICAL
: aRet
.Top()=-aOfs
.Y(); aRet
.Bottom()=-aOfs
.Y()+aSiz
.Height(); break;
79 case SDRHELPLINE_HORIZONTAL
: aRet
.Left()=-aOfs
.X(); aRet
.Right()=-aOfs
.X()+aSiz
.Width(); break;
80 case SDRHELPLINE_POINT
: {
81 Size
aRad(rOut
.PixelToLogic(Size(SDRHELPLINE_POINT_PIXELSIZE
,SDRHELPLINE_POINT_PIXELSIZE
)));
82 aRet
.Left() -=aRad
.Width();
83 aRet
.Right() +=aRad
.Width();
84 aRet
.Top() -=aRad
.Height();
85 aRet
.Bottom()+=aRad
.Height();
91 bool SdrHelpLine::IsVisibleEqual( const SdrHelpLine
& rHelpLine
, const OutputDevice
& rOut
) const
93 if( eKind
== rHelpLine
.eKind
)
95 Point
aPt1(rOut
.LogicToPixel(aPos
)), aPt2(rOut
.LogicToPixel(rHelpLine
.aPos
));
98 case SDRHELPLINE_POINT
:
100 case SDRHELPLINE_VERTICAL
:
101 return aPt1
.X() == aPt2
.X();
102 case SDRHELPLINE_HORIZONTAL
:
103 return aPt1
.Y() == aPt2
.Y();
109 void SdrHelpLineList::Clear()
111 USHORT nAnz
=GetCount();
112 for (USHORT i
=0; i
<nAnz
; i
++) {
118 void SdrHelpLineList::operator=(const SdrHelpLineList
& rSrcList
)
121 USHORT nAnz
=rSrcList
.GetCount();
122 for (USHORT i
=0; i
<nAnz
; i
++) {
127 bool SdrHelpLineList::operator==(const SdrHelpLineList
& rSrcList
) const
129 FASTBOOL bEqual
=FALSE
;
130 USHORT nAnz
=GetCount();
131 if (nAnz
==rSrcList
.GetCount()) {
133 for (USHORT i
=0; i
<nAnz
&& bEqual
; i
++) {
134 if (*GetObject(i
)!=*rSrcList
.GetObject(i
)) {
142 USHORT
SdrHelpLineList::HitTest(const Point
& rPnt
, USHORT nTolLog
, const OutputDevice
& rOut
) const
144 USHORT nAnz
=GetCount();
145 for (USHORT i
=nAnz
; i
>0;) {
147 if (GetObject(i
)->IsHit(rPnt
,nTolLog
,rOut
)) return i
;
149 return SDRHELPLINE_NOTFOUND
;