LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuconarc.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 102 1.0 %
Date: 2015-06-13 12:38:46 Functions: 2 17 11.8 %
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             : #include "fuconarc.hxx"
      21             : #include <svx/svdpagv.hxx>
      22             : #include <svx/svdocirc.hxx>
      23             : #include <sfx2/request.hxx>
      24             : #include <svl/intitem.hxx>
      25             : #include <svl/aeitem.hxx>
      26             : #include <sfx2/dispatch.hxx>
      27             : #include <svx/svdobj.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : 
      30             : #include <svx/svxids.hrc>
      31             : #include <math.h>
      32             : 
      33             : #include "app.hrc"
      34             : #include "Window.hxx"
      35             : #include "drawdoc.hxx"
      36             : #include "res_bmp.hrc"
      37             : #include "View.hxx"
      38             : #include "ViewShell.hxx"
      39             : #include "ViewShellBase.hxx"
      40             : #include "ToolBarManager.hxx"
      41             : 
      42             : #include <svx/sxciaitm.hxx>
      43             : 
      44             : using namespace com::sun::star;
      45             : 
      46             : namespace sd {
      47             : 
      48           0 : TYPEINIT1( FuConstructArc, FuConstruct );
      49             : 
      50           0 : FuConstructArc::FuConstructArc (
      51             :     ViewShell*  pViewSh,
      52             :     ::sd::Window*       pWin,
      53             :     ::sd::View*         pView,
      54             :     SdDrawDocument* pDoc,
      55             :     SfxRequest&     rReq )
      56           0 :     : FuConstruct( pViewSh, pWin, pView, pDoc, rReq )
      57             : {
      58           0 : }
      59             : 
      60           0 : rtl::Reference<FuPoor> FuConstructArc::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent  )
      61             : {
      62             :     FuConstructArc* pFunc;
      63           0 :     rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructArc( pViewSh, pWin, pView, pDoc, rReq ) );
      64           0 :     xFunc->DoExecute(rReq);
      65           0 :     pFunc->SetPermanent(bPermanent);
      66           0 :     return xFunc;
      67             : }
      68             : 
      69           0 : void FuConstructArc::DoExecute( SfxRequest& rReq )
      70             : {
      71           0 :     FuConstruct::DoExecute( rReq );
      72             : 
      73           0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
      74             :         ToolBarManager::TBG_FUNCTION,
      75           0 :         ToolBarManager::msDrawingObjectToolBar);
      76             : 
      77           0 :     const SfxItemSet *pArgs = rReq.GetArgs ();
      78             : 
      79           0 :     if (pArgs)
      80             :     {
      81           0 :         SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, false);
      82           0 :         SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, false);
      83           0 :         SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, false);
      84           0 :         SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, false);
      85           0 :         SFX_REQUEST_ARG (rReq, pPhiStart, SfxUInt32Item, ID_VAL_ANGLESTART, false);
      86           0 :         SFX_REQUEST_ARG (rReq, pPhiEnd, SfxUInt32Item, ID_VAL_ANGLEEND, false);
      87             : 
      88           0 :         Rectangle   aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
      89           0 :                                    pCenterY->GetValue () - pAxisY->GetValue () / 2,
      90           0 :                                    pCenterX->GetValue () + pAxisX->GetValue () / 2,
      91           0 :                                    pCenterY->GetValue () + pAxisY->GetValue () / 2);
      92             : 
      93           0 :         Activate();  // sets aObjKind
      94             :         SdrCircObj* pNewCircle =
      95           0 :         new SdrCircObj((SdrObjKind) mpView->GetCurrentObjIdentifier(),
      96             :                        aNewRectangle,
      97           0 :                        (long) (pPhiStart->GetValue () * 10.0),
      98           0 :                        (long) (pPhiEnd->GetValue () * 10.0));
      99           0 :         SdrPageView *pPV = mpView->GetSdrPageView();
     100             : 
     101           0 :         mpView->InsertObjectAtView(pNewCircle, *pPV, SdrInsertFlags::SETDEFLAYER);
     102             :     }
     103           0 : }
     104             : 
     105           0 : bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt )
     106             : {
     107           0 :     bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
     108             : 
     109           0 :     if ( rMEvt.IsLeft() && !mpView->IsAction() )
     110             :     {
     111           0 :         Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     112           0 :         mpWindow->CaptureMouse();
     113           0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     114           0 :         mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
     115             : 
     116           0 :         SdrObject* pObj = mpView->GetCreateObj();
     117             : 
     118           0 :         if (pObj)
     119             :         {
     120           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     121           0 :             SetStyleSheet(aAttr, pObj);
     122             : 
     123           0 :             pObj->SetMergedItemSet(aAttr);
     124             :         }
     125             : 
     126           0 :         bReturn = true;
     127             :     }
     128           0 :     return bReturn;
     129             : }
     130             : 
     131           0 : bool FuConstructArc::MouseMove( const MouseEvent& rMEvt )
     132             : {
     133           0 :     return FuConstruct::MouseMove(rMEvt);
     134             : }
     135             : 
     136           0 : bool FuConstructArc::MouseButtonUp( const MouseEvent& rMEvt )
     137             : {
     138           0 :     bool bReturn = false;
     139           0 :     bool bCreated = false;
     140             : 
     141           0 :     if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
     142             :     {
     143           0 :         const size_t nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount();
     144             : 
     145           0 :         if (mpView->EndCreateObj(SDRCREATE_NEXTPOINT) )
     146             :         {
     147           0 :             if (nCount != mpView->GetSdrPageView()->GetObjList()->GetObjCount())
     148             :             {
     149           0 :                 bCreated = true;
     150             :             }
     151             :         }
     152             : 
     153           0 :         bReturn = true;
     154             :     }
     155             : 
     156           0 :     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
     157             : 
     158           0 :     if (!bPermanent && bCreated)
     159           0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
     160             : 
     161           0 :     return bReturn;
     162             : }
     163             : 
     164             : /**
     165             :  * Process keyboard input
     166             :  * @returns sal_True if a KeyEvent is being processed, sal_False otherwise
     167             :  */
     168           0 : bool FuConstructArc::KeyInput(const KeyEvent& rKEvt)
     169             : {
     170           0 :     return FuConstruct::KeyInput(rKEvt);
     171             : }
     172             : 
     173           0 : void FuConstructArc::Activate()
     174             : {
     175             :     SdrObjKind aObjKind;
     176             : 
     177           0 :     switch( nSlotId )
     178             :     {
     179             :         case SID_DRAW_ARC      :
     180             :         case SID_DRAW_CIRCLEARC:
     181             :         {
     182           0 :             aObjKind = OBJ_CARC;
     183             :         }
     184           0 :         break;
     185             : 
     186             :         case SID_DRAW_PIE             :
     187             :         case SID_DRAW_PIE_NOFILL      :
     188             :         case SID_DRAW_CIRCLEPIE       :
     189             :         case SID_DRAW_CIRCLEPIE_NOFILL:
     190             :         {
     191           0 :             aObjKind = OBJ_SECT;
     192             :         }
     193           0 :         break;
     194             : 
     195             :         case SID_DRAW_ELLIPSECUT       :
     196             :         case SID_DRAW_ELLIPSECUT_NOFILL:
     197             :         case SID_DRAW_CIRCLECUT        :
     198             :         case SID_DRAW_CIRCLECUT_NOFILL :
     199             :         {
     200           0 :             aObjKind = OBJ_CCUT;
     201             :         }
     202           0 :         break;
     203             : 
     204             :         default:
     205             :         {
     206           0 :             aObjKind = OBJ_CARC;
     207             :         }
     208           0 :         break;
     209             :     }
     210             : 
     211           0 :     mpView->SetCurrentObj((sal_uInt16)aObjKind);
     212             : 
     213           0 :     FuConstruct::Activate();
     214           0 : }
     215             : 
     216           0 : void FuConstructArc::Deactivate()
     217             : {
     218           0 :     FuConstruct::Deactivate();
     219           0 : }
     220             : 
     221           0 : SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     222             : {
     223             : 
     224             :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     225           0 :         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
     226           0 :         0L, mpDoc);
     227             : 
     228           0 :     if(pObj)
     229             :     {
     230           0 :         if(pObj->ISA(SdrCircObj))
     231             :         {
     232           0 :             Rectangle aRect(rRectangle);
     233             : 
     234           0 :             if(SID_DRAW_ARC == nID ||
     235           0 :                 SID_DRAW_CIRCLEARC == nID ||
     236           0 :                 SID_DRAW_CIRCLEPIE == nID ||
     237           0 :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     238           0 :                 SID_DRAW_CIRCLECUT == nID ||
     239             :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     240             :             {
     241             :                 // force quadratic
     242           0 :                 ImpForceQuadratic(aRect);
     243             :             }
     244             : 
     245           0 :             pObj->SetLogicRect(aRect);
     246             : 
     247           0 :             SfxItemSet aAttr(mpDoc->GetPool());
     248           0 :             aAttr.Put(makeSdrCircStartAngleItem(9000));
     249           0 :             aAttr.Put(makeSdrCircEndAngleItem(0));
     250             : 
     251           0 :             if(SID_DRAW_PIE_NOFILL == nID ||
     252           0 :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     253           0 :                 SID_DRAW_ELLIPSECUT_NOFILL == nID ||
     254             :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     255             :             {
     256           0 :                 aAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
     257             :             }
     258             : 
     259           0 :             pObj->SetMergedItemSet(aAttr);
     260             :         }
     261             :         else
     262             :         {
     263             :             OSL_FAIL("Object is NO circle object");
     264             :         }
     265             :     }
     266             : 
     267           0 :     return pObj;
     268             : }
     269             : 
     270          66 : } // end of namespace sd
     271             : 
     272             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11