LibreOffice Module sc (master)  1
viewuno.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/awt/MouseButton.hpp>
21 #include <com/sun/star/drawing/ShapeCollection.hpp>
22 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
23 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
24 #include <com/sun/star/util/VetoException.hpp>
25 #include <com/sun/star/view/DocumentZoomType.hpp>
26 
27 #include <editeng/outliner.hxx>
28 #include <svx/svditer.hxx>
29 #include <svx/svdmark.hxx>
30 #include <svx/svdpage.hxx>
31 #include <svx/svdpagv.hxx>
32 #include <svx/svdview.hxx>
33 #include <svx/unoshape.hxx>
34 #include <svx/fmshell.hxx>
35 #include <sfx2/bindings.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <sfx2/request.hxx>
38 #include <sfx2/viewfrm.hxx>
41 #include <comphelper/sequence.hxx>
44 #include <vcl/svapp.hxx>
45 
46 #include <drawsh.hxx>
47 #include <drtxtob.hxx>
48 #include <transobj.hxx>
49 #include <editsh.hxx>
50 #include <viewuno.hxx>
51 #include <cellsuno.hxx>
52 #include <miscuno.hxx>
53 #include <tabvwsh.hxx>
54 #include <prevwsh.hxx>
55 #include <docsh.hxx>
56 #include <drwlayer.hxx>
57 #include <drawview.hxx>
58 #include <fupoor.hxx>
59 #include <sc.hrc>
60 #include <unonames.hxx>
61 #include <scmod.hxx>
62 #include <appoptio.hxx>
63 #include <gridwin.hxx>
64 #include <sheetevents.hxx>
65 #include <markdata.hxx>
66 #include <scextopt.hxx>
67 #include <preview.hxx>
68 #include <svx/sdrhittesthelper.hxx>
69 #include <formatsh.hxx>
70 #include <sfx2/app.hxx>
71 
72 using namespace com::sun::star;
73 
75 
76 // no Which-ID here, Map only for PropertySetInfo
77 
79 {
80  static const SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] =
81  {
88  { SC_UNO_HIDESPELL, 0, cppu::UnoType<bool>::get(), 0, 0}, /* deprecated #i91949 */
110  { u"", 0, css::uno::Type(), 0, 0 }
111  };
112  return aViewOptPropertyMap_Impl;
113 }
114 
115 constexpr OUStringLiteral SCTABVIEWOBJ_SERVICE = u"com.sun.star.sheet.SpreadsheetView";
116 constexpr OUStringLiteral SCVIEWSETTINGS_SERVICE = u"com.sun.star.sheet.SpreadsheetViewSettings";
117 
118 SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
119 
120 ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP) :
121  pViewShell( pViewSh ),
122  nPane( nP )
123 {
124  if (pViewShell)
125  StartListening(*pViewShell);
126 }
127 
129 {
130  SolarMutexGuard g;
131 
132  if (pViewShell)
133  EndListening(*pViewShell);
134 }
135 
137 {
138  if ( rHint.GetId() == SfxHintId::Dying )
139  pViewShell = nullptr;
140 }
141 
143 {
144  SC_QUERYINTERFACE( sheet::XViewPane )
145  SC_QUERYINTERFACE( sheet::XCellRangeReferrer )
146  SC_QUERYINTERFACE( view::XFormLayerAccess )
147  SC_QUERYINTERFACE( view::XControlAccess )
148  SC_QUERYINTERFACE( lang::XServiceInfo )
149  SC_QUERYINTERFACE( lang::XTypeProvider )
150 
151  return uno::Any(); // OWeakObject is in derived objects
152 }
153 
154 uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes()
155 {
156  static const uno::Sequence<uno::Type> aTypes
157  {
163  };
164  return aTypes;
165 }
166 
167 uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId()
168 {
169  return css::uno::Sequence<sal_Int8>();
170 }
171 
172 // XViewPane
173 
175 {
176  SolarMutexGuard aGuard;
177  if (pViewShell)
178  {
179  ScViewData& rViewData = pViewShell->GetViewData();
180  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
181  rViewData.GetActivePart() :
182  static_cast<ScSplitPos>(nPane);
183  ScHSplitPos eWhichH = WhichH( eWhich );
184 
185  return rViewData.GetPosX( eWhichH );
186  }
187  OSL_FAIL("no View ?!?");
188  return 0;
189 }
190 
191 void SAL_CALL ScViewPaneBase::setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn)
192 {
193  SolarMutexGuard aGuard;
194  if (pViewShell)
195  {
196  ScViewData& rViewData = pViewShell->GetViewData();
197  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
198  rViewData.GetActivePart() :
199  static_cast<ScSplitPos>(nPane);
200  ScHSplitPos eWhichH = WhichH( eWhich );
201 
202  tools::Long nDeltaX = static_cast<tools::Long>(nFirstVisibleColumn) - rViewData.GetPosX( eWhichH );
203  pViewShell->ScrollX( nDeltaX, eWhichH );
204  }
205 }
206 
208 {
209  SolarMutexGuard aGuard;
210  if (pViewShell)
211  {
212  ScViewData& rViewData = pViewShell->GetViewData();
213  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
214  rViewData.GetActivePart() :
215  static_cast<ScSplitPos>(nPane);
216  ScVSplitPos eWhichV = WhichV( eWhich );
217 
218  return rViewData.GetPosY( eWhichV );
219  }
220  OSL_FAIL("no View ?!?");
221  return 0;
222 }
223 
224 void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
225 {
226  SolarMutexGuard aGuard;
227  if (pViewShell)
228  {
229  ScViewData& rViewData = pViewShell->GetViewData();
230  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
231  rViewData.GetActivePart() :
232  static_cast<ScSplitPos>(nPane);
233  ScVSplitPos eWhichV = WhichV( eWhich );
234 
235  tools::Long nDeltaY = static_cast<tools::Long>(nFirstVisibleRow) - rViewData.GetPosY( eWhichV );
236  pViewShell->ScrollY( nDeltaY, eWhichV );
237  }
238 }
239 
240 table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange()
241 {
242  SolarMutexGuard aGuard;
243  table::CellRangeAddress aAdr;
244  if (pViewShell)
245  {
246  ScViewData& rViewData = pViewShell->GetViewData();
247  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
248  rViewData.GetActivePart() :
249  static_cast<ScSplitPos>(nPane);
250  ScHSplitPos eWhichH = WhichH( eWhich );
251  ScVSplitPos eWhichV = WhichV( eWhich );
252 
253  // VisibleCellsX returns only completely visible cells
254  // VisibleRange in Excel also partially visible ones
256 
257  SCCOL nVisX = rViewData.VisibleCellsX( eWhichH );
258  SCROW nVisY = rViewData.VisibleCellsY( eWhichV );
259  if (!nVisX) nVisX = 1; // there has to be something in the range
260  if (!nVisY) nVisY = 1;
261  aAdr.Sheet = rViewData.GetTabNo();
262  aAdr.StartColumn = rViewData.GetPosX( eWhichH );
263  aAdr.StartRow = rViewData.GetPosY( eWhichV );
264  aAdr.EndColumn = aAdr.StartColumn + nVisX - 1;
265  aAdr.EndRow = aAdr.StartRow + nVisY - 1;
266  }
267  return aAdr;
268 }
269 
270 // XCellRangeSource
271 
272 uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells()
273 {
274  SolarMutexGuard aGuard;
275  if (pViewShell)
276  {
277  ScDocShell* pDocSh = pViewShell->GetViewData().GetDocShell();
278 
279  table::CellRangeAddress aAdr(getVisibleRange());
280  ScRange aRange( static_cast<SCCOL>(aAdr.StartColumn), static_cast<SCROW>(aAdr.StartRow), aAdr.Sheet,
281  static_cast<SCCOL>(aAdr.EndColumn), static_cast<SCROW>(aAdr.EndRow), aAdr.Sheet );
282  if ( aRange.aStart == aRange.aEnd )
283  return new ScCellObj( pDocSh, aRange.aStart );
284  else
285  return new ScCellRangeObj( pDocSh, aRange );
286  }
287 
288  return nullptr;
289 }
290 
291 namespace
292 {
293  bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, sal_uInt16 _nPane, FmFormShell*& _rpFormShell, vcl::Window*& _rpWindow, SdrView*& _rpSdrView )
294  {
295  if ( !_pViewShell )
296  return false;
297 
298  ScViewData& rViewData = _pViewShell->GetViewData();
299  ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ?
300  rViewData.GetActivePart() :
301  static_cast<ScSplitPos>(_nPane);
302  _rpWindow = _pViewShell->GetWindowByPos( eWhich );
303  _rpSdrView = _pViewShell->GetScDrawView();
304  _rpFormShell = _pViewShell->GetFormShell();
305  return ( _rpFormShell != nullptr ) && ( _rpSdrView != nullptr )&& ( _rpWindow != nullptr );
306  }
307 }
308 
309 // XFormLayerAccess
310 uno::Reference< form::runtime::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& Form )
311 {
312  SolarMutexGuard aGuard;
313 
314  uno::Reference< form::runtime::XFormController > xController;
315 
316  vcl::Window* pWindow( nullptr );
317  SdrView* pSdrView( nullptr );
318  FmFormShell* pFormShell( nullptr );
319  if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
320  xController = FmFormShell::GetFormController( Form, *pSdrView, *pWindow->GetOutDev() );
321 
322  return xController;
323 }
324 
326 {
327  SolarMutexGuard aGuard;
328 
329  bool bIsFormDesignMode( true );
330 
331  FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : nullptr );
332  if ( pFormShell )
333  bIsFormDesignMode = pFormShell->IsDesignMode();
334 
335  return bIsFormDesignMode;
336 }
337 
338 void SAL_CALL ScViewPaneBase::setFormDesignMode( sal_Bool DesignMode )
339 {
340  SolarMutexGuard aGuard;
341 
342  vcl::Window* pWindow( nullptr );
343  SdrView* pSdrView( nullptr );
344  FmFormShell* pFormShell( nullptr );
345  if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
346  pFormShell->SetDesignMode( DesignMode );
347 }
348 
349 // XControlAccess
350 
351 uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl(
352  const uno::Reference<awt::XControlModel>& xModel )
353 {
354  SolarMutexGuard aGuard;
355 
356  uno::Reference<awt::XControl> xRet;
357 
358  vcl::Window* pWindow( nullptr );
359  SdrView* pSdrView( nullptr );
360  FmFormShell* pFormShell( nullptr );
361  if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
362  pFormShell->GetFormControl( xModel, *pSdrView, *pWindow->GetOutDev(), xRet );
363 
364  if ( !xRet.is() )
365  throw container::NoSuchElementException(); // no control found
366 
367  return xRet;
368 }
369 
370 awt::Rectangle ScViewPaneBase::GetVisArea() const
371 {
372  awt::Rectangle aVisArea;
373  if (pViewShell)
374  {
375  ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
376  pViewShell->GetViewData().GetActivePart() :
377  static_cast<ScSplitPos>(nPane);
378  ScGridWindow* pWindow = static_cast<ScGridWindow*>(pViewShell->GetWindowByPos(eWhich));
379  ScDocument& rDoc = pViewShell->GetViewData().GetDocument();
380  if (pWindow)
381  {
382  ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ?
384  ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ?
386  ScAddress aCell(pViewShell->GetViewData().GetPosX(eWhichH),
387  pViewShell->GetViewData().GetPosY(eWhichV),
388  pViewShell->GetViewData().GetTabNo());
389  tools::Rectangle aCellRect( rDoc.GetMMRect( aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) );
390  Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), pWindow->GetDrawMapMode( true ) ) );
391  Point aVisPos( aCellRect.TopLeft() );
392  if ( rDoc.IsLayoutRTL( aCell.Tab() ) )
393  {
394  aVisPos = aCellRect.TopRight();
395  aVisPos.AdjustX( -(aVisSize.Width()) );
396  }
397  tools::Rectangle aVisRect( aVisPos, aVisSize );
398  aVisArea = AWTRectangle(aVisRect);
399  }
400  }
401  return aVisArea;
402 }
403 
405  ScViewPaneBase( pViewSh, nP )
406 {
407 }
408 
410 {
411 }
412 
414 {
415  // ScViewPaneBase has everything except OWeakObject
416 
418  if (!aRet.hasValue())
419  aRet = OWeakObject::queryInterface( rType );
420  return aRet;
421 }
422 
423 void SAL_CALL ScViewPaneObj::acquire() noexcept
424 {
425  OWeakObject::acquire();
426 }
427 
428 void SAL_CALL ScViewPaneObj::release() noexcept
429 {
430  OWeakObject::release();
431 }
432 
433 // We need default ctor for SMART_REFLECTION_IMPLEMENTATION
434 
437  SfxBaseController( pViewSh ),
438  aPropSet( lcl_GetViewOptPropertyMap() ),
439  aMouseClickHandlers( 0 ),
440  aActivationListeners( 0 ),
441  nPreviousTab( 0 ),
442  bDrawSelModeSet(false),
443  bFilteredRangeSelection(false),
444  mbLeftMousePressed(false)
445 {
446  if (pViewSh)
447  nPreviousTab = pViewSh->GetViewData().GetTabNo();
448 }
449 
451 {
453  if (!aMouseClickHandlers.empty())
454  {
455  acquire();
457  }
458  if (!aActivationListeners.empty())
459  {
460  acquire();
462  }
463 }
464 
466 {
467  SC_QUERYINTERFACE( sheet::XSpreadsheetView )
468  SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster )
469  SC_QUERYINTERFACE( sheet::XActivationBroadcaster )
470  SC_QUERYINTERFACE( container::XEnumerationAccess )
471  SC_QUERYINTERFACE( container::XIndexAccess )
472  SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
473  SC_QUERYINTERFACE( view::XSelectionSupplier )
474  SC_QUERYINTERFACE( beans::XPropertySet )
475  SC_QUERYINTERFACE( sheet::XViewSplitable )
476  SC_QUERYINTERFACE( sheet::XViewFreezable )
477  SC_QUERYINTERFACE( sheet::XRangeSelection )
478  SC_QUERYINTERFACE( lang::XUnoTunnel )
479  SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
480  SC_QUERYINTERFACE( sheet::XSelectedSheetsSupplier )
481 
483  if (!aRet.hasValue())
484  aRet = SfxBaseController::queryInterface( rType );
485  return aRet;
486 }
487 
488 void SAL_CALL ScTabViewObj::acquire() noexcept
489 {
490  SfxBaseController::acquire();
491 }
492 
493 void SAL_CALL ScTabViewObj::release() noexcept
494 {
495  SfxBaseController::release();
496 }
497 
498 static void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, ScSheetEventId nEvent )
499 {
500  ScDocument& rDoc = pDocSh->GetDocument();
501  // when deleting a sheet, nPreviousTab can be invalid
502  // (could be handled with reference updates)
503  if (!rDoc.HasTable(nTab))
504  return;
505 
506  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
507  if (pEvents)
508  {
509  const OUString* pScript = pEvents->GetScript(nEvent);
510  if (pScript)
511  {
512  uno::Any aRet;
513  uno::Sequence<uno::Any> aParams;
514  uno::Sequence<sal_Int16> aOutArgsIndex;
515  uno::Sequence<uno::Any> aOutArgs;
516  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
517  }
518  }
519 
520  // execute VBA event handlers
521  try
522  {
523  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
524  // the parameter is the clicked object, as in the mousePressed call above
525  uno::Sequence< uno::Any > aArgs{ uno::Any(nTab) };
526  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
527  }
528  catch( uno::Exception& )
529  {
530  }
531 }
532 
533 void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
534 {
535  if ( !GetViewShell() )
536  return;
537 
538  ScViewData& rViewData = GetViewShell()->GetViewData();
539  ScDocShell* pDocSh = rViewData.GetDocShell();
540  if (!aActivationListeners.empty())
541  {
542  sheet::ActivationEvent aEvent;
543  uno::Reference< sheet::XSpreadsheetView > xView(this);
544  uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
545  aEvent.Source = xSource;
546  aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, rViewData.GetTabNo());
547  // Listener's handler may remove it from the listeners list
548  for (size_t i = aActivationListeners.size(); i > 0; --i)
549  {
550  try
551  {
552  aActivationListeners[i - 1]->activeSpreadsheetChanged( aEvent );
553  }
554  catch( uno::Exception& )
555  {
556  aActivationListeners.erase(aActivationListeners.begin() + (i - 1));
557  }
558  }
559  }
560 
561  /* Handle sheet events, but do not trigger event handlers, if the old
562  active sheet gets re-activated after inserting/deleting/moving a sheet. */
563  SCTAB nNewTab = rViewData.GetTabNo();
564  if ( !bSameTabButMoved && (nNewTab != nPreviousTab) )
565  {
567  lcl_CallActivate( pDocSh, nNewTab, ScSheetEventId::FOCUS );
568  }
569  nPreviousTab = nNewTab;
570 }
571 
572 uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes()
573 {
576  SfxBaseController::getTypes(),
577  uno::Sequence<uno::Type>
578  {
591  } );
592 }
593 
594 uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
595 {
596  return css::uno::Sequence<sal_Int8>();
597 }
598 
599 // XDocumentView
600 
601 static bool lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
602 {
603  for (size_t i = 0, nCount = rRanges.size(); i < nCount; ++i)
604  {
605  const ScRange & rRange = rRanges[ i ];
606  if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
607  return true;
608  }
609  return false;
610 }
611 
612 static void lcl_ShowObject( ScTabViewShell& rViewSh, const ScDrawView& rDrawView, const SdrObject* pSelObj )
613 {
614  bool bFound = false;
615  SCTAB nObjectTab = 0;
616 
617  SdrModel* pModel = rDrawView.GetModel();
618  sal_uInt16 nPageCount = pModel->GetPageCount();
619  for (sal_uInt16 i=0; i<nPageCount && !bFound; i++)
620  {
621  SdrPage* pPage = pModel->GetPage(i);
622  if (pPage)
623  {
624  SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
625  SdrObject* pObject = aIter.Next();
626  while (pObject && !bFound)
627  {
628  if ( pObject == pSelObj )
629  {
630  bFound = true;
631  nObjectTab = static_cast<SCTAB>(i);
632  }
633  pObject = aIter.Next();
634  }
635  }
636  }
637 
638  if (bFound)
639  {
640  rViewSh.SetTabNo( nObjectTab );
641  rViewSh.ScrollToObject( pSelObj );
642  }
643 }
644 
645 sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
646 {
647  SolarMutexGuard aGuard;
648  ScTabViewShell* pViewSh = GetViewShell();
649 
650  if ( !pViewSh )
651  return false;
652 
654 
655  bool bRet = false;
656  uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
657  if ( !xInterface.is() ) //clear all selections
658  {
659  ScDrawView* pDrawView = pViewSh->GetScDrawView();
660  if (pDrawView)
661  {
662  pDrawView->ScEndTextEdit();
663  pDrawView->UnmarkAll();
664  }
665  else //#102232#; if there is no DrawView remove range selection
666  pViewSh->Unmark();
667  bRet = true;
668  }
669 
670  if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
671  {
672  pViewSh->SetDrawSelMode(false);
673  pViewSh->UpdateLayerLocks();
674  bDrawSelModeSet = false;
675  }
676 
677  if (bRet)
678  return bRet;
679 
680  ScCellRangesBase* pRangesImp = comphelper::getFromUnoTunnel<ScCellRangesBase>( xInterface );
681  uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
682  uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
683  SvxShape* pShapeImp = comphelper::getFromUnoTunnel<SvxShape>( xShapeSel );
684 
685  if (pRangesImp) // Cell ranges
686  {
687  ScViewData& rViewData = pViewSh->GetViewData();
688  if ( rViewData.GetDocShell() == pRangesImp->GetDocShell() )
689  {
690  // perhaps remove drawing selection first
691  // (MarkListHasChanged removes sheet selection)
692 
693  ScDrawView* pDrawView = pViewSh->GetScDrawView();
694  if (pDrawView)
695  {
696  pDrawView->ScEndTextEdit();
697  pDrawView->UnmarkAll();
698  }
699  FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
700  if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
701  {
702  // execute the slot of drawing function again -> switch off
703  SfxDispatcher* pDisp = pViewSh->GetDispatcher();
704  if (pDisp)
705  pDisp->Execute( pFunc->GetSlotID(), SfxCallMode::SYNCHRON );
706  }
707  pViewSh->SetDrawShell(false);
708  pViewSh->SetDrawSelMode(false); // after Dispatcher-Execute
709 
710  // select ranges
711 
712  const ScRangeList& rRanges = pRangesImp->GetRangeList();
713  size_t nRangeCount = rRanges.size();
714  // for empty range list, remove selection (cursor remains where it was)
715  if ( nRangeCount == 0 )
716  pViewSh->Unmark();
717  else if ( nRangeCount == 1 )
718  pViewSh->MarkRange( rRanges[ 0 ] );
719  else
720  {
721  // multiselection
722 
723  const ScRange & rFirst = rRanges[ 0 ];
724  if ( !lcl_TabInRanges( rViewData.GetTabNo(), rRanges ) )
725  pViewSh->SetTabNo( rFirst.aStart.Tab() );
726  pViewSh->DoneBlockMode();
727  pViewSh->InitOwnBlockMode();
728  rViewData.GetMarkData().MarkFromRangeList( rRanges, true );
729  pViewSh->MarkDataChanged();
730  rViewData.GetDocShell()->PostPaintGridAll(); // Marks (old&new)
731  pViewSh->AlignToCursor( rFirst.aStart.Col(), rFirst.aStart.Row(),
732  SC_FOLLOW_JUMP );
733  pViewSh->SetCursor( rFirst.aStart.Col(), rFirst.aStart.Row() );
734 
736  }
737  bRet = true;
738  }
739  }
740  else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer
741  {
742  ScDrawView* pDrawView = pViewSh->GetScDrawView();
743  if (pDrawView)
744  {
745  pDrawView->ScEndTextEdit();
746  pDrawView->UnmarkAll();
747 
748  if (pShapeImp) // single shape
749  {
750  SdrObject *pObj = pShapeImp->GetSdrObject();
751  if (pObj)
752  {
753  lcl_ShowObject( *pViewSh, *pDrawView, pObj );
754  SdrPageView* pPV = pDrawView->GetSdrPageView();
755  if ( pPV && pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
756  {
757  pDrawView->MarkObj( pObj, pPV );
758  bRet = true;
759  }
760  }
761  }
762  else // Shape-Collection (xShapeColl is not 0)
763  {
764  // We'll switch to the sheet where the first object is
765  // and select all objects on that sheet
767 
768  tools::Long nCount = xShapeColl->getCount();
769  if (nCount)
770  {
771  SdrPageView* pPV = nullptr;
772  bool bAllMarked(true);
773  for ( tools::Long i = 0; i < nCount; i++ )
774  {
775  uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
776  if (xShapeInt.is())
777  {
778  SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShapeInt );
779  if (pObj)
780  {
781  if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
782  {
783  pViewSh->SetDrawSelMode(true);
784  pViewSh->UpdateLayerLocks();
785  bDrawSelModeSet = true;
786  }
787  if (!pPV) // first object
788  {
789  lcl_ShowObject( *pViewSh, *pDrawView, pObj );
790  pPV = pDrawView->GetSdrPageView();
791  }
792  if ( pPV && pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
793  {
794  if (pDrawView->IsObjMarkable( pObj, pPV ))
795  pDrawView->MarkObj( pObj, pPV );
796  else
797  bAllMarked = false;
798  }
799  }
800  }
801  }
802  if (bAllMarked)
803  bRet = true;
804  }
805  else
806  bRet = true; // empty XShapes (all shapes are deselected)
807  }
808 
809  if (bRet)
810  pViewSh->SetDrawShell(true);
811  }
812  }
813 
814  if (!bRet)
815  throw lang::IllegalArgumentException();
816 
817  return bRet;
818 }
819 
820 uno::Reference<drawing::XShapes> ScTabViewShell::getSelectedXShapes()
821 {
822  uno::Reference<drawing::XShapes> xShapes;
823  SdrView* pSdrView = GetScDrawView();
824  if (pSdrView)
825  {
826  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
827  const size_t nMarkCount = rMarkList.GetMarkCount();
828  if (nMarkCount)
829  {
830  // generate ShapeCollection (like in SdXImpressView::getSelection in Draw)
831  // XInterfaceRef will be returned and it has to be UsrObject-XInterface
832  xShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext());
833 
834  for (size_t i = 0; i < nMarkCount; ++i)
835  {
836  SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
837  if (pDrawObj)
838  {
839  uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
840  if (xShape.is())
841  xShapes->add(xShape);
842  }
843  }
844  }
845  }
846  return xShapes;
847 }
848 
850 {
851  SolarMutexGuard aGuard;
852  ScTabViewShell* pViewSh = GetViewShell();
854  if (pViewSh)
855  {
856  // is something selected in drawing layer?
857  uno::Reference<uno::XInterface> xRet(pViewSh->getSelectedXShapes());
858  if (xRet.is())
859  return uno::makeAny(xRet);
860 
861  // otherwise sheet (cell) selection
862 
863  ScViewData& rViewData = pViewSh->GetViewData();
864  ScDocShell* pDocSh = rViewData.GetDocShell();
865 
866  const ScMarkData& rMark = rViewData.GetMarkData();
867  SCTAB nTabs = rMark.GetSelectCount();
868 
869  ScRange aRange;
870  ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
871  if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
872  {
873  if (aRange.aStart == aRange.aEnd)
874  pObj = new ScCellObj( pDocSh, aRange.aStart );
875  else
876  pObj = new ScCellRangeObj( pDocSh, aRange );
877  }
878  else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
879  {
880  ScMarkData aFilteredMark( rMark );
881  ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
882  ScRangeList aRangeList;
883  aFilteredMark.FillRangeListWithMarks( &aRangeList, false);
884  // Theoretically a selection may start and end on a filtered row.
885  switch ( aRangeList.size() )
886  {
887  case 0:
888  // No unfiltered row, we have to return some object, so
889  // here is one with no ranges.
890  pObj = new ScCellRangesObj( pDocSh, aRangeList );
891  break;
892  case 1:
893  {
894  const ScRange& rRange = aRangeList[ 0 ];
895  if (rRange.aStart == rRange.aEnd)
896  pObj = new ScCellObj( pDocSh, rRange.aStart );
897  else
898  pObj = new ScCellRangeObj( pDocSh, rRange );
899  }
900  break;
901  default:
902  pObj = new ScCellRangesObj( pDocSh, aRangeList );
903  }
904  }
905  else // multiselection
906  {
907  ScRangeListRef xRanges;
908  rViewData.GetMultiArea( xRanges );
909 
910  // if there are more sheets, copy ranges
912  if ( nTabs > 1 )
913  rMark.ExtendRangeListTables( xRanges.get() );
914 
915  pObj = new ScCellRangesObj( pDocSh, *xRanges );
916  }
917 
918  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
919  {
920  // remember if the selection was from the cursor position without anything selected
921  // (used when rendering the selection)
922 
923  pObj->SetCursorOnly( true );
924  }
925  }
926 
927  return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj.get())));
928 }
929 
930 // XEnumerationAccess
931 
932 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
933 {
934  SolarMutexGuard aGuard;
935  return new ScIndexEnumeration(this, "com.sun.star.sheet.SpreadsheetViewPanesEnumeration");
936 }
937 
938 // XIndexAccess
939 
940 sal_Int32 SAL_CALL ScTabViewObj::getCount()
941 {
942  SolarMutexGuard aGuard;
943  ScTabViewShell* pViewSh = GetViewShell();
944  sal_uInt16 nPanes = 0;
945  if (pViewSh)
946  {
947  nPanes = 1;
948  ScViewData& rViewData = pViewSh->GetViewData();
949  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
950  nPanes *= 2;
951  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
952  nPanes *= 2;
953  }
954  return nPanes;
955 }
956 
957 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
958 {
959  SolarMutexGuard aGuard;
960  uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)));
961  if (!xPane.is())
962  throw lang::IndexOutOfBoundsException();
963 
964  return uno::makeAny(xPane);
965 }
966 
968 {
969  SolarMutexGuard aGuard;
971 }
972 
974 {
975  SolarMutexGuard aGuard;
976  return ( getCount() != 0 );
977 }
978 
979 // XSpreadsheetView
980 
982 {
983  static const ScSplitPos ePosHV[4] =
985 
986  ScTabViewShell* pViewSh = GetViewShell();
987  if (pViewSh)
988  {
989  ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default position
990  bool bError = false;
991  ScViewData& rViewData = pViewSh->GetViewData();
992  bool bHor = ( rViewData.GetHSplitMode() != SC_SPLIT_NONE );
993  bool bVer = ( rViewData.GetVSplitMode() != SC_SPLIT_NONE );
994  if ( bHor && bVer )
995  {
996  // bottom left, bottom right, top left, top right - like in Excel
997  if ( nIndex < 4 )
998  eWhich = ePosHV[nIndex];
999  else
1000  bError = true;
1001  }
1002  else if ( bHor )
1003  {
1004  if ( nIndex > 1 )
1005  bError = true;
1006  else if ( nIndex == 1 )
1007  eWhich = SC_SPLIT_BOTTOMRIGHT;
1008  // otherwise SC_SPLIT_BOTTOMLEFT
1009  }
1010  else if ( bVer )
1011  {
1012  if ( nIndex > 1 )
1013  bError = true;
1014  else if ( nIndex == 0 )
1015  eWhich = SC_SPLIT_TOPLEFT;
1016  // otherwise SC_SPLIT_BOTTOMLEFT
1017  }
1018  else if ( nIndex > 0 )
1019  bError = true; // not split: only 0 is valid
1020 
1021  if (!bError)
1022  return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) );
1023  }
1024 
1025  return nullptr;
1026 }
1027 
1028 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1029 {
1030  SolarMutexGuard aGuard;
1031  ScTabViewShell* pViewSh = GetViewShell();
1032  if (pViewSh)
1033  {
1034  ScViewData& rViewData = pViewSh->GetViewData();
1035  SCTAB nTab = rViewData.GetTabNo();
1036  return new ScTableSheetObj( rViewData.GetDocShell(), nTab );
1037  }
1038  return nullptr;
1039 }
1040 
1041 // support expand (but not replace) the active sheet
1042 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1043 {
1044  SolarMutexGuard aGuard;
1045  comphelper::ProfileZone aZone("setActiveSheet");
1046 
1047  ScTabViewShell* pViewSh = GetViewShell();
1048  if ( !(pViewSh && xActiveSheet.is()) )
1049  return;
1050 
1051  // XSpreadsheet and ScCellRangesBase -> has to be the same sheet
1052 
1053  ScCellRangesBase* pRangesImp = comphelper::getFromUnoTunnel<ScCellRangesBase>( xActiveSheet );
1054  if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == pRangesImp->GetDocShell() )
1055  {
1056  const ScRangeList& rRanges = pRangesImp->GetRangeList();
1057  if ( rRanges.size() == 1 )
1058  {
1059  SCTAB nNewTab = rRanges[ 0 ].aStart.Tab();
1060  if ( pViewSh->GetViewData().GetDocument().HasTable(nNewTab) )
1061  pViewSh->SetTabNo( nNewTab );
1062  }
1063  }
1064 }
1065 
1066 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1067 {
1068  uno::Reference< uno::XInterface > xTarget;
1069  if (GetViewShell())
1070  {
1071  SCCOL nX;
1072  SCROW nY;
1074  ScSplitPos eSplitMode = rData.GetActivePart();
1075  SCTAB nTab(rData.GetTabNo());
1076  rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1077 
1078  ScAddress aCellPos (nX, nY, nTab);
1079  rtl::Reference<ScCellObj> pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos);
1080 
1081  xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1082 
1083  ScDocument& rDoc = rData.GetDocument();
1084  if (ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer())
1085  {
1086  SdrPage* pDrawPage = nullptr;
1087  if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1088  pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1089 
1090  SdrView* pDrawView = GetViewShell()->GetScDrawView();
1091 
1092  if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1093  {
1094  vcl::Window* pActiveWin = rData.GetActiveWin();
1095  Point aPos = pActiveWin->PixelToLogic(rPoint);
1096 
1097  sal_uInt16 nHitLog = static_cast<sal_uInt16>(pActiveWin->PixelToLogic(
1098  Size(pDrawView->GetHitTolerancePixel(),0)).Width());
1099 
1100  const size_t nCount(pDrawPage->GetObjCount());
1101  bool bFound(false);
1102  for (size_t i = 0; i < nCount && !bFound; ++i)
1103  {
1104  SdrObject* pObj = pDrawPage->GetObj(i);
1105  if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), nullptr, false))
1106  {
1107  xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1108  bFound = true;
1109  }
1110  }
1111  }
1112  }
1113  }
1114  return xTarget;
1115 }
1116 
1118 {
1119  if ( !aMouseClickHandlers.empty() )
1120  return true;
1121 
1122  // also include sheet events, because MousePressed must be called for them
1123  ScViewData& rViewData = GetViewShell()->GetViewData();
1124  ScDocument& rDoc = rViewData.GetDocument();
1125  SCTAB nTab = rViewData.GetTabNo();
1126  return
1127  rDoc.HasSheetEventScript( nTab, ScSheetEventId::RIGHTCLICK, true ) ||
1128  rDoc.HasSheetEventScript( nTab, ScSheetEventId::DOUBLECLICK, true ) ||
1129  rDoc.HasSheetEventScript( nTab, ScSheetEventId::SELECT, true );
1130 
1131 }
1132 
1133 bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1134 {
1135  bool bReturn(false);
1136  if ( e.Buttons == css::awt::MouseButton::LEFT )
1137  mbLeftMousePressed = true;
1138 
1139  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1140  if (!aMouseClickHandlers.empty() && xTarget.is())
1141  {
1142  awt::EnhancedMouseEvent aMouseEvent;
1143 
1144  aMouseEvent.Buttons = e.Buttons;
1145  aMouseEvent.X = e.X;
1146  aMouseEvent.Y = e.Y;
1147  aMouseEvent.ClickCount = e.ClickCount;
1148  aMouseEvent.PopupTrigger = e.PopupTrigger;
1149  aMouseEvent.Target = xTarget;
1150  aMouseEvent.Modifiers = e.Modifiers;
1151 
1152  // Listener's handler may remove it from the listeners list
1153  for (size_t i = aMouseClickHandlers.size(); i > 0; --i)
1154  {
1155  try
1156  {
1157  if (!aMouseClickHandlers[i - 1]->mousePressed(aMouseEvent))
1158  bReturn = true;
1159  }
1160  catch ( uno::Exception& )
1161  {
1162  aMouseClickHandlers.erase(aMouseClickHandlers.begin() + (i - 1));
1163  }
1164  }
1165  }
1166 
1167  // handle sheet events
1168  bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1169  bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1170  if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1171  {
1173 
1174  ScTabViewShell* pViewSh = GetViewShell();
1175  ScViewData& rViewData = pViewSh->GetViewData();
1176  ScDocShell* pDocSh = rViewData.GetDocShell();
1177  ScDocument& rDoc = pDocSh->GetDocument();
1178  SCTAB nTab = rViewData.GetTabNo();
1179  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1180  if (pEvents)
1181  {
1182  const OUString* pScript = pEvents->GetScript(nEvent);
1183  if (pScript)
1184  {
1185  // the macro parameter is the clicked object, as in the mousePressed call above
1186  uno::Sequence<uno::Any> aParams{ uno::Any(xTarget) };
1187 
1188  uno::Any aRet;
1189  uno::Sequence<sal_Int16> aOutArgsIndex;
1190  uno::Sequence<uno::Any> aOutArgs;
1191 
1192  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1193 
1194  // look for a boolean return value of true
1195  bool bRetValue = false;
1196  if ((aRet >>= bRetValue) && bRetValue)
1197  bReturn = true;
1198  }
1199  }
1200 
1201  // execute VBA event handler
1202  if (!bReturn && xTarget.is()) try
1203  {
1204  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1205  // the parameter is the clicked object, as in the mousePressed call above
1206  uno::Sequence< uno::Any > aArgs{ uno::Any(xTarget) };
1207  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1208  }
1209  catch( util::VetoException& )
1210  {
1211  bReturn = true;
1212  }
1213  catch( uno::Exception& )
1214  {
1215  }
1216  }
1217 
1218  return bReturn;
1219 }
1220 
1221 bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1222 {
1223  if ( e.Buttons == css::awt::MouseButton::LEFT )
1224  {
1225  try
1226  {
1227  ScTabViewShell* pViewSh = GetViewShell();
1228  ScViewData& rViewData = pViewSh->GetViewData();
1229  ScDocShell* pDocSh = rViewData.GetDocShell();
1230  ScDocument& rDoc = pDocSh->GetDocument();
1231  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1232  uno::Sequence< uno::Any > aArgs{ getSelection() };
1233  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1234  }
1235  catch( uno::Exception& )
1236  {
1237  }
1238  mbLeftMousePressed = false;
1239  }
1240 
1241  bool bReturn(false);
1242 
1243  if (!aMouseClickHandlers.empty())
1244  {
1245  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1246 
1247  if (xTarget.is())
1248  {
1249  awt::EnhancedMouseEvent aMouseEvent;
1250 
1251  aMouseEvent.Buttons = e.Buttons;
1252  aMouseEvent.X = e.X;
1253  aMouseEvent.Y = e.Y;
1254  aMouseEvent.ClickCount = e.ClickCount;
1255  aMouseEvent.PopupTrigger = e.PopupTrigger;
1256  aMouseEvent.Target = xTarget;
1257  aMouseEvent.Modifiers = e.Modifiers;
1258 
1259  // Listener's handler may remove it from the listeners list
1260  for (size_t i = aMouseClickHandlers.size(); i > 0; --i)
1261  {
1262  try
1263  {
1264  if (!aMouseClickHandlers[i - 1]->mouseReleased( aMouseEvent ))
1265  bReturn = true;
1266  }
1267  catch ( uno::Exception& )
1268  {
1269  aMouseClickHandlers.erase(aMouseClickHandlers.begin() + (i - 1));
1270  }
1271  }
1272  }
1273  }
1274  return bReturn;
1275 }
1276 
1277 // XEnhancedMouseClickBroadcaster
1278 
1280 {
1281  lang::EventObject aEvent;
1282  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1283  for (const auto& rListener : aMouseClickHandlers)
1284  {
1285  try
1286  {
1287  rListener->disposing(aEvent);
1288  }
1289  catch ( uno::Exception& )
1290  {
1291  }
1292  }
1293  aMouseClickHandlers.clear();
1294 }
1295 
1297 {
1298  lang::EventObject aEvent;
1299  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1300  for (const auto& rListener : aActivationListeners)
1301  {
1302  try
1303  {
1304  rListener->disposing(aEvent);
1305  }
1306  catch ( uno::Exception& )
1307  {
1308  }
1309  }
1310  aActivationListeners.clear();
1311 }
1312 
1313 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1314 {
1315  SolarMutexGuard aGuard;
1316 
1317  if (aListener.is())
1318  {
1319  aMouseClickHandlers.push_back( aListener );
1320  }
1321 }
1322 
1323 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1324 {
1325  SolarMutexGuard aGuard;
1326  sal_uInt16 nCount = aMouseClickHandlers.size();
1327  aMouseClickHandlers.erase(
1328  std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
1329  aMouseClickHandlers.end());
1330  if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
1332 }
1333 
1334 // XActivationBroadcaster
1335 
1336 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1337 {
1338  SolarMutexGuard aGuard;
1339 
1340  if (aListener.is())
1341  {
1342  aActivationListeners.push_back( aListener );
1343  }
1344 }
1345 
1346 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1347 {
1348  SolarMutexGuard aGuard;
1349  sal_uInt16 nCount = aActivationListeners.size();
1350  aActivationListeners.erase(
1351  std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
1352  aActivationListeners.end());
1353  if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
1355 }
1356 
1357 sal_Int16 ScTabViewObj::GetZoom() const
1358 {
1359  ScTabViewShell* pViewSh = GetViewShell();
1360  if (pViewSh)
1361  {
1362  const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y will be shown
1363  return static_cast<sal_Int16>(tools::Long( rZoomY * 100 ));
1364  }
1365  return 0;
1366 }
1367 
1368 void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1369 {
1370  ScTabViewShell* pViewSh = GetViewShell();
1371  if (!pViewSh)
1372  return;
1373 
1374  if ( nZoom != GetZoom() && nZoom != 0 )
1375  {
1376  if (!pViewSh->GetViewData().IsPagebreakMode())
1377  {
1378  ScModule* pScMod = SC_MOD();
1379  ScAppOptions aNewOpt(pScMod->GetAppOptions());
1380  aNewOpt.SetZoom( nZoom );
1381  aNewOpt.SetZoomType( pViewSh->GetViewData().GetView()->GetZoomType() );
1382  pScMod->SetAppOptions( aNewOpt );
1383  }
1384  }
1385  Fraction aFract( nZoom, 100 );
1386  pViewSh->SetZoom( aFract, aFract, true );
1387  pViewSh->PaintGrid();
1388  pViewSh->PaintTop();
1389  pViewSh->PaintLeft();
1390  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1391  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1392  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_IN);
1393  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_OUT);
1394 }
1395 
1396 sal_Int16 ScTabViewObj::GetZoomType() const
1397 {
1398  sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1399  ScTabViewShell* pViewSh = GetViewShell();
1400  if (pViewSh)
1401  {
1402  SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1403  switch (eZoomType)
1404  {
1405  case SvxZoomType::PERCENT:
1406  aZoomType = view::DocumentZoomType::BY_VALUE;
1407  break;
1408  case SvxZoomType::OPTIMAL:
1409  aZoomType = view::DocumentZoomType::OPTIMAL;
1410  break;
1411  case SvxZoomType::WHOLEPAGE:
1412  aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1413  break;
1414  case SvxZoomType::PAGEWIDTH:
1415  aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1416  break;
1417  case SvxZoomType::PAGEWIDTH_NOBORDER:
1418  aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1419  break;
1420  }
1421  }
1422  return aZoomType;
1423 }
1424 
1425 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1426 {
1427  ScTabViewShell* pViewSh = GetViewShell();
1428  if (!pViewSh)
1429  return;
1430 
1431  ScDBFunc* pView = pViewSh->GetViewData().GetView();
1432  if (!pView)
1433  return;
1434 
1435  SvxZoomType eZoomType;
1436  switch (aZoomType)
1437  {
1438  case view::DocumentZoomType::BY_VALUE:
1439  eZoomType = SvxZoomType::PERCENT;
1440  break;
1441  case view::DocumentZoomType::OPTIMAL:
1442  eZoomType = SvxZoomType::OPTIMAL;
1443  break;
1444  case view::DocumentZoomType::ENTIRE_PAGE:
1445  eZoomType = SvxZoomType::WHOLEPAGE;
1446  break;
1447  case view::DocumentZoomType::PAGE_WIDTH:
1448  eZoomType = SvxZoomType::PAGEWIDTH;
1449  break;
1450  case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1451  eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1452  break;
1453  default:
1454  eZoomType = SvxZoomType::OPTIMAL;
1455  }
1456  sal_Int16 nZoom(GetZoom());
1457  sal_Int16 nOldZoom(nZoom);
1458  if ( eZoomType == SvxZoomType::PERCENT )
1459  {
1460  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1461  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1462  }
1463  else
1464  nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1465 
1466  switch ( eZoomType )
1467  {
1468  case SvxZoomType::WHOLEPAGE:
1469  case SvxZoomType::PAGEWIDTH:
1470  pView->SetZoomType( eZoomType, true );
1471  break;
1472 
1473  default:
1474  pView->SetZoomType( SvxZoomType::PERCENT, true );
1475  }
1476  SetZoom( nZoom );
1477 }
1478 
1480 {
1481  SolarMutexGuard aGuard;
1482  // what menu slot SID_WINDOW_SPLIT does
1483 
1484  ScTabViewShell* pViewSh = GetViewShell();
1485  if (pViewSh)
1486  {
1487  ScViewData& rViewData = pViewSh->GetViewData();
1488  return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1489  rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1490  }
1491 
1492  return false;
1493 }
1494 
1496 {
1497  SolarMutexGuard aGuard;
1498  // what menu slot SID_WINDOW_FIX does
1499 
1500  ScTabViewShell* pViewSh = GetViewShell();
1501  if (pViewSh)
1502  {
1503  ScViewData& rViewData = pViewSh->GetViewData();
1504  return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1505  rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1506  }
1507 
1508  return false;
1509 }
1510 
1512 {
1513  SolarMutexGuard aGuard;
1514  ScTabViewShell* pViewSh = GetViewShell();
1515  if (pViewSh)
1516  {
1517  ScViewData& rViewData = pViewSh->GetViewData();
1518  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1519  return rViewData.GetHSplitPos();
1520  }
1521  return 0;
1522 }
1523 
1525 {
1526  SolarMutexGuard aGuard;
1527  ScTabViewShell* pViewSh = GetViewShell();
1528  if (pViewSh)
1529  {
1530  ScViewData& rViewData = pViewSh->GetViewData();
1531  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1532  return rViewData.GetVSplitPos();
1533  }
1534  return 0;
1535 }
1536 
1537 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1538 {
1539  SolarMutexGuard aGuard;
1540  ScTabViewShell* pViewSh = GetViewShell();
1541  if (pViewSh)
1542  {
1543  ScViewData& rViewData = pViewSh->GetViewData();
1544  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1545  {
1546  tools::Long nSplit = rViewData.GetHSplitPos();
1547 
1549  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1550  ePos = SC_SPLIT_TOPLEFT;
1551 
1552  SCCOL nCol;
1553  SCROW nRow;
1554  rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1555  if ( nCol > 0 )
1556  return nCol;
1557  }
1558  }
1559  return 0;
1560 }
1561 
1562 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow()
1563 {
1564  SolarMutexGuard aGuard;
1565  ScTabViewShell* pViewSh = GetViewShell();
1566  if (pViewSh)
1567  {
1568  ScViewData& rViewData = pViewSh->GetViewData();
1569  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1570  {
1571  tools::Long nSplit = rViewData.GetVSplitPos();
1572 
1573  // split vertically
1574  SCCOL nCol;
1575  SCROW nRow;
1576  rViewData.GetPosFromPixel( 0, nSplit, SC_SPLIT_TOPLEFT, nCol, nRow, false );
1577  if ( nRow > 0 )
1578  return nRow;
1579  }
1580  }
1581  return 0;
1582 }
1583 
1584 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1585 {
1586  SolarMutexGuard aGuard;
1587  ScTabViewShell* pViewSh = GetViewShell();
1588  if (pViewSh)
1589  {
1590  pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ) );
1591  pViewSh->FreezeSplitters( false );
1592  pViewSh->InvalidateSplit();
1593  }
1594 }
1595 
1596 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1597 {
1598  SolarMutexGuard aGuard;
1599  ScTabViewShell* pViewSh = GetViewShell();
1600  if (!pViewSh)
1601  return;
1602 
1603  // first, remove them all -> no stress with scrolling in the meantime
1604 
1605  pViewSh->RemoveSplit();
1606 
1607  Point aWinStart;
1608  vcl::Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1609  if (pWin)
1610  aWinStart = pWin->GetPosPixel();
1611 
1612  ScViewData& rViewData = pViewSh->GetViewData();
1613  Point aSplit(rViewData.GetScrPos( static_cast<SCCOL>(nColumns), static_cast<SCROW>(nRows), SC_SPLIT_BOTTOMLEFT, true ));
1614  aSplit += aWinStart;
1615 
1616  pViewSh->SplitAtPixel( aSplit );
1617  pViewSh->FreezeSplitters( true );
1618  pViewSh->InvalidateSplit();
1619 }
1620 
1622  const uno::Reference<view::XSelectionChangeListener>& xListener )
1623 {
1624  SolarMutexGuard aGuard;
1625  aSelectionChgListeners.push_back( xListener );
1626 }
1627 
1629  const uno::Reference< view::XSelectionChangeListener >& xListener )
1630 {
1631  SolarMutexGuard aGuard;
1632  auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener);
1633  if (it != aSelectionChgListeners.end())
1634  aSelectionChgListeners.erase(it);
1635 }
1636 
1638 {
1639  // Selection changed so end any style preview
1640  // Note: executing this slot through the dispatcher
1641  // will cause the style dialog to be raised so we go
1642  // direct here
1643  ScFormatShell aShell( GetViewShell()->GetViewData() );
1644  SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1645  SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1646  aShell.ExecuteStyle( aReq );
1647  lang::EventObject aEvent;
1648  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1649  for (const auto& rListener : aSelectionChgListeners)
1650  rListener->selectionChanged( aEvent );
1651 
1652  // handle sheet events
1653  ScTabViewShell* pViewSh = GetViewShell();
1654  ScViewData& rViewData = pViewSh->GetViewData();
1655  ScDocShell* pDocSh = rViewData.GetDocShell();
1656  ScDocument& rDoc = pDocSh->GetDocument();
1657  SCTAB nTab = rViewData.GetTabNo();
1658  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1659  if (pEvents)
1660  {
1661  const OUString* pScript = pEvents->GetScript(ScSheetEventId::SELECT);
1662  if (pScript)
1663  {
1664  // the macro parameter is the selection as returned by getSelection
1665  uno::Sequence<uno::Any> aParams{ getSelection() };
1666  uno::Any aRet;
1667  uno::Sequence<sal_Int16> aOutArgsIndex;
1668  uno::Sequence<uno::Any> aOutArgs;
1669  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1670  }
1671  }
1672 
1673  SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
1674 
1675  if ( mbLeftMousePressed ) // selection still in progress
1676  return;
1677 
1678  try
1679  {
1680  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1681  uno::Sequence< uno::Any > aArgs{ getSelection() };
1682  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1683  }
1684  catch( uno::Exception& )
1685  {
1686  }
1687 }
1688 
1689 // XPropertySet (view options)
1691 
1692 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1693 {
1694  SolarMutexGuard aGuard;
1695  static uno::Reference<beans::XPropertySetInfo> aRef(
1697  return aRef;
1698 }
1699 
1701  const OUString& aPropertyName, const uno::Any& aValue )
1702 {
1703  SolarMutexGuard aGuard;
1704 
1705  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1706  {
1708  return;
1709  }
1710 
1711  ScTabViewShell* pViewSh = GetViewShell();
1712  if (!pViewSh)
1713  return;
1714 
1715  ScViewData& rViewData = pViewSh->GetViewData();
1716  const ScViewOptions& rOldOpt = pViewSh->GetViewData().GetOptions();
1717  ScViewOptions aNewOpt(rOldOpt);
1718 
1719  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1721  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1723  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1725  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1727  else if ( aPropertyName == SC_UNO_SHOWANCHOR )
1729  else if ( aPropertyName == SC_UNO_SHOWFORM )
1731  else if ( aPropertyName == SC_UNO_SHOWGRID )
1733  else if ( aPropertyName == SC_UNO_SHOWHELP )
1735  else if ( aPropertyName == SC_UNO_SHOWNOTES )
1737  else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
1739  else if ( aPropertyName == SC_UNO_SHOWZERO )
1741  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1743  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1745  else if ( aPropertyName == SC_UNO_SHOWOBJ )
1746  {
1747  sal_Int16 nIntVal = 0;
1748  if ( aValue >>= nIntVal )
1749  {
1750  //#i80528# adapt to new range eventually
1751  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1752 
1753  aNewOpt.SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
1754  }
1755  }
1756  else if ( aPropertyName == SC_UNO_SHOWCHARTS )
1757  {
1758  sal_Int16 nIntVal = 0;
1759  if ( aValue >>= nIntVal )
1760  {
1761  //#i80528# adapt to new range eventually
1762  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1763 
1764  aNewOpt.SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
1765  }
1766  }
1767  else if ( aPropertyName == SC_UNO_SHOWDRAW )
1768  {
1769  sal_Int16 nIntVal = 0;
1770  if ( aValue >>= nIntVal )
1771  {
1772  //#i80528# adapt to new range eventually
1773  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1774 
1775  aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
1776  }
1777  }
1778  else if ( aPropertyName == SC_UNO_GRIDCOLOR )
1779  {
1780  Color nIntVal;
1781  if ( aValue >>= nIntVal )
1782  aNewOpt.SetGridColor( nIntVal, OUString() );
1783  }
1784  else if ( aPropertyName == SC_UNO_ZOOMTYPE )
1785  {
1786  sal_Int16 nIntVal = 0;
1787  if ( aValue >>= nIntVal )
1788  SetZoomType(nIntVal);
1789  }
1790  else if ( aPropertyName == SC_UNO_ZOOMVALUE )
1791  {
1792  sal_Int16 nIntVal = 0;
1793  if ( aValue >>= nIntVal )
1794  SetZoom(nIntVal);
1795  }
1796 
1797  // Options are set on the view and document (for new views),
1798  // so that they remain during saving.
1801 
1802  if ( aNewOpt == rOldOpt )
1803  return;
1804 
1805  rViewData.SetOptions( aNewOpt );
1806  rViewData.GetDocument().SetViewOptions( aNewOpt );
1807  rViewData.GetDocShell()->SetDocumentModified();
1808 
1809  pViewSh->UpdateFixPos();
1810  pViewSh->PaintGrid();
1811  pViewSh->PaintTop();
1812  pViewSh->PaintLeft();
1813  pViewSh->PaintExtras();
1814  pViewSh->InvalidateBorder();
1815 
1816  SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1817  rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> check in menu
1818  rBindings.Invalidate( FID_TOGGLESYNTAX );
1819 }
1820 
1821 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1822 {
1823  SolarMutexGuard aGuard;
1824  uno::Any aRet;
1825 
1826  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1827  {
1828  aRet <<= bFilteredRangeSelection;
1829  return aRet;
1830  }
1831 
1832  ScTabViewShell* pViewSh = GetViewShell();
1833  if (pViewSh)
1834  {
1835  const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1836 
1837  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1838  aRet <<= rOpt.GetOption( VOPT_HEADER );
1839  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1840  aRet <<= rOpt.GetOption( VOPT_HSCROLL );
1841  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1842  aRet <<= rOpt.GetOption( VOPT_OUTLINER );
1843  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1844  aRet <<= rOpt.GetOption( VOPT_TABCONTROLS );
1845  else if ( aPropertyName == SC_UNO_SHOWANCHOR ) aRet <<= rOpt.GetOption( VOPT_ANCHOR );
1846  else if ( aPropertyName == SC_UNO_SHOWFORM ) aRet <<= rOpt.GetOption( VOPT_FORMULAS );
1847  else if ( aPropertyName == SC_UNO_SHOWGRID ) aRet <<= rOpt.GetOption( VOPT_GRID );
1848  else if ( aPropertyName == SC_UNO_SHOWHELP ) aRet <<= rOpt.GetOption( VOPT_HELPLINES );
1849  else if ( aPropertyName == SC_UNO_SHOWNOTES ) aRet <<= rOpt.GetOption( VOPT_NOTES );
1850  else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= rOpt.GetOption( VOPT_PAGEBREAKS );
1851  else if ( aPropertyName == SC_UNO_SHOWZERO ) aRet <<= rOpt.GetOption( VOPT_NULLVALS );
1852  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1853  aRet <<= rOpt.GetOption( VOPT_SYNTAX );
1854  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1855  aRet <<= rOpt.GetOption( VOPT_VSCROLL );
1856  else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1857  else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1858  else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1859  else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= rOpt.GetGridColor();
1860  else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1861  else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1862  else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1863  else if ( aPropertyName == SC_UNO_VISAREASCREEN )
1864  {
1865  ScViewData& rViewData = pViewSh->GetViewData();
1866  vcl::Window* pActiveWin = rViewData.GetActiveWin();
1867  if ( pActiveWin )
1868  {
1869  tools::Rectangle aRect = pActiveWin->GetWindowExtentsRelative( nullptr );
1870  aRet <<= AWTRectangle( aRect );
1871  }
1872  }
1873  }
1874 
1875  return aRet;
1876 }
1877 
1878 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1879  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1880 {
1881  SolarMutexGuard aGuard;
1882  aPropertyChgListeners.push_back( xListener );
1883 }
1884 
1885 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1886  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1887 {
1888  SolarMutexGuard aGuard;
1889  auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener);
1890  if (it != aPropertyChgListeners.end())
1891  aPropertyChgListeners.erase(it);
1892 }
1893 
1894 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
1895  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1896 {
1897 }
1898 
1899 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
1900  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1901 {
1902 }
1903 
1905 {
1906  beans::PropertyChangeEvent aEvent;
1907  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1908  for (const auto& rListener : aPropertyChgListeners)
1909  rListener->propertyChange( aEvent );
1910 }
1911 
1912 // XRangeSelection
1913 
1915  const uno::Sequence<beans::PropertyValue>& aArguments )
1916 {
1917  SolarMutexGuard aGuard;
1918  ScTabViewShell* pViewSh = GetViewShell();
1919  if (!pViewSh)
1920  return;
1921 
1922  OUString aInitVal, aTitle;
1923  bool bCloseOnButtonUp = false;
1924  bool bSingleCell = false;
1925  bool bMultiSelection = false;
1926 
1927  OUString aStrVal;
1928  for (const beans::PropertyValue& rProp : aArguments)
1929  {
1930  OUString aPropName(rProp.Name);
1931 
1932  if (aPropName == SC_UNONAME_CLOSEONUP )
1933  bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1934  else if (aPropName == SC_UNONAME_TITLE )
1935  {
1936  if ( rProp.Value >>= aStrVal )
1937  aTitle = aStrVal;
1938  }
1939  else if (aPropName == SC_UNONAME_INITVAL )
1940  {
1941  if ( rProp.Value >>= aStrVal )
1942  aInitVal = aStrVal;
1943  }
1944  else if (aPropName == SC_UNONAME_SINGLECELL )
1945  bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1946  else if (aPropName == SC_UNONAME_MULTISEL )
1947  bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1948  }
1949 
1950  pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
1951 }
1952 
1954 {
1955  SolarMutexGuard aGuard;
1956  ScTabViewShell* pViewSh = GetViewShell();
1957  if (pViewSh)
1958  pViewSh->StopSimpleRefDialog();
1959 }
1960 
1962  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1963 {
1964  SolarMutexGuard aGuard;
1965  aRangeSelListeners.push_back( xListener );
1966 }
1967 
1969  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1970 {
1971  SolarMutexGuard aGuard;
1972  auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
1973  if (it != aRangeSelListeners.end())
1974  aRangeSelListeners.erase(it);
1975 }
1976 
1978  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1979 {
1980  SolarMutexGuard aGuard;
1981  aRangeChgListeners.push_back( xListener );
1982 }
1983 
1985  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1986 {
1987  SolarMutexGuard aGuard;
1988  auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
1989  if (it != aRangeChgListeners.end())
1990  aRangeChgListeners.erase(it);
1991 }
1992 
1993 void ScTabViewObj::RangeSelDone( const OUString& rText )
1994 {
1995  sheet::RangeSelectionEvent aEvent;
1996  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1997  aEvent.RangeDescriptor = rText;
1998 
1999  // copy on the stack because listener could remove itself
2000  auto const listeners(aRangeSelListeners);
2001 
2002  for (const auto& rListener : listeners)
2003  rListener->done( aEvent );
2004 }
2005 
2006 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2007 {
2008  sheet::RangeSelectionEvent aEvent;
2009  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2010  aEvent.RangeDescriptor = rText;
2011 
2012  // copy on the stack because listener could remove itself
2013  auto const listeners(aRangeSelListeners);
2014 
2015  for (const auto& rListener : listeners)
2016  rListener->aborted( aEvent );
2017 }
2018 
2019 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2020 {
2021  sheet::RangeSelectionEvent aEvent;
2022  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2023  aEvent.RangeDescriptor = rText;
2024 
2025  // copy on the stack because listener could remove itself
2026  auto const listener(aRangeChgListeners);
2027 
2028  for (const auto& rListener : listener)
2029  rListener->descriptorChanged( aEvent );
2030 }
2031 
2032 // XServiceInfo
2034 {
2035  return "ScTabViewObj";
2036 }
2037 
2038 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2039 {
2040  return cppu::supportsService(this, rServiceName);
2041 }
2042 
2043 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2044 {
2046 }
2047 
2048 // XUnoTunnel
2049 
2051 
2052 css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2053 {
2054  SolarMutexGuard aGuard;
2055  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2056  if (pShell)
2057  return pShell->GetEditView()->GetTransferable();
2058 
2059  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2060  if (pTextShell)
2061  {
2062  ScViewData& rViewData = GetViewShell()->GetViewData();
2063  ScDrawView* pView = rViewData.GetScDrawView();
2064  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2065  if (pOutView)
2066  return pOutView->GetEditView().GetTransferable();
2067  }
2068 
2069  ScDrawShell* pDrawShell = dynamic_cast<ScDrawShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2070  if (pDrawShell)
2071  return pDrawShell->GetDrawView()->CopyToTransferable();
2072 
2073  return GetViewShell()->CopyToTransferable();
2074 }
2075 
2076 void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans )
2077 {
2078  SolarMutexGuard aGuard;
2079  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2080  if (pShell)
2081  pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2082  else
2083  {
2084  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2085  if (pTextShell)
2086  {
2087  ScViewData& rViewData = GetViewShell()->GetViewData();
2088  ScDrawView* pView = rViewData.GetScDrawView();
2089  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2090  if ( pOutView )
2091  {
2092  pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2093  return;
2094  }
2095  }
2096 
2097  GetViewShell()->PasteFromTransferable( xTrans );
2098  }
2099 }
2100 
2101 namespace {
2102 
2103 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2104 {
2105  uno::Sequence<sal_Int32> aRet(rSelected.size());
2106  auto aRetRange = asNonConstRange(aRet);
2107  size_t i = 0;
2108  for (const auto& rTab : rSelected)
2109  {
2110  aRetRange[i] = static_cast<sal_Int32>(rTab);
2111  ++i;
2112  }
2113 
2114  return aRet;
2115 }
2116 
2117 }
2118 
2119 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2120 {
2121  ScTabViewShell* pViewSh = GetViewShell();
2122  if (!pViewSh)
2123  return uno::Sequence<sal_Int32>();
2124 
2125  ScViewData& rViewData = pViewSh->GetViewData();
2126 
2127  // #i95280# when printing from the shell, the view is never activated,
2128  // so Excel view settings must also be evaluated here.
2129  ScExtDocOptions* pExtOpt = rViewData.GetDocument().GetExtDocOptions();
2130  if (pExtOpt && pExtOpt->IsChanged())
2131  {
2132  pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2133  pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2134  pExtOpt->SetChanged(false);
2135  }
2136 
2137  return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2138 }
2139 
2141  SfxBaseController(pViewSh),
2142  mpViewShell(pViewSh)
2143 {
2144  if (mpViewShell)
2146 }
2147 
2149 {
2150  if (mpViewShell)
2152 }
2153 
2155 {
2156  SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2157  return SfxBaseController::queryInterface(rType);
2158 }
2159 
2160 void ScPreviewObj::acquire() noexcept
2161 {
2162  SfxBaseController::acquire();
2163 }
2164 
2165 void ScPreviewObj::release() noexcept
2166 {
2167  SfxBaseController::release();
2168 }
2169 
2171 {
2172  if (rHint.GetId() == SfxHintId::Dying)
2173  mpViewShell = nullptr;
2174 }
2175 
2176 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2177 {
2178  ScPreview* p = mpViewShell ? mpViewShell->GetPreview() : nullptr;
2179  if (!p)
2180  return uno::Sequence<sal_Int32>();
2181 
2182  return toSequence(p->GetSelectedTabs());
2183 }
2184 
2185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetChanged(bool bChanged)
If set to true, the data will be copied to the view data after import.
Definition: scextopt.cxx:165
If set, cloned formula cells will start to listen to the document.
SdrUnoObj * GetFormControl(const css::uno::Reference< css::awt::XControlModel > &_rxModel, const SdrView &_rView, const OutputDevice &_rDevice, css::uno::Reference< css::awt::XControl > &_out_rxControl) const
#define MAXZOOM
Definition: global.hxx:79
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3109
virtual Point GetPosPixel() const
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:418
#define SC_UNO_COLROWHDR
Definition: unonames.hxx:538
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:87
#define SC_UNO_SHOWCHARTS
Definition: unonames.hxx:545
virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getTransferable() override
Definition: viewuno.cxx:2052
bool mbLeftMousePressed
Definition: viewuno.hxx:170
bool hasValue()
std::vector< css::uno::Reference< css::beans::XPropertyChangeListener > > aPropertyChgListeners
Definition: viewuno.hxx:152
virtual void SAL_CALL removeRangeSelectionListener(const css::uno::Reference< css::sheet::XRangeSelectionListener > &aListener) override
Definition: viewuno.cxx:1968
#define SC_UNONAME_MULTISEL
Definition: unonames.hxx:645
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:413
ScAddress aStart
Definition: address.hxx:499
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:353
void FreezeSplitters(bool bFreeze, SplitMethod eSplitMethod=SC_SPLIT_METHOD_CURSOR, SCCOLROW nFreezeIndex=-1)
Definition: tabview.cxx:1912
virtual void SAL_CALL release() noexcept override
Definition: viewuno.cxx:428
size_t GetMarkCount() const
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: viewuno.cxx:136
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:42
void RangeSelAborted(const OUString &rText)
Definition: viewuno.cxx:2006
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:718
void ReadExtOptions(const ScExtDocOptions &rOpt)
Definition: viewdata.cxx:3501
virtual css::uno::Reference< css::form::runtime::XFormController > SAL_CALL getFormController(const css::uno::Reference< css::form::XForm > &Form) override
Definition: viewuno.cxx:310
virtual const FmFormShell * GetFormShell() const override
Definition: tabvwsh.hxx:334
MapMode GetDrawMapMode(bool bForce=false)
MapMode for the drawinglayer objects.
Definition: gridwin3.cxx:252
SCROW Row() const
Definition: address.hxx:261
ScVSplitPos
Definition: viewdata.hxx:46
ScDocShell * GetDocShell() const
Definition: cellsuno.hxx:242
static void lcl_CallActivate(ScDocShell *pDocSh, SCTAB nTab, ScSheetEventId nEvent)
Definition: viewuno.cxx:498
void PostPaintGridAll()
Definition: docsh3.cxx:183
virtual void SAL_CALL acquire() noexcept override
Definition: viewuno.cxx:2160
#define SC_UNO_SHOWFORM
Definition: unonames.hxx:547
virtual void SAL_CALL setFirstVisibleRow(sal_Int32 nFirstVisibleRow) override
Definition: viewuno.cxx:224
const css::uno::Reference< css::script::vba::XVBAEventProcessor > & GetVbaEventProcessor() const
Definition: document.hxx:2454
#define SC_UNO_ZOOMVALUE
Definition: unonames.hxx:573
bool IsObjMarkable(SdrObject const *pObj, SdrPageView const *pPV) const
virtual void SAL_CALL addRangeSelectionChangeListener(const css::uno::Reference< css::sheet::XRangeSelectionChangeListener > &aListener) override
Definition: viewuno.cxx:1977
bool PaintExtras()
Definition: tabview3.cxx:2759
#define OLD_UNO_HORSCROLL
Definition: unonames.hxx:584
#define SC_UNO_VALUEHIGH
Definition: unonames.hxx:554
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1687
bool IsChanged() const
Definition: scextopt.cxx:160
virtual void SAL_CALL startRangeSelection(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: viewuno.cxx:1914
SfxDispatcher * GetDispatcher()
#define SC_UNO_SHOWHELP
Definition: unonames.hxx:549
std::vector< css::uno::Reference< css::awt::XEnhancedMouseClickHandler > > aMouseClickHandlers
Definition: viewuno.hxx:154
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: viewuno.cxx:957
bool MousePressed(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1133
long Long
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual void SAL_CALL splitAtPosition(sal_Int32 nPixelX, sal_Int32 nPixelY) override
Definition: viewuno.cxx:1584
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:712
Reference< XInterface > xTarget
virtual OUString SAL_CALL getImplementationName() override
Definition: viewuno.cxx:2033
bool IsMouseListening() const
Definition: viewuno.cxx:1117
SdrObject * GetObj(size_t nNum) const
virtual Size GetSizePixel() const
size_t GetObjCount() const
void SAL_CALL mouseReleased(const css::awt::MouseEvent &e) override
void FillRangeListWithMarks(ScRangeList *pList, bool bClear, SCTAB nForTab=-1) const
Create a range list of marks.
Definition: markdata.cxx:386
void SetDocumentModified()
Definition: docsh.cxx:2939
rtl::Reference< ScViewPaneObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) const
Definition: viewuno.cxx:981
const ContentProperties & rData
virtual void SAL_CALL removeEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1323
std::vector< css::uno::Reference< css::sheet::XRangeSelectionChangeListener > > aRangeChgListeners
Definition: viewuno.hxx:150
SCTAB GetTabNo() const
Definition: viewdata.hxx:394
#define OLD_UNO_SHEETTABS
Definition: unonames.hxx:586
constexpr SdrLayerID SC_LAYER_BACK(1)
void PaintGrid()
Definition: tabview3.cxx:2628
virtual void SAL_CALL setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn) override
Definition: viewuno.cxx:191
void Unmark()
Definition: tabview3.cxx:1723
ScAddress aEnd
Definition: address.hxx:500
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:76
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:397
sal_Int16 GetZoomType() const
Definition: viewuno.cxx:1396
SdrMark * GetMark(size_t nNum) const
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
void SheetChanged(bool bSameTabButMoved)
Definition: viewuno.cxx:533
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: viewuno.cxx:154
virtual sal_Int32 SAL_CALL getSplitColumn() override
Definition: viewuno.cxx:1537
EditView * GetEditView()
Definition: editsh.hxx:68
void Invalidate(sal_uInt16 nId)
#define SC_UNONAME_SINGLECELL
Definition: unonames.hxx:644
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: viewuno.cxx:2038
UNO3_GETIMPLEMENTATION_IMPL(ScTabViewObj)
EmbeddedObjectRef * pObject
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:363
virtual void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: viewuno.cxx:2170
css::chart::ChartAxisLabelPosition ePos
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1400
const ScRangeList & GetRangeList() const
Definition: cellsuno.hxx:244
static bool lcl_TabInRanges(SCTAB nTab, const ScRangeList &rRanges)
Definition: viewuno.cxx:601
std::vector< css::uno::Reference< css::sheet::XActivationEventListener > > aActivationListeners
Definition: viewuno.hxx:156
static const SfxItemPropertyMapEntry * lcl_GetViewOptPropertyMap()
Clipping Marks.
Definition: viewuno.cxx:78
SfxHintId GetId() const
#define SC_UNO_SHOWOBJ
Definition: unonames.hxx:551
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
Definition: markdata.cxx:333
ScSplitPos
Definition: viewdata.hxx:44
SfxApplication * SfxGetpApp()
ScViewPaneObj(ScTabViewShell *pViewSh, sal_uInt16 nP)
Definition: viewuno.cxx:404
css::uno::Reference< css::drawing::XShapes > getSelectedXShapes()
Definition: viewuno.cxx:820
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: viewuno.cxx:1821
SCTAB nPreviousTab
Definition: viewuno.hxx:157
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:2154
constexpr tools::Long Width() const
#define SC_VIEWPANE_ACTIVE
Definition: viewuno.hxx:51
ScDrawView * GetDrawView()
Definition: drawsh5.cxx:681
constexpr OUStringLiteral SCVIEWSETTINGS_SERVICE
Definition: viewuno.cxx:116
virtual ~ScViewPaneObj() override
Definition: viewuno.cxx:409
void UpdateFixPos()
Definition: tabview.cxx:759
Reference< XController > xController
void PaintLeft()
Definition: tabview3.cxx:2706
tools::Long GetVSplitPos() const
Definition: viewdata.hxx:418
virtual void SAL_CALL addActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1336
#define SC_UNO_SHOWGRID
Definition: unonames.hxx:548
void InvalidateBorder()
constexpr OUStringLiteral SCTABVIEWOBJ_SERVICE
Definition: viewuno.cxx:115
SfxShell * GetShell(sal_uInt16 nIdx) const
SdrPage * getSdrPageFromSdrObject() const
void SetObjMode(ScVObjType eObj, ScVObjMode eMode)
Definition: viewopti.hxx:90
ScPreviewObj(ScPreviewShell *pViewSh)
Definition: viewuno.cxx:2140
void SetZoom(sal_Int16 Zoom)
Definition: viewuno.cxx:1368
virtual void SAL_CALL insertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &xTrans) override
Definition: viewuno.cxx:2076
void RangeSelChanged(const OUString &rText)
Definition: viewuno.cxx:2019
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2684
std::vector< css::uno::Reference< css::view::XSelectionChangeListener > > aSelectionChgListeners
Definition: viewuno.hxx:146
bool IsMultiMarked() const
Definition: markdata.hxx:82
SCTAB GetSelectCount() const
Definition: markdata.cxx:194
virtual void SAL_CALL release() noexcept override
Definition: viewuno.cxx:2165
void MarkDataChanged()
Definition: tabview3.cxx:1746
int nCount
virtual sal_Bool SAL_CALL isFormDesignMode() override
Definition: viewuno.cxx:325
virtual sal_Int32 SAL_CALL getSplitRow() override
Definition: viewuno.cxx:1562
bool MouseReleased(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1221
virtual css::uno::Reference< css::drawing::XShape > getUnoShape()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3940
SdrObject * SdrObjectPrimitiveHit(const SdrObject &rObject, const Point &rPnt, sal_uInt16 nTol, const SdrPageView &rSdrPageView, const SdrLayerIDSet *pVisiLayer, bool bTextOnly, drawinglayer::primitive2d::Primitive2DContainer *pHitContainer)
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:191
SCTAB Tab() const
Definition: address.hxx:270
virtual css::uno::Reference< css::awt::XControl > SAL_CALL getControl(const css::uno::Reference< css::awt::XControlModel > &xModel) override
Definition: viewuno.cxx:351
static sal_Int32 GetVbaSheetEventId(ScSheetEventId nEvent)
Definition: sheetevents.cxx:39
bool HasSheetEventScript(SCTAB nTab, ScSheetEventId nEvent, bool bWithVbaEvents=false) const
Definition: documen3.cxx:676
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:409
css::awt::Rectangle GetVisArea() const
Definition: viewuno.cxx:370
#define SC_UNO_SHOWPAGEBR
Definition: unonames.hxx:552
void UnmarkAll()
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1414
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:415
#define SC_UNO_VISAREA
Definition: unonames.hxx:571
const Fraction & GetZoomY() const
Definition: viewdata.hxx:459
void EndMouseListening()
Definition: viewuno.cxx:1279
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3137
ScViewData & GetViewData()
Definition: tabview.hxx:333
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:90
void PaintTop()
Definition: tabview3.cxx:2639
#define SC_QUERYINTERFACE(x)
Definition: miscuno.hxx:86
EditView & GetEditView() const
ScPreview * GetPreview()
Definition: prevwsh.hxx:115
void ScrollToObject(const SdrObject *pDrawObj)
Definition: tabview5.cxx:550
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: viewuno.cxx:2043
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2689
virtual void SAL_CALL addEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1313
#define OLD_UNO_VERTSCROLL
Definition: unonames.hxx:588
SdrObject * GetMarkedSdrObj() const
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:713
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:428
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1064
T * get() const
vcl::Window * GetWindowByPos(ScSplitPos ePos) const
Definition: tabview.hxx:371
virtual sal_Bool SAL_CALL hasElements() override
Definition: viewuno.cxx:973
#define SC_UNO_SHOWDRAW
Definition: unonames.hxx:546
virtual sal_Int32 SAL_CALL getCount() override
Definition: viewuno.cxx:940
#define SC_UNONAME_TITLE
Definition: unonames.hxx:642
void EndActivationListening()
Definition: viewuno.cxx:1296
DECL_LISTENERMULTIPLEXER_END void SAL_CALL mousePressed(const css::awt::MouseEvent &e) override
void StopSimpleRefDialog()
Definition: tabvwsh4.cxx:1162
bool IsMarked() const
Definition: markdata.hxx:81
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getReferredCells() override
Definition: viewuno.cxx:272
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: viewuno.cxx:1700
SfxDispatcher * GetDispatcher() const
static SfxApplication * Get()
int i
Point GetScrPos(SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich, bool bAllowNeg=false, SCTAB nForTab=-1) const
Definition: viewdata.cxx:2376
void ExtendRangeListTables(ScRangeList *pList) const
Definition: markdata.cxx:446
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:142
std::vector< css::uno::Reference< css::sheet::XRangeSelectionListener > > aRangeSelListeners
Definition: viewuno.hxx:148
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:60
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1899
bool bFilteredRangeSelection
Definition: viewuno.hxx:159
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: viewuno.cxx:932
void GetPosFromPixel(tools::Long nClickX, tools::Long nClickY, ScSplitPos eWhich, SCCOL &rPosX, SCROW &rPosY, bool bTestMerge=true, bool bRepair=false, SCTAB nForTab=-1)
Definition: viewdata.cxx:2757
sal_Int16 SCCOL
Definition: types.hxx:21
virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1621
virtual void SAL_CALL abortRangeSelection() override
Definition: viewuno.cxx:1953
#define SC_MOD()
Definition: scmod.hxx:250
SfxBindings & GetBindings()
tools::Long GetHSplitPos() const
Definition: viewdata.hxx:417
#define SC_UNO_GRIDCOLOR
Definition: unonames.hxx:539
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1967
const SdrMarkList & GetMarkedObjectList() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1798
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:726
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:465
void SetDrawShell(bool bActive)
Definition: tabvwsh4.cxx:611
size_t size() const
Definition: rangelst.hxx:89
virtual void SAL_CALL addRangeSelectionListener(const css::uno::Reference< css::sheet::XRangeSelectionListener > &aListener) override
Definition: viewuno.cxx:1961
sal_Int16 GetZoom() const
Definition: viewuno.cxx:1357
float u
unsigned char sal_Bool
virtual void SAL_CALL acquire() noexcept override
Definition: viewuno.cxx:488
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1179
const SfxItemPropertyMap & getPropertyMap() const
ErrCode CallXScript(const OUString &rScriptURL, const css::uno::Sequence< css::uno::Any > &aParams, css::uno::Any &aRet, css::uno::Sequence< sal_Int16 > &aOutParamIndex, css::uno::Sequence< css::uno::Any > &aOutParam, bool bRaiseError=true, const css::uno::Any *aCaller=nullptr)
#define SC_UNO_SHOWANCHOR
Definition: unonames.hxx:544
bool GetOption(ScViewOption eOpt) const
Definition: viewopti.hxx:88
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: viewuno.cxx:167
ScGridWindow * GetActiveWin()
Definition: viewdata.cxx:3125
const OutlinerView * GetTextEditOutlinerView() const
virtual sal_Int32 SAL_CALL getFirstVisibleColumn() override
Definition: viewuno.cxx:174
OUString aPropName
const ScMarkData::MarkedTabsType & GetSelectedTabs() const
Definition: preview.hxx:160
ScPreviewShell * mpViewShell
Definition: viewuno.hxx:290
css::uno::Type const & get()
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:63
void InvalidateSplit()
Definition: tabview.cxx:2111
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1996
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void InitOwnBlockMode()
Definition: tabview2.cxx:332
#define SC_UNO_SHOWZERO
Definition: unonames.hxx:553
Point PixelToLogic(const Point &rDevicePt) const
css::uno::Reference< css::datatransfer::XTransferable > GetTransferable() const
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: viewuno.cxx:594
virtual ~ScPreviewObj() override
Definition: viewuno.cxx:2148
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument &rDoc)
Definition: viewutil.cxx:223
sal_uInt16 CalcZoom(SvxZoomType eType, sal_uInt16 nOldZoom)
Definition: tabview2.cxx:1181
ScTabViewShell * GetViewShell() const
Definition: viewuno.hxx:74
#define SC_UNO_VISAREASCREEN
Definition: unonames.hxx:576
void RemoveSplit()
Definition: tabview.cxx:2067
static ScViewData * GetViewData()
Definition: docsh4.cxx:2579
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
virtual sal_Bool SAL_CALL getIsWindowSplit() override
Definition: viewuno.cxx:1479
Base class for all functions.
Definition: fupoor.hxx:39
void SetZoom(sal_uInt16 nNew)
Definition: appoptio.hxx:41
#define SC_UNO_ZOOMTYPE
Definition: unonames.hxx:572
virtual void SAL_CALL freezeAtPosition(sal_Int32 nColumns, sal_Int32 nRows) override
Definition: viewuno.cxx:1596
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1894
void RangeSelDone(const OUString &rText)
Definition: viewuno.cxx:1993
#define SC_UNO_HORSCROLL
Definition: unonames.hxx:541
SCCOL Col() const
Definition: address.hxx:266
virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL getActiveSheet() override
Definition: viewuno.cxx:1028
void InsertText(const OUString &rNew, bool bSelect=false, bool bLOKShowSelect=true)
ScDBFunc * GetView() const
Definition: viewdata.cxx:861
virtual SdrLayerID GetLayer() const
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2176
const OUString * GetScript(ScSheetEventId nEvent) const
Definition: sheetevents.cxx:99
rtl::Reference< ScTransferObj > CopyToTransferable()
Definition: viewfun3.cxx:431
SfxItemPropertySet aPropSet
Definition: viewuno.hxx:144
static css::uno::Reference< css::form::runtime::XFormController > GetFormController(const css::uno::Reference< css::form::XForm > &_rxForm, const SdrView &_rView, const OutputDevice &_rDevice)
ScHSplitPos
Definition: viewdata.hxx:45
SdrObject * Next()
void SetDesignMode(bool _bDesignMode)
sal_Int32 SCROW
Definition: types.hxx:17
void SelectionChanged()
Definition: viewuno.cxx:1637
virtual sal_Int32 SAL_CALL getSplitHorizontal() override
Definition: viewuno.cxx:1511
virtual css::uno::Any SAL_CALL getSelection() override
Definition: viewuno.cxx:849
#define SC_UNO_SHEETTABS
Definition: unonames.hxx:543
virtual css::table::CellRangeAddress SAL_CALL getVisibleRange() override
Definition: viewuno.cxx:240
virtual void SAL_CALL removeRangeSelectionChangeListener(const css::uno::Reference< css::sheet::XRangeSelectionChangeListener > &aListener) override
Definition: viewuno.cxx:1984
void StartSimpleRefDialog(const OUString &rTitle, const OUString &rInitVal, bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection)
Definition: tabvwsh4.cxx:1127
ScDrawView * GetScDrawView()
Definition: tabview.hxx:341
#define OLD_UNO_COLROWHDR
Definition: unonames.hxx:583
SdrPage * GetPage() const
#define SC_UNO_HIDESPELL
Definition: unonames.hxx:540
void PasteFromTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable)
Definition: viewfun3.cxx:621
virtual void SAL_CALL release() noexcept override
Definition: viewuno.cxx:493
::OutputDevice const * GetOutDev() const
#define SC_UNO_OUTLSYMB
Definition: unonames.hxx:542
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:663
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:321
virtual bool IsDesignMode() const override
really derive cell from range?
Definition: cellsuno.hxx:637
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
sal_uInt16 GetHitTolerancePixel() const
virtual sal_Int32 SAL_CALL getFirstVisibleRow() override
Definition: viewuno.cxx:207
SdrObject * GetSdrObject() const
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:544
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPrintable?
Definition: viewuno.cxx:1692
void * p
Reference< XComponentContext > getProcessComponentContext()
virtual void SAL_CALL removeActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1346
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
#define SC_UNO_SHOWNOTES
Definition: unonames.hxx:550
css::uno::Reference< css::uno::XInterface > GetClickedObject(const Point &rPoint) const
Definition: viewuno.cxx:1066
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2119
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:896
virtual sal_Int32 SAL_CALL getSplitVertical() override
Definition: viewuno.cxx:1524
virtual void SAL_CALL acquire() noexcept override
Definition: viewuno.cxx:423
#define SC_UNONAME_CLOSEONUP
Definition: unonames.hxx:643
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:916
void VisAreaChanged()
Definition: viewuno.cxx:1904
virtual sal_Bool SAL_CALL hasFrozenPanes() override
Definition: viewuno.cxx:1495
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:986
Color const & GetGridColor(OUString *pStrName=nullptr) const
Definition: viewopti.cxx:118
SdrPageView * GetSdrPageView() const
css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable()
Definition: drawvie4.cxx:374
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:423
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1202
#define OLD_UNO_OUTLSYMB
Definition: unonames.hxx:585
#define SC_UNO_FILTERED_RANGE_SELECTION
Definition: unonames.hxx:575
#define SC_QUERY_MULTIPLE(x, y)
Definition: miscuno.hxx:93
#define MINZOOM
Definition: global.hxx:78
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
virtual sal_Bool SAL_CALL select(const css::uno::Any &aSelection) override
Definition: viewuno.cxx:645
virtual void SAL_CALL setFormDesignMode(sal_Bool DesignMode) override
Definition: viewuno.cxx:338
#define SC_UNO_VERTSCROLL
Definition: unonames.hxx:555
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
SvxZoomType
void SetGridColor(const Color &rCol, const OUString &rName)
Definition: viewopti.hxx:93
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:138
void UpdateLayerLocks()
Definition: tabview5.cxx:356
bool IsPagebreakMode() const
Definition: viewdata.hxx:424
virtual void SAL_CALL setActiveSheet(const css::uno::Reference< css::sheet::XSpreadsheet > &xActiveSheet) override
Definition: viewuno.cxx:1042
ScSheetEventId
Definition: sheetevents.hxx:27
bool bDrawSelModeSet
Definition: viewuno.hxx:158
ScTabViewObj()=delete
#define SC_UNONAME_INITVAL
Definition: unonames.hxx:641
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:45
SdrModel * GetModel() const
void ExecuteStyle(SfxRequest &rReq)
Definition: formatsh.cxx:251
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: viewuno.cxx:1885
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: viewuno.cxx:572
virtual void SAL_CALL removeSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1628
static void lcl_ShowObject(ScTabViewShell &rViewSh, const ScDrawView &rDrawView, const SdrObject *pSelObj)
Definition: viewuno.cxx:612
ScVObjMode GetObjMode(ScVObjType eObj) const
Definition: viewopti.hxx:91
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: viewuno.cxx:1878
void SetZoomType(sal_Int16 ZoomType)
Definition: viewuno.cxx:1425
void SplitAtPixel(const Point &rPixel)
Definition: tabview.cxx:2096
AnyEventRef aEvent
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:416
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
#define OLD_UNO_VALUEHIGH
Definition: unonames.hxx:587
sal_uInt16 GetPageCount() const
virtual css::uno::Type SAL_CALL getElementType() override
Definition: viewuno.cxx:967
sal_Int16 SCTAB
Definition: types.hxx:22
virtual ~ScViewPaneBase() override
Definition: viewuno.cxx:128
void SetDrawSelMode(bool bNew)
Definition: tabview.hxx:317
virtual ~ScTabViewObj() override
Definition: viewuno.cxx:450