1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <svx/svdmark.hxx>
29cdf0e10cSrcweir #include <svx/svdview.hxx>
30cdf0e10cSrcweir #include <svx/svdopath.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include "view.hxx"
33cdf0e10cSrcweir #include "edtwin.hxx"
34cdf0e10cSrcweir #include "wrtsh.hxx"
35cdf0e10cSrcweir #include "drawbase.hxx"
36cdf0e10cSrcweir #include "conpoly.hxx"
37cdf0e10cSrcweir #include <basegfx/polygon/b2dpolygon.hxx>
38cdf0e10cSrcweir
39cdf0e10cSrcweir /*************************************************************************
40cdf0e10cSrcweir |*
41cdf0e10cSrcweir |* Konstruktor
42cdf0e10cSrcweir |*
43cdf0e10cSrcweir \************************************************************************/
44cdf0e10cSrcweir
45cdf0e10cSrcweir
46cdf0e10cSrcweir
ConstPolygon(SwWrtShell * pWrtShell,SwEditWin * pEditWin,SwView * pSwView)47cdf0e10cSrcweir ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) :
48cdf0e10cSrcweir SwDrawBase(pWrtShell, pEditWin, pSwView)
49cdf0e10cSrcweir {
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
52cdf0e10cSrcweir /*************************************************************************
53cdf0e10cSrcweir |*
54cdf0e10cSrcweir |* MouseButtonDown-event
55cdf0e10cSrcweir |*
56cdf0e10cSrcweir \************************************************************************/
57cdf0e10cSrcweir
58cdf0e10cSrcweir
59cdf0e10cSrcweir
MouseButtonDown(const MouseEvent & rMEvt)60cdf0e10cSrcweir sal_Bool ConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir sal_Bool bReturn;
63cdf0e10cSrcweir
64cdf0e10cSrcweir if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True)
65cdf0e10cSrcweir aLastPos = rMEvt.GetPosPixel();
66cdf0e10cSrcweir
67cdf0e10cSrcweir return (bReturn);
68cdf0e10cSrcweir }
69cdf0e10cSrcweir
70cdf0e10cSrcweir /*************************************************************************
71cdf0e10cSrcweir |*
72cdf0e10cSrcweir |* MouseMove-event
73cdf0e10cSrcweir |*
74cdf0e10cSrcweir \************************************************************************/
75cdf0e10cSrcweir
76cdf0e10cSrcweir
77cdf0e10cSrcweir
MouseMove(const MouseEvent & rMEvt)78cdf0e10cSrcweir sal_Bool ConstPolygon::MouseMove(const MouseEvent& rMEvt)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir sal_Bool bReturn = sal_False;
81cdf0e10cSrcweir
82cdf0e10cSrcweir bReturn = SwDrawBase::MouseMove(rMEvt);
83cdf0e10cSrcweir
84cdf0e10cSrcweir return bReturn;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir /*************************************************************************
88cdf0e10cSrcweir |*
89cdf0e10cSrcweir |* MouseButtonUp-event
90cdf0e10cSrcweir |*
91cdf0e10cSrcweir \************************************************************************/
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweir
MouseButtonUp(const MouseEvent & rMEvt)95cdf0e10cSrcweir sal_Bool ConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir sal_Bool bReturn = sal_False;
98cdf0e10cSrcweir
99cdf0e10cSrcweir if (m_pSh->IsDrawCreate())
100cdf0e10cSrcweir {
101cdf0e10cSrcweir if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
102cdf0e10cSrcweir m_pWin->GetSdrDrawMode() != OBJ_FREELINE)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir if (!m_pSh->EndCreate(SDRCREATE_NEXTPOINT))
105cdf0e10cSrcweir {
106cdf0e10cSrcweir m_pSh->BreakCreate();
107cdf0e10cSrcweir EnterSelectMode(rMEvt);
108cdf0e10cSrcweir return sal_True;
109cdf0e10cSrcweir }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir else
112cdf0e10cSrcweir {
113cdf0e10cSrcweir Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel()));
114cdf0e10cSrcweir bReturn = SwDrawBase::MouseButtonUp(rMEvt);
115cdf0e10cSrcweir
116cdf0e10cSrcweir // #i85045# removed double mechanism to check for AutoClose polygon
117cdf0e10cSrcweir // after construction; the method here did not check for already closed and
118cdf0e10cSrcweir // also worked only for a single polygon. Removing.
119cdf0e10cSrcweir }
120cdf0e10cSrcweir }
121cdf0e10cSrcweir else
122cdf0e10cSrcweir bReturn = SwDrawBase::MouseButtonUp(rMEvt);
123cdf0e10cSrcweir
124cdf0e10cSrcweir return (bReturn);
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir /*************************************************************************
128cdf0e10cSrcweir |*
129cdf0e10cSrcweir |* Function aktivieren
130cdf0e10cSrcweir |*
131cdf0e10cSrcweir \************************************************************************/
132cdf0e10cSrcweir
133cdf0e10cSrcweir
134cdf0e10cSrcweir
Activate(const sal_uInt16 nSlotId)135cdf0e10cSrcweir void ConstPolygon::Activate(const sal_uInt16 nSlotId)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir switch (nSlotId)
138cdf0e10cSrcweir {
139cdf0e10cSrcweir case SID_DRAW_POLYGON_NOFILL:
140cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_PLIN);
141cdf0e10cSrcweir break;
142cdf0e10cSrcweir
143cdf0e10cSrcweir case SID_DRAW_BEZIER_NOFILL:
144cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_PATHLINE);
145cdf0e10cSrcweir break;
146cdf0e10cSrcweir
147cdf0e10cSrcweir case SID_DRAW_FREELINE_NOFILL:
148cdf0e10cSrcweir m_pWin->SetSdrDrawMode(OBJ_FREELINE);
149cdf0e10cSrcweir break;
150cdf0e10cSrcweir
151cdf0e10cSrcweir default:
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir SwDrawBase::Activate(nSlotId);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir
159cdf0e10cSrcweir
160