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_sc.hxx" 30 31 #include "fuconuno.hxx" 32 #include "tabvwsh.hxx" 33 #include "sc.hrc" 34 #include "drawview.hxx" 35 36 /************************************************************************* 37 |* 38 |* Konstruktor 39 |* 40 \************************************************************************/ 41 42 FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, 43 SdrModel* pDoc, SfxRequest& rReq) 44 : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq) 45 { 46 SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, sal_False ); 47 SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False ); 48 if( pInventorItem ) 49 nInventor = pInventorItem->GetValue(); 50 if( pIdentifierItem ) 51 nIdentifier = pIdentifierItem->GetValue(); 52 } 53 54 /************************************************************************* 55 |* 56 |* Destruktor 57 |* 58 \************************************************************************/ 59 60 FuConstUnoControl::~FuConstUnoControl() 61 { 62 } 63 64 /************************************************************************* 65 |* 66 |* MouseButtonDown-event 67 |* 68 \************************************************************************/ 69 70 sal_Bool __EXPORT FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt) 71 { 72 // #95491# remember button state for creation of own MouseEvents 73 SetMouseButtonCode(rMEvt.GetButtons()); 74 75 sal_Bool bReturn = FuConstruct::MouseButtonDown(rMEvt); 76 77 if ( rMEvt.IsLeft() && !pView->IsAction() ) 78 { 79 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 80 pWindow->CaptureMouse(); 81 pView->BegCreateObj(aPnt); 82 bReturn = sal_True; 83 } 84 return bReturn; 85 } 86 87 /************************************************************************* 88 |* 89 |* MouseMove-event 90 |* 91 \************************************************************************/ 92 93 sal_Bool __EXPORT FuConstUnoControl::MouseMove(const MouseEvent& rMEvt) 94 { 95 return FuConstruct::MouseMove(rMEvt); 96 } 97 98 /************************************************************************* 99 |* 100 |* MouseButtonUp-event 101 |* 102 \************************************************************************/ 103 104 sal_Bool __EXPORT FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt) 105 { 106 // #95491# remember button state for creation of own MouseEvents 107 SetMouseButtonCode(rMEvt.GetButtons()); 108 109 sal_Bool bReturn = sal_False; 110 111 if ( pView->IsCreateObj() && rMEvt.IsLeft() ) 112 { 113 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 114 pView->EndCreateObj(SDRCREATE_FORCEEND); 115 bReturn = sal_True; 116 } 117 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); 118 } 119 120 /************************************************************************* 121 |* 122 |* Tastaturereignisse bearbeiten 123 |* 124 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 125 |* FALSE. 126 |* 127 \************************************************************************/ 128 129 sal_Bool __EXPORT FuConstUnoControl::KeyInput(const KeyEvent& rKEvt) 130 { 131 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 132 return(bReturn); 133 } 134 135 /************************************************************************* 136 |* 137 |* Function aktivieren 138 |* 139 \************************************************************************/ 140 141 void FuConstUnoControl::Activate() 142 { 143 pView->SetCurrentObj( nIdentifier, nInventor ); 144 145 aNewPointer = Pointer( POINTER_DRAW_RECT ); 146 aOldPointer = pWindow->GetPointer(); 147 pViewShell->SetActivePointer( aNewPointer ); 148 149 SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS); 150 if (pLayer) 151 pView->SetActiveLayer( pLayer->GetName() ); 152 153 FuConstruct::Activate(); 154 } 155 156 /************************************************************************* 157 |* 158 |* Function deaktivieren 159 |* 160 \************************************************************************/ 161 162 void FuConstUnoControl::Deactivate() 163 { 164 FuConstruct::Deactivate(); 165 166 SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT); 167 if (pLayer) 168 pView->SetActiveLayer( pLayer->GetName() ); 169 170 pViewShell->SetActivePointer( aOldPointer ); 171 } 172 173 // #98185# Create default drawing objects via keyboard 174 SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle) 175 { 176 // case SID_FM_CREATE_CONTROL: 177 178 SdrObject* pObj = SdrObjFactory::MakeNewObject( 179 pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), 180 0L, pDrDoc); 181 182 if(pObj) 183 { 184 pObj->SetLogicRect(rRectangle); 185 } 186 187 return pObj; 188 } 189 190 191