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