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