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 SdrDragStatUserData::~SdrDragStatUserData() = default;
25 SdrDragStat::~SdrDragStat()
29 void SdrDragStat::Clear()
33 mvPnts
.emplace_back();
36 void SdrDragStat::Reset()
50 bEndDragChangesAttributes
=false;
51 bEndDragChangesGeoAndAttributes
=false;
52 mbEndDragChangesLayout
=false;
55 aActionRect
=tools::Rectangle();
58 void SdrDragStat::Reset(const Point
& rPnt
)
66 void SdrDragStat::NextMove(const Point
& rPnt
)
73 void SdrDragStat::NextPoint()
75 mvPnts
.emplace_back(aRealNow
);
78 void SdrDragStat::PrevPoint()
80 if (mvPnts
.size()>1) { // one has to remain at all times
81 mvPnts
.erase(mvPnts
.begin()+mvPnts
.size()-2);
82 mvPnts
.back() = aRealNow
;
86 bool SdrDragStat::CheckMinMoved(const Point
& rPnt
)
89 tools::Long dx
=rPnt
.X()-GetPrev().X(); if (dx
<0) dx
=-dx
;
90 tools::Long dy
=rPnt
.Y()-GetPrev().Y(); if (dy
<0) dy
=-dy
;
91 if (dx
>=tools::Long(nMinMov
) || dy
>=tools::Long(nMinMov
))
97 Fraction
SdrDragStat::GetXFact() const
99 tools::Long nMul
=mvPnts
.back().X()-aRef1
.X();
100 tools::Long nDiv
=GetPrev().X()-aRef1
.X();
102 if (bHorFixed
) { nMul
=1; nDiv
=1; }
103 return Fraction(nMul
,nDiv
);
106 Fraction
SdrDragStat::GetYFact() const
108 tools::Long nMul
=mvPnts
.back().Y()-aRef1
.Y();
109 tools::Long nDiv
=GetPrev().Y()-aRef1
.Y();
111 if (bVerFixed
) { nMul
=1; nDiv
=1; }
112 return Fraction(nMul
,nDiv
);
115 void SdrDragStat::TakeCreateRect(tools::Rectangle
& rRect
) const
117 rRect
=tools::Rectangle(mvPnts
[0], mvPnts
.back());
118 if (mvPnts
.size()>1) {
119 Point
aBtmRgt(mvPnts
[1]);
120 rRect
.SetRight(aBtmRgt
.X() );
121 rRect
.SetBottom(aBtmRgt
.Y() );
123 if (pView
!=nullptr && pView
->IsCreate1stPointAsCenter()) {
124 rRect
.AdjustTop(rRect
.Top()-rRect
.Bottom() );
125 rRect
.AdjustLeft(rRect
.Left()-rRect
.Right() );
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */