LibreOffice Module sw (master) 1
conpoly.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/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 <conpoly.hxx>
28
29ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
30 SwDrawBase(pWrtShell, pEditWin, pSwView)
31{
32}
33
35{
36 bool bReturn = false;
37
38 if (m_pSh->IsDrawCreate())
39 {
40 if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
41 m_pWin->GetSdrDrawMode() != SdrObjKind::FreehandLine &&
42 m_pWin->GetSdrDrawMode() != SdrObjKind::FreehandFill)
43 {
44 if (!m_pSh->EndCreate(SdrCreateCmd::NextPoint))
45 {
47 EnterSelectMode(rMEvt);
48 return true;
49 }
50 }
51 else
52 {
53 bReturn = SwDrawBase::MouseButtonUp(rMEvt);
54
55 // #i85045# removed double mechanism to check for AutoClose polygon
56 // after construction; the method here did not check for already closed and
57 // also worked only for a single polygon. Removing.
58 }
59 }
60 else
61 bReturn = SwDrawBase::MouseButtonUp(rMEvt);
62
63 return bReturn;
64}
65
66void ConstPolygon::Activate(const sal_uInt16 nSlotId)
67{
68 switch (nSlotId)
69 {
70 case SID_DRAW_POLYGON_NOFILL:
71 case SID_DRAW_XPOLYGON_NOFILL:
72 m_pWin->SetSdrDrawMode(SdrObjKind::PolyLine);
73 break;
74
75 case SID_DRAW_POLYGON:
76 case SID_DRAW_XPOLYGON:
77 m_pWin->SetSdrDrawMode(SdrObjKind::Polygon);
78 break;
79
80 case SID_DRAW_BEZIER_NOFILL:
81 m_pWin->SetSdrDrawMode(SdrObjKind::PathLine);
82 break;
83
84 case SID_DRAW_BEZIER_FILL:
85 m_pWin->SetSdrDrawMode(SdrObjKind::PathFill);
86 break;
87
88 case SID_DRAW_FREELINE_NOFILL:
89 m_pWin->SetSdrDrawMode(SdrObjKind::FreehandLine);
90 break;
91
92 case SID_DRAW_FREELINE:
93 m_pWin->SetSdrDrawMode(SdrObjKind::FreehandFill);
94 break;
95
96 default:
97 break;
98 }
99
100 SwDrawBase::Activate(nSlotId);
101}
102
103/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
Definition: conpoly.cxx:34
ConstPolygon(SwWrtShell *pSh, SwEditWin *pWin, SwView *pView)
Definition: conpoly.cxx:29
virtual void Activate(const sal_uInt16 nSlotId) override
Definition: conpoly.cxx:66
sal_uInt16 GetClicks() const
bool IsLeft() const
virtual void Activate(const sal_uInt16 nSlotId)
Definition: drawbase.cxx:432
SwWrtShell * m_pSh
Definition: drawbase.hxx:36
VclPtr< SwEditWin > m_pWin
Definition: drawbase.hxx:37
virtual bool MouseButtonUp(const MouseEvent &rMEvt)
Definition: drawbase.cxx:239
void EnterSelectMode(const MouseEvent &rMEvt)
Definition: drawbase.cxx:489
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
bool EndCreate(SdrCreateCmd eSdrCreateCmd)
Definition: feshview.cxx:1839
bool IsDrawCreate() const
Definition: feshview.cxx:2228
void BreakCreate()
Definition: feshview.cxx:2221
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97