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