LCOV - code coverage report
Current view: top level - sd/source/ui/view - drbezob.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 128 0.0 %
Date: 2014-04-14 Functions: 0 14 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             : #include "BezierObjectBar.hxx"
      21             : #include <sfx2/app.hxx>
      22             : #include <sfx2/msg.hxx>
      23             : #include <sfx2/viewfrm.hxx>
      24             : #include <sfx2/objface.hxx>
      25             : 
      26             : #include <svx/svxids.hrc>
      27             : #include <svl/eitem.hxx>
      28             : #include <sfx2/request.hxx>
      29             : #include <svx/svdopath.hxx>
      30             : #include <svl/aeitem.hxx>
      31             : #include <svx/svdundo.hxx>
      32             : #include <sfx2/dispatch.hxx>
      33             : 
      34             : #include "sdresid.hxx"
      35             : 
      36             : #include "res_bmp.hrc"
      37             : #include "glob.hrc"
      38             : #include "strings.hrc"
      39             : 
      40             : #include "DrawDocShell.hxx"
      41             : #include "ViewShell.hxx"
      42             : #include "Window.hxx"
      43             : #include "drawview.hxx"
      44             : #include "drawdoc.hxx"
      45             : #include "fusel.hxx"
      46             : #include "fuconbez.hxx"
      47             : 
      48             : 
      49             : using namespace sd;
      50             : #define BezierObjectBar
      51             : #include "sdslots.hxx"
      52             : 
      53             : namespace sd {
      54             : 
      55             : /**
      56             :  * Declare default interface (Slotmap must not be empty)
      57             :  */
      58             : 
      59           0 : SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL))
      60             : {
      61           0 : }
      62             : 
      63           0 : TYPEINIT1(BezierObjectBar, ::SfxShell);
      64             : 
      65             : 
      66           0 : BezierObjectBar::BezierObjectBar(
      67             :     ViewShell* pSdViewShell,
      68             :     ::sd::View* pSdView)
      69             :     : SfxShell(pSdViewShell->GetViewShell()),
      70             :       mpView(pSdView),
      71           0 :       mpViewSh(pSdViewShell)
      72             : {
      73           0 :     DrawDocShell* pDocShell = mpViewSh->GetDocSh();
      74           0 :     SetPool(&pDocShell->GetPool());
      75           0 :     SetUndoManager(pDocShell->GetUndoManager());
      76           0 :     SetRepeatTarget(mpView);
      77             : 
      78           0 :     SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR );
      79           0 : }
      80             : 
      81             : 
      82           0 : BezierObjectBar::~BezierObjectBar()
      83             : {
      84           0 :     SetRepeatTarget(NULL);
      85           0 : }
      86             : 
      87             : 
      88             : /**
      89             :  * Status of attribute items.
      90             :  */
      91             : 
      92           0 : void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
      93             : {
      94           0 :     SfxItemSet aAttrSet( mpView->GetDoc().GetPool() );
      95           0 :     mpView->GetAttributes( aAttrSet );
      96           0 :     rSet.Put(aAttrSet, false); // <- sal_False, so DontCare-Status gets aquired
      97             : 
      98           0 :     rtl::Reference<FuPoor> xFunc( mpViewSh->GetCurrentFunction() );
      99             : 
     100           0 :     if(xFunc.is())
     101             :     {
     102           0 :         if(xFunc->ISA(FuSelection))
     103             :         {
     104           0 :             sal_uInt16 nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode();
     105           0 :             rSet.Put(SfxBoolItem(nEditMode, true));
     106             :         }
     107           0 :         else if (xFunc->ISA(FuConstructBezierPolygon))
     108             :         {
     109           0 :             sal_uInt16 nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
     110           0 :             rSet.Put(SfxBoolItem(nEditMode, true));
     111             :         }
     112             :     }
     113             : 
     114           0 :     if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed())
     115             :     {
     116             :         // #i77187# if object is move and/or size protected, do not allow point editing at all
     117           0 :         rSet.DisableItem(SID_BEZIER_MOVE);
     118           0 :         rSet.DisableItem(SID_BEZIER_INSERT);
     119             : 
     120           0 :         rSet.DisableItem(SID_BEZIER_DELETE);
     121           0 :         rSet.DisableItem(SID_BEZIER_CUTLINE);
     122           0 :         rSet.DisableItem(SID_BEZIER_CONVERT);
     123             : 
     124           0 :         rSet.DisableItem(SID_BEZIER_EDGE);
     125           0 :         rSet.DisableItem(SID_BEZIER_SMOOTH);
     126           0 :         rSet.DisableItem(SID_BEZIER_SYMMTR);
     127             : 
     128           0 :         rSet.DisableItem(SID_BEZIER_CLOSE);
     129             : 
     130           0 :         rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
     131             :     }
     132             :     else
     133             :     {
     134           0 :         IPolyPolygonEditorController* pIPPEC = 0;
     135           0 :         if( mpView->GetMarkedObjectList().GetMarkCount() )
     136           0 :             pIPPEC = mpView;
     137             :         else
     138           0 :             pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
     139             : 
     140           0 :         if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
     141             :         {
     142           0 :             rSet.DisableItem(SID_BEZIER_CUTLINE);
     143             :         }
     144           0 :         if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
     145             :         {
     146           0 :             rSet.DisableItem(SID_BEZIER_DELETE);
     147             :         }
     148           0 :         if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
     149             :         {
     150           0 :             rSet.DisableItem(SID_BEZIER_CONVERT);
     151             :         }
     152             :         else
     153             :         {
     154           0 :             SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
     155           0 :             switch (eSegm)
     156             :             {
     157           0 :                 case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
     158           0 :                 case SDRPATHSEGMENT_LINE    : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,false)); break; // Button down = curve
     159           0 :                 case SDRPATHSEGMENT_CURVE   : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,true));  break;
     160           0 :                 default: break;
     161             :             }
     162             :         }
     163           0 :         if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
     164             :         {
     165           0 :             rSet.DisableItem(SID_BEZIER_EDGE);
     166           0 :             rSet.DisableItem(SID_BEZIER_SMOOTH);
     167           0 :             rSet.DisableItem(SID_BEZIER_SYMMTR);
     168             :         }
     169             :         else
     170             :         {
     171           0 :             SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
     172           0 :             switch (eSmooth)
     173             :             {
     174           0 :                 case SDRPATHSMOOTH_DONTCARE  : break;
     175           0 :                 case SDRPATHSMOOTH_ANGULAR   : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE,  true)); break;
     176           0 :                 case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,true)); break;
     177           0 :                 case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,true)); break;
     178             :             }
     179             :         }
     180           0 :         if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
     181             :         {
     182           0 :             rSet.DisableItem(SID_BEZIER_CLOSE);
     183             :         }
     184             :         else
     185             :         {
     186           0 :             SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
     187           0 :             switch (eClose)
     188             :             {
     189           0 :                 case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
     190           0 :                 case SDROBJCLOSED_OPEN    : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,false)); break;
     191           0 :                 case SDROBJCLOSED_CLOSED  : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,true)); break;
     192           0 :                 default: break;
     193             :             }
     194             :         }
     195             : 
     196           0 :         if(pIPPEC == mpView)
     197           0 :             rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
     198             :         else
     199           0 :             rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
     200           0 :     }
     201           0 : }
     202             : 
     203             : /**
     204             :  * Process SfxRequests
     205             :  */
     206             : 
     207           0 : void BezierObjectBar::Execute(SfxRequest& rReq)
     208             : {
     209           0 :     sal_uInt16 nSId = rReq.GetSlot();
     210             : 
     211           0 :     switch (nSId)
     212             :     {
     213             :         case SID_BEZIER_CUTLINE:
     214             :         case SID_BEZIER_CONVERT:
     215             :         case SID_BEZIER_DELETE:
     216             :         case SID_BEZIER_EDGE:
     217             :         case SID_BEZIER_SMOOTH:
     218             :         case SID_BEZIER_SYMMTR:
     219             :         case SID_BEZIER_CLOSE:
     220             :         {
     221           0 :             const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     222             : 
     223           0 :             IPolyPolygonEditorController* pIPPEC = 0;
     224           0 :             if( rMarkList.GetMarkCount() )
     225           0 :                 pIPPEC = mpView;
     226             :             else
     227           0 :                 pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
     228             : 
     229           0 :             if( pIPPEC && !mpView->IsAction())
     230             :             {
     231           0 :                 switch (nSId)
     232             :                 {
     233             :                     case SID_BEZIER_DELETE:
     234           0 :                         pIPPEC->DeleteMarkedPoints();
     235           0 :                         break;
     236             : 
     237             :                     case SID_BEZIER_CUTLINE:
     238           0 :                         pIPPEC->RipUpAtMarkedPoints();
     239           0 :                         break;
     240             : 
     241             :                     case SID_BEZIER_CONVERT:
     242             :                     {
     243           0 :                         pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
     244           0 :                         break;
     245             :                     }
     246             : 
     247             :                     case SID_BEZIER_EDGE:
     248             :                     case SID_BEZIER_SMOOTH:
     249             :                     case SID_BEZIER_SYMMTR:
     250             :                     {
     251             :                         SdrPathSmoothKind eKind;
     252             : 
     253           0 :                         switch (nSId)
     254             :                         {
     255             :                             default:
     256           0 :                             case SID_BEZIER_EDGE:   eKind = SDRPATHSMOOTH_ANGULAR; break;
     257           0 :                             case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
     258           0 :                             case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
     259             :                         }
     260             : 
     261           0 :                         pIPPEC->SetMarkedPointsSmooth(eKind);
     262           0 :                         break;
     263             :                     }
     264             : 
     265             :                     case SID_BEZIER_CLOSE:
     266             :                     {
     267           0 :                         SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
     268           0 :                         const bool bUndo = mpView->IsUndoEnabled();
     269           0 :                         if( bUndo )
     270           0 :                             mpView->BegUndo(SD_RESSTR(STR_UNDO_BEZCLOSE));
     271             : 
     272           0 :                         mpView->UnmarkAllPoints();
     273             : 
     274           0 :                         if( bUndo )
     275           0 :                             mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
     276             : 
     277           0 :                         pPathObj->ToggleClosed();
     278             : 
     279           0 :                         if( bUndo )
     280           0 :                             mpView->EndUndo();
     281           0 :                         break;
     282             :                     }
     283             :                 }
     284             :             }
     285             : 
     286           0 :             if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
     287           0 :                 mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
     288             : 
     289           0 :             rReq.Ignore();
     290             :         }
     291           0 :         break;
     292             : 
     293             :         case SID_BEZIER_ELIMINATE_POINTS:
     294             :         {
     295           0 :             mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints());
     296           0 :             Invalidate(SID_BEZIER_ELIMINATE_POINTS);
     297           0 :             rReq.Done();
     298             :         }
     299           0 :         break;
     300             : 
     301             :         case SID_BEZIER_MOVE:
     302             :         case SID_BEZIER_INSERT:
     303             :         {
     304           0 :             rtl::Reference<FuPoor> xFunc( mpViewSh->GetCurrentFunction() );
     305             : 
     306           0 :             if(xFunc.is())
     307             :             {
     308           0 :                 if(xFunc->ISA(FuSelection))
     309             :                 {
     310           0 :                     static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
     311             :                 }
     312           0 :                 else if(xFunc->ISA(FuConstructBezierPolygon))
     313             :                 {
     314           0 :                     static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
     315             :                 }
     316             :             }
     317             : 
     318           0 :             rReq.Ignore ();
     319             :         }
     320           0 :         break;
     321             : 
     322             :         default:
     323           0 :         break;
     324             :     }
     325             : 
     326           0 :     Invalidate();
     327           0 : }
     328             : 
     329             : 
     330             : } // end of namespace sd
     331             : 
     332             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10