LibreOffice Module sc (master)  1
tabvwshb.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 <com/sun/star/chart2/data/XDataReceiver.hpp>
21 #include <com/sun/star/awt/XRequestCallback.hpp>
22 #include <com/sun/star/awt/Rectangle.hpp>
23 
24 #include <com/sun/star/embed/EmbedMisc.hpp>
25 #include <com/sun/star/embed/XEmbeddedObject.hpp>
26 #include <vcl/errinf.hxx>
27 #include <sfx2/app.hxx>
29 #include <svx/svxdlg.hxx>
31 #include <svx/svditer.hxx>
32 #include <svx/svdmark.hxx>
33 #include <svx/svdograf.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <svx/svdoole2.hxx>
36 #include <svx/svdouno.hxx>
37 #include <svx/svdview.hxx>
38 #include <sfx2/linkmgr.hxx>
39 #include <svx/fontworkbar.hxx>
40 #include <sfx2/bindings.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/viewfrm.hxx>
43 #include <svtools/soerr.hxx>
44 #include <svl/rectitem.hxx>
45 #include <svl/stritem.hxx>
46 #include <svl/slstitm.hxx>
47 #include <svl/whiter.hxx>
49 #include <sot/exchange.hxx>
50 #include <tools/diagnose_ex.h>
51 
52 #include <tabvwsh.hxx>
53 #include <scmod.hxx>
54 #include <document.hxx>
55 #include <sc.hrc>
56 #include <client.hxx>
57 #include <fuinsert.hxx>
58 #include <docsh.hxx>
59 #include <drawview.hxx>
61 #include <gridwin.hxx>
62 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
63 #include <svx/svdpagv.hxx>
64 
65 #include <comphelper/lok.hxx>
66 
67 using namespace com::sun::star;
68 
70 {
71  // is called from paint
72 
73  uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
74  vcl::Window* pWin = GetActiveWin();
75 
76  // when already connected do not execute SetObjArea/SetSizeScale again
77 
78  SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
79  if ( pClient )
80  return;
81 
82  pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj );
83  ScViewData& rViewData = GetViewData();
84  ScDocShell* pDocSh = rViewData.GetDocShell();
85  ScDocument& rDoc = pDocSh->GetDocument();
86  bool bNegativeX = comphelper::LibreOfficeKit::isActive() && rDoc.IsNegativePage(rViewData.GetTabNo());
87  if (bNegativeX)
88  pClient->SetNegativeX(true);
89 
90  tools::Rectangle aRect = pObj->GetLogicRect();
91  Size aDrawSize = aRect.GetSize();
92 
93  Size aOleSize = pObj->GetOrigObjSize();
94 
95  Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
96  Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
97  aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj
98  aScaleHeight.ReduceInaccurate(10);
99  pClient->SetSizeScale(aScaleWidth,aScaleHeight);
100 
101  // visible section is only changed inplace!
102  // the object area must be set after the scaling since it triggers the resizing
103  aRect.SetSize( aOleSize );
104  pClient->SetObjArea( aRect );
105 }
106 
107 namespace {
108 
109 class PopupCallback : public cppu::WeakImplHelper<css::awt::XCallback>
110 {
111  ScTabViewShell* m_pViewShell;
112  SdrOle2Obj* m_pObject;
113 
114 public:
115  explicit PopupCallback(ScTabViewShell* pViewShell, SdrOle2Obj* pObject)
116  : m_pViewShell(pViewShell)
117  , m_pObject(pObject)
118  {}
119 
120  // XCallback
121  virtual void SAL_CALL notify(const css::uno::Any& aData) override
122  {
123  uno::Sequence<beans::PropertyValue> aProperties;
124  if (!(aData >>= aProperties))
125  return;
126 
127  awt::Rectangle xRectangle;
128  sal_Int32 dimensionIndex = 0;
129  OUString sPivotTableName("DataPilot1");
130 
131  for (beans::PropertyValue const & rProperty : std::as_const(aProperties))
132  {
133  if (rProperty.Name == "Rectangle")
134  rProperty.Value >>= xRectangle;
135  if (rProperty.Name == "DimensionIndex")
136  rProperty.Value >>= dimensionIndex;
137  if (rProperty.Name == "PivotTableName")
138  rProperty.Value >>= sPivotTableName;
139  }
140 
141  tools::Rectangle aChartRect = m_pObject->GetLogicRect();
142 
143  Point aPoint(xRectangle.X + aChartRect.Left(), xRectangle.Y + aChartRect.Top());
144  Size aSize(xRectangle.Width, xRectangle.Height);
145 
146  m_pViewShell->DoDPFieldPopup(sPivotTableName, dimensionIndex, aPoint, aSize);
147  }
148 };
149 
150 }
151 
152 void ScTabViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb)
153 {
154  // Do not leave the hint message box on top of the object
155  RemoveHintWindow();
156 
157  uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
158  vcl::Window* pWin = GetActiveWin();
159  ErrCode nErr = ERRCODE_NONE;
160  bool bErrorShown = false;
161 
162  {
163  ScViewData& rViewData = GetViewData();
164  ScDocShell* pDocSh = rViewData.GetDocShell();
165  ScDocument& rDoc = pDocSh->GetDocument();
166  bool bNegativeX = comphelper::LibreOfficeKit::isActive() && rDoc.IsNegativePage(rViewData.GetTabNo());
167  SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
168  if ( !pClient )
169  pClient = new ScClient( this, pWin, GetScDrawView()->GetModel(), pObj );
170 
171  if (bNegativeX)
172  pClient->SetNegativeX(true);
173 
174  if ( (sal_uInt32(nErr) & ERRCODE_ERROR_MASK) == 0 && xObj.is() )
175  {
176  tools::Rectangle aRect = pObj->GetLogicRect();
177 
178  {
179  // #i118485# center on BoundRect for activation,
180  // OLE may be sheared/rotated now
181  const tools::Rectangle& rBoundRect = pObj->GetCurrentBoundRect();
182  const Point aDelta(rBoundRect.Center() - aRect.Center());
183  aRect.Move(aDelta.X(), aDelta.Y());
184  }
185 
186  Size aDrawSize = aRect.GetSize();
187 
188  MapMode aMapMode( MapUnit::Map100thMM );
189  Size aOleSize = pObj->GetOrigObjSize( &aMapMode );
190 
191  if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
192  && ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
193  {
194  // scale must always be 1 - change VisArea if different from client size
195 
196  if ( aDrawSize != aOleSize )
197  {
198  MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pClient->GetAspect() ) );
199  aOleSize = OutputDevice::LogicToLogic( aDrawSize,
200  MapMode(MapUnit::Map100thMM), MapMode(aUnit));
201  awt::Size aSz( aOleSize.Width(), aOleSize.Height() );
202  xObj->setVisualAreaSize( pClient->GetAspect(), aSz );
203  }
204  Fraction aOne( 1, 1 );
205  pClient->SetSizeScale( aOne, aOne );
206  }
207  else
208  {
209  // calculate scale from client and VisArea size
210 
211  Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
212  Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
213  aScaleWidth.ReduceInaccurate(10); // compatible with SdrOle2Obj
214  aScaleHeight.ReduceInaccurate(10);
215  pClient->SetSizeScale(aScaleWidth,aScaleHeight);
216  }
217 
218  // visible section is only changed inplace!
219  // the object area must be set after the scaling since it triggers the resizing
220  aRect.SetSize( aOleSize );
221  pClient->SetObjArea( aRect );
222 
223  nErr = pClient->DoVerb( nVerb );
224  bErrorShown = true;
225  // SfxViewShell::DoVerb shows its error messages
226 
227  // attach listener to selection changes in chart that affect cell
228  // ranges, so those can be highlighted
229  // note: do that after DoVerb, so that the chart controller exists
230  if ( SvtModuleOptions().IsChart() )
231  {
232  SvGlobalName aObjClsId ( xObj->getClassID() );
233  if (SotExchange::IsChart( aObjClsId ))
234  {
235  try
236  {
237  uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
238  uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
239  xSup->getComponent(), uno::UNO_QUERY_THROW );
240  uno::Reference< chart2::data::XRangeHighlighter > xRangeHighlighter(
241  xDataReceiver->getRangeHighlighter());
242  if (xRangeHighlighter.is())
243  {
244  uno::Reference< view::XSelectionChangeListener > xListener(
245  new ScChartRangeSelectionListener( this ));
246  xRangeHighlighter->addSelectionChangeListener( xListener );
247  }
248  uno::Reference<awt::XRequestCallback> xPopupRequest(xDataReceiver->getPopupRequest());
249  if (xPopupRequest.is())
250  {
251  uno::Reference<awt::XCallback> xCallback(new PopupCallback(this, pObj));
252  uno::Any aAny;
253  xPopupRequest->addCallback(xCallback, aAny);
254  }
255  }
256  catch( const uno::Exception & )
257  {
258  TOOLS_WARN_EXCEPTION( "sc", "Exception caught while querying chart" );
259  }
260  }
261  }
262  }
263  }
264  if (nErr != ERRCODE_NONE && !bErrorShown)
266 
267  // #i118524# refresh handles to suppress for activated OLE
268  if(GetScDrawView())
269  {
270  GetScDrawView()->AdjustMarkHdl();
271  }
273  //TODO/LATER: how "SetDocumentName"?
274  //xIPObj->SetDocumentName( GetViewData().GetDocShell()->GetTitle() );
275 }
276 
278 {
279  SdrView* pView = GetScDrawView();
280  if (!pView)
281  return ERRCODE_SO_NOTIMPL; // should not be
282 
283  SdrOle2Obj* pOle2Obj = nullptr;
284 
285  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
286  if (rMarkList.GetMarkCount() == 1)
287  {
288  SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
289  if (pObj->GetObjIdentifier() == SdrObjKind::OLE2)
290  pOle2Obj = static_cast<SdrOle2Obj*>(pObj);
291  }
292 
293  if (pOle2Obj)
294  {
295  ActivateObject( pOle2Obj, nVerb );
296  }
297  else
298  {
299  OSL_FAIL("no object for Verb found");
300  }
301 
302  return ERRCODE_NONE;
303 }
304 
306 {
307  // deactivate inplace editing if currently active
308 
309  ScModule* pScMod = SC_MOD();
310  bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
311 
312  ScClient* pClient = static_cast<ScClient*>(GetIPClient());
313  if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
314  pClient->DeactivateObject();
315 }
316 
317 IMPL_LINK( ScTabViewShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvent, void )
318 {
319  if( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::CANCEL )
320  {
321  ScTabView* pTabView = GetViewData().GetView();
322  ScDrawView* pView = pTabView->GetScDrawView();
323  ScViewData& rData = GetViewData();
324  ScDocShell* pScDocSh = rData.GetDocShell();
325  ScDocument& rScDoc = pScDocSh->GetDocument();
326  // leave OLE inplace mode and unmark
327  OSL_ASSERT( pView );
328  DeactivateOle();
329  pView->UnMarkAll();
330 
331  rScDoc.GetUndoManager()->Undo();
332  rScDoc.GetUndoManager()->ClearRedo();
333 
334  // leave the draw shell
335  SetDrawShell( false );
336 
337  // reset marked cell area
338  ScMarkData aMark = GetViewData().GetMarkData();
339  GetViewData().GetViewShell()->SetMarkData(aMark);
340  }
341  else
342  {
343  OSL_ASSERT( pEvent->DialogResult == ui::dialogs::ExecutableDialogResults::OK );
344  //@todo maybe move chart to different table
345  }
346 }
347 
349 {
350  sal_uInt16 nSlot = rReq.GetSlot();
351  if (nSlot != SID_OBJECTRESIZE )
352  {
353  SC_MOD()->InputEnterHandler();
354  UpdateInputHandler();
355  }
356 
357  // insertion of border for Chart is cancelled:
358  FuPoor* pPoor = GetDrawFuncPtr();
359  if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART )
360  GetViewData().GetDispatcher().Execute(SID_DRAW_CHART, SfxCallMode::SLOT | SfxCallMode::RECORD);
361 
362  MakeDrawLayer();
363 
364  SfxBindings& rBindings = GetViewFrame()->GetBindings();
365  ScTabView* pTabView = GetViewData().GetView();
366  vcl::Window* pWin = pTabView->GetActiveWin();
367  ScDrawView* pView = pTabView->GetScDrawView();
368  ScDocShell* pDocSh = GetViewData().GetDocShell();
369  ScDocument& rDoc = pDocSh->GetDocument();
370  SdrModel* pDrModel = pView->GetModel();
371 
372  switch ( nSlot )
373  {
374  case SID_INSERT_GRAPHIC:
375  FuInsertGraphic(*this, pWin, pView, pDrModel, rReq);
376  // shell is set in MarkListHasChanged
377  break;
378 
379  case SID_INSERT_AVMEDIA:
380  FuInsertMedia(*this, pWin, pView, pDrModel, rReq);
381  // shell is set in MarkListHasChanged
382  break;
383 
384  case SID_INSERT_DIAGRAM:
385  FuInsertChart(*this, pWin, pView, pDrModel, rReq, LINK( this, ScTabViewShell, DialogClosedHdl ));
387  pDocSh->SetModified();
388  break;
389 
390  case SID_INSERT_OBJECT:
391  case SID_INSERT_SMATH:
392  case SID_INSERT_FLOATINGFRAME:
393  FuInsertOLE(*this, pWin, pView, pDrModel, rReq);
394  break;
395 
396  case SID_INSERT_SIGNATURELINE:
397  case SID_EDIT_SIGNATURELINE:
398  {
399  const uno::Reference<frame::XModel> xModel( GetViewData().GetDocShell()->GetBaseModel() );
400 
403  pWin->GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_SIGNATURELINE));
404  pDialog->Execute();
405  break;
406  }
407 
408  case SID_SIGN_SIGNATURELINE:
409  {
410  const uno::Reference<frame::XModel> xModel(
411  GetViewData().GetDocShell()->GetBaseModel());
412 
415  pFact->CreateSignSignatureLineDialog(GetFrameWeld(), xModel));
416  pDialog->Execute();
417  break;
418  }
419 
420  case SID_INSERT_QRCODE:
421  case SID_EDIT_QRCODE:
422  {
423  const uno::Reference<frame::XModel> xModel( GetViewData().GetDocShell()->GetBaseModel() );
424 
427  pWin->GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE));
428  pDialog->Execute();
429  break;
430  }
431 
432  case SID_ADDITIONS_DIALOG:
433  {
434  OUString sAdditionsTag = "";
435 
436  const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(FN_PARAM_ADDITIONS_TAG);
437  if (pStringArg)
438  sAdditionsTag = pStringArg->GetValue();
439 
442  pFact->CreateAdditionsDialog(pWin->GetFrameWeld(), sAdditionsTag));
443  pDialog->Execute();
444  break;
445  }
446 
447  case SID_OBJECTRESIZE:
448  {
449  // the server would like to change the client size
450 
451  SfxInPlaceClient* pClient = GetIPClient();
452 
453  if ( pClient && pClient->IsObjectInPlaceActive() )
454  {
455  const SfxRectangleItem& rRect = rReq.GetArgs()->Get(SID_OBJECTRESIZE);
456  tools::Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) );
457 
458  if ( pView->AreObjectsMarked() )
459  {
460  const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
461 
462  if (rMarkList.GetMarkCount() == 1)
463  {
464  SdrMark* pMark = rMarkList.GetMark(0);
465  SdrObject* pObj = pMark->GetMarkedSdrObj();
466 
467  SdrObjKind nSdrObjKind = pObj->GetObjIdentifier();
468 
469  if (nSdrObjKind == SdrObjKind::OLE2)
470  {
471  if ( static_cast<SdrOle2Obj*>(pObj)->GetObjRef().is() )
472  {
473  pObj->SetLogicRect(aRect);
474  }
475  }
476  }
477  }
478  }
479  }
480  break;
481 
482  case SID_LINKS:
483  {
485  ScopedVclPtr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog(pWin->GetFrameWeld(), rDoc.GetLinkManager()));
486  pDlg->Execute();
487  rBindings.Invalidate( nSlot );
488  SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreaLinksChanged ) ); // Navigator
489  rReq.Done();
490  }
491  break;
492 
493  case SID_FM_CREATE_FIELDCONTROL:
494  {
495  const SfxUnoAnyItem* pDescriptorItem = rReq.GetArg<SfxUnoAnyItem>(SID_FM_DATACCESS_DESCRIPTOR);
496  OSL_ENSURE( pDescriptorItem, "SID_FM_CREATE_FIELDCONTROL: invalid request args!" );
497 
498  if(pDescriptorItem)
499  {
501 
502  ScDrawView* pDrView = GetScDrawView();
503  SdrPageView* pPageView = pDrView ? pDrView->GetSdrPageView() : nullptr;
504  if(pPageView)
505  {
506  svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
507  SdrObjectUniquePtr pNewDBField = pDrView->CreateFieldControl(aDescriptor);
508 
509  if(pNewDBField)
510  {
511  tools::Rectangle aVisArea = pWin->PixelToLogic(tools::Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
512  Point aObjPos(aVisArea.Center());
513  Size aObjSize(pNewDBField->GetLogicRect().GetSize());
514  aObjPos.AdjustX( -(aObjSize.Width() / 2) );
515  aObjPos.AdjustY( -(aObjSize.Height() / 2) );
516  tools::Rectangle aNewObjectRectangle(aObjPos, aObjSize);
517 
518  pNewDBField->SetLogicRect(aNewObjectRectangle);
519 
520  // controls must be on control layer, groups on front layer
521  if ( dynamic_cast<const SdrUnoObj*>( pNewDBField.get() ) != nullptr )
522  pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
523  else
524  pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
525  if (dynamic_cast<const SdrObjGroup*>( pNewDBField.get() ) != nullptr)
526  {
527  SdrObjListIter aIter( *pNewDBField, SdrIterMode::DeepWithGroups );
528  SdrObject* pSubObj = aIter.Next();
529  while (pSubObj)
530  {
531  if ( dynamic_cast<const SdrUnoObj*>( pSubObj) != nullptr )
532  pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
533  else
534  pSubObj->NbcSetLayer(SC_LAYER_FRONT);
535  pSubObj = aIter.Next();
536  }
537  }
538 
539  pView->InsertObjectAtView(pNewDBField.release(), *pPageView);
540  }
541  }
542  }
543  rReq.Done();
544  }
545  break;
546 
547  case SID_FONTWORK_GALLERY_FLOATER:
548  svx::FontworkBar::execute(*pView, rReq, GetViewFrame()->GetBindings());
549  rReq.Ignore();
550  break;
551  }
552 }
553 
555 {
556  bool bOle = GetViewFrame()->GetFrame().IsInPlace();
557  bool bTabProt = GetViewData().GetDocument().IsTabProtected(GetViewData().GetTabNo());
558  ScDocShell* pDocShell = GetViewData().GetDocShell();
559  bool bShared = pDocShell && pDocShell->IsDocShared();
560  SdrView* pSdrView = GetScDrawView();
561 
562  SfxWhichIter aIter(rSet);
563  sal_uInt16 nWhich = aIter.FirstWhich();
564  while ( nWhich )
565  {
566  switch ( nWhich )
567  {
568  case SID_INSERT_DIAGRAM:
569  if ( bOle || bTabProt || !SvtModuleOptions().IsChart() || bShared )
570  rSet.DisableItem( nWhich );
571  break;
572 
573  case SID_INSERT_SMATH:
574  if ( bOle || bTabProt || !SvtModuleOptions().IsMath() || bShared )
575  rSet.DisableItem( nWhich );
576  break;
577 
578  case SID_INSERT_OBJECT:
579  case SID_INSERT_FLOATINGFRAME:
580  if ( bOle || bTabProt || bShared )
581  rSet.DisableItem( nWhich );
582  break;
583 
584  case SID_INSERT_AVMEDIA:
585  case SID_FONTWORK_GALLERY_FLOATER:
586  if ( bTabProt || bShared )
587  rSet.DisableItem( nWhich );
588  break;
589 
590  case SID_INSERT_SIGNATURELINE:
591  if ( bTabProt || bShared || (pSdrView && pSdrView->GetMarkedObjectCount() != 0))
592  rSet.DisableItem( nWhich );
593  break;
594  case SID_EDIT_SIGNATURELINE:
595  case SID_SIGN_SIGNATURELINE:
596  if (!IsSignatureLineSelected() || IsSignatureLineSigned())
597  rSet.DisableItem(nWhich);
598  break;
599 
600  case SID_INSERT_QRCODE:
601  if ( bTabProt || bShared || (pSdrView && pSdrView->GetMarkedObjectCount() != 0))
602  rSet.DisableItem( nWhich );
603  break;
604  case SID_EDIT_QRCODE:
605  if (!IsQRCodeSelected())
606  rSet.DisableItem(nWhich);
607  break;
608 
609  case SID_INSERT_GRAPHIC:
610  if (bTabProt || bShared)
611  {
612  // do not disable 'insert graphic' item if the currently marked area is editable (not protected)
613  // if there is no marked area, check the current cell
614  bool bDisableInsertImage = true;
615  ScMarkData& rMark = GetViewData().GetMarkData();
616  if (!rMark.GetMarkedRanges().empty() && GetViewData().GetDocument().IsSelectionEditable(rMark))
617  bDisableInsertImage = false;
618  else
619  {
620  if (GetViewData().GetDocument().IsBlockEditable
621  (GetViewData().GetTabNo(), GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetCurX(), GetViewData().GetCurY()))
622  {
623  bDisableInsertImage = false;
624  }
625  }
626 
627  if (bDisableInsertImage)
628  rSet.DisableItem(nWhich);
629  }
630  break;
631 
632  case SID_LINKS:
633  {
634  if (GetViewData().GetDocument().GetLinkManager()->GetLinks().empty())
635  rSet.DisableItem( SID_LINKS );
636  }
637  break;
638  }
639  nWhich = aIter.NextWhich();
640  }
641 }
642 
644 {
645  SdrView* pSdrView = GetScDrawView();
646  if (!pSdrView)
647  return false;
648 
649  if (pSdrView->GetMarkedObjectCount() != 1)
650  return false;
651 
652  SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
653  if (!pPickObj)
654  return false;
655 
656  SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
657  if (!pGraphic)
658  return false;
659 
660  return pGraphic->isSignatureLine();
661 }
662 
664 {
665  SdrView* pSdrView = GetScDrawView();
666  if (!pSdrView)
667  return false;
668 
669  if (pSdrView->GetMarkedObjectCount() != 1)
670  return false;
671 
672  SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
673  if (!pPickObj)
674  return false;
675 
676  SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
677  if (!pGraphic)
678  return false;
679 
680  if(pGraphic->getQrCode())
681  {
682  return true;
683  }
684  else{
685  return false;
686  }
687 }
688 
690 {
691  SdrView* pSdrView = GetScDrawView();
692  if (!pSdrView)
693  return false;
694 
695  if (pSdrView->GetMarkedObjectCount() != 1)
696  return false;
697 
698  SdrObject* pPickObj = pSdrView->GetMarkedObjectByIndex(0);
699  if (!pPickObj)
700  return false;
701 
702  SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj);
703  if (!pGraphic)
704  return false;
705 
706  return pGraphic->isSignatureLineSigned();
707 }
708 
710 {
711  SfxShell* pSh = GetViewData().GetDispatcher().GetShell(0);
712  SfxUndoManager* pUndoManager = pSh->GetUndoManager();
713 
714  const SfxItemSet* pReqArgs = rReq.GetArgs();
715  ScDocShell* pDocSh = GetViewData().GetDocShell();
716 
717  sal_uInt16 nSlot = rReq.GetSlot();
718  switch ( nSlot )
719  {
720  case SID_UNDO:
721  case SID_REDO:
722  if ( pUndoManager )
723  {
724  bool bIsUndo = ( nSlot == SID_UNDO );
725 
726  sal_uInt16 nCount = 1;
727  const SfxPoolItem* pItem;
728  if ( pReqArgs && pReqArgs->GetItemState( nSlot, true, &pItem ) == SfxItemState::SET )
729  nCount = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
730 
731  // Repair mode: allow undo/redo of all undo actions, even if access would
732  // be limited based on the view shell ID.
733  bool bRepair = false;
734  if (pReqArgs && pReqArgs->GetItemState(SID_REPAIRPACKAGE, false, &pItem) == SfxItemState::SET)
735  bRepair = static_cast<const SfxBoolItem*>(pItem)->GetValue();
736 
737  if (comphelper::LibreOfficeKit::isActive() && !bRepair)
738  {
739  SfxUndoAction* pAction = nullptr;
740  if (bIsUndo)
741  {
742  if (pUndoManager->GetUndoActionCount() != 0)
743  pAction = pUndoManager->GetUndoAction();
744  }
745  else
746  {
747  if (pUndoManager->GetRedoActionCount() != 0)
748  pAction = pUndoManager->GetRedoAction();
749  }
750  if (pAction)
751  {
752  ViewShellId nViewShellId = GetViewShellId();
753  if (pAction->GetViewShellId() != nViewShellId)
754  {
755  rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE)));
756  return;
757  }
758  }
759  }
760 
761  // lock paint for more than one cell undo action (not for editing within a cell)
762  bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() );
763  if ( bLockPaint )
764  pDocSh->LockPaint();
765 
766  try
767  {
768  for (sal_uInt16 i=0; i<nCount; i++)
769  {
770  if ( bIsUndo )
771  pUndoManager->Undo();
772  else
773  pUndoManager->Redo();
774  }
775  }
776  catch ( const uno::Exception& )
777  {
778  // no need to handle. By definition, the UndoManager handled this by clearing the
779  // Undo/Redo stacks
780  }
781 
782  if ( bLockPaint )
783  pDocSh->UnlockPaint();
784 
785  GetViewFrame()->GetBindings().InvalidateAll(false);
786  }
787  break;
788 // default:
789 // GetViewFrame()->ExecuteSlot( rReq );
790  }
791 }
792 
794 {
795  SfxShell* pSh = GetViewData().GetDispatcher().GetShell(0);
796  SfxUndoManager* pUndoManager = pSh->GetUndoManager();
797 
798  SfxWhichIter aIter(rSet);
799  sal_uInt16 nWhich = aIter.FirstWhich();
800  while ( nWhich )
801  {
802  switch (nWhich)
803  {
804  case SID_GETUNDOSTRINGS:
805  case SID_GETREDOSTRINGS:
806  {
807  SfxStringListItem aStrLst( nWhich );
808  if ( pUndoManager )
809  {
810  std::vector<OUString> &aList = aStrLst.GetList();
811  bool bIsUndo = ( nWhich == SID_GETUNDOSTRINGS );
812  size_t nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount();
813  for (size_t i=0; i<nCount; ++i)
814  {
815  aList.push_back( bIsUndo ? pUndoManager->GetUndoActionComment(i) :
816  pUndoManager->GetRedoActionComment(i) );
817  }
818  }
819  rSet.Put( aStrLst );
820  }
821  break;
822  default:
823  // get state from sfx view frame
824  GetViewFrame()->GetSlotState( nWhich, nullptr, &rSet );
825  }
826 
827  nWhich = aIter.NextWhich();
828  }
829 }
830 
831 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxUndoAction * GetUndoAction(size_t nNo=0) const
void UnlockPaint()
Definition: docsh3.cxx:322
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
size_t GetMarkCount() const
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
virtual const tools::Rectangle & GetCurrentBoundRect() const
#define ERRCODE_SO_NOTIMPL
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
SC_DLLPUBLIC bool IsNegativePage(SCTAB nTab) const
Definition: document.cxx:997
bool SetObjArea(const tools::Rectangle &)
void ExecDrawIns(SfxRequest &rReq)
Definition: tabvwshb.cxx:348
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
bool IsObjectInPlaceActive() const
css::drawing::BarCode * getQrCode() const
constexpr tools::Long Left() const
bool AreObjectsMarked() const
static SvxAbstractDialogFactory * Create()
void GetDrawInsState(SfxItemSet &rSet)
Definition: tabvwshb.cxx:554
sal_uInt16 FirstWhich()
const ContentProperties & rData
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
void Done(bool bRemove=false)
SdrMark * GetMark(size_t nNum) const
virtual SfxBindings & GetBindings() override
virtual SfxUndoManager * GetUndoManager()
Size GetOrigObjSize(MapMode const *pTargetMapMode=nullptr) const
ErrCode DoVerb(sal_Int32 nVerb)
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual SdrObjKind GetObjIdentifier() const
SC_DLLPUBLIC SfxUndoManager * GetUndoManager()
Definition: document.cxx:6478
virtual short Execute()=0
static sal_uInt16 IsChart(const SvGlobalName &rName)
virtual bool Undo()
bool InsertObjectAtView(SdrObject *pObj, SdrPageView &rPV, SdrInsertFlags nOptions=SdrInsertFlags::NONE)
sal_uInt16 NextWhich()
SfxApplication * SfxGetpApp()
SdrObjKind
#define ERRCODE_ERROR_MASK
constexpr tools::Long Width() const
weld::Window * GetFrameWeld() const
SfxShell * GetShell(sal_uInt16 nIdx) const
PropertiesInfo aProperties
void SetSizeScale(const Fraction &rScaleWidth, const Fraction &rScaleHeight)
int nCount
bool IsDocShared() const
bool isSignatureLine() const
const css::uno::Any & GetValue() const
virtual size_t GetRedoActionCount(bool const i_currentLevel=CurrentLevel) const
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:90
ScGridWindow * GetActiveWin()
Definition: tabview.cxx:887
void ConnectObject(const SdrOle2Obj *pObj)
Definition: tabvwshb.cxx:69
bool empty() const
Definition: rangelst.hxx:88
SdrObject * GetMarkedSdrObj() const
void ReduceInaccurate(unsigned nSignificantBits)
#define TOOLS_WARN_EXCEPTION(area, stream)
sal_uInt16 GetCurRefDlgId() const
Definition: scmod.hxx:228
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SfxDispatcher * GetDispatcher() const
virtual void ClearRedo()
int i
virtual VclPtr< AbstractQrCodeGenDialog > CreateQrCodeGenDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel, bool bEditExisting)=0
size_t GetMarkedObjectCount() const
static void execute(SdrView &rSdrView, SfxRequest const &rReq, SfxBindings &rBindings)
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
#define SC_MOD()
Definition: scmod.hxx:249
void SetSize(const Size &rSize)
const OUString & GetValue() const
const SdrMarkList & GetMarkedObjectList() const
const T * GetArg(sal_uInt16 nSlotId) const
constexpr tools::Long Top() const
SdrObjectUniquePtr CreateFieldControl(std::u16string_view rFieldDesc) const
virtual void SetLogicRect(const tools::Rectangle &rRect)
virtual VclPtr< AbstractSignatureLineDialog > CreateSignatureLineDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel, bool bEditExisting)=0
Point PixelToLogic(const Point &rDevicePt) const
void SetNegativeX(bool bSet)
virtual size_t GetUndoActionCount(bool const i_currentLevel=CurrentLevel) const
void DoDPFieldPopup(std::u16string_view rPivotTableName, sal_Int32 nDimensionIndex, Point aPoint, Size aSize)
Definition: tabview3.cxx:2608
Base class for all functions.
Definition: fupoor.hxx:39
void GetUndoState(SfxItemSet &rSet)
Definition: tabvwshb.cxx:793
std::vector< OUString > & GetList()
void DeactivateOle()
Definition: tabvwshb.cxx:305
void DeactivateObject()
constexpr Point Center() const
void ActivateObject(SdrOle2Obj *pObj, sal_Int32 nVerb)
Definition: tabvwshb.cxx:152
void SetReturnValue(const SfxPoolItem &)
SdrObject * Next()
virtual VclPtr< AbstractSignSignatureLineDialog > CreateSignSignatureLineDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XModel > xModel)=0
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
OUString GetUndoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
sal_uInt16 GetSlot() const
virtual ViewShellId GetViewShellId() const
constexpr Size GetSize() const
void DisableItem(sal_uInt16 nWhich)
OUString GetRedoActionComment(size_t nNo=0, bool const i_currentLevel=CurrentLevel) const
ScDrawView * GetScDrawView()
Definition: tabview.hxx:341
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
#define ERRCODE_NONE
constexpr tools::Long Height() const
SfxUndoAction * GetRedoAction(size_t nNo=0) const
constexpr SdrLayerID SC_LAYER_FRONT(0)
bool IsSignatureLineSelected()
Definition: tabvwshb.cxx:643
IMPL_LINK(ScTabViewShell, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent *, pEvent, void)
Definition: tabvwshb.cxx:317
sal_Int64 GetAspect() const
const tools::Rectangle & GetValue() const
bool IsQRCodeSelected()
Definition: tabvwshb.cxx:663
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
std::unique_ptr< SdrObject, SdrObjectFreeOp > SdrObjectUniquePtr
SdrObject * GetMarkedObjectByIndex(size_t nNum) const
SdrPageView * GetSdrPageView() const
Size GetOutputSizePixel() const
void Move(tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
ScRangeList GetMarkedRanges() const
Definition: markdata.cxx:450
virtual void SetModified(bool=true) override
Definition: docsh.cxx:2937
static VclAbstractDialogFactory * Create()
MapUnit
Reference< XModel > xModel
bool IsRefDialogOpen()
Definition: scmod.cxx:1662
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:229
void Ignore()
SdrModel * GetModel() const
void LockPaint()
Definition: docsh3.cxx:317
constexpr SdrLayerID SC_LAYER_CONTROLS(3)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual ErrCode DoVerb(sal_Int32 nVerb) override
Definition: tabvwshb.cxx:277
bool isSignatureLineSigned() const
virtual VclPtr< AbstractAdditionsDialog > CreateAdditionsDialog(weld::Window *pParent, const OUString &sAdditionsTag)=0
void ExecuteUndo(SfxRequest &rReq)
Definition: tabvwshb.cxx:709
void UnMarkAll(SdrPageView const *pPV=nullptr)
bool IsSignatureLineSigned()
Definition: tabvwshb.cxx:689
virtual const tools::Rectangle & GetLogicRect() const override
virtual void NbcSetLayer(SdrLayerID nLayer)