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