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/fmglob.hxx> 33 #include <svx/svdview.hxx> 34 #include <svx/fmshell.hxx> 35 36 #include "view.hxx" 37 #include "edtwin.hxx" 38 #include "wrtsh.hxx" 39 #include "drawbase.hxx" 40 #include "conform.hxx" 41 42 extern sal_Bool bNoInterrupt; // in mainwn.cxx 43 44 /************************************************************************* 45 |* 46 |* Konstruktor 47 |* 48 \************************************************************************/ 49 50 51 ConstFormControl::ConstFormControl(SwWrtShell* pWrtShell, SwEditWin* pEditWin, SwView* pSwView) : 52 SwDrawBase(pWrtShell, pEditWin, pSwView) 53 { 54 m_bInsForm = sal_True; 55 } 56 57 /************************************************************************* 58 |* 59 |* MouseButtonDown-event 60 |* 61 \************************************************************************/ 62 63 64 sal_Bool ConstFormControl::MouseButtonDown(const MouseEvent& rMEvt) 65 { 66 sal_Bool bReturn = sal_False; 67 68 SdrView *pSdrView = m_pSh->GetDrawView(); 69 70 pSdrView->SetOrtho(rMEvt.IsShift()); 71 pSdrView->SetAngleSnapEnabled(rMEvt.IsShift()); 72 73 if (rMEvt.IsMod2()) 74 { 75 pSdrView->SetCreate1stPointAsCenter(sal_True); 76 pSdrView->SetResizeAtCenter(sal_True); 77 } 78 else 79 { 80 pSdrView->SetCreate1stPointAsCenter(sal_False); 81 pSdrView->SetResizeAtCenter(sal_False); 82 } 83 84 SdrViewEvent aVEvt; 85 SdrHitKind eHit = pSdrView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); 86 87 // Nur neues Objekt, wenn nicht im Basismode (bzw reinem Selektionsmode) 88 if (rMEvt.IsLeft() && !m_pWin->IsDrawAction() && 89 (eHit == SDRHIT_UNMARKEDOBJECT || eHit == SDRHIT_NONE || m_pSh->IsDrawCreate())) 90 { 91 bNoInterrupt = sal_True; 92 m_pWin->CaptureMouse(); 93 94 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT)); 95 96 m_aStartPos = m_pWin->PixelToLogic(rMEvt.GetPosPixel()); 97 bReturn = m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, m_aStartPos); 98 99 if (bReturn) 100 m_pWin->SetDrawAction(sal_True); 101 } 102 else 103 bReturn = SwDrawBase::MouseButtonDown(rMEvt); 104 105 return (bReturn); 106 } 107 108 /************************************************************************* 109 |* 110 |* Function aktivieren 111 |* 112 \************************************************************************/ 113 114 115 void ConstFormControl::Activate(const sal_uInt16 nSlotId) 116 { 117 m_pWin->SetSdrDrawMode( static_cast<SdrObjKind>(nSlotId) ); 118 SwDrawBase::Activate(nSlotId); 119 m_pSh->GetDrawView()->SetCurrentObj(nSlotId); 120 121 m_pWin->SetPointer(Pointer(POINTER_DRAW_RECT)); 122 } 123 /* -----------------------------19.04.2002 12:42------------------------------ 124 125 ---------------------------------------------------------------------------*/ 126 void ConstFormControl::CreateDefaultObject() 127 { 128 Point aStartPos(GetDefaultCenterPos()); 129 Point aEndPos(aStartPos); 130 aStartPos.X() -= 2 * MM50; 131 aStartPos.Y() -= MM50; 132 aEndPos.X() += 2 * MM50; 133 aEndPos.Y() += MM50; 134 135 if(!m_pSh->HasDrawView()) 136 m_pSh->MakeDrawView(); 137 138 SdrView *pSdrView = m_pSh->GetDrawView(); 139 pSdrView->SetDesignMode(sal_True); 140 m_pSh->BeginCreate( static_cast< sal_uInt16 >(m_pWin->GetSdrDrawMode()), FmFormInventor, aStartPos); 141 m_pSh->MoveCreate(aEndPos); 142 m_pSh->EndCreate(SDRCREATE_FORCEEND); 143 } 144 145