LibreOffice Module sw (master)  1
conarc.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/svdobj.hxx>
21 #include <svx/svxids.hrc>
22 #include <vcl/event.hxx>
23 
24 #include <view.hxx>
25 #include <edtwin.hxx>
26 #include <wrtsh.hxx>
27 #include <drawbase.hxx>
28 #include <conarc.hxx>
29 
30 ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
31  : SwDrawBase(pWrtShell, pEditWin, pSwView)
32  , m_nButtonUpCount(0)
33 {
34 }
35 
37 {
38  bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
39  if (bReturn && !m_nButtonUpCount)
41  return bReturn;
42 }
43 
45 {
46  bool bReturn = false;
47 
48  if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
49  {
50  Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
51  if (!m_nButtonUpCount && aPnt == m_aStartPoint)
52  {
54  bReturn = true;
55  }
56  else
57  {
59 
60  if (m_nButtonUpCount == 3) // Generating of circular arc finished
61  {
63  m_nButtonUpCount = 0;
64  bReturn = true;
65  }
66  else
67  m_pSh->EndCreate(SdrCreateCmd::NextPoint);
68  }
69  }
70 
71  return bReturn;
72 }
73 
74 void ConstArc::Activate(const sal_uInt16 nSlotId)
75 {
76  switch (nSlotId)
77  {
78  case SID_DRAW_ARC:
80  break;
81  case SID_DRAW_PIE:
83  break;
84  case SID_DRAW_CIRCLECUT:
86  break;
87  default:
89  break;
90  }
91 
92  SwDrawBase::Activate(nSlotId);
93 }
94 
96 {
97  m_nButtonUpCount = 0;
98 
100 }
101 
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ConstArc(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conarc.cxx:30
OBJ_CARC
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: drawbase.cxx:239
OBJ_SECT
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
Point m_aStartPoint
Definition: conarc.hxx:27
void SetSdrDrawMode(SdrObjKind eSdrObjectKind)
Definition: edtwin.hxx:215
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:427
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: conarc.cxx:36
sal_uInt16 m_nButtonUpCount
Definition: conarc.hxx:28
virtual void Deactivate()
Definition: drawbase.cxx:439
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
virtual bool MouseButtonDown(const MouseEvent &rMEvt)
Definition: drawbase.cxx:62
Point PixelToLogic(const Point &rDevicePt) const
bool IsLeft() const
const Point & GetPosPixel() const
bool IsDrawAction() const
Definition: edtwin.hxx:208
bool IsDrawCreate() const
Definition: feshview.cxx:2131
OBJ_CCUT
OBJ_NONE
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conarc.cxx:44
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conarc.cxx:74
virtual void Deactivate() override
Definition: conarc.cxx:95
Definition: view.hxx:144
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1732