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()
51 bEndDragChangesAttributes
=false;
52 bEndDragChangesGeoAndAttributes
=false;
55 aActionRect
=Rectangle();
58 void SdrDragStat::Reset(const Point
& rPnt
)
66 void SdrDragStat::NextMove(const Point
& rPnt
)
70 Point aBla
=KorregPos(GetRealNow(),GetPrev());
74 void SdrDragStat::NextPoint(bool bSaveReal
)
77 if (bSaveReal
) aPnt
=aRealNow
;
78 aPnts
.push_back(new Point(KorregPos(GetRealNow(),aPnt
)));
82 void SdrDragStat::PrevPoint()
84 if (aPnts
.size()>=2) { // one has to remain at all times
85 Point
* pPnt
=aPnts
[aPnts
.size()-2];
86 aPnts
.erase(aPnts
.begin()+aPnts
.size()-2);
88 Now()=KorregPos(GetRealNow(),GetPrev());
92 Point
SdrDragStat::KorregPos(const Point
& rNow
, const Point
& /*rPrev*/) const
98 bool SdrDragStat::CheckMinMoved(const Point
& rPnt
)
101 long dx
=rPnt
.X()-GetPrev().X(); if (dx
<0) dx
=-dx
;
102 long dy
=rPnt
.Y()-GetPrev().Y(); if (dy
<0) dy
=-dy
;
103 if (dx
>=long(nMinMov
) || dy
>=long(nMinMov
))
109 Fraction
SdrDragStat::GetXFact() const
111 long nMul
=GetNow().X()-aRef1
.X();
112 long nDiv
=GetPrev().X()-aRef1
.X();
114 if (bHorFixed
) { nMul
=1; nDiv
=1; }
115 return Fraction(nMul
,nDiv
);
118 Fraction
SdrDragStat::GetYFact() const
120 long nMul
=GetNow().Y()-aRef1
.Y();
121 long nDiv
=GetPrev().Y()-aRef1
.Y();
123 if (bVerFixed
) { nMul
=1; nDiv
=1; }
124 return Fraction(nMul
,nDiv
);
127 void SdrDragStat::TakeCreateRect(Rectangle
& rRect
) const
129 rRect
=Rectangle(GetStart(),GetNow());
130 if (GetPointAnz()>=2) {
131 Point
aBtmRgt(GetPoint(1));
132 rRect
.Right()=aBtmRgt
.X();
133 rRect
.Bottom()=aBtmRgt
.Y();
135 if (pView
!=NULL
&& pView
->IsCreate1stPointAsCenter()) {
136 rRect
.Top()+=rRect
.Top()-rRect
.Bottom();
137 rRect
.Left()+=rRect
.Left()-rRect
.Right();
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */