1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10*5b190011SAndrew Rist * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5b190011SAndrew Rist * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19*5b190011SAndrew Rist * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "fuconarc.hxx" 28cdf0e10cSrcweir #include <svx/svdpagv.hxx> 29cdf0e10cSrcweir #include <svx/svdocirc.hxx> 30cdf0e10cSrcweir #include <sfx2/request.hxx> 31cdf0e10cSrcweir #include <svl/intitem.hxx> 32cdf0e10cSrcweir #include <svl/aeitem.hxx> 33cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 34cdf0e10cSrcweir #include <svx/svdobj.hxx> 35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <svx/svxids.hrc> 39cdf0e10cSrcweir #include <math.h> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include "app.hrc" 42cdf0e10cSrcweir #include "Window.hxx" 43cdf0e10cSrcweir #include "drawdoc.hxx" 44cdf0e10cSrcweir #include "res_bmp.hrc" 45cdf0e10cSrcweir #include "View.hxx" 46cdf0e10cSrcweir #include "ViewShell.hxx" 47cdf0e10cSrcweir #include "ViewShellBase.hxx" 48cdf0e10cSrcweir #include "ToolBarManager.hxx" 49cdf0e10cSrcweir 50cdf0e10cSrcweir // #97016# 51cdf0e10cSrcweir #include <svx/sxciaitm.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace sd { 54cdf0e10cSrcweir 55cdf0e10cSrcweir TYPEINIT1( FuConstructArc, FuConstruct ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir /************************************************************************* 58cdf0e10cSrcweir |* 59cdf0e10cSrcweir |* Konstruktor 60cdf0e10cSrcweir |* 61cdf0e10cSrcweir \************************************************************************/ 62cdf0e10cSrcweir 63cdf0e10cSrcweir FuConstructArc::FuConstructArc ( 64cdf0e10cSrcweir ViewShell* pViewSh, 65cdf0e10cSrcweir ::sd::Window* pWin, 66cdf0e10cSrcweir ::sd::View* pView, 67cdf0e10cSrcweir SdDrawDocument* pDoc, 68cdf0e10cSrcweir SfxRequest& rReq ) 69cdf0e10cSrcweir : FuConstruct( pViewSh, pWin, pView, pDoc, rReq ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir FunctionReference FuConstructArc::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ) 74cdf0e10cSrcweir { 75cdf0e10cSrcweir FuConstructArc* pFunc; 76cdf0e10cSrcweir FunctionReference xFunc( pFunc = new FuConstructArc( pViewSh, pWin, pView, pDoc, rReq ) ); 77cdf0e10cSrcweir xFunc->DoExecute(rReq); 78cdf0e10cSrcweir pFunc->SetPermanent(bPermanent); 79cdf0e10cSrcweir return xFunc; 80cdf0e10cSrcweir } 81cdf0e10cSrcweir 82cdf0e10cSrcweir void FuConstructArc::DoExecute( SfxRequest& rReq ) 83cdf0e10cSrcweir { 84cdf0e10cSrcweir FuConstruct::DoExecute( rReq ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar( 87cdf0e10cSrcweir ToolBarManager::TBG_FUNCTION, 88cdf0e10cSrcweir ToolBarManager::msDrawingObjectToolBar); 89cdf0e10cSrcweir 90cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs (); 91cdf0e10cSrcweir 92cdf0e10cSrcweir if (pArgs) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False); 95cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False); 96cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, sal_False); 97cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, sal_False); 98cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pPhiStart, SfxUInt32Item, ID_VAL_ANGLESTART, sal_False); 99cdf0e10cSrcweir SFX_REQUEST_ARG (rReq, pPhiEnd, SfxUInt32Item, ID_VAL_ANGLEEND, sal_False); 100cdf0e10cSrcweir 101cdf0e10cSrcweir Rectangle aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2, 102cdf0e10cSrcweir pCenterY->GetValue () - pAxisY->GetValue () / 2, 103cdf0e10cSrcweir pCenterX->GetValue () + pAxisX->GetValue () / 2, 104cdf0e10cSrcweir pCenterY->GetValue () + pAxisY->GetValue () / 2); 105cdf0e10cSrcweir 106cdf0e10cSrcweir Activate(); // Setzt aObjKind 107cdf0e10cSrcweir SdrCircObj* pNewCircle = 108cdf0e10cSrcweir new SdrCircObj((SdrObjKind) mpView->GetCurrentObjIdentifier(), 109cdf0e10cSrcweir aNewRectangle, 110cdf0e10cSrcweir (long) (pPhiStart->GetValue () * 10.0), 111cdf0e10cSrcweir (long) (pPhiEnd->GetValue () * 10.0)); 112cdf0e10cSrcweir SdrPageView *pPV = mpView->GetSdrPageView(); 113cdf0e10cSrcweir 114cdf0e10cSrcweir mpView->InsertObjectAtView(pNewCircle, *pPV, SDRINSERT_SETDEFLAYER); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir /************************************************************************* 119cdf0e10cSrcweir |* 120cdf0e10cSrcweir |* MouseButtonDown-event 121cdf0e10cSrcweir |* 122cdf0e10cSrcweir \************************************************************************/ 123cdf0e10cSrcweir 124cdf0e10cSrcweir sal_Bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir sal_Bool bReturn = FuConstruct::MouseButtonDown( rMEvt ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir if ( rMEvt.IsLeft() && !mpView->IsAction() ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 131cdf0e10cSrcweir mpWindow->CaptureMouse(); 132cdf0e10cSrcweir sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() ); 133cdf0e10cSrcweir mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog); 134cdf0e10cSrcweir 135cdf0e10cSrcweir SdrObject* pObj = mpView->GetCreateObj(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir if (pObj) 138cdf0e10cSrcweir { 139cdf0e10cSrcweir SfxItemSet aAttr(mpDoc->GetPool()); 140cdf0e10cSrcweir SetStyleSheet(aAttr, pObj); 141cdf0e10cSrcweir 142cdf0e10cSrcweir //-/ pObj->NbcSetAttributes(aAttr, sal_False); 143cdf0e10cSrcweir pObj->SetMergedItemSet(aAttr); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir bReturn = sal_True; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir return bReturn; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir /************************************************************************* 152cdf0e10cSrcweir |* 153cdf0e10cSrcweir |* MouseMove-event 154cdf0e10cSrcweir |* 155cdf0e10cSrcweir \************************************************************************/ 156cdf0e10cSrcweir 157cdf0e10cSrcweir sal_Bool FuConstructArc::MouseMove( const MouseEvent& rMEvt ) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir return FuConstruct::MouseMove(rMEvt); 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir /************************************************************************* 163cdf0e10cSrcweir |* 164cdf0e10cSrcweir |* MouseButtonUp-event 165cdf0e10cSrcweir |* 166cdf0e10cSrcweir \************************************************************************/ 167cdf0e10cSrcweir 168cdf0e10cSrcweir sal_Bool FuConstructArc::MouseButtonUp( const MouseEvent& rMEvt ) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir sal_Bool bReturn = sal_False; 171cdf0e10cSrcweir sal_Bool bCreated = sal_False; 172cdf0e10cSrcweir 173cdf0e10cSrcweir if ( mpView->IsCreateObj() && rMEvt.IsLeft() ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir sal_uLong nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir if (mpView->EndCreateObj(SDRCREATE_NEXTPOINT) ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir if (nCount != mpView->GetSdrPageView()->GetObjList()->GetObjCount()) 182cdf0e10cSrcweir { 183cdf0e10cSrcweir bCreated = sal_True; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir } 186cdf0e10cSrcweir 187cdf0e10cSrcweir bReturn = sal_True; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn; 191cdf0e10cSrcweir 192cdf0e10cSrcweir if (!bPermanent && bCreated) 193cdf0e10cSrcweir mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 194cdf0e10cSrcweir 195cdf0e10cSrcweir return bReturn; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir /************************************************************************* 199cdf0e10cSrcweir |* 200cdf0e10cSrcweir |* Tastaturereignisse bearbeiten 201cdf0e10cSrcweir |* 202cdf0e10cSrcweir |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls 203cdf0e10cSrcweir |* sal_False. 204cdf0e10cSrcweir |* 205cdf0e10cSrcweir \************************************************************************/ 206cdf0e10cSrcweir 207cdf0e10cSrcweir sal_Bool FuConstructArc::KeyInput(const KeyEvent& rKEvt) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir sal_Bool bReturn = FuConstruct::KeyInput(rKEvt); 210cdf0e10cSrcweir return(bReturn); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir /************************************************************************* 214cdf0e10cSrcweir |* 215cdf0e10cSrcweir |* Function aktivieren 216cdf0e10cSrcweir |* 217cdf0e10cSrcweir \************************************************************************/ 218cdf0e10cSrcweir 219cdf0e10cSrcweir void FuConstructArc::Activate() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir SdrObjKind aObjKind; 222cdf0e10cSrcweir 223cdf0e10cSrcweir switch( nSlotId ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir case SID_DRAW_ARC : 226cdf0e10cSrcweir case SID_DRAW_CIRCLEARC: 227cdf0e10cSrcweir { 228cdf0e10cSrcweir aObjKind = OBJ_CARC; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir break; 231cdf0e10cSrcweir 232cdf0e10cSrcweir case SID_DRAW_PIE : 233cdf0e10cSrcweir case SID_DRAW_PIE_NOFILL : 234cdf0e10cSrcweir case SID_DRAW_CIRCLEPIE : 235cdf0e10cSrcweir case SID_DRAW_CIRCLEPIE_NOFILL: 236cdf0e10cSrcweir { 237cdf0e10cSrcweir aObjKind = OBJ_SECT; 238cdf0e10cSrcweir } 239cdf0e10cSrcweir break; 240cdf0e10cSrcweir 241cdf0e10cSrcweir case SID_DRAW_ELLIPSECUT : 242cdf0e10cSrcweir case SID_DRAW_ELLIPSECUT_NOFILL: 243cdf0e10cSrcweir case SID_DRAW_CIRCLECUT : 244cdf0e10cSrcweir case SID_DRAW_CIRCLECUT_NOFILL : 245cdf0e10cSrcweir { 246cdf0e10cSrcweir aObjKind = OBJ_CCUT; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir break; 249cdf0e10cSrcweir 250cdf0e10cSrcweir default: 251cdf0e10cSrcweir { 252cdf0e10cSrcweir aObjKind = OBJ_CARC; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir break; 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir mpView->SetCurrentObj((sal_uInt16)aObjKind); 258cdf0e10cSrcweir 259cdf0e10cSrcweir FuConstruct::Activate(); 260cdf0e10cSrcweir // FuDraw::Activate(); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir /************************************************************************* 264cdf0e10cSrcweir |* 265cdf0e10cSrcweir |* Function deaktivieren 266cdf0e10cSrcweir |* 267cdf0e10cSrcweir \************************************************************************/ 268cdf0e10cSrcweir 269cdf0e10cSrcweir void FuConstructArc::Deactivate() 270cdf0e10cSrcweir { 271cdf0e10cSrcweir FuConstruct::Deactivate(); 272cdf0e10cSrcweir // FuDraw::Deactivate(); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir // #97016# 276cdf0e10cSrcweir SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir // case SID_DRAW_ARC: 279cdf0e10cSrcweir // case SID_DRAW_CIRCLEARC: 280cdf0e10cSrcweir // case SID_DRAW_PIE: 281cdf0e10cSrcweir // case SID_DRAW_PIE_NOFILL: 282cdf0e10cSrcweir // case SID_DRAW_CIRCLEPIE: 283cdf0e10cSrcweir // case SID_DRAW_CIRCLEPIE_NOFILL: 284cdf0e10cSrcweir // case SID_DRAW_ELLIPSECUT: 285cdf0e10cSrcweir // case SID_DRAW_ELLIPSECUT_NOFILL: 286cdf0e10cSrcweir // case SID_DRAW_CIRCLECUT: 287cdf0e10cSrcweir // case SID_DRAW_CIRCLECUT_NOFILL: 288cdf0e10cSrcweir 289cdf0e10cSrcweir SdrObject* pObj = SdrObjFactory::MakeNewObject( 290cdf0e10cSrcweir mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(), 291cdf0e10cSrcweir 0L, mpDoc); 292cdf0e10cSrcweir 293cdf0e10cSrcweir if(pObj) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir if(pObj->ISA(SdrCircObj)) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir Rectangle aRect(rRectangle); 298cdf0e10cSrcweir 299cdf0e10cSrcweir if(SID_DRAW_ARC == nID || 300cdf0e10cSrcweir SID_DRAW_CIRCLEARC == nID || 301cdf0e10cSrcweir SID_DRAW_CIRCLEPIE == nID || 302cdf0e10cSrcweir SID_DRAW_CIRCLEPIE_NOFILL == nID || 303cdf0e10cSrcweir SID_DRAW_CIRCLECUT == nID || 304cdf0e10cSrcweir SID_DRAW_CIRCLECUT_NOFILL == nID) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir // force quadratic 307cdf0e10cSrcweir ImpForceQuadratic(aRect); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir pObj->SetLogicRect(aRect); 311cdf0e10cSrcweir 312cdf0e10cSrcweir SfxItemSet aAttr(mpDoc->GetPool()); 313cdf0e10cSrcweir aAttr.Put(SdrCircStartAngleItem(9000)); 314cdf0e10cSrcweir aAttr.Put(SdrCircEndAngleItem(0)); 315cdf0e10cSrcweir 316cdf0e10cSrcweir if(SID_DRAW_PIE_NOFILL == nID || 317cdf0e10cSrcweir SID_DRAW_CIRCLEPIE_NOFILL == nID || 318cdf0e10cSrcweir SID_DRAW_ELLIPSECUT_NOFILL == nID || 319cdf0e10cSrcweir SID_DRAW_CIRCLECUT_NOFILL == nID) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir aAttr.Put(XFillStyleItem(XFILL_NONE)); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir pObj->SetMergedItemSet(aAttr); 325cdf0e10cSrcweir } 326cdf0e10cSrcweir else 327cdf0e10cSrcweir { 328cdf0e10cSrcweir DBG_ERROR("Object is NO circle object"); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir } 331cdf0e10cSrcweir 332cdf0e10cSrcweir return pObj; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir 335cdf0e10cSrcweir } // end of namespace sd 336