LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuconarc.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 102 0.0 %
Date: 2014-04-14 Functions: 0 15 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "fuconarc.hxx"
      22             : #include <svx/svdpagv.hxx>
      23             : #include <svx/svdocirc.hxx>
      24             : #include <sfx2/request.hxx>
      25             : #include <svl/intitem.hxx>
      26             : #include <svl/aeitem.hxx>
      27             : #include <sfx2/dispatch.hxx>
      28             : #include <svx/svdobj.hxx>
      29             : #include <sfx2/viewfrm.hxx>
      30             : 
      31             : 
      32             : #include <svx/svxids.hrc>
      33             : #include <math.h>
      34             : 
      35             : #include "app.hrc"
      36             : #include "Window.hxx"
      37             : #include "drawdoc.hxx"
      38             : #include "res_bmp.hrc"
      39             : #include "View.hxx"
      40             : #include "ViewShell.hxx"
      41             : #include "ViewShellBase.hxx"
      42             : #include "ToolBarManager.hxx"
      43             : 
      44             : #include <svx/sxciaitm.hxx>
      45             : 
      46             : namespace sd {
      47             : 
      48           0 : TYPEINIT1( FuConstructArc, FuConstruct );
      49             : 
      50             : 
      51           0 : FuConstructArc::FuConstructArc (
      52             :     ViewShell*  pViewSh,
      53             :     ::sd::Window*       pWin,
      54             :     ::sd::View*         pView,
      55             :     SdDrawDocument* pDoc,
      56             :     SfxRequest&     rReq )
      57           0 :     : FuConstruct( pViewSh, pWin, pView, pDoc, rReq )
      58             : {
      59           0 : }
      60             : 
      61           0 : rtl::Reference<FuPoor> FuConstructArc::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent  )
      62             : {
      63             :     FuConstructArc* pFunc;
      64           0 :     rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( pViewSh, pWin, pView, pDoc, rReq ) );
      65           0 :     xFunc->DoExecute(rReq);
      66           0 :     pFunc->SetPermanent(bPermanent);
      67           0 :     return xFunc;
      68             : }
      69             : 
      70           0 : void FuConstructArc::DoExecute( SfxRequest& rReq )
      71             : {
      72           0 :     FuConstruct::DoExecute( rReq );
      73             : 
      74           0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
      75             :         ToolBarManager::TBG_FUNCTION,
      76           0 :         ToolBarManager::msDrawingObjectToolBar);
      77             : 
      78           0 :     const SfxItemSet *pArgs = rReq.GetArgs ();
      79             : 
      80           0 :     if (pArgs)
      81             :     {
      82           0 :         SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, false);
      83           0 :         SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, false);
      84           0 :         SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, false);
      85           0 :         SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, false);
      86           0 :         SFX_REQUEST_ARG (rReq, pPhiStart, SfxUInt32Item, ID_VAL_ANGLESTART, false);
      87           0 :         SFX_REQUEST_ARG (rReq, pPhiEnd, SfxUInt32Item, ID_VAL_ANGLEEND, false);
      88             : 
      89           0 :         Rectangle   aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
      90           0 :                                    pCenterY->GetValue () - pAxisY->GetValue () / 2,
      91           0 :                                    pCenterX->GetValue () + pAxisX->GetValue () / 2,
      92           0 :                                    pCenterY->GetValue () + pAxisY->GetValue () / 2);
      93             : 
      94           0 :         Activate();  // sets aObjKind
      95             :         SdrCircObj* pNewCircle =
      96           0 :         new SdrCircObj((SdrObjKind) mpView->GetCurrentObjIdentifier(),
      97             :                        aNewRectangle,
      98           0 :                        (long) (pPhiStart->GetValue () * 10.0),
      99           0 :                        (long) (pPhiEnd->GetValue () * 10.0));
     100           0 :         SdrPageView *pPV = mpView->GetSdrPageView();
     101             : 
     102           0 :         mpView->InsertObjectAtView(pNewCircle, *pPV, SDRINSERT_SETDEFLAYER);
     103             :     }
     104           0 : }
     105             : 
     106             : 
     107           0 : sal_Bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt )
     108             : {
     109           0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
     110             : 
     111           0 :     if ( rMEvt.IsLeft() && !mpView->IsAction() )
     112             :     {
     113           0 :         Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     114           0 :         mpWindow->CaptureMouse();
     115           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     116           0 :         mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
     117             : 
     118           0 :         SdrObject* pObj = mpView->GetCreateObj();
     119             : 
     120           0 :         if (pObj)
     121             :         {
     122           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     123           0 :             SetStyleSheet(aAttr, pObj);
     124             : 
     125           0 :             pObj->SetMergedItemSet(aAttr);
     126             :         }
     127             : 
     128           0 :         bReturn = sal_True;
     129             :     }
     130           0 :     return bReturn;
     131             : }
     132             : 
     133             : 
     134           0 : sal_Bool FuConstructArc::MouseMove( const MouseEvent& rMEvt )
     135             : {
     136           0 :     return FuConstruct::MouseMove(rMEvt);
     137             : }
     138             : 
     139             : 
     140           0 : sal_Bool FuConstructArc::MouseButtonUp( const MouseEvent& rMEvt )
     141             : {
     142           0 :     sal_Bool bReturn = sal_False;
     143           0 :     sal_Bool bCreated = sal_False;
     144             : 
     145           0 :     if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
     146             :     {
     147           0 :         sal_uLong nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount();
     148             : 
     149           0 :         if (mpView->EndCreateObj(SDRCREATE_NEXTPOINT) )
     150             :         {
     151           0 :             if (nCount != mpView->GetSdrPageView()->GetObjList()->GetObjCount())
     152             :             {
     153           0 :                 bCreated = sal_True;
     154             :             }
     155             :         }
     156             : 
     157           0 :         bReturn = sal_True;
     158             :     }
     159             : 
     160           0 :     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
     161             : 
     162           0 :     if (!bPermanent && bCreated)
     163           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     164             : 
     165           0 :     return bReturn;
     166             : }
     167             : 
     168             : /**
     169             :  * Process keyboard input
     170             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     171             :  */
     172           0 : sal_Bool FuConstructArc::KeyInput(const KeyEvent& rKEvt)
     173             : {
     174           0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     175           0 :     return(bReturn);
     176             : }
     177             : 
     178             : 
     179           0 : void FuConstructArc::Activate()
     180             : {
     181             :     SdrObjKind aObjKind;
     182             : 
     183           0 :     switch( nSlotId )
     184             :     {
     185             :         case SID_DRAW_ARC      :
     186             :         case SID_DRAW_CIRCLEARC:
     187             :         {
     188           0 :             aObjKind = OBJ_CARC;
     189             :         }
     190           0 :         break;
     191             : 
     192             :         case SID_DRAW_PIE             :
     193             :         case SID_DRAW_PIE_NOFILL      :
     194             :         case SID_DRAW_CIRCLEPIE       :
     195             :         case SID_DRAW_CIRCLEPIE_NOFILL:
     196             :         {
     197           0 :             aObjKind = OBJ_SECT;
     198             :         }
     199           0 :         break;
     200             : 
     201             :         case SID_DRAW_ELLIPSECUT       :
     202             :         case SID_DRAW_ELLIPSECUT_NOFILL:
     203             :         case SID_DRAW_CIRCLECUT        :
     204             :         case SID_DRAW_CIRCLECUT_NOFILL :
     205             :         {
     206           0 :             aObjKind = OBJ_CCUT;
     207             :         }
     208           0 :         break;
     209             : 
     210             :         default:
     211             :         {
     212           0 :             aObjKind = OBJ_CARC;
     213             :         }
     214           0 :         break;
     215             :     }
     216             : 
     217           0 :     mpView->SetCurrentObj((sal_uInt16)aObjKind);
     218             : 
     219           0 :     FuConstruct::Activate();
     220           0 : }
     221             : 
     222             : 
     223           0 : void FuConstructArc::Deactivate()
     224             : {
     225           0 :     FuConstruct::Deactivate();
     226           0 : }
     227             : 
     228           0 : SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     229             : {
     230             : 
     231             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     232           0 :         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
     233           0 :         0L, mpDoc);
     234             : 
     235           0 :     if(pObj)
     236             :     {
     237           0 :         if(pObj->ISA(SdrCircObj))
     238             :         {
     239           0 :             Rectangle aRect(rRectangle);
     240             : 
     241           0 :             if(SID_DRAW_ARC == nID ||
     242           0 :                 SID_DRAW_CIRCLEARC == nID ||
     243           0 :                 SID_DRAW_CIRCLEPIE == nID ||
     244           0 :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     245           0 :                 SID_DRAW_CIRCLECUT == nID ||
     246             :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     247             :             {
     248             :                 // force quadratic
     249           0 :                 ImpForceQuadratic(aRect);
     250             :             }
     251             : 
     252           0 :             pObj->SetLogicRect(aRect);
     253             : 
     254           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     255           0 :             aAttr.Put(SdrCircStartAngleItem(9000));
     256           0 :             aAttr.Put(SdrCircEndAngleItem(0));
     257             : 
     258           0 :             if(SID_DRAW_PIE_NOFILL == nID ||
     259           0 :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     260           0 :                 SID_DRAW_ELLIPSECUT_NOFILL == nID ||
     261             :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     262             :             {
     263           0 :                 aAttr.Put(XFillStyleItem(XFILL_NONE));
     264             :             }
     265             : 
     266           0 :             pObj->SetMergedItemSet(aAttr);
     267             :         }
     268             :         else
     269             :         {
     270             :             OSL_FAIL("Object is NO circle object");
     271             :         }
     272             :     }
     273             : 
     274           0 :     return pObj;
     275             : }
     276             : 
     277             : } // end of namespace sd
     278             : 
     279             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10