1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <svx/svdmark.hxx> 33 #include <svx/svdview.hxx> 34 #include <svx/svdopath.hxx> 35 36 #include "view.hxx" 37 #include "edtwin.hxx" 38 #include "wrtsh.hxx" 39 #include "drawbase.hxx" 40 #include "conpoly.hxx" 41 #include <basegfx/polygon/b2dpolygon.hxx> 42 43 /************************************************************************* 44 |* 45 |* Konstruktor 46 |* 47 \************************************************************************/ 48 49 50 51 ConstPolygon::ConstPolygon(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) : 52 SwDrawBase(pWrtShell, pEditWin, pSwView) 53 { 54 } 55 56 /************************************************************************* 57 |* 58 |* MouseButtonDown-event 59 |* 60 \************************************************************************/ 61 62 63 64 sal_Bool ConstPolygon::MouseButtonDown(const MouseEvent& rMEvt) 65 { 66 sal_Bool bReturn; 67 68 if ((bReturn = SwDrawBase::MouseButtonDown(rMEvt)) == sal_True) 69 aLastPos = rMEvt.GetPosPixel(); 70 71 return (bReturn); 72 } 73 74 /************************************************************************* 75 |* 76 |* MouseMove-event 77 |* 78 \************************************************************************/ 79 80 81 82 sal_Bool ConstPolygon::MouseMove(const MouseEvent& rMEvt) 83 { 84 sal_Bool bReturn = sal_False; 85 86 bReturn = SwDrawBase::MouseMove(rMEvt); 87 88 return bReturn; 89 } 90 91 /************************************************************************* 92 |* 93 |* MouseButtonUp-event 94 |* 95 \************************************************************************/ 96 97 98 99 sal_Bool ConstPolygon::MouseButtonUp(const MouseEvent& rMEvt) 100 { 101 sal_Bool bReturn = sal_False; 102 103 if (m_pSh->IsDrawCreate()) 104 { 105 if (rMEvt.IsLeft() && rMEvt.GetClicks() == 1 && 106 m_pWin->GetSdrDrawMode() != OBJ_FREELINE) 107 { 108 if (!m_pSh->EndCreate(SDRCREATE_NEXTPOINT)) 109 { 110 m_pSh->BreakCreate(); 111 EnterSelectMode(rMEvt); 112 return sal_True; 113 } 114 } 115 else 116 { 117 Point aPnt(m_pWin->PixelToLogic(rMEvt.GetPosPixel())); 118 bReturn = SwDrawBase::MouseButtonUp(rMEvt); 119 120 // #i85045# removed double mechanism to check for AutoClose polygon 121 // after construction; the method here did not check for already closed and 122 // also worked only for a single polygon. Removing. 123 } 124 } 125 else 126 bReturn = SwDrawBase::MouseButtonUp(rMEvt); 127 128 return (bReturn); 129 } 130 131 /************************************************************************* 132 |* 133 |* Function aktivieren 134 |* 135 \************************************************************************/ 136 137 138 139 void ConstPolygon::Activate(const sal_uInt16 nSlotId) 140 { 141 switch (nSlotId) 142 { 143 case SID_DRAW_POLYGON_NOFILL: 144 m_pWin->SetSdrDrawMode(OBJ_PLIN); 145 break; 146 147 case SID_DRAW_BEZIER_NOFILL: 148 m_pWin->SetSdrDrawMode(OBJ_PATHLINE); 149 break; 150 151 case SID_DRAW_FREELINE_NOFILL: 152 m_pWin->SetSdrDrawMode(OBJ_FREELINE); 153 break; 154 155 default: 156 break; 157 } 158 159 SwDrawBase::Activate(nSlotId); 160 } 161 162 163 164