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