1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sd.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "BezierObjectBar.hxx" 32*cdf0e10cSrcweir #include <sfx2/app.hxx> 33*cdf0e10cSrcweir #include <sfx2/msg.hxx> 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 36*cdf0e10cSrcweir #include <sfx2/objface.hxx> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <svx/svxids.hrc> 39*cdf0e10cSrcweir #include <svl/eitem.hxx> 40*cdf0e10cSrcweir #include <sfx2/request.hxx> 41*cdf0e10cSrcweir #include <svx/svdopath.hxx> 42*cdf0e10cSrcweir #include <svl/aeitem.hxx> 43*cdf0e10cSrcweir #include <svx/svdundo.hxx> 44*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include "sdresid.hxx" 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include "res_bmp.hrc" 52*cdf0e10cSrcweir #include "glob.hrc" 53*cdf0e10cSrcweir #include "strings.hrc" 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir #include "DrawDocShell.hxx" 56*cdf0e10cSrcweir #include "ViewShell.hxx" 57*cdf0e10cSrcweir #include "Window.hxx" 58*cdf0e10cSrcweir #include "drawview.hxx" 59*cdf0e10cSrcweir #include "drawdoc.hxx" 60*cdf0e10cSrcweir #include "sdresid.hxx" 61*cdf0e10cSrcweir #include "fusel.hxx" 62*cdf0e10cSrcweir #include "fuconbez.hxx" 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir using namespace sd; 66*cdf0e10cSrcweir #define BezierObjectBar 67*cdf0e10cSrcweir #include "sdslots.hxx" 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir namespace sd { 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir /************************************************************************* 72*cdf0e10cSrcweir |* 73*cdf0e10cSrcweir |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein) 74*cdf0e10cSrcweir |* 75*cdf0e10cSrcweir \************************************************************************/ 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL)) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir TYPEINIT1(BezierObjectBar, ::SfxShell); 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir /************************************************************************* 86*cdf0e10cSrcweir |* 87*cdf0e10cSrcweir |* Standard-Konstruktor 88*cdf0e10cSrcweir |* 89*cdf0e10cSrcweir \************************************************************************/ 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir BezierObjectBar::BezierObjectBar( 92*cdf0e10cSrcweir ViewShell* pSdViewShell, 93*cdf0e10cSrcweir ::sd::View* pSdView) 94*cdf0e10cSrcweir : SfxShell(pSdViewShell->GetViewShell()), 95*cdf0e10cSrcweir mpView(pSdView), 96*cdf0e10cSrcweir mpViewSh(pSdViewShell) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir DrawDocShell* pDocShell = mpViewSh->GetDocSh(); 99*cdf0e10cSrcweir SetPool(&pDocShell->GetPool()); 100*cdf0e10cSrcweir SetUndoManager(pDocShell->GetUndoManager()); 101*cdf0e10cSrcweir SetRepeatTarget(mpView); 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR ); 104*cdf0e10cSrcweir } 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /************************************************************************* 107*cdf0e10cSrcweir |* 108*cdf0e10cSrcweir |* Destruktor 109*cdf0e10cSrcweir |* 110*cdf0e10cSrcweir \************************************************************************/ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir BezierObjectBar::~BezierObjectBar() 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir SetRepeatTarget(NULL); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir /************************************************************************* 119*cdf0e10cSrcweir |* 120*cdf0e10cSrcweir |* Status der Attribut-Items 121*cdf0e10cSrcweir |* 122*cdf0e10cSrcweir \************************************************************************/ 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void BezierObjectBar::GetAttrState(SfxItemSet& rSet) 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir SfxItemSet aAttrSet( mpView->GetDoc()->GetPool() ); 127*cdf0e10cSrcweir mpView->GetAttributes( aAttrSet ); 128*cdf0e10cSrcweir rSet.Put(aAttrSet, sal_False); // <- sal_False, damit DontCare-Status uebernommen wird 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir FunctionReference xFunc( mpViewSh->GetCurrentFunction() ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir if(xFunc.is()) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir if(xFunc->ISA(FuSelection)) 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir sal_uInt16 nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode(); 137*cdf0e10cSrcweir rSet.Put(SfxBoolItem(nEditMode, sal_True)); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir else if (xFunc->ISA(FuConstructBezierPolygon)) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir sal_uInt16 nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode(); 142*cdf0e10cSrcweir rSet.Put(SfxBoolItem(nEditMode, sal_True)); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed()) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir // #i77187# if object is move and/or size protected, do not allow point editing at all 149*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_MOVE); 150*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_INSERT); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_DELETE); 153*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CUTLINE); 154*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CONVERT); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_EDGE); 157*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_SMOOTH); 158*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_SYMMTR); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CLOSE); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir else 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir IPolyPolygonEditorController* pIPPEC = 0; 167*cdf0e10cSrcweir if( mpView->GetMarkedObjectList().GetMarkCount() ) 168*cdf0e10cSrcweir pIPPEC = mpView; 169*cdf0e10cSrcweir else 170*cdf0e10cSrcweir pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible()) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CUTLINE); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible()) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_DELETE); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible()) 181*cdf0e10cSrcweir { 182*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CONVERT); 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir else 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind(); 187*cdf0e10cSrcweir switch (eSegm) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break; 190*cdf0e10cSrcweir case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_False)); break; // Button reingedrueckt = Kurve 191*cdf0e10cSrcweir case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_True)); break; 192*cdf0e10cSrcweir default: break; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible()) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_EDGE); 198*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_SMOOTH); 199*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_SYMMTR); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir else 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth(); 204*cdf0e10cSrcweir switch (eSmooth) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir case SDRPATHSMOOTH_DONTCARE : break; 207*cdf0e10cSrcweir case SDRPATHSMOOTH_ANGULAR : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, sal_True)); break; 208*cdf0e10cSrcweir case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,sal_True)); break; 209*cdf0e10cSrcweir case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,sal_True)); break; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible()) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir rSet.DisableItem(SID_BEZIER_CLOSE); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir else 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState(); 219*cdf0e10cSrcweir switch (eClose) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break; 222*cdf0e10cSrcweir case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_False)); break; 223*cdf0e10cSrcweir case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_True)); break; 224*cdf0e10cSrcweir default: break; 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir if(pIPPEC == mpView) 229*cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints())); 230*cdf0e10cSrcweir else 231*cdf0e10cSrcweir rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir /************************************************************************* 237*cdf0e10cSrcweir |* 238*cdf0e10cSrcweir |* Bearbeitung der SfxRequests 239*cdf0e10cSrcweir |* 240*cdf0e10cSrcweir \************************************************************************/ 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir void BezierObjectBar::Execute(SfxRequest& rReq) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir sal_uInt16 nSId = rReq.GetSlot(); 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir switch (nSId) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir case SID_BEZIER_CUTLINE: 249*cdf0e10cSrcweir case SID_BEZIER_CONVERT: 250*cdf0e10cSrcweir case SID_BEZIER_DELETE: 251*cdf0e10cSrcweir case SID_BEZIER_EDGE: 252*cdf0e10cSrcweir case SID_BEZIER_SMOOTH: 253*cdf0e10cSrcweir case SID_BEZIER_SYMMTR: 254*cdf0e10cSrcweir case SID_BEZIER_CLOSE: 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir IPolyPolygonEditorController* pIPPEC = 0; 259*cdf0e10cSrcweir if( rMarkList.GetMarkCount() ) 260*cdf0e10cSrcweir pIPPEC = mpView; 261*cdf0e10cSrcweir else 262*cdf0e10cSrcweir pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() ); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir if( pIPPEC && !mpView->IsAction()) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir switch (nSId) 267*cdf0e10cSrcweir { 268*cdf0e10cSrcweir case SID_BEZIER_DELETE: 269*cdf0e10cSrcweir pIPPEC->DeleteMarkedPoints(); 270*cdf0e10cSrcweir break; 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir case SID_BEZIER_CUTLINE: 273*cdf0e10cSrcweir pIPPEC->RipUpAtMarkedPoints(); 274*cdf0e10cSrcweir break; 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir case SID_BEZIER_CONVERT: 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE); 279*cdf0e10cSrcweir break; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir case SID_BEZIER_EDGE: 283*cdf0e10cSrcweir case SID_BEZIER_SMOOTH: 284*cdf0e10cSrcweir case SID_BEZIER_SYMMTR: 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir SdrPathSmoothKind eKind; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir switch (nSId) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir default: 291*cdf0e10cSrcweir case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break; 292*cdf0e10cSrcweir case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break; 293*cdf0e10cSrcweir case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break; 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir pIPPEC->SetMarkedPointsSmooth(eKind); 297*cdf0e10cSrcweir break; 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir case SID_BEZIER_CLOSE: 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj(); 303*cdf0e10cSrcweir const bool bUndo = mpView->IsUndoEnabled(); 304*cdf0e10cSrcweir if( bUndo ) 305*cdf0e10cSrcweir mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE))); 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir mpView->UnmarkAllPoints(); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir if( bUndo ) 310*cdf0e10cSrcweir mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj)); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir pPathObj->ToggleClosed(); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir if( bUndo ) 315*cdf0e10cSrcweir mpView->EndUndo(); 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() ) 322*cdf0e10cSrcweir mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir rReq.Ignore(); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir break; 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir case SID_BEZIER_ELIMINATE_POINTS: 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints()); 331*cdf0e10cSrcweir Invalidate(SID_BEZIER_ELIMINATE_POINTS); 332*cdf0e10cSrcweir rReq.Done(); 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir break; 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir case SID_BEZIER_MOVE: 337*cdf0e10cSrcweir case SID_BEZIER_INSERT: 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir FunctionReference xFunc( mpViewSh->GetCurrentFunction() ); 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir if(xFunc.is()) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir if(xFunc->ISA(FuSelection)) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot()); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir else if(xFunc->ISA(FuConstructBezierPolygon)) 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot()); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir rReq.Ignore (); 354*cdf0e10cSrcweir } 355*cdf0e10cSrcweir break; 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir default: 358*cdf0e10cSrcweir break; 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir Invalidate(); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir } // end of namespace sd 366