LibreOffice Module sc (master)  1
drawsh5.cxx
Go to the documentation of this file.
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 <editeng/eeitem.hxx>
21 
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 <sfx2/docfile.hxx>
34 #include <osl/diagnose.h>
35 
36 #include <com/sun/star/form/FormButtonType.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/beans/XPropertySetInfo.hpp>
39 
40 #include <drawsh.hxx>
41 #include <drawview.hxx>
42 #include <viewdata.hxx>
43 #include <tabvwsh.hxx>
44 #include <docsh.hxx>
45 #include <undotab.hxx>
46 #include <drwlayer.hxx>
47 #include <userdat.hxx>
48 #include <drtxtob.hxx>
49 #include <memory>
50 
51 #include <sc.hrc>
52 
53 using namespace com::sun::star;
54 
55 void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
56 {
57  ScDrawView* pView = rViewData.GetScDrawView();
58  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
59 
60  // Hyperlink
61 
62  SvxHyperlinkItem aHLinkItem;
63 
64  if ( rMarkList.GetMarkCount() == 1 ) // URL-Button marked ?
65  {
66  SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
67  ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
68  if ( pInfo && !pInfo->GetHlink().isEmpty() )
69  {
70  aHLinkItem.SetURL( pInfo->GetHlink() );
71  aHLinkItem.SetInsertMode(HLINK_FIELD);
72  }
73  SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
74  if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
75  {
76  const uno::Reference<awt::XControlModel>& xControlModel = pUnoCtrl->GetUnoControlModel();
77  OSL_ENSURE( xControlModel.is(), "UNO-Control without model" );
78  if( !xControlModel.is() )
79  return;
80 
81  uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
82  uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
83 
84  OUString sPropButtonType( "ButtonType" );
85 
86  if(xInfo->hasPropertyByName( sPropButtonType ))
87  {
88  uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
89  form::FormButtonType eTmp;
90  if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
91  {
92  OUString sTmp;
93  // Label
94  OUString sPropLabel( "Label" );
95  if(xInfo->hasPropertyByName( sPropLabel ))
96  {
97  aAny = xPropSet->getPropertyValue( sPropLabel );
98  if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
99  {
100  aHLinkItem.SetName(sTmp);
101  }
102  }
103  // URL
104  OUString sPropTargetURL( "TargetURL" );
105  if(xInfo->hasPropertyByName( sPropTargetURL ))
106  {
107  aAny = xPropSet->getPropertyValue( sPropTargetURL );
108  if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
109  {
110  aHLinkItem.SetURL(sTmp);
111  }
112  }
113  // Target
114  OUString sPropTargetFrame( "TargetFrame" );
115  if(xInfo->hasPropertyByName( sPropTargetFrame ))
116  {
117  aAny = xPropSet->getPropertyValue( sPropTargetFrame );
118  if ( (aAny >>= sTmp) && !sTmp.isEmpty() )
119  {
120  aHLinkItem.SetTargetFrame(sTmp);
121  }
122  }
123  aHLinkItem.SetInsertMode(HLINK_BUTTON);
124  }
125  }
126  }
127  }
128 
129  rSet.Put(aHLinkItem);
130 }
131 
133 {
134  const SfxItemSet* pReqArgs = rReq.GetArgs();
135 
136  sal_uInt16 nSlot = rReq.GetSlot();
137  switch ( nSlot )
138  {
139  case SID_HYPERLINK_SETLINK:
140  if( pReqArgs )
141  {
142  const SfxPoolItem* pItem;
143  if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, true, &pItem ) == SfxItemState::SET )
144  {
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();
150 
151  bool bDone = false;
152  if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
153  {
154  ScDrawView* pView = rViewData.GetScDrawView();
155  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
156  if ( rMarkList.GetMarkCount() == 1 )
157  {
158  SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
159  SdrUnoObj* pUnoCtrl = dynamic_cast<SdrUnoObj*>( pObj );
160  if (pUnoCtrl && SdrInventor::FmForm == pUnoCtrl->GetObjInventor())
161  {
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;
167 
168  uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
169  uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
170 
171  OUString sPropTargetURL( "TargetURL" );
172 
173  // Is it possible to set a URL in the object?
174  if (xInfo->hasPropertyByName( sPropTargetURL ))
175  {
176 
177  OUString sPropButtonType( "ButtonType");
178  OUString sPropTargetFrame( "TargetFrame" );
179  OUString sPropLabel( "Label" );
180 
181  if ( xInfo->hasPropertyByName( sPropLabel ) )
182  {
183  xPropSet->setPropertyValue( sPropLabel, uno::Any(rName) );
184  }
185 
186  OUString aTmp = INetURLObject::GetAbsURL( rViewData.GetDocShell()->GetMedium()->GetBaseURL(), rURL );
187  xPropSet->setPropertyValue( sPropTargetURL, uno::Any(aTmp) );
188 
189  if( !rTarget.isEmpty() && xInfo->hasPropertyByName( sPropTargetFrame ) )
190  {
191  xPropSet->setPropertyValue( sPropTargetFrame, uno::Any(rTarget) );
192  }
193 
194  if ( xInfo->hasPropertyByName( sPropButtonType ) )
195  {
196  xPropSet->setPropertyValue( sPropButtonType, uno::Any(form::FormButtonType_URL) );
197  }
198 
200  rViewData.GetDocShell()->SetDocumentModified();
201  bDone = true;
202  }
203  }
204  else
205  {
206  SetHlinkForObject( pObj, rURL );
207  bDone = true;
208  }
209  }
210  }
211 
212  if (!bDone)
213  rViewData.GetViewShell()->
214  InsertURL( rName, rURL, rTarget, static_cast<sal_uInt16>(eMode) );
215 
216  // If "text" is received by InsertURL of ViewShell, then the DrawShell is turned off !!!
217  }
218  }
219  break;
220  default:
221  OSL_FAIL("wrong slot");
222  }
223 }
224 
225 // Functions on Drawing-Objects
226 
228 {
229  SfxBindings& rBindings = rViewData.GetBindings();
230  ScTabView* pTabView = rViewData.GetView();
231  ScDrawView* pView = pTabView->GetScDrawView();
232  sal_uInt16 nSlotId = rReq.GetSlot();
233 
234  switch (nSlotId)
235  {
236  case SID_OBJECT_HEAVEN:
238  rBindings.Invalidate(SID_OBJECT_HEAVEN);
239  rBindings.Invalidate(SID_OBJECT_HELL);
240  break;
241  case SID_OBJECT_HELL:
243  rBindings.Invalidate(SID_OBJECT_HEAVEN);
244  rBindings.Invalidate(SID_OBJECT_HELL);
245  // leave draw shell if nothing selected (layer may be locked)
246  rViewData.GetViewShell()->UpdateDrawShell();
247  break;
248 
249  case SID_FRAME_TO_TOP:
250  pView->PutMarkedToTop();
251  break;
252  case SID_FRAME_TO_BOTTOM:
253  pView->PutMarkedToBtm();
254  break;
255  case SID_FRAME_UP:
256  pView->MovMarkedToTop();
257  break;
258  case SID_FRAME_DOWN:
259  pView->MovMarkedToBtm();
260  break;
261 
262  case SID_GROUP:
263  pView->GroupMarked();
264  break;
265  case SID_UNGROUP:
266  pView->UnGroupMarked();
267  break;
268  case SID_ENTER_GROUP:
269  pView->EnterMarkedGroup();
270  break;
271  case SID_LEAVE_GROUP:
272  pView->LeaveOneGroup();
273  break;
274 
275  case SID_MIRROR_HORIZONTAL:
276  case SID_FLIP_HORIZONTAL:
277  pView->MirrorAllMarkedHorizontal();
278  rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
279  break;
280  case SID_MIRROR_VERTICAL:
281  case SID_FLIP_VERTICAL:
282  pView->MirrorAllMarkedVertical();
283  rBindings.Invalidate( SID_ATTR_TRANSFORM_ANGLE );
284  break;
285 
286  case SID_OBJECT_ALIGN_LEFT:
287  case SID_ALIGN_ANY_LEFT:
288  if (pView->IsAlignPossible())
289  pView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE);
290  break;
291  case SID_OBJECT_ALIGN_CENTER:
292  case SID_ALIGN_ANY_HCENTER:
293  if (pView->IsAlignPossible())
294  pView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE);
295  break;
296  case SID_OBJECT_ALIGN_RIGHT:
297  case SID_ALIGN_ANY_RIGHT:
298  if (pView->IsAlignPossible())
299  pView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE);
300  break;
301  case SID_OBJECT_ALIGN_UP:
302  case SID_ALIGN_ANY_TOP:
303  if (pView->IsAlignPossible())
304  pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top);
305  break;
306  case SID_OBJECT_ALIGN_MIDDLE:
307  case SID_ALIGN_ANY_VCENTER:
308  if (pView->IsAlignPossible())
309  pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center);
310  break;
311  case SID_OBJECT_ALIGN_DOWN:
312  case SID_ALIGN_ANY_BOTTOM:
313  if (pView->IsAlignPossible())
314  pView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom);
315  break;
316 
317  case SID_DELETE:
318  case SID_DELETE_CONTENTS:
319  pView->DeleteMarked();
320  rViewData.GetViewShell()->UpdateDrawShell();
321  break;
322 
323  case SID_CUT:
324  pView->DoCut();
325  rViewData.GetViewShell()->UpdateDrawShell();
326  break;
327 
328  case SID_COPY:
329  pView->DoCopy();
330  break;
331 
332  case SID_PASTE:
333  ScClipUtil::PasteFromClipboard(GetViewData(), GetViewData().GetViewShell(), true);
334  break;
335 
336  case SID_SELECTALL:
337  pView->MarkAll();
338  break;
339 
340  case SID_ANCHOR_PAGE:
341  pView->SetPageAnchored();
342  rBindings.Invalidate( SID_ANCHOR_PAGE );
343  rBindings.Invalidate( SID_ANCHOR_CELL );
344  rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
345  break;
346 
347  case SID_ANCHOR_CELL:
348  pView->SetCellAnchored(false);
349  rBindings.Invalidate( SID_ANCHOR_PAGE );
350  rBindings.Invalidate( SID_ANCHOR_CELL );
351  rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
352  break;
353 
354  case SID_ANCHOR_CELL_RESIZE:
355  pView->SetCellAnchored(true);
356  rBindings.Invalidate( SID_ANCHOR_PAGE );
357  rBindings.Invalidate( SID_ANCHOR_CELL );
358  rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
359  break;
360 
361  case SID_ANCHOR_TOGGLE:
362  {
363  switch( pView->GetAnchorType() )
364  {
365  case SCA_CELL:
366  case SCA_CELL_RESIZE:
367  pView->SetPageAnchored();
368  break;
369  default:
370  pView->SetCellAnchored(false);
371  break;
372  }
373  }
374  rBindings.Invalidate( SID_ANCHOR_PAGE );
375  rBindings.Invalidate( SID_ANCHOR_CELL );
376  rBindings.Invalidate( SID_ANCHOR_CELL_RESIZE );
377  break;
378 
379  case SID_OBJECT_ROTATE:
380  {
382  if (pView->GetDragMode() == SdrDragMode::Rotate)
383  eMode = SdrDragMode::Move;
384  else
385  eMode = SdrDragMode::Rotate;
386  pView->SetDragMode( eMode );
387  rBindings.Invalidate( SID_OBJECT_ROTATE );
388  rBindings.Invalidate( SID_OBJECT_MIRROR );
389  if (eMode == SdrDragMode::Rotate && !pView->IsFrameDragSingles())
390  {
391  pView->SetFrameDragSingles();
392  rBindings.Invalidate( SID_BEZIER_EDIT );
393  }
394  }
395  break;
396  case SID_OBJECT_MIRROR:
397  {
399  if (pView->GetDragMode() == SdrDragMode::Mirror)
400  eMode = SdrDragMode::Move;
401  else
402  eMode = SdrDragMode::Mirror;
403  pView->SetDragMode( eMode );
404  rBindings.Invalidate( SID_OBJECT_ROTATE );
405  rBindings.Invalidate( SID_OBJECT_MIRROR );
406  if (eMode == SdrDragMode::Mirror && !pView->IsFrameDragSingles())
407  {
408  pView->SetFrameDragSingles();
409  rBindings.Invalidate( SID_BEZIER_EDIT );
410  }
411  }
412  break;
413  case SID_BEZIER_EDIT:
414  {
415  bool bOld = pView->IsFrameDragSingles();
416  pView->SetFrameDragSingles( !bOld );
417  rBindings.Invalidate( SID_BEZIER_EDIT );
418  if (bOld && pView->GetDragMode() != SdrDragMode::Move)
419  {
420  pView->SetDragMode( SdrDragMode::Move );
421  rBindings.Invalidate( SID_OBJECT_ROTATE );
422  rBindings.Invalidate( SID_OBJECT_MIRROR );
423  }
424  }
425  break;
426 
427  case SID_FONTWORK:
428  {
429  sal_uInt16 nId = ScGetFontWorkId();
430  SfxViewFrame* pViewFrm = rViewData.GetViewShell()->GetViewFrame();
431 
432  if ( rReq.GetArgs() )
433  pViewFrm->SetChildWindow( nId,
434  static_cast<const SfxBoolItem&>(
435  (rReq.GetArgs()->Get(SID_FONTWORK))).
436  GetValue() );
437  else
438  pViewFrm->ToggleChildWindow( nId );
439 
440  rBindings.Invalidate( SID_FONTWORK );
441  rReq.Done();
442  }
443  break;
444 
445  case SID_ORIGINALSIZE:
446  pView->SetMarkedOriginalSize();
447  break;
448 
449  case SID_FITCELLSIZE:
450  pView->FitToCellSize();
451  break;
452 
453  case SID_ENABLE_HYPHENATION:
454  {
455  const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_ENABLE_HYPHENATION);
456  if( pItem )
457  {
459  bool bValue = pItem->GetValue();
460  aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
461  pView->SetAttributes( aSet );
462  }
463  rReq.Done();
464  }
465  break;
466 
467  case SID_RENAME_OBJECT:
468  {
469  if(1 == pView->GetMarkedObjectCount())
470  {
471  // #i68101#
472  SdrObject* pSelected = pView->GetMarkedObjectByIndex(0);
473  OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
474 
475  if(SC_LAYER_INTERN != pSelected->GetLayer())
476  {
477  OUString aName = pSelected->GetName();
478 
480  vcl::Window* pWin = rViewData.GetActiveWin();
481  ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(pWin ? pWin->GetFrameWeld() : nullptr, aName));
482 
483  pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
484 
485  if(RET_OK == pDlg->Execute())
486  {
487  ScDocShell* pDocSh = rViewData.GetDocShell();
488  pDlg->GetName(aName);
489 
490  if (aName != pSelected->GetName())
491  {
492  // handle name change
493  const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
494 
495  if (OBJ_GRAF == nObjType && aName.isEmpty())
496  {
497  // graphics objects must have names
498  // (all graphics are supposed to be in the navigator)
499  ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
500 
501  if(pModel)
502  {
503  aName = pModel->GetNewGraphicName();
504  }
505  }
506 
507  // An undo action for renaming is missing in svdraw (99363).
508  // For OLE objects (which can be identified using the persist name),
509  // ScUndoRenameObject can be used until there is a common action for all objects.
510  if(OBJ_OLE2 == nObjType)
511  {
512  const OUString aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
513 
514  if(!aPersistName.isEmpty())
515  {
516  pDocSh->GetUndoManager()->AddUndoAction(
517  std::make_unique<ScUndoRenameObject>(pDocSh, aPersistName, pSelected->GetName(), aName));
518  }
519  }
520 
521  // set new name
522  pSelected->SetName(aName);
523  }
524 
525  // ChartListenerCollectionNeedsUpdate is needed for Navigator update
527  pDocSh->SetDrawModified();
528  }
529  }
530  }
531  break;
532  }
533 
534  // #i68101#
535  case SID_TITLE_DESCRIPTION_OBJECT:
536  {
537  if(1 == pView->GetMarkedObjectCount())
538  {
539  SdrObject* pSelected = pView->GetMarkedObjectByIndex(0);
540  OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
541 
542  if(SC_LAYER_INTERN != pSelected->GetLayer())
543  {
544  OUString aTitle(pSelected->GetTitle());
545  OUString aDescription(pSelected->GetDescription());
546 
548  vcl::Window* pWin = rViewData.GetActiveWin();
549  ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(
550  pWin ? pWin->GetFrameWeld() : nullptr, aTitle, aDescription));
551 
552  if(RET_OK == pDlg->Execute())
553  {
554  ScDocShell* pDocSh = rViewData.GetDocShell();
555 
556  // handle Title and Description
557  pDlg->GetTitle(aTitle);
558  pDlg->GetDescription(aDescription);
559  pSelected->SetTitle(aTitle);
560  pSelected->SetDescription(aDescription);
561 
562  // ChartListenerCollectionNeedsUpdate is needed for Navigator update
564  pDocSh->SetDrawModified();
565  }
566  }
567  }
568  break;
569  }
570 
571  case SID_EXTRUSION_TOGGLE:
572  case SID_EXTRUSION_TILT_DOWN:
573  case SID_EXTRUSION_TILT_UP:
574  case SID_EXTRUSION_TILT_LEFT:
575  case SID_EXTRUSION_TILT_RIGHT:
576  case SID_EXTRUSION_3D_COLOR:
577  case SID_EXTRUSION_DEPTH:
578  case SID_EXTRUSION_DIRECTION:
579  case SID_EXTRUSION_PROJECTION:
580  case SID_EXTRUSION_LIGHTING_DIRECTION:
581  case SID_EXTRUSION_LIGHTING_INTENSITY:
582  case SID_EXTRUSION_SURFACE:
583  case SID_EXTRUSION_DEPTH_FLOATER:
584  case SID_EXTRUSION_DIRECTION_FLOATER:
585  case SID_EXTRUSION_LIGHTING_FLOATER:
586  case SID_EXTRUSION_SURFACE_FLOATER:
587  case SID_EXTRUSION_DEPTH_DIALOG:
588  svx::ExtrusionBar::execute( pView, rReq, rBindings );
589  rReq.Ignore ();
590  break;
591 
592  case SID_FONTWORK_SHAPE:
593  case SID_FONTWORK_SHAPE_TYPE:
594  case SID_FONTWORK_ALIGNMENT:
595  case SID_FONTWORK_SAME_LETTER_HEIGHTS:
596  case SID_FONTWORK_CHARACTER_SPACING:
597  case SID_FONTWORK_KERN_CHARACTER_PAIRS:
598  case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
599  case SID_FONTWORK_ALIGNMENT_FLOATER:
600  case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
601  svx::FontworkBar::execute( *pView, rReq, rBindings );
602  rReq.Ignore ();
603  break;
604 
605  default:
606  break;
607  }
608 }
609 
610 IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog&, rDialog, bool )
611 {
612  OUString aName;
613  rDialog.GetName( aName );
614 
615  ScDrawLayer* pModel = rViewData.GetDocument().GetDrawLayer();
616  if ( !aName.isEmpty() && pModel )
617  {
618  SCTAB nDummyTab;
619  if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
620  {
621  // existing object found -> name invalid
622  return false;
623  }
624  }
625 
626  return true; // name is valid
627 }
628 
630 {
631  ScDrawView* pDrView = rViewData.GetScDrawView();
632  const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
633 
634  if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
635  {
636  const SfxItemSet& rSet = *rReq.GetArgs();
637 
638  if ( pDrView->IsTextEdit() )
639  pDrView->ScEndTextEdit();
640 
641  pDrView->SetAttributes(rSet);
642  }
643 }
644 
646 {
647  ScViewFunc* pView = rViewData.GetView();
648  if ( pView->HasPaintBrush() )
649  {
650  // cancel paintbrush mode
651  pView->ResetBrushDocument();
652  }
653  else
654  {
655  bool bLock = false;
656  const SfxItemSet *pArgs = rReq.GetArgs();
657  if( pArgs && pArgs->Count() >= 1 )
658  bLock = pArgs->Get(SID_FORMATPAINTBRUSH).GetValue();
659 
660  ScDrawView* pDrawView = rViewData.GetScDrawView();
661  if ( pDrawView && pDrawView->AreObjectsMarked() )
662  {
663  std::unique_ptr<SfxItemSet> pItemSet(new SfxItemSet( pDrawView->GetAttrFromMarked(true/*bOnlyHardAttr*/) ));
664  pView->SetDrawBrushSet( std::move(pItemSet), bLock );
665  }
666  }
667 }
668 
670 {
671  ScDrawView* pDrawView = rViewData.GetScDrawView();
672  bool bSelection = pDrawView && pDrawView->AreObjectsMarked();
673  bool bHasPaintBrush = rViewData.GetView()->HasPaintBrush();
674 
675  if ( !bHasPaintBrush && !bSelection )
676  rSet.DisableItem( SID_FORMATPAINTBRUSH );
677  else
678  rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
679 }
680 
682 {
683  return rViewData.GetView()->GetScDrawView();
684 }
685 
686 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetURL(const OUString &rURL)
SfxViewFrame * GetViewFrame() const
bool GetValue() const
virtual void GetName(OUString &rName)=0
static void execute(SdrView &rSdrView, SfxRequest const &rReq, SfxBindings &rBindings)
void MovMarkedToBtm()
void ResetBrushDocument()
Definition: tabview5.cxx:646
size_t GetMarkCount() const
void ExecDrawFunc(SfxRequest &rReq)
Definition: drawsh5.cxx:227
void AlignMarkedObjects(SdrHorAlign eHor, SdrVertAlign eVert)
void GetHLinkState(SfxItemSet &rSet)
Definition: drawsh5.cxx:55
std::string GetValue
void SetName(const OUString &rStr, const bool bSetChanged=true)
const OUString & GetTargetFrame() const
IMPL_LINK(ScDrawShell, NameObjectHdl, AbstractSvxObjectNameDialog &, rDialog, bool)
Definition: drawsh5.cxx:610
bool AreObjectsMarked() const
void MirrorAllMarkedHorizontal()
void MarkAll()
static SvxAbstractDialogFactory * Create()
static ScMacroInfo * GetMacroInfo(SdrObject *pObj, bool bCreate=false)
Definition: drwlayer.cxx:2630
OUString GetDescription() const
FilterGroup & rTarget
sal_Int16 nId
void PutMarkedToTop()
constexpr SdrLayerID SC_LAYER_BACK(1)
virtual void GetTitle(OUString &rTitle)=0
void Done(bool bRemove=false)
SdrMark * GetMark(size_t nNum) const
void SetFrameDragSingles(bool bOn=true)
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual SdrObjKind GetObjIdentifier() const
virtual void GetDescription(OUString &rDescription)=0
void ExecuteHLink(const SfxRequest &rReq)
Definition: drawsh5.cxx:132
static void execute(SdrView *pSdrView, SfxRequest const &rReq, SfxBindings &rBindings)
SdrDragMode GetDragMode() const
void EnterMarkedGroup()
virtual SfxUndoManager * GetUndoManager() override
Definition: docsh.cxx:2806
void ToggleChildWindow(sal_uInt16)
ScDrawView * GetDrawView()
Definition: drawsh5.cxx:681
weld::Window * GetFrameWeld() const
void SetTargetFrame(const OUString &rTarget)
virtual void DeleteMarked() override
Definition: drawview.cxx:856
void SetChartListenerCollectionNeedsUpdate(bool bFlg)
Definition: document.hxx:2153
void MovMarkedToTop()
static OUString GetAbsURL(OUString const &rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
Mode eMode
virtual VclPtr< AbstractSvxObjectNameDialog > CreateSvxObjectNameDialog(weld::Window *pParent, const OUString &rName)=0
SdrObject * GetMarkedSdrObj() const
ScDocument * GetDocument() const
Definition: drwlayer.hxx:129
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1057
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
const OUString & GetURL() const
void MirrorAllMarkedVertical()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetCellAnchored(bool bResizeWithCell)
Definition: drawvie3.cxx:87
HLINK_BUTTON
size_t GetMarkedObjectCount() const
void SetMarkedToLayer(SdrLayerID nLayerNo)
Definition: drawview.cxx:212
void ExecFormatPaintbrush(const SfxRequest &rReq)
Definition: drawsh5.cxx:645
void ExecFormText(const SfxRequest &rReq)
Definition: drawsh5.cxx:629
const SdrMarkList & GetMarkedObjectList() const
sal_uInt16 Count() const
const T * GetArg(sal_uInt16 nSlotId) const
bool SetAttributes(const SfxItemSet &rSet, bool bReplaceAll=false)
OBJ_GRAF
SvxLinkInsertMode
OUString GetTitle() const
HLINK_FIELD
void LeaveOneGroup()
OUString GetNewGraphicName(tools::Long *pnCounter=nullptr) const
Definition: drwlayer.cxx:2189
void SetPageAnchored()
Definition: drawvie3.cxx:62
void SetName(const OUString &rName)
SfxViewShell * GetViewShell() const
void UnGroupMarked()
OUString GetName() const
virtual SdrInventor GetObjInventor() const
virtual SdrLayerID GetLayer() const
void DoCut()
Definition: drawview.cxx:284
SdrObject * GetNamedObject(std::u16string_view rName, sal_uInt16 nId, SCTAB &rFoundTab) const
Definition: drwlayer.cxx:2161
bool HasPaintBrush() const
Definition: tabview.hxx:585
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
bool IsAlignPossible() const
sal_uInt16 GetSlot() const
void SetMarkedOriginalSize()
Definition: drawvie4.cxx:432
ScAnchorType GetAnchorType() const
Definition: drawvie3.cxx:113
void DisableItem(sal_uInt16 nWhich)
virtual bool IsTextEdit() const final override
ScDrawView * GetScDrawView()
Definition: tabview.hxx:341
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void GroupMarked()
SdrDragMode
constexpr SdrLayerID SC_LAYER_FRONT(0)
OUString aName
RET_OK
constexpr SdrLayerID SC_LAYER_INTERN(2)
void SetChildWindow(sal_uInt16 nId, bool bVisible, bool bSetFocus=true)
void SetDescription(const OUString &rStr)
constexpr TypedWhichId< SfxBoolItem > EE_PARA_HYPHENATE(EE_PARA_START+6)
SfxItemSet GetAttrFromMarked(bool bOnlyHardAttr) const
bool IsFrameDragSingles() const
void SetDragMode(SdrDragMode eMode)
const ScDocument & GetDocument() const
Definition: docsh.hxx:216
virtual void SetCheckNameHdl(const Link< AbstractSvxObjectNameDialog &, bool > &rLink)=0
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:894
void SetInsertMode(SvxLinkInsertMode eNew)
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
const OUString & GetName() const
SvxLinkInsertMode GetInsertMode() const
const OUString & GetHlink() const
Definition: userdat.hxx:85
void SetDrawModified()
SetDrawModified - without Formula update.
Definition: docsh.cxx:2884
void DoCopy()
Definition: drawvie4.cxx:333
void PutMarkedToBtm()
void StateFormatPaintbrush(SfxItemSet &rSet)
Definition: drawsh5.cxx:669
void PasteFromClipboard(ScViewData &rViewData, ScTabViewShell *pTabViewShell, bool bShowDialog)
Definition: cliputil.cxx:49
sal_uInt16 ScGetFontWorkId()
Definition: drtxtob2.cxx:37
void Ignore()
OBJ_OLE2
void SetTitle(const OUString &rStr)
void FitToCellSize()
Definition: drawvie4.cxx:523
void SetDrawBrushSet(std::unique_ptr< SfxItemSet > pNew, bool bLock)
Definition: tabview5.cxx:636
sal_Int16 SCTAB
Definition: types.hxx:22