LCOV - code coverage report
Current view: top level - sd/source/ui/func - fuconarc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 146 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "fuconarc.hxx"
      31                 :            : #include <svx/svdpagv.hxx>
      32                 :            : #include <svx/svdocirc.hxx>
      33                 :            : #include <sfx2/request.hxx>
      34                 :            : #include <svl/intitem.hxx>
      35                 :            : #include <svl/aeitem.hxx>
      36                 :            : #include <sfx2/dispatch.hxx>
      37                 :            : #include <svx/svdobj.hxx>
      38                 :            : #include <sfx2/viewfrm.hxx>
      39                 :            : 
      40                 :            : 
      41                 :            : #include <svx/svxids.hrc>
      42                 :            : #include <math.h>
      43                 :            : 
      44                 :            : #include "app.hrc"
      45                 :            : #include "Window.hxx"
      46                 :            : #include "drawdoc.hxx"
      47                 :            : #include "res_bmp.hrc"
      48                 :            : #include "View.hxx"
      49                 :            : #include "ViewShell.hxx"
      50                 :            : #include "ViewShellBase.hxx"
      51                 :            : #include "ToolBarManager.hxx"
      52                 :            : 
      53                 :            : #include <svx/sxciaitm.hxx>
      54                 :            : 
      55                 :            : namespace sd {
      56                 :            : 
      57 [ #  # ][ #  # ]:          0 : TYPEINIT1( FuConstructArc, FuConstruct );
      58                 :            : 
      59                 :            : /*************************************************************************
      60                 :            : |*
      61                 :            : |* Konstruktor
      62                 :            : |*
      63                 :            : \************************************************************************/
      64                 :            : 
      65                 :          0 : FuConstructArc::FuConstructArc (
      66                 :            :     ViewShell*  pViewSh,
      67                 :            :     ::sd::Window*       pWin,
      68                 :            :     ::sd::View*         pView,
      69                 :            :     SdDrawDocument* pDoc,
      70                 :            :     SfxRequest&     rReq )
      71                 :          0 :     : FuConstruct( pViewSh, pWin, pView, pDoc, rReq )
      72                 :            : {
      73                 :          0 : }
      74                 :            : 
      75                 :          0 : FunctionReference FuConstructArc::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent  )
      76                 :            : {
      77                 :            :     FuConstructArc* pFunc;
      78 [ #  # ][ #  # ]:          0 :     FunctionReference xFunc( pFunc = new FuConstructArc( pViewSh, pWin, pView, pDoc, rReq ) );
      79         [ #  # ]:          0 :     xFunc->DoExecute(rReq);
      80                 :          0 :     pFunc->SetPermanent(bPermanent);
      81                 :          0 :     return xFunc;
      82                 :            : }
      83                 :            : 
      84                 :          0 : void FuConstructArc::DoExecute( SfxRequest& rReq )
      85                 :            : {
      86                 :          0 :     FuConstruct::DoExecute( rReq );
      87                 :            : 
      88                 :          0 :     mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBar(
      89                 :            :         ToolBarManager::TBG_FUNCTION,
      90         [ #  # ]:          0 :         ToolBarManager::msDrawingObjectToolBar);
      91                 :            : 
      92                 :          0 :     const SfxItemSet *pArgs = rReq.GetArgs ();
      93                 :            : 
      94         [ #  # ]:          0 :     if (pArgs)
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False);
      97 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False);
      98 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pAxisX, SfxUInt32Item, ID_VAL_AXIS_X, sal_False);
      99 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pAxisY, SfxUInt32Item, ID_VAL_AXIS_Y, sal_False);
     100 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pPhiStart, SfxUInt32Item, ID_VAL_ANGLESTART, sal_False);
     101 [ #  # ][ #  # ]:          0 :         SFX_REQUEST_ARG (rReq, pPhiEnd, SfxUInt32Item, ID_VAL_ANGLEEND, sal_False);
     102                 :            : 
     103                 :          0 :         Rectangle   aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
     104                 :          0 :                                    pCenterY->GetValue () - pAxisY->GetValue () / 2,
     105                 :          0 :                                    pCenterX->GetValue () + pAxisX->GetValue () / 2,
     106         [ #  # ]:          0 :                                    pCenterY->GetValue () + pAxisY->GetValue () / 2);
     107                 :            : 
     108         [ #  # ]:          0 :         Activate();  // Setzt aObjKind
     109                 :            :         SdrCircObj* pNewCircle =
     110                 :          0 :         new SdrCircObj((SdrObjKind) mpView->GetCurrentObjIdentifier(),
     111                 :            :                        aNewRectangle,
     112                 :          0 :                        (long) (pPhiStart->GetValue () * 10.0),
     113 [ #  # ][ #  # ]:          0 :                        (long) (pPhiEnd->GetValue () * 10.0));
     114                 :          0 :         SdrPageView *pPV = mpView->GetSdrPageView();
     115                 :            : 
     116         [ #  # ]:          0 :         mpView->InsertObjectAtView(pNewCircle, *pPV, SDRINSERT_SETDEFLAYER);
     117                 :            :     }
     118                 :          0 : }
     119                 :            : 
     120                 :            : /*************************************************************************
     121                 :            : |*
     122                 :            : |* MouseButtonDown-event
     123                 :            : |*
     124                 :            : \************************************************************************/
     125                 :            : 
     126                 :          0 : sal_Bool FuConstructArc::MouseButtonDown( const MouseEvent& rMEvt )
     127                 :            : {
     128                 :          0 :     sal_Bool bReturn = FuConstruct::MouseButtonDown( rMEvt );
     129                 :            : 
     130 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && !mpView->IsAction() )
                 [ #  # ]
     131                 :            :     {
     132         [ #  # ]:          0 :         Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
     133         [ #  # ]:          0 :         mpWindow->CaptureMouse();
     134         [ #  # ]:          0 :         sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
     135         [ #  # ]:          0 :         mpView->BegCreateObj(aPnt, (OutputDevice*) NULL, nDrgLog);
     136                 :            : 
     137                 :          0 :         SdrObject* pObj = mpView->GetCreateObj();
     138                 :            : 
     139         [ #  # ]:          0 :         if (pObj)
     140                 :            :         {
     141         [ #  # ]:          0 :             SfxItemSet aAttr(mpDoc->GetPool());
     142         [ #  # ]:          0 :             SetStyleSheet(aAttr, pObj);
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :             pObj->SetMergedItemSet(aAttr);
     145                 :            :         }
     146                 :            : 
     147                 :          0 :         bReturn = sal_True;
     148                 :            :     }
     149                 :          0 :     return bReturn;
     150                 :            : }
     151                 :            : 
     152                 :            : /*************************************************************************
     153                 :            : |*
     154                 :            : |* MouseMove-event
     155                 :            : |*
     156                 :            : \************************************************************************/
     157                 :            : 
     158                 :          0 : sal_Bool FuConstructArc::MouseMove( const MouseEvent& rMEvt )
     159                 :            : {
     160                 :          0 :     return FuConstruct::MouseMove(rMEvt);
     161                 :            : }
     162                 :            : 
     163                 :            : /*************************************************************************
     164                 :            : |*
     165                 :            : |* MouseButtonUp-event
     166                 :            : |*
     167                 :            : \************************************************************************/
     168                 :            : 
     169                 :          0 : sal_Bool FuConstructArc::MouseButtonUp( const MouseEvent& rMEvt )
     170                 :            : {
     171                 :          0 :     sal_Bool bReturn = sal_False;
     172                 :          0 :     sal_Bool bCreated = sal_False;
     173                 :            : 
     174 [ #  # ][ #  # ]:          0 :     if ( mpView->IsCreateObj() && rMEvt.IsLeft() )
                 [ #  # ]
     175                 :            :     {
     176                 :          0 :         sal_uLong nCount = mpView->GetSdrPageView()->GetObjList()->GetObjCount();
     177                 :            : 
     178         [ #  # ]:          0 :         if (mpView->EndCreateObj(SDRCREATE_NEXTPOINT) )
     179                 :            :         {
     180         [ #  # ]:          0 :             if (nCount != mpView->GetSdrPageView()->GetObjList()->GetObjCount())
     181                 :            :             {
     182                 :          0 :                 bCreated = sal_True;
     183                 :            :             }
     184                 :            :         }
     185                 :            : 
     186                 :          0 :         bReturn = sal_True;
     187                 :            :     }
     188                 :            : 
     189 [ #  # ][ #  # ]:          0 :     bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
     190                 :            : 
     191 [ #  # ][ #  # ]:          0 :     if (!bPermanent && bCreated)
     192                 :          0 :         mpViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     193                 :            : 
     194                 :          0 :     return bReturn;
     195                 :            : }
     196                 :            : 
     197                 :            : /*************************************************************************
     198                 :            : |*
     199                 :            : |* Tastaturereignisse bearbeiten
     200                 :            : |*
     201                 :            : |* Wird ein KeyEvent bearbeitet, so ist der Return-Wert sal_True, andernfalls
     202                 :            : |* sal_False.
     203                 :            : |*
     204                 :            : \************************************************************************/
     205                 :            : 
     206                 :          0 : sal_Bool FuConstructArc::KeyInput(const KeyEvent& rKEvt)
     207                 :            : {
     208                 :          0 :     sal_Bool bReturn = FuConstruct::KeyInput(rKEvt);
     209                 :          0 :     return(bReturn);
     210                 :            : }
     211                 :            : 
     212                 :            : /*************************************************************************
     213                 :            : |*
     214                 :            : |* Function aktivieren
     215                 :            : |*
     216                 :            : \************************************************************************/
     217                 :            : 
     218                 :          0 : void FuConstructArc::Activate()
     219                 :            : {
     220                 :            :     SdrObjKind aObjKind;
     221                 :            : 
     222   [ #  #  #  # ]:          0 :     switch( nSlotId )
     223                 :            :     {
     224                 :            :         case SID_DRAW_ARC      :
     225                 :            :         case SID_DRAW_CIRCLEARC:
     226                 :            :         {
     227                 :          0 :             aObjKind = OBJ_CARC;
     228                 :            :         }
     229                 :          0 :         break;
     230                 :            : 
     231                 :            :         case SID_DRAW_PIE             :
     232                 :            :         case SID_DRAW_PIE_NOFILL      :
     233                 :            :         case SID_DRAW_CIRCLEPIE       :
     234                 :            :         case SID_DRAW_CIRCLEPIE_NOFILL:
     235                 :            :         {
     236                 :          0 :             aObjKind = OBJ_SECT;
     237                 :            :         }
     238                 :          0 :         break;
     239                 :            : 
     240                 :            :         case SID_DRAW_ELLIPSECUT       :
     241                 :            :         case SID_DRAW_ELLIPSECUT_NOFILL:
     242                 :            :         case SID_DRAW_CIRCLECUT        :
     243                 :            :         case SID_DRAW_CIRCLECUT_NOFILL :
     244                 :            :         {
     245                 :          0 :             aObjKind = OBJ_CCUT;
     246                 :            :         }
     247                 :          0 :         break;
     248                 :            : 
     249                 :            :         default:
     250                 :            :         {
     251                 :          0 :             aObjKind = OBJ_CARC;
     252                 :            :         }
     253                 :          0 :         break;
     254                 :            :     }
     255                 :            : 
     256                 :          0 :     mpView->SetCurrentObj((sal_uInt16)aObjKind);
     257                 :            : 
     258                 :          0 :     FuConstruct::Activate();
     259                 :          0 : }
     260                 :            : 
     261                 :            : /*************************************************************************
     262                 :            : |*
     263                 :            : |* Function deaktivieren
     264                 :            : |*
     265                 :            : \************************************************************************/
     266                 :            : 
     267                 :          0 : void FuConstructArc::Deactivate()
     268                 :            : {
     269                 :          0 :     FuConstruct::Deactivate();
     270                 :          0 : }
     271                 :            : 
     272                 :          0 : SdrObject* FuConstructArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
     273                 :            : {
     274                 :            : 
     275                 :            :     SdrObject* pObj = SdrObjFactory::MakeNewObject(
     276                 :          0 :         mpView->GetCurrentObjInventor(), mpView->GetCurrentObjIdentifier(),
     277                 :          0 :         0L, mpDoc);
     278                 :            : 
     279         [ #  # ]:          0 :     if(pObj)
     280                 :            :     {
     281         [ #  # ]:          0 :         if(pObj->ISA(SdrCircObj))
     282                 :            :         {
     283                 :          0 :             Rectangle aRect(rRectangle);
     284                 :            : 
     285 [ #  # ][ #  # ]:          0 :             if(SID_DRAW_ARC == nID ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     286                 :            :                 SID_DRAW_CIRCLEARC == nID ||
     287                 :            :                 SID_DRAW_CIRCLEPIE == nID ||
     288                 :            :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     289                 :            :                 SID_DRAW_CIRCLECUT == nID ||
     290                 :            :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     291                 :            :             {
     292                 :            :                 // force quadratic
     293         [ #  # ]:          0 :                 ImpForceQuadratic(aRect);
     294                 :            :             }
     295                 :            : 
     296         [ #  # ]:          0 :             pObj->SetLogicRect(aRect);
     297                 :            : 
     298         [ #  # ]:          0 :             SfxItemSet aAttr(mpDoc->GetPool());
     299 [ #  # ][ #  # ]:          0 :             aAttr.Put(SdrCircStartAngleItem(9000));
                 [ #  # ]
     300 [ #  # ][ #  # ]:          0 :             aAttr.Put(SdrCircEndAngleItem(0));
                 [ #  # ]
     301                 :            : 
     302 [ #  # ][ #  # ]:          0 :             if(SID_DRAW_PIE_NOFILL == nID ||
         [ #  # ][ #  # ]
     303                 :            :                 SID_DRAW_CIRCLEPIE_NOFILL == nID ||
     304                 :            :                 SID_DRAW_ELLIPSECUT_NOFILL == nID ||
     305                 :            :                 SID_DRAW_CIRCLECUT_NOFILL == nID)
     306                 :            :             {
     307 [ #  # ][ #  # ]:          0 :                 aAttr.Put(XFillStyleItem(XFILL_NONE));
                 [ #  # ]
     308                 :            :             }
     309                 :            : 
     310 [ #  # ][ #  # ]:          0 :             pObj->SetMergedItemSet(aAttr);
     311                 :            :         }
     312                 :            :         else
     313                 :            :         {
     314                 :            :             OSL_FAIL("Object is NO circle object");
     315                 :            :         }
     316                 :            :     }
     317                 :            : 
     318                 :          0 :     return pObj;
     319                 :            : }
     320                 :            : 
     321                 :            : } // end of namespace sd
     322                 :            : 
     323                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10