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: svddrag.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"
33 #include <svx/svdview.hxx>
34 #include <svx/svddrag.hxx>
36 void SdrDragStat::Clear(FASTBOOL bLeaveOne
)
38 void* pP
=aPnts
.First();
43 if (pUser
!=NULL
) delete pUser
;
47 aPnts
.Insert(new Point
,CONTAINER_APPEND
);
51 void SdrDragStat::Reset()
65 bEndDragChangesAttributes
=FALSE
;
66 bEndDragChangesGeoAndAttributes
=FALSE
;
69 aActionRect
=Rectangle();
72 void SdrDragStat::Reset(const Point
& rPnt
)
81 void SdrDragStat::NextMove(const Point
& rPnt
)
83 aRealPos0
=GetRealNow();
86 Point aBla
=KorregPos(GetRealNow(),GetPrev());
90 void SdrDragStat::NextPoint(FASTBOOL bSaveReal
)
93 if (bSaveReal
) aPnt
=aRealNow
;
94 aPnts
.Insert(new Point(KorregPos(GetRealNow(),aPnt
)),CONTAINER_APPEND
);
98 void SdrDragStat::PrevPoint()
100 if (aPnts
.Count()>=2) { // einer muss immer da bleiben
101 Point
* pPnt
=(Point
*)(aPnts
.GetObject(aPnts
.Count()-2));
102 aPnts
.Remove(aPnts
.Count()-2);
104 Now()=KorregPos(GetRealNow(),GetPrev());
108 Point
SdrDragStat::KorregPos(const Point
& rNow
, const Point
& /*rPrev*/) const
114 FASTBOOL
SdrDragStat::CheckMinMoved(const Point
& rPnt
)
117 long dx
=rPnt
.X()-GetPrev().X(); if (dx
<0) dx
=-dx
;
118 long dy
=rPnt
.Y()-GetPrev().Y(); if (dy
<0) dy
=-dy
;
119 if (dx
>=long(nMinMov
) || dy
>=long(nMinMov
))
125 Fraction
SdrDragStat::GetXFact() const
127 long nMul
=GetNow().X()-aRef1
.X();
128 long nDiv
=GetPrev().X()-aRef1
.X();
130 if (bHorFixed
) { nMul
=1; nDiv
=1; }
131 return Fraction(nMul
,nDiv
);
134 Fraction
SdrDragStat::GetYFact() const
136 long nMul
=GetNow().Y()-aRef1
.Y();
137 long nDiv
=GetPrev().Y()-aRef1
.Y();
139 if (bVerFixed
) { nMul
=1; nDiv
=1; }
140 return Fraction(nMul
,nDiv
);
143 void SdrDragStat::TakeCreateRect(Rectangle
& rRect
) const
145 rRect
=Rectangle(GetStart(),GetNow());
146 if (GetPointAnz()>=2) {
147 Point
aBtmRgt(GetPoint(1));
148 rRect
.Right()=aBtmRgt
.X();
149 rRect
.Bottom()=aBtmRgt
.Y();
151 if (pView
!=NULL
&& pView
->IsCreate1stPointAsCenter()) {
152 rRect
.Top()+=rRect
.Top()-rRect
.Bottom();
153 rRect
.Left()+=rRect
.Left()-rRect
.Right();