merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / ribbar / conpoly.cxx
blob13f1092343064f943d638fd1cefe1677f62131b1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: conpoly.cxx,v $
10 * $Revision: 1.12 $
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>
39 #include "view.hxx"
40 #include "edtwin.hxx"
41 #include "wrtsh.hxx"
42 #include "drawbase.hxx"
43 #include "conpoly.hxx"
44 #include <basegfx/polygon/b2dpolygon.hxx>
46 /*************************************************************************
48 |* Konstruktor
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)
69 BOOL bReturn;
71 if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == TRUE)
72 aLastPos = rMEvt.GetPosPixel();
74 return (bReturn);
77 /*************************************************************************
79 |* MouseMove-event
81 \************************************************************************/
85 BOOL ConstPolygon::MouseMove(const MouseEvent& rMEvt)
87 BOOL bReturn = FALSE;
89 bReturn = SwDrawBase::MouseMove(rMEvt);
91 return bReturn;
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);
115 return TRUE;
118 else
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.
128 else
129 bReturn = SwDrawBase::MouseButtonUp(rMEvt);
131 return (bReturn);
134 /*************************************************************************
136 |* Function aktivieren
138 \************************************************************************/
142 void ConstPolygon::Activate(const USHORT nSlotId)
144 switch (nSlotId)
146 case SID_DRAW_POLYGON_NOFILL:
147 m_pWin->SetSdrDrawMode(OBJ_PLIN);
148 break;
150 case SID_DRAW_BEZIER_NOFILL:
151 m_pWin->SetSdrDrawMode(OBJ_PATHLINE);
152 break;
154 case SID_DRAW_FREELINE_NOFILL:
155 m_pWin->SetSdrDrawMode(OBJ_FREELINE);
156 break;
158 default:
159 break;
162 SwDrawBase::Activate(nSlotId);