1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conpoly.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <svx/svdmark.hxx>
36 #include <svx/svdview.hxx>
37 #include <svx/svdopath.hxx>
42 #include "drawbase.hxx"
43 #include "conpoly.hxx"
44 #include <basegfx/polygon/b2dpolygon.hxx>
46 /*************************************************************************
50 \************************************************************************/
54 ConstPolygon::ConstPolygon(SwWrtShell
* pWrtShell
, SwEditWin
* pEditWin
, SwView
* pSwView
) :
55 SwDrawBase(pWrtShell
, pEditWin
, pSwView
)
59 /*************************************************************************
61 |* MouseButtonDown-event
63 \************************************************************************/
67 BOOL
ConstPolygon::MouseButtonDown(const MouseEvent
& rMEvt
)
71 if ((bReturn
= SwDrawBase::MouseButtonDown(rMEvt
)) == TRUE
)
72 aLastPos
= rMEvt
.GetPosPixel();
77 /*************************************************************************
81 \************************************************************************/
85 BOOL
ConstPolygon::MouseMove(const MouseEvent
& rMEvt
)
89 bReturn
= SwDrawBase::MouseMove(rMEvt
);
94 /*************************************************************************
96 |* MouseButtonUp-event
98 \************************************************************************/
102 BOOL
ConstPolygon::MouseButtonUp(const MouseEvent
& rMEvt
)
104 BOOL bReturn
= FALSE
;
106 if (m_pSh
->IsDrawCreate())
108 if (rMEvt
.IsLeft() && rMEvt
.GetClicks() == 1 &&
109 m_pWin
->GetSdrDrawMode() != OBJ_FREELINE
)
111 if (!m_pSh
->EndCreate(SDRCREATE_NEXTPOINT
))
113 m_pSh
->BreakCreate();
114 EnterSelectMode(rMEvt
);
120 Point
aPnt(m_pWin
->PixelToLogic(rMEvt
.GetPosPixel()));
121 bReturn
= SwDrawBase::MouseButtonUp(rMEvt
);
123 // #i85045# removed double mechanism to check for AutoClose polygon
124 // after construction; the method here did not check for already closed and
125 // also worked only for a single polygon. Removing.
129 bReturn
= SwDrawBase::MouseButtonUp(rMEvt
);
134 /*************************************************************************
136 |* Function aktivieren
138 \************************************************************************/
142 void ConstPolygon::Activate(const USHORT nSlotId
)
146 case SID_DRAW_POLYGON_NOFILL
:
147 m_pWin
->SetSdrDrawMode(OBJ_PLIN
);
150 case SID_DRAW_BEZIER_NOFILL
:
151 m_pWin
->SetSdrDrawMode(OBJ_PATHLINE
);
154 case SID_DRAW_FREELINE_NOFILL
:
155 m_pWin
->SetSdrDrawMode(OBJ_FREELINE
);
162 SwDrawBase::Activate(nSlotId
);