/src/libreoffice/sw/source/uibase/ribbar/conarc.cxx
Line | Count | Source |
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/svxids.hrc> |
21 | | #include <vcl/event.hxx> |
22 | | |
23 | | #include <view.hxx> |
24 | | #include <edtwin.hxx> |
25 | | #include <wrtsh.hxx> |
26 | | #include <drawbase.hxx> |
27 | | #include <conarc.hxx> |
28 | | |
29 | | ConstArc::ConstArc(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView& rSwView) |
30 | 0 | : SwDrawBase(pWrtShell, pEditWin, rSwView) |
31 | 0 | , m_nButtonUpCount(0) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | bool ConstArc::MouseButtonDown(const MouseEvent& rMEvt) |
36 | 0 | { |
37 | 0 | bool bReturn = SwDrawBase::MouseButtonDown(rMEvt); |
38 | 0 | if (bReturn && !m_nButtonUpCount) |
39 | 0 | m_aStartPoint = m_pWin->PixelToLogic(rMEvt.GetPosPixel()); |
40 | 0 | return bReturn; |
41 | 0 | } |
42 | | |
43 | | bool ConstArc::MouseButtonUp(const MouseEvent& rMEvt) |
44 | 0 | { |
45 | 0 | bool bReturn = false; |
46 | |
|
47 | 0 | if ((m_pSh->IsDrawCreate() || m_pWin->IsDrawAction()) && rMEvt.IsLeft()) |
48 | 0 | { |
49 | 0 | Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel())); |
50 | 0 | if (!m_nButtonUpCount && aPnt == m_aStartPoint) |
51 | 0 | { |
52 | 0 | SwDrawBase::MouseButtonUp(rMEvt); |
53 | 0 | bReturn = true; |
54 | 0 | } |
55 | 0 | else |
56 | 0 | { |
57 | 0 | m_nButtonUpCount++; |
58 | |
|
59 | 0 | if (m_nButtonUpCount == 3) // Generating of circular arc finished |
60 | 0 | { |
61 | 0 | SwDrawBase::MouseButtonUp(rMEvt); |
62 | 0 | m_nButtonUpCount = 0; |
63 | 0 | bReturn = true; |
64 | 0 | } |
65 | 0 | else |
66 | 0 | m_pSh->EndCreate(SdrCreateCmd::NextPoint); |
67 | 0 | } |
68 | 0 | } |
69 | |
|
70 | 0 | return bReturn; |
71 | 0 | } |
72 | | |
73 | | void ConstArc::Activate(const sal_uInt16 nSlotId) |
74 | 0 | { |
75 | 0 | switch (nSlotId) |
76 | 0 | { |
77 | 0 | case SID_DRAW_ARC: |
78 | 0 | m_pWin->SetSdrDrawMode(SdrObjKind::CircleArc); |
79 | 0 | break; |
80 | 0 | case SID_DRAW_PIE: |
81 | 0 | m_pWin->SetSdrDrawMode(SdrObjKind::CircleSection); |
82 | 0 | break; |
83 | 0 | case SID_DRAW_CIRCLECUT: |
84 | 0 | m_pWin->SetSdrDrawMode(SdrObjKind::CircleCut); |
85 | 0 | break; |
86 | 0 | default: |
87 | 0 | m_pWin->SetSdrDrawMode(SdrObjKind::NONE); |
88 | 0 | break; |
89 | 0 | } |
90 | | |
91 | 0 | SwDrawBase::Activate(nSlotId); |
92 | 0 | } |
93 | | |
94 | | void ConstArc::Deactivate() |
95 | 0 | { |
96 | 0 | m_nButtonUpCount = 0; |
97 | |
|
98 | 0 | SwDrawBase::Deactivate(); |
99 | 0 | } |
100 | | |
101 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |