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 "fuconarc.hxx" 28 #include "sc.hrc" 29 #include "tabvwsh.hxx" 30 #include "drawview.hxx" 31 32 // #98185# Create default drawing objects via keyboard 33 #include <svx/svdocirc.hxx> 34 #include <svx/sxciaitm.hxx> 35 36 /************************************************************************* 37 |* 38 |* Konstruktor 39 |* 40 \************************************************************************/ 41 42 FuConstArc::FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, 43 SdrModel* pDoc, SfxRequest& rReq ) 44 : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq ) 45 { 46 } 47 48 /************************************************************************* 49 |* 50 |* Destruktor 51 |* 52 \************************************************************************/ 53 54 FuConstArc::~FuConstArc() 55 { 56 } 57 58 /************************************************************************* 59 |* 60 |* MouseButtonDown-event 61 |* 62 \************************************************************************/ 63 64 sal_Bool __EXPORT FuConstArc::MouseButtonDown( const MouseEvent& rMEvt ) 65 { 66 // #95491# remember button state for creation of own MouseEvents 67 SetMouseButtonCode(rMEvt.GetButtons()); 68 69 sal_Bool bReturn = FuConstruct::MouseButtonDown( rMEvt ); 70 71 if ( rMEvt.IsLeft() && !pView->IsAction() ) 72 { 73 Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 74 pWindow->CaptureMouse(); 75 pView->BegCreateObj( aPnt ); 76 bReturn = sal_True; 77 } 78 return bReturn; 79 } 80 81 /************************************************************************* 82 |* 83 |* MouseMove-event 84 |* 85 \************************************************************************/ 86 87 sal_Bool __EXPORT FuConstArc::MouseMove( const MouseEvent& rMEvt ) 88 { 89 return FuConstruct::MouseMove(rMEvt); 90 } 91 92 /************************************************************************* 93 |* 94 |* MouseButtonUp-event 95 |* 96 \************************************************************************/ 97 98 sal_Bool __EXPORT FuConstArc::MouseButtonUp( const MouseEvent& rMEvt ) 99 { 100 // #95491# remember button state for creation of own MouseEvents 101 SetMouseButtonCode(rMEvt.GetButtons()); 102 103 sal_Bool bReturn = sal_False; 104 105 if ( pView->IsCreateObj() && rMEvt.IsLeft() ) 106 { 107 // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 108 pView->EndCreateObj( SDRCREATE_NEXTPOINT ); 109 bReturn = sal_True; 110 } 111 /* 112 else if ( pView->IsCreateObj() && rMEvt.IsRight() ) 113 { 114 // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 115 pView->EndCreateObj( SDRCREATE_FORCEEND ); 116 bReturn = sal_True; 117 } 118 */ 119 return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); 120 } 121 122 /************************************************************************* 123 |* 124 |* Tastaturereignisse bearbeiten 125 |* 126 |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 127 |* FALSE. 128 |* 129 \************************************************************************/ 130 131 sal_Bool __EXPORT FuConstArc::KeyInput(const KeyEvent& rKEvt) 132 { 133 sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 134 return(bReturn); 135 } 136 137 /************************************************************************* 138 |* 139 |* Function aktivieren 140 |* 141 \************************************************************************/ 142 143 void FuConstArc::Activate() 144 { 145 SdrObjKind aObjKind; 146 147 switch (aSfxRequest.GetSlot() ) 148 { 149 case SID_DRAW_ARC: 150 aNewPointer = Pointer( POINTER_DRAW_ARC ); 151 aObjKind = OBJ_CARC; 152 break; 153 154 case SID_DRAW_PIE: 155 aNewPointer = Pointer( POINTER_DRAW_PIE ); 156 aObjKind = OBJ_SECT; 157 break; 158 159 case SID_DRAW_CIRCLECUT: 160 aNewPointer = Pointer( POINTER_DRAW_CIRCLECUT ); 161 aObjKind = OBJ_CCUT; 162 break; 163 164 default: 165 aNewPointer = Pointer( POINTER_CROSS ); 166 aObjKind = OBJ_CARC; 167 break; 168 } 169 170 pView->SetCurrentObj( sal::static_int_cast<sal_uInt16>( aObjKind ) ); 171 172 aOldPointer = pWindow->GetPointer(); 173 pViewShell->SetActivePointer( aNewPointer ); 174 175 FuDraw::Activate(); 176 } 177 178 /************************************************************************* 179 |* 180 |* Function deaktivieren 181 |* 182 \************************************************************************/ 183 184 void FuConstArc::Deactivate() 185 { 186 FuDraw::Deactivate(); 187 pViewShell->SetActivePointer( aOldPointer ); 188 } 189 190 // #98185# Create default drawing objects via keyboard 191 SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) 192 { 193 // case SID_DRAW_ARC: 194 // case SID_DRAW_PIE: 195 // case SID_DRAW_CIRCLECUT: 196 197 SdrObject* pObj = SdrObjFactory::MakeNewObject( 198 pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), 199 0L, pDrDoc); 200 201 if(pObj) 202 { 203 if(pObj->ISA(SdrCircObj)) 204 { 205 Rectangle aRect(rRectangle); 206 207 if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID) 208 { 209 // force quadratic 210 ImpForceQuadratic(aRect); 211 } 212 213 pObj->SetLogicRect(aRect); 214 215 SfxItemSet aAttr(pDrDoc->GetItemPool()); 216 aAttr.Put(SdrCircStartAngleItem(9000)); 217 aAttr.Put(SdrCircEndAngleItem(0)); 218 219 pObj->SetMergedItemSet(aAttr); 220 } 221 else 222 { 223 DBG_ERROR("Object is NO circle object"); 224 } 225 } 226 227 return pObj; 228 } 229 230 231