LibreOffice Module svx (master) 1
svddrag.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <svx/svdview.hxx>
21#include <svx/svddrag.hxx>
22
24
26{
27}
28
30{
31 mpUserData.reset();
32 mvPnts.clear();
33 mvPnts.emplace_back();
34}
35
37{
38 pView=nullptr;
39 pPageView=nullptr;
40 bShown=false;
41 nMinMov=1;
42 bMinMoved=false;
43 bHorFixed=false;
44 bVerFixed=false;
45 bWantNoSnap=false;
46 pHdl=nullptr;
47 bOrtho4=false;
48 bOrtho8=false;
49 pDragMethod=nullptr;
53 bMouseIsUp=false;
54 Clear();
56}
57
58void SdrDragStat::Reset(const Point& rPnt)
59{
60 Reset();
61 mvPnts[0]=rPnt;
62 aPos0=rPnt;
63 aRealNow=rPnt;
64}
65
67{
68 aPos0=mvPnts.back();
69 aRealNow=rPnt;
70 mvPnts.back()=rPnt;
71}
72
74{
75 mvPnts.emplace_back(aRealNow);
76}
77
79{
80 if (mvPnts.size()>1) { // one has to remain at all times
81 mvPnts.erase(mvPnts.begin()+mvPnts.size()-2);
82 mvPnts.back() = aRealNow;
83 }
84}
85
87{
88 if (!bMinMoved) {
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))
92 bMinMoved=true;
93 }
94 return bMinMoved;
95}
96
98{
99 tools::Long nMul=mvPnts.back().X()-aRef1.X();
100 tools::Long nDiv=GetPrev().X()-aRef1.X();
101 if (nDiv==0) nDiv=1;
102 if (bHorFixed) { nMul=1; nDiv=1; }
103 return Fraction(nMul,nDiv);
104}
105
107{
108 tools::Long nMul=mvPnts.back().Y()-aRef1.Y();
109 tools::Long nDiv=GetPrev().Y()-aRef1.Y();
110 if (nDiv==0) nDiv=1;
111 if (bVerFixed) { nMul=1; nDiv=1; }
112 return Fraction(nMul,nDiv);
113}
114
116{
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() );
122 }
123 if (pView!=nullptr && pView->IsCreate1stPointAsCenter()) {
124 rRect.AdjustTop(rRect.Top()-rRect.Bottom() );
125 rRect.AdjustLeft(rRect.Left()-rRect.Right() );
126 }
127}
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long Y() const
constexpr tools::Long X() const
bool IsCreate1stPointAsCenter() const
Definition: svdcrtv.hxx:133
bool bOrtho8
Definition: svddrag.hxx:73
SdrHdl * pHdl
Definition: svddrag.hxx:48
bool bVerFixed
Definition: svddrag.hxx:69
std::unique_ptr< SdrDragStatUserData > mpUserData
Definition: svddrag.hxx:76
bool mbEndDragChangesLayout
Table row drag: table will re-layout itself later.
Definition: svddrag.hxx:61
void PrevPoint()
Definition: svddrag.cxx:78
Fraction GetYFact() const
Definition: svddrag.cxx:106
bool bEndDragChangesGeoAndAttributes
Definition: svddrag.hxx:59
void NextMove(const Point &rPnt)
Definition: svddrag.cxx:66
Point aRef1
Definition: svddrag.hxx:52
bool bHorFixed
Definition: svddrag.hxx:68
bool bMouseIsUp
Definition: svddrag.hxx:62
void Clear()
Definition: svddrag.cxx:29
bool bMinMoved
Definition: svddrag.hxx:66
bool bEndDragChangesAttributes
Definition: svddrag.hxx:58
bool bShown
Definition: svddrag.hxx:64
void TakeCreateRect(tools::Rectangle &rRect) const
Definition: svddrag.cxx:115
std::vector< Point > mvPnts
Definition: svddrag.hxx:51
Fraction GetXFact() const
Definition: svddrag.cxx:97
void Reset()
Definition: svddrag.cxx:36
Point aPos0
Definition: svddrag.hxx:54
bool CheckMinMoved(const Point &rPnt)
Definition: svddrag.cxx:86
SdrView * pView
Definition: svddrag.hxx:49
bool bOrtho4
Definition: svddrag.hxx:72
SdrPageView * pPageView
Definition: svddrag.hxx:50
~SdrDragStat()
Definition: svddrag.cxx:25
SdrDragMethod * pDragMethod
Definition: svddrag.hxx:75
sal_uInt16 nMinMov
Definition: svddrag.hxx:65
const Point & GetPrev() const
Definition: svddrag.hxx:103
void NextPoint()
Definition: svddrag.cxx:73
tools::Rectangle aActionRect
Definition: svddrag.hxx:56
Point aRealNow
Definition: svddrag.hxx:55
bool bWantNoSnap
Definition: svddrag.hxx:70
constexpr tools::Long Top() const
constexpr void SetRight(tools::Long v)
constexpr tools::Long Right() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
constexpr void SetBottom(tools::Long v)
tools::Long AdjustLeft(tools::Long nHorzMoveDelta)
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
long Long
virtual ~SdrDragStatUserData()=0