1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include <svx/svdview.hxx>
21 #include <svx/svddrag.hxx>
23 void SdrDragStat::Clear(bool bLeaveOne
)
25 while (!aPnts
.empty()) {
33 aPnts
.push_back(new Point
);
37 void SdrDragStat::Reset()
46 bWantNoSnap
=sal_False
;
51 bEndDragChangesAttributes
=sal_False
;
52 bEndDragChangesGeoAndAttributes
=sal_False
;
55 aActionRect
=Rectangle();
58 void SdrDragStat::Reset(const Point
& rPnt
)
67 void SdrDragStat::NextMove(const Point
& rPnt
)
69 aRealPos0
=GetRealNow();
72 Point aBla
=KorregPos(GetRealNow(),GetPrev());
76 void SdrDragStat::NextPoint(bool bSaveReal
)
79 if (bSaveReal
) aPnt
=aRealNow
;
80 aPnts
.push_back(new Point(KorregPos(GetRealNow(),aPnt
)));
84 void SdrDragStat::PrevPoint()
86 if (aPnts
.size()>=2) { // one has to remain at all times
87 Point
* pPnt
=aPnts
[aPnts
.size()-2];
88 aPnts
.erase(aPnts
.begin()+aPnts
.size()-2);
90 Now()=KorregPos(GetRealNow(),GetPrev());
94 Point
SdrDragStat::KorregPos(const Point
& rNow
, const Point
& /*rPrev*/) const
100 bool SdrDragStat::CheckMinMoved(const Point
& rPnt
)
103 long dx
=rPnt
.X()-GetPrev().X(); if (dx
<0) dx
=-dx
;
104 long dy
=rPnt
.Y()-GetPrev().Y(); if (dy
<0) dy
=-dy
;
105 if (dx
>=long(nMinMov
) || dy
>=long(nMinMov
))
111 Fraction
SdrDragStat::GetXFact() const
113 long nMul
=GetNow().X()-aRef1
.X();
114 long nDiv
=GetPrev().X()-aRef1
.X();
116 if (bHorFixed
) { nMul
=1; nDiv
=1; }
117 return Fraction(nMul
,nDiv
);
120 Fraction
SdrDragStat::GetYFact() const
122 long nMul
=GetNow().Y()-aRef1
.Y();
123 long nDiv
=GetPrev().Y()-aRef1
.Y();
125 if (bVerFixed
) { nMul
=1; nDiv
=1; }
126 return Fraction(nMul
,nDiv
);
129 void SdrDragStat::TakeCreateRect(Rectangle
& rRect
) const
131 rRect
=Rectangle(GetStart(),GetNow());
132 if (GetPointAnz()>=2) {
133 Point
aBtmRgt(GetPoint(1));
134 rRect
.Right()=aBtmRgt
.X();
135 rRect
.Bottom()=aBtmRgt
.Y();
137 if (pView
!=NULL
&& pView
->IsCreate1stPointAsCenter()) {
138 rRect
.Top()+=rRect
.Top()-rRect
.Bottom();
139 rRect
.Left()+=rRect
.Left()-rRect
.Right();
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */