tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / drawfunc / drawsh5.cxx
blob58b3f3538da6a50de6d313a65fb0d727a95d691a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <editeng/eeitem.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <sfx2/request.hxx>
24 #include <sfx2/bindings.hxx>
25 #include <tools/urlobj.hxx>
26 #include <cliputil.hxx>
27 #include <svx/svxdlg.hxx>
28 #include <svx/hlnkitem.hxx>
29 #include <svx/svdoole2.hxx>
30 #include <svx/svdouno.hxx>
31 #include <svx/extrusionbar.hxx>
32 #include <svx/fontworkbar.hxx>
33 #include <svx/svdogrp.hxx>
34 #include <sfx2/docfile.hxx>
35 #include <osl/diagnose.h>
36 #include <svx/diagram/IDiagramHelper.hxx>
38 #include <com/sun/star/form/FormButtonType.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/beans/XPropertySetInfo.hpp>
42 #include <drawsh.hxx>
43 #include <drawview.hxx>
44 #include <viewdata.hxx>
45 #include <tabvwsh.hxx>
46 #include <docsh.hxx>
47 #include <undotab.hxx>
48 #include <drwlayer.hxx>
49 #include <drtxtob.hxx>
50 #include <memory>
52 #include <sc.hrc>
54 using namespace com::sun::star;
56 void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
58 ScDrawView* pView = rViewData.GetScDrawView();
59 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
61 // Hyperlink
63 SvxHyperlinkItem aHLinkItem;
65 if ( rMarkList.GetMarkCount() == 1 ) // URL-Button marked ?
67 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
68 if ( pObj && !pObj->getHyperlink().isEmpty() )
70 aHLinkItem.SetURL( pObj->getHyperlink() );
71 aHLinkItem.SetInsertMode(HLINK_FIELD);
73 SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
74 if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
76 const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->GetUnoControlModel();
77 OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
78 if( !xControlModel.is() )
79 return;
81 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
82 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
84 OUString sPropButtonType( u"ButtonType"_ustr );
86 if(xInfo->hasPropertyByName( sPropButtonType ))
88 uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
89 form::FormButtonType eTmp;
90 if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
92 OUString sTmp;
93 // Label
94 OUString sPropLabel( u"Label"_ustr );
95 if(xInfo->hasPropertyByName( sPropLabel ))
97 aAny = xPropSet->getPropertyValue( sPropLabel );
98 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
100 aHLinkItem.SetName(sTmp);
103 // URL
104 OUString sPropTargetURL( u"TargetURL"_ustr );
105 if(xInfo->hasPropertyByName( sPropTargetURL ))
107 aAny = xPropSet->getPropertyValue( sPropTargetURL );
108 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
110 aHLinkItem.SetURL(sTmp);
113 // Target
114 OUString sPropTargetFrame( u"TargetFrame"_ustr );
115 if(xInfo->hasPropertyByName( sPropTargetFrame ))
117 aAny = xPropSet->getPropertyValue( sPropTargetFrame );
118 if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
120 aHLinkItem.SetTargetFrame(sTmp);
123 aHLinkItem.SetInsertMode(HLINK_BUTTON);
129 rSet.Put(aHLinkItem);
132 void ScDrawShell::ExecuteHLink( const SfxRequest& rReq )
134 const SfxItemSet* pReqArgs = rReq.GetArgs();
136 sal_uInt16 nSlot = rReq.GetSlot();
137 switch ( nSlot )
139 case SID_HYPERLINK_SETLINK:
140 if( pReqArgs )
142 const SfxPoolItem* pItem;
143 if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
145 const SvxHyperlinkItem* pHyper = static_cast<const SvxHyperlinkItem*>(pItem);
146 const OUString& rName = pHyper->GetName();
147 const OUString& rURL = pHyper->GetURL();
148 const OUString& rTarget = pHyper->GetTargetFrame();
149 SvxLinkInsertMode eMode = pHyper->GetInsertMode();
151 bool bDone = false;
152 if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
154 ScDrawView* pView = rViewData.GetScDrawView();
155 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
156 if ( rMarkList.GetMarkCount() == 1 )
158 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
159 SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
160 if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
162 const uno::Reference<awt::XControlModel>& xControlModel =
163 pUnoCtrl->GetUnoControlModel();
164 OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
165 if( !xControlModel.is() )
166 return;
168 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
169 uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
171 OUString sPropTargetURL( u"TargetURL"_ustr );
173 // Is it possible to set a URL in the object?
174 if (xInfo->hasPropertyByName( sPropTargetURL ))
177 OUString sPropButtonType( u"ButtonType"_ustr);
178 OUString sPropTargetFrame( u"TargetFrame"_ustr );
179 OUString sPropLabel( u"Label"_ustr );
181 if ( xInfo->hasPropertyByName( sPropLabel ) )
183 xPropSet->setPropertyValue( sPropLabel, uno::Any(rName) );
186 OUString aTmp = INetURLObject::GetAbsURL( rViewData.GetDocShell()->GetMedium()->GetBaseURL(), rURL );
187 xPropSet->setPropertyValue( sPropTargetURL, uno::Any(aTmp) );
189 if( !rTarget.isEmpty() && xInfo->hasPropertyByName( sPropTargetFrame ) )
191 xPropSet->setPropertyValue( sPropTargetFrame, uno::Any(rTarget) );
194 if ( xInfo->hasPropertyByName( sPropButtonType ) )
196 xPropSet->setPropertyValue( sPropButtonType, uno::Any(form::FormButtonType_URL) );
199 //! Undo ???
200 rViewData.GetDocShell()->SetDocumentModified();
201 bDone = true;
204 else
206 pObj->setHyperlink(rURL);
207 setModified();
208 bDone = true;
213 if (!bDone)
214 rViewData.GetViewShell()->
215 InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) );
217 // If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!!
220 break;
221 default:
222 OSL_FAIL("wrong slot");
226 // Functions on Drawing-Objects
228 void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
230 SfxBindings& rBindings = rViewData.GetBindings();
231 ScTabView* pTabView = rViewData.GetView();
232 ScDrawView* pView = pTabView->GetScDrawView();
233 sal_uInt16 nSlotId = rReq.GetSlot();
235 switch (nSlotId)
237 case SID_OBJECT_HEAVEN:
238 pView->SetMarkedToLayer( SC_LAYER_FRONT );
239 rBindings.Invalidate(SID_OBJECT_HEAVEN);
240 rBindings.Invalidate(SID_OBJECT_HELL);
241 break;
242 case SID_OBJECT_HELL:
243 pView->SetMarkedToLayer( SC_LAYER_BACK );
244 rBindings.Invalidate(SID_OBJECT_HEAVEN);
245 rBindings.Invalidate(SID_OBJECT_HELL);
246 // leave draw shell if nothing selected (layer may be locked)
247 rViewData.GetViewShell()->UpdateDrawShell();
248 break;
250 case SID_FRAME_TO_TOP:
251 pView->PutMarkedToTop();
252 break;
253 case SID_FRAME_TO_BOTTOM:
254 pView->PutMarkedToBtm();
255 break;
256 case SID_FRAME_UP:
257 pView->MovMarkedToTop();
258 break;
259 case SID_FRAME_DOWN:
260 pView->MovMarkedToBtm();
261 break;
263 case SID_GROUP:
264 pView->GroupMarked();
265 break;
266 case SID_UNGROUP:
267 pView->UnGroupMarked();
268 break;
269 case SID_ENTER_GROUP:
270 pView->EnterMarkedGroup();
271 break;
272 case SID_LEAVE_GROUP:
273 pView->LeaveOneGroup();
274 break;
276 case SID_REGENERATE_DIAGRAM:
277 case SID_EDIT_DIAGRAM:
279 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
281 if (1 == rMarkList.GetMarkCount())
283 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
285 // Support advanced DiagramHelper
286 if(nullptr != pObj && pObj->isDiagram())
288 if(SID_REGENERATE_DIAGRAM == nSlotId)
290 pView->UnmarkAll();
291 pObj->getDiagramHelper()->reLayout(*static_cast<SdrObjGroup*>(pObj));
292 pView->MarkObj(pObj, pView->GetSdrPageView());
294 else // SID_EDIT_DIAGRAM
296 VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
297 vcl::Window* pWin = rViewData.GetActiveWin();
298 VclPtr<VclAbstractDialog> pDlg = pFact->CreateDiagramDialog(
299 pWin ? pWin->GetFrameWeld() : nullptr,
300 *static_cast<SdrObjGroup*>(pObj));
301 pDlg->StartExecuteAsync(
302 [pDlg] (sal_Int32 /*nResult*/)->void
304 pDlg->disposeOnce();
311 rReq.Done();
313 break;
315 case SID_MIRROR_HORIZONTAL:
316 case SID_FLIP_HORIZONTAL:
317 pView->MirrorAllMarkedHorizontal();
318 rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
319 break;
320 case SID_MIRROR_VERTICAL:
321 case SID_FLIP_VERTICAL:
322 pView->MirrorAllMarkedVertical();
323 rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
324 break;
326 case SID_OBJECT_ALIGN_LEFT:
327 case SID_ALIGN_ANY_LEFT:
328 if (pView->IsAlignPossible())
329 pView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE);
330 break;
331 case SID_OBJECT_ALIGN_CENTER:
332 case SID_ALIGN_ANY_HCENTER:
333 if (pView->IsAlignPossible())
334 pView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE);
335 break;
336 case SID_OBJECT_ALIGN_RIGHT:
337 case SID_ALIGN_ANY_RIGHT:
338 if (pView->IsAlignPossible())
339 pView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE);
340 break;
341 case SID_OBJECT_ALIGN_UP:
342 case SID_ALIGN_ANY_TOP:
343 if (pView->IsAlignPossible())
344 pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top);
345 break;
346 case SID_OBJECT_ALIGN_MIDDLE:
347 case SID_ALIGN_ANY_VCENTER:
348 if (pView->IsAlignPossible())
349 pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center);
350 break;
351 case SID_OBJECT_ALIGN_DOWN:
352 case SID_ALIGN_ANY_BOTTOM:
353 if (pView->IsAlignPossible())
354 pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom);
355 break;
357 case SID_DELETE:
358 case SID_DELETE_CONTENTS:
359 pView->DeleteMarked();
360 rViewData.GetViewShell()->UpdateDrawShell();
361 break;
363 case SID_CUT:
364 pView->DoCut();
365 rViewData.GetViewShell()->UpdateDrawShell();
366 break;
368 case SID_COPY:
369 pView->DoCopy();
370 break;
372 case SID_PASTE:
373 ScClipUtil::PasteFromClipboard(GetViewData(), GetViewData().GetViewShell(), true);
374 break;
376 case SID_SELECTALL:
377 pView->MarkAll();
378 break;
380 case SID_ANCHOR_PAGE:
381 pView->SetPageAnchored();
382 rBindings.Invalidate( SID_ANCHOR_PAGE );
383 rBindings.Invalidate( SID_ANCHOR_CELL );
384 rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
385 break;
387 case SID_ANCHOR_CELL:
388 pView->SetCellAnchored(false);
389 rBindings.Invalidate( SID_ANCHOR_PAGE );
390 rBindings.Invalidate( SID_ANCHOR_CELL );
391 rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
392 break;
394 case SID_ANCHOR_CELL_RESIZE:
395 pView->SetCellAnchored(true);
396 rBindings.Invalidate( SID_ANCHOR_PAGE );
397 rBindings.Invalidate( SID_ANCHOR_CELL );
398 rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
399 break;
401 case SID_ANCHOR_TOGGLE:
403 switch( pView->GetAnchorType() )
405 case SCA_CELL:
406 case SCA_CELL_RESIZE:
407 pView->SetPageAnchored();
408 break;
409 default:
410 pView->SetCellAnchored(false);
411 break;
414 rBindings.Invalidate( SID_ANCHOR_PAGE );
415 rBindings.Invalidate( SID_ANCHOR_CELL );
416 rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
417 break;
419 case SID_OBJECT_ROTATE:
421 SdrDragMode eMode;
422 if (pView->GetDragMode() == SdrDragMode::Rotate)
423 eMode = SdrDragMode::Move;
424 else
425 eMode = SdrDragMode::Rotate;
426 pView->SetDragMode( eMode );
427 rBindings.Invalidate( SID_OBJECT_ROTATE );
428 rBindings.Invalidate( SID_OBJECT_MIRROR );
429 if (eMode == SdrDragMode::Rotate && !pView->IsFrameDragSingles())
431 pView->SetFrameDragSingles();
432 rBindings.Invalidate( SID_BEZIER_EDIT );
435 break;
436 case SID_OBJECT_MIRROR:
438 SdrDragMode eMode;
439 if (pView->GetDragMode() == SdrDragMode::Mirror)
440 eMode = SdrDragMode::Move;
441 else
442 eMode = SdrDragMode::Mirror;
443 pView->SetDragMode( eMode );
444 rBindings.Invalidate( SID_OBJECT_ROTATE );
445 rBindings.Invalidate( SID_OBJECT_MIRROR );
446 if (eMode == SdrDragMode::Mirror && !pView->IsFrameDragSingles())
448 pView->SetFrameDragSingles();
449 rBindings.Invalidate( SID_BEZIER_EDIT );
452 break;
453 case SID_BEZIER_EDIT:
455 bool bOld = pView->IsFrameDragSingles();
456 pView->SetFrameDragSingles( !bOld );
457 rBindings.Invalidate( SID_BEZIER_EDIT );
458 if (bOld && pView->GetDragMode() != SdrDragMode::Move)
460 pView->SetDragMode( SdrDragMode::Move );
461 rBindings.Invalidate( SID_OBJECT_ROTATE );
462 rBindings.Invalidate( SID_OBJECT_MIRROR );
465 break;
467 case SID_FONTWORK:
469 sal_uInt16 nId = ScGetFontWorkId();
470 SfxViewFrame& rViewFrm = rViewData.GetViewShell()->GetViewFrame();
472 if ( rReq.GetArgs() )
473 rViewFrm.SetChildWindow( nId,
474 static_cast<const SfxBoolItem&>(
475 (rReq.GetArgs()->Get(SID_FONTWORK))).
476 GetValue() );
477 else
478 rViewFrm.ToggleChildWindow( nId );
480 rBindings.Invalidate( SID_FONTWORK );
481 rReq.Done();
483 break;
485 case SID_ORIGINALSIZE:
486 pView->SetMarkedOriginalSize();
487 break;
489 case SID_FITCELLSIZE:
490 pView->FitToCellSize();
491 break;
493 case SID_ENABLE_HYPHENATION:
495 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION);
496 if( pItem )
498 SfxItemSetFixed<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE> aSet( GetPool() );
499 bool bValue = pItem->GetValue();
500 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
501 pView->SetAttributes( aSet );
503 rReq.Done();
505 break;
507 case SID_RENAME_OBJECT:
509 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
510 if(1 == rMarkList.GetMarkCount())
512 // #i68101#
513 SdrObject* pSelected = rMarkList.GetMark(0)->GetMarkedSdrObj();
514 assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
516 if(SC_LAYER_INTERN != pSelected->GetLayer())
518 OUString aOldName = pSelected->GetName();
520 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
521 vcl::Window* pWin = rViewData.GetActiveWin();
522 VclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aOldName));
524 pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
526 pDlg->StartExecuteAsync(
527 [this, pDlg, pSelected] (sal_Int32 nResult)->void
529 if (nResult == RET_OK)
531 ScDocShell* pDocSh = rViewData.GetDocShell();
532 OUString aNewName = pDlg->GetName();
534 if (aNewName != pSelected->GetName())
536 // handle name change
537 const SdrObjKind nObjType(pSelected->GetObjIdentifier());
539 if (SdrObjKind::Graphic == nObjType && aNewName.isEmpty())
541 // graphics objects must have names
542 // (all graphics are supposed to be in the navigator)
543 ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
545 if(pModel)
547 aNewName = pModel->GetNewGraphicName();
551 // An undo action for renaming is missing in svdraw (99363).
552 // For OLE objects (which can be identified using the persist name),
553 // ScUndoRenameObject can be used until there is a common action for all objects.
554 if(SdrObjKind::OLE2 == nObjType)
556 const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
558 if(!aPersistName.isEmpty())
560 pDocSh->GetUndoManager()->AddUndoAction(
561 std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aNewName));
565 // set new name
566 pSelected->SetName(aNewName);
569 // ChartListenerCollectionNeedsUpdate is needed for Navigator update
570 pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
571 pDocSh->SetDrawModified();
573 pDlg->disposeOnce();
578 break;
581 // #i68101#
582 case SID_TITLE_DESCRIPTION_OBJECT:
584 const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
585 if(1 == rMarkList.GetMarkCount())
587 SdrObject* pSelected = rMarkList.GetMark(0)->GetMarkedSdrObj();
588 assert(pSelected && "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
590 if(SC_LAYER_INTERN != pSelected->GetLayer())
592 OUString aTitle(pSelected->GetTitle());
593 OUString aDescription(pSelected->GetDescription());
594 bool isDecorative(pSelected->IsDecorative());
596 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
597 vcl::Window* pWin = rViewData.GetActiveWin();
598 VclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(
599 pWin ? pWin->GetFrameWeld() : nullptr, aTitle, aDescription, isDecorative));
601 pDlg->StartExecuteAsync(
602 [this, pDlg, pSelected] (sal_Int32 nResult)->void
604 if (nResult == RET_OK)
606 ScDocShell* pDocSh = rViewData.GetDocShell();
608 // handle Title and Description
609 pSelected->SetTitle(pDlg->GetTitle());
610 pSelected->SetDescription(pDlg->GetDescription());
611 pSelected->SetDecorative(pDlg->IsDecorative());
613 // ChartListenerCollectionNeedsUpdate is needed for Navigator update
614 pDocSh->GetDocument().SetChartListenerCollectionNeedsUpdate( true );
615 pDocSh->SetDrawModified();
617 pDlg->disposeOnce();
622 break;
625 case SID_EXTRUSION_TOGGLE:
626 case SID_EXTRUSION_TILT_DOWN:
627 case SID_EXTRUSION_TILT_UP:
628 case SID_EXTRUSION_TILT_LEFT:
629 case SID_EXTRUSION_TILT_RIGHT:
630 case SID_EXTRUSION_3D_COLOR:
631 case SID_EXTRUSION_DEPTH:
632 case SID_EXTRUSION_DIRECTION:
633 case SID_EXTRUSION_PROJECTION:
634 case SID_EXTRUSION_LIGHTING_DIRECTION:
635 case SID_EXTRUSION_LIGHTING_INTENSITY:
636 case SID_EXTRUSION_SURFACE:
637 case SID_EXTRUSION_DEPTH_FLOATER:
638 case SID_EXTRUSION_DIRECTION_FLOATER:
639 case SID_EXTRUSION_LIGHTING_FLOATER:
640 case SID_EXTRUSION_SURFACE_FLOATER:
641 case SID_EXTRUSION_DEPTH_DIALOG:
642 svx::ExtrusionBar::execute( pView, rReq, rBindings );
643 rReq.Ignore ();
644 break;
646 case SID_FONTWORK_SHAPE:
647 case SID_FONTWORK_SHAPE_TYPE:
648 case SID_FONTWORK_ALIGNMENT:
649 case SID_FONTWORK_SAME_LETTER_HEIGHTS:
650 case SID_FONTWORK_CHARACTER_SPACING:
651 case SID_FONTWORK_KERN_CHARACTER_PAIRS:
652 case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
653 case SID_FONTWORK_ALIGNMENT_FLOATER:
654 case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
655 svx::FontworkBar::execute( *pView, rReq, rBindings );
656 rReq.Ignore ();
657 break;
659 default:
660 break;
664 IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
666 OUString aName = rDialog.GetName();
668 ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
669 if ( !aName.isEmpty() && pModel )
671 SCTAB nDummyTab;
672 if ( pModel->GetNamedObject( aName, SdrObjKind::NONE, nDummyTab ) )
674 // existing object found -> name invalid
675 return false;
679 return true; // name is valid
682 void ScDrawShell::ExecFormText(const SfxRequest& rReq)
684 ScDrawView* pDrView = rViewData.GetScDrawView();
685 const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
687 if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
689 const SfxItemSet& rSet = *rReq.GetArgs();
691 if ( pDrView->IsTextEdit() )
692 pDrView->ScEndTextEdit();
694 pDrView->SetAttributes(rSet);
698 void ScDrawShell::ExecFormatPaintbrush( const SfxRequest& rReq )
700 ScViewFunc* pView = rViewData.GetView();
701 if ( pView->HasPaintBrush() )
703 // cancel paintbrush mode
704 pView->ResetBrushDocument();
706 else
708 bool bLock = false;
709 const SfxItemSet *pArgs = rReq.GetArgs();
710 if( pArgs && pArgs->Count() >= 1 )
711 bLock = pArgs->Get(SID_FORMATPAINTBRUSH).GetValue();
713 ScDrawView* pDrawView = rViewData.GetScDrawView();
714 if ( pDrawView && pDrawView->GetMarkedObjectList().GetMarkCount() != 0 )
716 std::unique_ptr<SfxItemSet> pItemSet(new SfxItemSet( pDrawView->GetAttrFromMarked(true/*bOnlyHardAttr*/) ));
717 pView->SetDrawBrushSet( std::move(pItemSet), bLock );
722 void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
724 ScDrawView* pDrawView = rViewData.GetScDrawView();
725 bool bSelection = pDrawView && pDrawView->GetMarkedObjectList().GetMarkCount() != 0;
726 bool bHasPaintBrush = rViewData.GetView()->HasPaintBrush();
728 if ( !bHasPaintBrush && !bSelection )
729 rSet.DisableItem( SID_FORMATPAINTBRUSH );
730 else
731 rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
734 ScDrawView* ScDrawShell::GetDrawView()
736 return rViewData.GetView()->GetScDrawView();
739 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */