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