1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include <svx/svdview.hxx>
30 #include <svx/svddrag.hxx>
32 void SdrDragStat::Clear(bool bLeaveOne
)
34 void* pP
=aPnts
.First();
39 if (pUser
!=NULL
) delete pUser
;
43 aPnts
.Insert(new Point
,CONTAINER_APPEND
);
47 void SdrDragStat::Reset()
56 bWantNoSnap
=sal_False
;
61 bEndDragChangesAttributes
=sal_False
;
62 bEndDragChangesGeoAndAttributes
=sal_False
;
65 aActionRect
=Rectangle();
68 void SdrDragStat::Reset(const Point
& rPnt
)
77 void SdrDragStat::NextMove(const Point
& rPnt
)
79 aRealPos0
=GetRealNow();
82 Point aBla
=KorregPos(GetRealNow(),GetPrev());
86 void SdrDragStat::NextPoint(bool bSaveReal
)
89 if (bSaveReal
) aPnt
=aRealNow
;
90 aPnts
.Insert(new Point(KorregPos(GetRealNow(),aPnt
)),CONTAINER_APPEND
);
94 void SdrDragStat::PrevPoint()
96 if (aPnts
.Count()>=2) { // one has to remain at all times
97 Point
* pPnt
=(Point
*)(aPnts
.GetObject(aPnts
.Count()-2));
98 aPnts
.Remove(aPnts
.Count()-2);
100 Now()=KorregPos(GetRealNow(),GetPrev());
104 Point
SdrDragStat::KorregPos(const Point
& rNow
, const Point
& /*rPrev*/) const
110 bool SdrDragStat::CheckMinMoved(const Point
& rPnt
)
113 long dx
=rPnt
.X()-GetPrev().X(); if (dx
<0) dx
=-dx
;
114 long dy
=rPnt
.Y()-GetPrev().Y(); if (dy
<0) dy
=-dy
;
115 if (dx
>=long(nMinMov
) || dy
>=long(nMinMov
))
121 Fraction
SdrDragStat::GetXFact() const
123 long nMul
=GetNow().X()-aRef1
.X();
124 long nDiv
=GetPrev().X()-aRef1
.X();
126 if (bHorFixed
) { nMul
=1; nDiv
=1; }
127 return Fraction(nMul
,nDiv
);
130 Fraction
SdrDragStat::GetYFact() const
132 long nMul
=GetNow().Y()-aRef1
.Y();
133 long nDiv
=GetPrev().Y()-aRef1
.Y();
135 if (bVerFixed
) { nMul
=1; nDiv
=1; }
136 return Fraction(nMul
,nDiv
);
139 void SdrDragStat::TakeCreateRect(Rectangle
& rRect
) const
141 rRect
=Rectangle(GetStart(),GetNow());
142 if (GetPointAnz()>=2) {
143 Point
aBtmRgt(GetPoint(1));
144 rRect
.Right()=aBtmRgt
.X();
145 rRect
.Bottom()=aBtmRgt
.Y();
147 if (pView
!=NULL
&& pView
->IsCreate1stPointAsCenter()) {
148 rRect
.Top()+=rRect
.Top()-rRect
.Bottom();
149 rRect
.Left()+=rRect
.Left()-rRect
.Right();
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */