Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / sw / source / uibase / ribbar / conarc.cxx
blob67ab49b8bc2fba60786d65e6c68c3505b581ca41
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/svdobj.hxx>
22 #include <view.hxx>
23 #include <edtwin.hxx>
24 #include <wrtsh.hxx>
25 #include <drawbase.hxx>
26 #include <conarc.hxx>
28 ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView)
29 : SwDrawBase(pWrtShell, pEditWin, pSwView), m_nButtonUpCount(0)
33 bool ConstArc::MouseButtonDown( const MouseEvent& rMEvt )
35 bool bReturn = SwDrawBase::MouseButtonDown(rMEvt);
36 if (bReturn)
38 if (!m_nButtonUpCount)
39 m_aStartPoint = m_pWin->PixelToLogic(rMEvt.GetPosPixel());
41 return bReturn;
44 bool ConstArc::MouseButtonUp( const MouseEvent& rMEvt )
46 bool bReturn = false;
48 if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft())
50 Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
51 if (!m_nButtonUpCount && aPnt == m_aStartPoint)
53 SwDrawBase::MouseButtonUp(rMEvt);
54 bReturn = true;
56 else
57 { m_nButtonUpCount++;
59 if (m_nButtonUpCount == 3) // Generating of circular arc finished
61 SwDrawBase::MouseButtonUp(rMEvt);
62 m_nButtonUpCount = 0;
63 bReturn = true;
65 else
66 m_pSh->EndCreate(SdrCreateCmd::NextPoint);
70 return bReturn;
73 void ConstArc::Activate(const sal_uInt16 nSlotId)
75 switch (nSlotId)
77 case SID_DRAW_ARC:
78 m_pWin->SetSdrDrawMode(OBJ_CARC);
79 break;
80 case SID_DRAW_PIE:
81 m_pWin->SetSdrDrawMode(OBJ_SECT);
82 break;
83 case SID_DRAW_CIRCLECUT:
84 m_pWin->SetSdrDrawMode(OBJ_CCUT);
85 break;
86 default:
87 m_pWin->SetSdrDrawMode(OBJ_NONE);
88 break;
91 SwDrawBase::Activate(nSlotId);
94 void ConstArc::Deactivate()
96 m_nButtonUpCount = 0;
98 SwDrawBase::Deactivate();
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */