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  {u"" 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( 1 );
526  aArgs[ 0 ] <<= nTab;
527  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
528  }
529  catch( uno::Exception& )
530  {
531  }
532 }
533 
534 void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
535 {
536  if ( !GetViewShell() )
537  return;
538 
539  ScViewData& rViewData = GetViewShell()->GetViewData();
540  ScDocShell* pDocSh = rViewData.GetDocShell();
541  if (!aActivationListeners.empty())
542  {
543  sheet::ActivationEvent aEvent;
544  uno::Reference< sheet::XSpreadsheetView > xView(this);
545  uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
546  aEvent.Source = xSource;
547  aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, rViewData.GetTabNo());
548  for (auto it = aActivationListeners.begin(); it != aActivationListeners.end(); )
549  {
550  try
551  {
552  (*it)->activeSpreadsheetChanged( aEvent );
553  ++it;
554  }
555  catch( uno::Exception& )
556  {
557  it = aActivationListeners.erase( it);
558  }
559  }
560  }
561 
562  /* Handle sheet events, but do not trigger event handlers, if the old
563  active sheet gets re-activated after inserting/deleting/moving a sheet. */
564  SCTAB nNewTab = rViewData.GetTabNo();
565  if ( !bSameTabButMoved && (nNewTab != nPreviousTab) )
566  {
568  lcl_CallActivate( pDocSh, nNewTab, ScSheetEventId::FOCUS );
569  }
570  nPreviousTab = nNewTab;
571 }
572 
573 uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes()
574 {
577  SfxBaseController::getTypes(),
578  uno::Sequence<uno::Type>
579  {
592  } );
593 }
594 
595 uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
596 {
597  return css::uno::Sequence<sal_Int8>();
598 }
599 
600 // XDocumentView
601 
602 static bool lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
603 {
604  for (size_t i = 0, nCount = rRanges.size(); i < nCount; ++i)
605  {
606  const ScRange & rRange = rRanges[ i ];
607  if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
608  return true;
609  }
610  return false;
611 }
612 
613 static void lcl_ShowObject( ScTabViewShell& rViewSh, const ScDrawView& rDrawView, const SdrObject* pSelObj )
614 {
615  bool bFound = false;
616  SCTAB nObjectTab = 0;
617 
618  SdrModel* pModel = rDrawView.GetModel();
619  sal_uInt16 nPageCount = pModel->GetPageCount();
620  for (sal_uInt16 i=0; i<nPageCount && !bFound; i++)
621  {
622  SdrPage* pPage = pModel->GetPage(i);
623  if (pPage)
624  {
625  SdrObjListIter aIter( pPage, SdrIterMode::DeepWithGroups );
626  SdrObject* pObject = aIter.Next();
627  while (pObject && !bFound)
628  {
629  if ( pObject == pSelObj )
630  {
631  bFound = true;
632  nObjectTab = static_cast<SCTAB>(i);
633  }
634  pObject = aIter.Next();
635  }
636  }
637  }
638 
639  if (bFound)
640  {
641  rViewSh.SetTabNo( nObjectTab );
642  rViewSh.ScrollToObject( pSelObj );
643  }
644 }
645 
646 sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
647 {
648  SolarMutexGuard aGuard;
649  ScTabViewShell* pViewSh = GetViewShell();
650 
651  if ( !pViewSh )
652  return false;
653 
655 
656  bool bRet = false;
657  uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
658  if ( !xInterface.is() ) //clear all selections
659  {
660  ScDrawView* pDrawView = pViewSh->GetScDrawView();
661  if (pDrawView)
662  {
663  pDrawView->ScEndTextEdit();
664  pDrawView->UnmarkAll();
665  }
666  else //#102232#; if there is no DrawView remove range selection
667  pViewSh->Unmark();
668  bRet = true;
669  }
670 
671  if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
672  {
673  pViewSh->SetDrawSelMode(false);
674  pViewSh->UpdateLayerLocks();
675  bDrawSelModeSet = false;
676  }
677 
678  if (bRet)
679  return bRet;
680 
681  ScCellRangesBase* pRangesImp = comphelper::getFromUnoTunnel<ScCellRangesBase>( xInterface );
682  uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
683  uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
684  SvxShape* pShapeImp = comphelper::getFromUnoTunnel<SvxShape>( xShapeSel );
685 
686  if (pRangesImp) // Cell ranges
687  {
688  ScViewData& rViewData = pViewSh->GetViewData();
689  if ( rViewData.GetDocShell() == pRangesImp->GetDocShell() )
690  {
691  // perhaps remove drawing selection first
692  // (MarkListHasChanged removes sheet selection)
693 
694  ScDrawView* pDrawView = pViewSh->GetScDrawView();
695  if (pDrawView)
696  {
697  pDrawView->ScEndTextEdit();
698  pDrawView->UnmarkAll();
699  }
700  FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
701  if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
702  {
703  // execute the slot of drawing function again -> switch off
704  SfxDispatcher* pDisp = pViewSh->GetDispatcher();
705  if (pDisp)
706  pDisp->Execute( pFunc->GetSlotID(), SfxCallMode::SYNCHRON );
707  }
708  pViewSh->SetDrawShell(false);
709  pViewSh->SetDrawSelMode(false); // after Dispatcher-Execute
710 
711  // select ranges
712 
713  const ScRangeList& rRanges = pRangesImp->GetRangeList();
714  size_t nRangeCount = rRanges.size();
715  // for empty range list, remove selection (cursor remains where it was)
716  if ( nRangeCount == 0 )
717  pViewSh->Unmark();
718  else if ( nRangeCount == 1 )
719  pViewSh->MarkRange( rRanges[ 0 ] );
720  else
721  {
722  // multiselection
723 
724  const ScRange & rFirst = rRanges[ 0 ];
725  if ( !lcl_TabInRanges( rViewData.GetTabNo(), rRanges ) )
726  pViewSh->SetTabNo( rFirst.aStart.Tab() );
727  pViewSh->DoneBlockMode();
728  pViewSh->InitOwnBlockMode();
729  rViewData.GetMarkData().MarkFromRangeList( rRanges, true );
730  pViewSh->MarkDataChanged();
731  rViewData.GetDocShell()->PostPaintGridAll(); // Marks (old&new)
732  pViewSh->AlignToCursor( rFirst.aStart.Col(), rFirst.aStart.Row(),
733  SC_FOLLOW_JUMP );
734  pViewSh->SetCursor( rFirst.aStart.Col(), rFirst.aStart.Row() );
735 
737  }
738  bRet = true;
739  }
740  }
741  else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer
742  {
743  ScDrawView* pDrawView = pViewSh->GetScDrawView();
744  if (pDrawView)
745  {
746  pDrawView->ScEndTextEdit();
747  pDrawView->UnmarkAll();
748 
749  if (pShapeImp) // single shape
750  {
751  SdrObject *pObj = pShapeImp->GetSdrObject();
752  if (pObj)
753  {
754  lcl_ShowObject( *pViewSh, *pDrawView, pObj );
755  SdrPageView* pPV = pDrawView->GetSdrPageView();
756  if ( pPV && pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
757  {
758  pDrawView->MarkObj( pObj, pPV );
759  bRet = true;
760  }
761  }
762  }
763  else // Shape-Collection (xShapeColl is not 0)
764  {
765  // We'll switch to the sheet where the first object is
766  // and select all objects on that sheet
768 
769  tools::Long nCount = xShapeColl->getCount();
770  if (nCount)
771  {
772  SdrPageView* pPV = nullptr;
773  bool bAllMarked(true);
774  for ( tools::Long i = 0; i < nCount; i++ )
775  {
776  uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
777  if (xShapeInt.is())
778  {
779  SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShapeInt );
780  if (pObj)
781  {
782  if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
783  {
784  pViewSh->SetDrawSelMode(true);
785  pViewSh->UpdateLayerLocks();
786  bDrawSelModeSet = true;
787  }
788  if (!pPV) // first object
789  {
790  lcl_ShowObject( *pViewSh, *pDrawView, pObj );
791  pPV = pDrawView->GetSdrPageView();
792  }
793  if ( pPV && pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
794  {
795  if (pDrawView->IsObjMarkable( pObj, pPV ))
796  pDrawView->MarkObj( pObj, pPV );
797  else
798  bAllMarked = false;
799  }
800  }
801  }
802  }
803  if (bAllMarked)
804  bRet = true;
805  }
806  else
807  bRet = true; // empty XShapes (all shapes are deselected)
808  }
809 
810  if (bRet)
811  pViewSh->SetDrawShell(true);
812  }
813  }
814 
815  if (!bRet)
816  throw lang::IllegalArgumentException();
817 
818  return bRet;
819 }
820 
821 uno::Reference<drawing::XShapes> ScTabViewShell::getSelectedXShapes()
822 {
823  uno::Reference<drawing::XShapes> xShapes;
824  SdrView* pSdrView = GetScDrawView();
825  if (pSdrView)
826  {
827  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
828  const size_t nMarkCount = rMarkList.GetMarkCount();
829  if (nMarkCount)
830  {
831  // generate ShapeCollection (like in SdXImpressView::getSelection in Draw)
832  // XInterfaceRef will be returned and it has to be UsrObject-XInterface
833  xShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext());
834 
835  for (size_t i = 0; i < nMarkCount; ++i)
836  {
837  SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
838  if (pDrawObj)
839  {
840  uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
841  if (xShape.is())
842  xShapes->add(xShape);
843  }
844  }
845  }
846  }
847  return xShapes;
848 }
849 
851 {
852  SolarMutexGuard aGuard;
853  ScTabViewShell* pViewSh = GetViewShell();
855  if (pViewSh)
856  {
857  // is something selected in drawing layer?
858  uno::Reference<uno::XInterface> xRet(pViewSh->getSelectedXShapes());
859  if (xRet.is())
860  return uno::makeAny(xRet);
861 
862  // otherwise sheet (cell) selection
863 
864  ScViewData& rViewData = pViewSh->GetViewData();
865  ScDocShell* pDocSh = rViewData.GetDocShell();
866 
867  const ScMarkData& rMark = rViewData.GetMarkData();
868  SCTAB nTabs = rMark.GetSelectCount();
869 
870  ScRange aRange;
871  ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
872  if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
873  {
874  if (aRange.aStart == aRange.aEnd)
875  pObj = new ScCellObj( pDocSh, aRange.aStart );
876  else
877  pObj = new ScCellRangeObj( pDocSh, aRange );
878  }
879  else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
880  {
881  ScMarkData aFilteredMark( rMark );
882  ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
883  ScRangeList aRangeList;
884  aFilteredMark.FillRangeListWithMarks( &aRangeList, false);
885  // Theoretically a selection may start and end on a filtered row.
886  switch ( aRangeList.size() )
887  {
888  case 0:
889  // No unfiltered row, we have to return some object, so
890  // here is one with no ranges.
891  pObj = new ScCellRangesObj( pDocSh, aRangeList );
892  break;
893  case 1:
894  {
895  const ScRange& rRange = aRangeList[ 0 ];
896  if (rRange.aStart == rRange.aEnd)
897  pObj = new ScCellObj( pDocSh, rRange.aStart );
898  else
899  pObj = new ScCellRangeObj( pDocSh, rRange );
900  }
901  break;
902  default:
903  pObj = new ScCellRangesObj( pDocSh, aRangeList );
904  }
905  }
906  else // multiselection
907  {
908  ScRangeListRef xRanges;
909  rViewData.GetMultiArea( xRanges );
910 
911  // if there are more sheets, copy ranges
913  if ( nTabs > 1 )
914  rMark.ExtendRangeListTables( xRanges.get() );
915 
916  pObj = new ScCellRangesObj( pDocSh, *xRanges );
917  }
918 
919  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
920  {
921  // remember if the selection was from the cursor position without anything selected
922  // (used when rendering the selection)
923 
924  pObj->SetCursorOnly( true );
925  }
926  }
927 
928  return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj.get())));
929 }
930 
931 // XEnumerationAccess
932 
933 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
934 {
935  SolarMutexGuard aGuard;
936  return new ScIndexEnumeration(this, "com.sun.star.sheet.SpreadsheetViewPanesEnumeration");
937 }
938 
939 // XIndexAccess
940 
941 sal_Int32 SAL_CALL ScTabViewObj::getCount()
942 {
943  SolarMutexGuard aGuard;
944  ScTabViewShell* pViewSh = GetViewShell();
945  sal_uInt16 nPanes = 0;
946  if (pViewSh)
947  {
948  nPanes = 1;
949  ScViewData& rViewData = pViewSh->GetViewData();
950  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
951  nPanes *= 2;
952  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
953  nPanes *= 2;
954  }
955  return nPanes;
956 }
957 
958 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
959 {
960  SolarMutexGuard aGuard;
961  uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)));
962  if (!xPane.is())
963  throw lang::IndexOutOfBoundsException();
964 
965  return uno::makeAny(xPane);
966 }
967 
969 {
970  SolarMutexGuard aGuard;
972 }
973 
975 {
976  SolarMutexGuard aGuard;
977  return ( getCount() != 0 );
978 }
979 
980 // XSpreadsheetView
981 
983 {
984  static const ScSplitPos ePosHV[4] =
986 
987  ScTabViewShell* pViewSh = GetViewShell();
988  if (pViewSh)
989  {
990  ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default position
991  bool bError = false;
992  ScViewData& rViewData = pViewSh->GetViewData();
993  bool bHor = ( rViewData.GetHSplitMode() != SC_SPLIT_NONE );
994  bool bVer = ( rViewData.GetVSplitMode() != SC_SPLIT_NONE );
995  if ( bHor && bVer )
996  {
997  // bottom left, bottom right, top left, top right - like in Excel
998  if ( nIndex < 4 )
999  eWhich = ePosHV[nIndex];
1000  else
1001  bError = true;
1002  }
1003  else if ( bHor )
1004  {
1005  if ( nIndex > 1 )
1006  bError = true;
1007  else if ( nIndex == 1 )
1008  eWhich = SC_SPLIT_BOTTOMRIGHT;
1009  // otherwise SC_SPLIT_BOTTOMLEFT
1010  }
1011  else if ( bVer )
1012  {
1013  if ( nIndex > 1 )
1014  bError = true;
1015  else if ( nIndex == 0 )
1016  eWhich = SC_SPLIT_TOPLEFT;
1017  // otherwise SC_SPLIT_BOTTOMLEFT
1018  }
1019  else if ( nIndex > 0 )
1020  bError = true; // not split: only 0 is valid
1021 
1022  if (!bError)
1023  return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) );
1024  }
1025 
1026  return nullptr;
1027 }
1028 
1029 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1030 {
1031  SolarMutexGuard aGuard;
1032  ScTabViewShell* pViewSh = GetViewShell();
1033  if (pViewSh)
1034  {
1035  ScViewData& rViewData = pViewSh->GetViewData();
1036  SCTAB nTab = rViewData.GetTabNo();
1037  return new ScTableSheetObj( rViewData.GetDocShell(), nTab );
1038  }
1039  return nullptr;
1040 }
1041 
1042 // support expand (but not replace) the active sheet
1043 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1044 {
1045  SolarMutexGuard aGuard;
1046  comphelper::ProfileZone aZone("setActiveSheet");
1047 
1048  ScTabViewShell* pViewSh = GetViewShell();
1049  if ( !(pViewSh && xActiveSheet.is()) )
1050  return;
1051 
1052  // XSpreadsheet and ScCellRangesBase -> has to be the same sheet
1053 
1054  ScCellRangesBase* pRangesImp = comphelper::getFromUnoTunnel<ScCellRangesBase>( xActiveSheet );
1055  if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == pRangesImp->GetDocShell() )
1056  {
1057  const ScRangeList& rRanges = pRangesImp->GetRangeList();
1058  if ( rRanges.size() == 1 )
1059  {
1060  SCTAB nNewTab = rRanges[ 0 ].aStart.Tab();
1061  if ( pViewSh->GetViewData().GetDocument().HasTable(nNewTab) )
1062  pViewSh->SetTabNo( nNewTab );
1063  }
1064  }
1065 }
1066 
1067 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1068 {
1069  uno::Reference< uno::XInterface > xTarget;
1070  if (GetViewShell())
1071  {
1072  SCCOL nX;
1073  SCROW nY;
1075  ScSplitPos eSplitMode = rData.GetActivePart();
1076  SCTAB nTab(rData.GetTabNo());
1077  rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1078 
1079  ScAddress aCellPos (nX, nY, nTab);
1080  rtl::Reference<ScCellObj> pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos);
1081 
1082  xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1083 
1084  ScDocument& rDoc = rData.GetDocument();
1085  if (ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer())
1086  {
1087  SdrPage* pDrawPage = nullptr;
1088  if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1089  pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1090 
1091  SdrView* pDrawView = GetViewShell()->GetScDrawView();
1092 
1093  if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1094  {
1095  vcl::Window* pActiveWin = rData.GetActiveWin();
1096  Point aPos = pActiveWin->PixelToLogic(rPoint);
1097 
1098  sal_uInt16 nHitLog = static_cast<sal_uInt16>(pActiveWin->PixelToLogic(
1099  Size(pDrawView->GetHitTolerancePixel(),0)).Width());
1100 
1101  const size_t nCount(pDrawPage->GetObjCount());
1102  bool bFound(false);
1103  for (size_t i = 0; i < nCount && !bFound; ++i)
1104  {
1105  SdrObject* pObj = pDrawPage->GetObj(i);
1106  if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), nullptr, false))
1107  {
1108  xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1109  bFound = true;
1110  }
1111  }
1112  }
1113  }
1114  }
1115  return xTarget;
1116 }
1117 
1119 {
1120  if ( !aMouseClickHandlers.empty() )
1121  return true;
1122 
1123  // also include sheet events, because MousePressed must be called for them
1124  ScViewData& rViewData = GetViewShell()->GetViewData();
1125  ScDocument& rDoc = rViewData.GetDocument();
1126  SCTAB nTab = rViewData.GetTabNo();
1127  return
1128  rDoc.HasSheetEventScript( nTab, ScSheetEventId::RIGHTCLICK, true ) ||
1129  rDoc.HasSheetEventScript( nTab, ScSheetEventId::DOUBLECLICK, true ) ||
1130  rDoc.HasSheetEventScript( nTab, ScSheetEventId::SELECT, true );
1131 
1132 }
1133 
1134 bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1135 {
1136  bool bReturn(false);
1137  if ( e.Buttons == css::awt::MouseButton::LEFT )
1138  mbLeftMousePressed = true;
1139 
1140  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1141  if (!aMouseClickHandlers.empty() && xTarget.is())
1142  {
1143  awt::EnhancedMouseEvent aMouseEvent;
1144 
1145  aMouseEvent.Buttons = e.Buttons;
1146  aMouseEvent.X = e.X;
1147  aMouseEvent.Y = e.Y;
1148  aMouseEvent.ClickCount = e.ClickCount;
1149  aMouseEvent.PopupTrigger = e.PopupTrigger;
1150  aMouseEvent.Target = xTarget;
1151  aMouseEvent.Modifiers = e.Modifiers;
1152 
1153  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1154  {
1155  try
1156  {
1157  if (!(*it)->mousePressed( aMouseEvent ))
1158  bReturn = true;
1159  ++it;
1160  }
1161  catch ( uno::Exception& )
1162  {
1163  it = aMouseClickHandlers.erase(it);
1164  }
1165  }
1166  }
1167 
1168  // handle sheet events
1169  bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1170  bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1171  if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1172  {
1174 
1175  ScTabViewShell* pViewSh = GetViewShell();
1176  ScViewData& rViewData = pViewSh->GetViewData();
1177  ScDocShell* pDocSh = rViewData.GetDocShell();
1178  ScDocument& rDoc = pDocSh->GetDocument();
1179  SCTAB nTab = rViewData.GetTabNo();
1180  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1181  if (pEvents)
1182  {
1183  const OUString* pScript = pEvents->GetScript(nEvent);
1184  if (pScript)
1185  {
1186  // the macro parameter is the clicked object, as in the mousePressed call above
1187  uno::Sequence<uno::Any> aParams(1);
1188  aParams[0] <<= xTarget;
1189 
1190  uno::Any aRet;
1191  uno::Sequence<sal_Int16> aOutArgsIndex;
1192  uno::Sequence<uno::Any> aOutArgs;
1193 
1194  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1195 
1196  // look for a boolean return value of true
1197  bool bRetValue = false;
1198  if ((aRet >>= bRetValue) && bRetValue)
1199  bReturn = true;
1200  }
1201  }
1202 
1203  // execute VBA event handler
1204  if (!bReturn && xTarget.is()) try
1205  {
1206  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1207  // the parameter is the clicked object, as in the mousePressed call above
1208  uno::Sequence< uno::Any > aArgs( 1 );
1209  aArgs[ 0 ] <<= xTarget;
1210  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1211  }
1212  catch( util::VetoException& )
1213  {
1214  bReturn = true;
1215  }
1216  catch( uno::Exception& )
1217  {
1218  }
1219  }
1220 
1221  return bReturn;
1222 }
1223 
1224 bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1225 {
1226  if ( e.Buttons == css::awt::MouseButton::LEFT )
1227  {
1228  try
1229  {
1230  ScTabViewShell* pViewSh = GetViewShell();
1231  ScViewData& rViewData = pViewSh->GetViewData();
1232  ScDocShell* pDocSh = rViewData.GetDocShell();
1233  ScDocument& rDoc = pDocSh->GetDocument();
1234  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1235  uno::Sequence< uno::Any > aArgs( 1 );
1236  aArgs[ 0 ] = getSelection();
1237  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1238  }
1239  catch( uno::Exception& )
1240  {
1241  }
1242  mbLeftMousePressed = false;
1243  }
1244 
1245  bool bReturn(false);
1246 
1247  if (!aMouseClickHandlers.empty())
1248  {
1249  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1250 
1251  if (xTarget.is())
1252  {
1253  awt::EnhancedMouseEvent aMouseEvent;
1254 
1255  aMouseEvent.Buttons = e.Buttons;
1256  aMouseEvent.X = e.X;
1257  aMouseEvent.Y = e.Y;
1258  aMouseEvent.ClickCount = e.ClickCount;
1259  aMouseEvent.PopupTrigger = e.PopupTrigger;
1260  aMouseEvent.Target = xTarget;
1261  aMouseEvent.Modifiers = e.Modifiers;
1262 
1263  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1264  {
1265  try
1266  {
1267  if (!(*it)->mouseReleased( aMouseEvent ))
1268  bReturn = true;
1269  ++it;
1270  }
1271  catch ( uno::Exception& )
1272  {
1273  it = aMouseClickHandlers.erase(it);
1274  }
1275  }
1276  }
1277  }
1278  return bReturn;
1279 }
1280 
1281 // XEnhancedMouseClickBroadcaster
1282 
1284 {
1285  lang::EventObject aEvent;
1286  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1287  for (const auto& rListener : aMouseClickHandlers)
1288  {
1289  try
1290  {
1291  rListener->disposing(aEvent);
1292  }
1293  catch ( uno::Exception& )
1294  {
1295  }
1296  }
1297  aMouseClickHandlers.clear();
1298 }
1299 
1301 {
1302  lang::EventObject aEvent;
1303  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1304  for (const auto& rListener : aActivationListeners)
1305  {
1306  try
1307  {
1308  rListener->disposing(aEvent);
1309  }
1310  catch ( uno::Exception& )
1311  {
1312  }
1313  }
1314  aActivationListeners.clear();
1315 }
1316 
1317 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1318 {
1319  SolarMutexGuard aGuard;
1320 
1321  if (aListener.is())
1322  {
1323  aMouseClickHandlers.push_back( aListener );
1324  }
1325 }
1326 
1327 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1328 {
1329  SolarMutexGuard aGuard;
1330  sal_uInt16 nCount = aMouseClickHandlers.size();
1331  aMouseClickHandlers.erase(
1332  std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
1333  aMouseClickHandlers.end());
1334  if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
1336 }
1337 
1338 // XActivationBroadcaster
1339 
1340 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1341 {
1342  SolarMutexGuard aGuard;
1343 
1344  if (aListener.is())
1345  {
1346  aActivationListeners.push_back( aListener );
1347  }
1348 }
1349 
1350 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1351 {
1352  SolarMutexGuard aGuard;
1353  sal_uInt16 nCount = aActivationListeners.size();
1354  aActivationListeners.erase(
1355  std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
1356  aActivationListeners.end());
1357  if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
1359 }
1360 
1361 sal_Int16 ScTabViewObj::GetZoom() const
1362 {
1363  ScTabViewShell* pViewSh = GetViewShell();
1364  if (pViewSh)
1365  {
1366  const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y will be shown
1367  return static_cast<sal_Int16>(tools::Long( rZoomY * 100 ));
1368  }
1369  return 0;
1370 }
1371 
1372 void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1373 {
1374  ScTabViewShell* pViewSh = GetViewShell();
1375  if (!pViewSh)
1376  return;
1377 
1378  if ( nZoom != GetZoom() && nZoom != 0 )
1379  {
1380  if (!pViewSh->GetViewData().IsPagebreakMode())
1381  {
1382  ScModule* pScMod = SC_MOD();
1383  ScAppOptions aNewOpt(pScMod->GetAppOptions());
1384  aNewOpt.SetZoom( nZoom );
1385  aNewOpt.SetZoomType( pViewSh->GetViewData().GetView()->GetZoomType() );
1386  pScMod->SetAppOptions( aNewOpt );
1387  }
1388  }
1389  Fraction aFract( nZoom, 100 );
1390  pViewSh->SetZoom( aFract, aFract, true );
1391  pViewSh->PaintGrid();
1392  pViewSh->PaintTop();
1393  pViewSh->PaintLeft();
1394  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1395  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1396  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_IN);
1397  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_OUT);
1398 }
1399 
1400 sal_Int16 ScTabViewObj::GetZoomType() const
1401 {
1402  sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1403  ScTabViewShell* pViewSh = GetViewShell();
1404  if (pViewSh)
1405  {
1406  SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1407  switch (eZoomType)
1408  {
1409  case SvxZoomType::PERCENT:
1410  aZoomType = view::DocumentZoomType::BY_VALUE;
1411  break;
1412  case SvxZoomType::OPTIMAL:
1413  aZoomType = view::DocumentZoomType::OPTIMAL;
1414  break;
1415  case SvxZoomType::WHOLEPAGE:
1416  aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1417  break;
1418  case SvxZoomType::PAGEWIDTH:
1419  aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1420  break;
1421  case SvxZoomType::PAGEWIDTH_NOBORDER:
1422  aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1423  break;
1424  }
1425  }
1426  return aZoomType;
1427 }
1428 
1429 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1430 {
1431  ScTabViewShell* pViewSh = GetViewShell();
1432  if (!pViewSh)
1433  return;
1434 
1435  ScDBFunc* pView = pViewSh->GetViewData().GetView();
1436  if (!pView)
1437  return;
1438 
1439  SvxZoomType eZoomType;
1440  switch (aZoomType)
1441  {
1442  case view::DocumentZoomType::BY_VALUE:
1443  eZoomType = SvxZoomType::PERCENT;
1444  break;
1445  case view::DocumentZoomType::OPTIMAL:
1446  eZoomType = SvxZoomType::OPTIMAL;
1447  break;
1448  case view::DocumentZoomType::ENTIRE_PAGE:
1449  eZoomType = SvxZoomType::WHOLEPAGE;
1450  break;
1451  case view::DocumentZoomType::PAGE_WIDTH:
1452  eZoomType = SvxZoomType::PAGEWIDTH;
1453  break;
1454  case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1455  eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1456  break;
1457  default:
1458  eZoomType = SvxZoomType::OPTIMAL;
1459  }
1460  sal_Int16 nZoom(GetZoom());
1461  sal_Int16 nOldZoom(nZoom);
1462  if ( eZoomType == SvxZoomType::PERCENT )
1463  {
1464  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1465  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1466  }
1467  else
1468  nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1469 
1470  switch ( eZoomType )
1471  {
1472  case SvxZoomType::WHOLEPAGE:
1473  case SvxZoomType::PAGEWIDTH:
1474  pView->SetZoomType( eZoomType, true );
1475  break;
1476 
1477  default:
1478  pView->SetZoomType( SvxZoomType::PERCENT, true );
1479  }
1480  SetZoom( nZoom );
1481 }
1482 
1484 {
1485  SolarMutexGuard aGuard;
1486  // what menu slot SID_WINDOW_SPLIT does
1487 
1488  ScTabViewShell* pViewSh = GetViewShell();
1489  if (pViewSh)
1490  {
1491  ScViewData& rViewData = pViewSh->GetViewData();
1492  return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1493  rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1494  }
1495 
1496  return false;
1497 }
1498 
1500 {
1501  SolarMutexGuard aGuard;
1502  // what menu slot SID_WINDOW_FIX does
1503 
1504  ScTabViewShell* pViewSh = GetViewShell();
1505  if (pViewSh)
1506  {
1507  ScViewData& rViewData = pViewSh->GetViewData();
1508  return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1509  rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1510  }
1511 
1512  return false;
1513 }
1514 
1516 {
1517  SolarMutexGuard aGuard;
1518  ScTabViewShell* pViewSh = GetViewShell();
1519  if (pViewSh)
1520  {
1521  ScViewData& rViewData = pViewSh->GetViewData();
1522  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1523  return rViewData.GetHSplitPos();
1524  }
1525  return 0;
1526 }
1527 
1529 {
1530  SolarMutexGuard aGuard;
1531  ScTabViewShell* pViewSh = GetViewShell();
1532  if (pViewSh)
1533  {
1534  ScViewData& rViewData = pViewSh->GetViewData();
1535  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1536  return rViewData.GetVSplitPos();
1537  }
1538  return 0;
1539 }
1540 
1541 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1542 {
1543  SolarMutexGuard aGuard;
1544  ScTabViewShell* pViewSh = GetViewShell();
1545  if (pViewSh)
1546  {
1547  ScViewData& rViewData = pViewSh->GetViewData();
1548  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1549  {
1550  tools::Long nSplit = rViewData.GetHSplitPos();
1551 
1553  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1554  ePos = SC_SPLIT_TOPLEFT;
1555 
1556  SCCOL nCol;
1557  SCROW nRow;
1558  rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1559  if ( nCol > 0 )
1560  return nCol;
1561  }
1562  }
1563  return 0;
1564 }
1565 
1566 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow()
1567 {
1568  SolarMutexGuard aGuard;
1569  ScTabViewShell* pViewSh = GetViewShell();
1570  if (pViewSh)
1571  {
1572  ScViewData& rViewData = pViewSh->GetViewData();
1573  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1574  {
1575  tools::Long nSplit = rViewData.GetVSplitPos();
1576 
1577  // split vertically
1578  SCCOL nCol;
1579  SCROW nRow;
1580  rViewData.GetPosFromPixel( 0, nSplit, SC_SPLIT_TOPLEFT, nCol, nRow, false );
1581  if ( nRow > 0 )
1582  return nRow;
1583  }
1584  }
1585  return 0;
1586 }
1587 
1588 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1589 {
1590  SolarMutexGuard aGuard;
1591  ScTabViewShell* pViewSh = GetViewShell();
1592  if (pViewSh)
1593  {
1594  pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ) );
1595  pViewSh->FreezeSplitters( false );
1596  pViewSh->InvalidateSplit();
1597  }
1598 }
1599 
1600 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1601 {
1602  SolarMutexGuard aGuard;
1603  ScTabViewShell* pViewSh = GetViewShell();
1604  if (!pViewSh)
1605  return;
1606 
1607  // first, remove them all -> no stress with scrolling in the meantime
1608 
1609  pViewSh->RemoveSplit();
1610 
1611  Point aWinStart;
1612  vcl::Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1613  if (pWin)
1614  aWinStart = pWin->GetPosPixel();
1615 
1616  ScViewData& rViewData = pViewSh->GetViewData();
1617  Point aSplit(rViewData.GetScrPos( static_cast<SCCOL>(nColumns), static_cast<SCROW>(nRows), SC_SPLIT_BOTTOMLEFT, true ));
1618  aSplit += aWinStart;
1619 
1620  pViewSh->SplitAtPixel( aSplit );
1621  pViewSh->FreezeSplitters( true );
1622  pViewSh->InvalidateSplit();
1623 }
1624 
1626  const uno::Reference<view::XSelectionChangeListener>& xListener )
1627 {
1628  SolarMutexGuard aGuard;
1629  aSelectionChgListeners.push_back( xListener );
1630 }
1631 
1633  const uno::Reference< view::XSelectionChangeListener >& xListener )
1634 {
1635  SolarMutexGuard aGuard;
1636  auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener);
1637  if (it != aSelectionChgListeners.end())
1638  aSelectionChgListeners.erase(it);
1639 }
1640 
1642 {
1643  // Selection changed so end any style preview
1644  // Note: executing this slot through the dispatcher
1645  // will cause the style dialog to be raised so we go
1646  // direct here
1647  ScFormatShell aShell( GetViewShell()->GetViewData() );
1648  SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1649  SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1650  aShell.ExecuteStyle( aReq );
1651  lang::EventObject aEvent;
1652  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1653  for (const auto& rListener : aSelectionChgListeners)
1654  rListener->selectionChanged( aEvent );
1655 
1656  // handle sheet events
1657  ScTabViewShell* pViewSh = GetViewShell();
1658  ScViewData& rViewData = pViewSh->GetViewData();
1659  ScDocShell* pDocSh = rViewData.GetDocShell();
1660  ScDocument& rDoc = pDocSh->GetDocument();
1661  SCTAB nTab = rViewData.GetTabNo();
1662  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1663  if (pEvents)
1664  {
1665  const OUString* pScript = pEvents->GetScript(ScSheetEventId::SELECT);
1666  if (pScript)
1667  {
1668  // the macro parameter is the selection as returned by getSelection
1669  uno::Sequence<uno::Any> aParams(1);
1670  aParams[0] = getSelection();
1671  uno::Any aRet;
1672  uno::Sequence<sal_Int16> aOutArgsIndex;
1673  uno::Sequence<uno::Any> aOutArgs;
1674  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1675  }
1676  }
1677 
1678  SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
1679 
1680  if ( mbLeftMousePressed ) // selection still in progress
1681  return;
1682 
1683  try
1684  {
1685  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1686  uno::Sequence< uno::Any > aArgs( 1 );
1687  aArgs[ 0 ] = getSelection();
1688  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1689  }
1690  catch( uno::Exception& )
1691  {
1692  }
1693 }
1694 
1695 // XPropertySet (view options)
1697 
1698 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1699 {
1700  SolarMutexGuard aGuard;
1701  static uno::Reference<beans::XPropertySetInfo> aRef(
1703  return aRef;
1704 }
1705 
1707  const OUString& aPropertyName, const uno::Any& aValue )
1708 {
1709  SolarMutexGuard aGuard;
1710 
1711  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1712  {
1714  return;
1715  }
1716 
1717  ScTabViewShell* pViewSh = GetViewShell();
1718  if (!pViewSh)
1719  return;
1720 
1721  ScViewData& rViewData = pViewSh->GetViewData();
1722  const ScViewOptions& rOldOpt = pViewSh->GetViewData().GetOptions();
1723  ScViewOptions aNewOpt(rOldOpt);
1724 
1725  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1727  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1729  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1731  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1733  else if ( aPropertyName == SC_UNO_SHOWANCHOR )
1735  else if ( aPropertyName == SC_UNO_SHOWFORM )
1737  else if ( aPropertyName == SC_UNO_SHOWGRID )
1739  else if ( aPropertyName == SC_UNO_SHOWHELP )
1741  else if ( aPropertyName == SC_UNO_SHOWNOTES )
1743  else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
1745  else if ( aPropertyName == SC_UNO_SHOWZERO )
1747  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1749  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1751  else if ( aPropertyName == SC_UNO_SHOWOBJ )
1752  {
1753  sal_Int16 nIntVal = 0;
1754  if ( aValue >>= nIntVal )
1755  {
1756  //#i80528# adapt to new range eventually
1757  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1758 
1759  aNewOpt.SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
1760  }
1761  }
1762  else if ( aPropertyName == SC_UNO_SHOWCHARTS )
1763  {
1764  sal_Int16 nIntVal = 0;
1765  if ( aValue >>= nIntVal )
1766  {
1767  //#i80528# adapt to new range eventually
1768  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1769 
1770  aNewOpt.SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
1771  }
1772  }
1773  else if ( aPropertyName == SC_UNO_SHOWDRAW )
1774  {
1775  sal_Int16 nIntVal = 0;
1776  if ( aValue >>= nIntVal )
1777  {
1778  //#i80528# adapt to new range eventually
1779  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1780 
1781  aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
1782  }
1783  }
1784  else if ( aPropertyName == SC_UNO_GRIDCOLOR )
1785  {
1786  Color nIntVal;
1787  if ( aValue >>= nIntVal )
1788  aNewOpt.SetGridColor( nIntVal, OUString() );
1789  }
1790  else if ( aPropertyName == SC_UNO_ZOOMTYPE )
1791  {
1792  sal_Int16 nIntVal = 0;
1793  if ( aValue >>= nIntVal )
1794  SetZoomType(nIntVal);
1795  }
1796  else if ( aPropertyName == SC_UNO_ZOOMVALUE )
1797  {
1798  sal_Int16 nIntVal = 0;
1799  if ( aValue >>= nIntVal )
1800  SetZoom(nIntVal);
1801  }
1802 
1803  // Options are set on the view and document (for new views),
1804  // so that they remain during saving.
1807 
1808  if ( aNewOpt == rOldOpt )
1809  return;
1810 
1811  rViewData.SetOptions( aNewOpt );
1812  rViewData.GetDocument().SetViewOptions( aNewOpt );
1813  rViewData.GetDocShell()->SetDocumentModified();
1814 
1815  pViewSh->UpdateFixPos();
1816  pViewSh->PaintGrid();
1817  pViewSh->PaintTop();
1818  pViewSh->PaintLeft();
1819  pViewSh->PaintExtras();
1820  pViewSh->InvalidateBorder();
1821 
1822  SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1823  rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> check in menu
1824  rBindings.Invalidate( FID_TOGGLESYNTAX );
1825 }
1826 
1827 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1828 {
1829  SolarMutexGuard aGuard;
1830  uno::Any aRet;
1831 
1832  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1833  {
1834  aRet <<= bFilteredRangeSelection;
1835  return aRet;
1836  }
1837 
1838  ScTabViewShell* pViewSh = GetViewShell();
1839  if (pViewSh)
1840  {
1841  const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1842 
1843  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1844  aRet <<= rOpt.GetOption( VOPT_HEADER );
1845  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1846  aRet <<= rOpt.GetOption( VOPT_HSCROLL );
1847  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1848  aRet <<= rOpt.GetOption( VOPT_OUTLINER );
1849  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1850  aRet <<= rOpt.GetOption( VOPT_TABCONTROLS );
1851  else if ( aPropertyName == SC_UNO_SHOWANCHOR ) aRet <<= rOpt.GetOption( VOPT_ANCHOR );
1852  else if ( aPropertyName == SC_UNO_SHOWFORM ) aRet <<= rOpt.GetOption( VOPT_FORMULAS );
1853  else if ( aPropertyName == SC_UNO_SHOWGRID ) aRet <<= rOpt.GetOption( VOPT_GRID );
1854  else if ( aPropertyName == SC_UNO_SHOWHELP ) aRet <<= rOpt.GetOption( VOPT_HELPLINES );
1855  else if ( aPropertyName == SC_UNO_SHOWNOTES ) aRet <<= rOpt.GetOption( VOPT_NOTES );
1856  else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= rOpt.GetOption( VOPT_PAGEBREAKS );
1857  else if ( aPropertyName == SC_UNO_SHOWZERO ) aRet <<= rOpt.GetOption( VOPT_NULLVALS );
1858  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1859  aRet <<= rOpt.GetOption( VOPT_SYNTAX );
1860  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1861  aRet <<= rOpt.GetOption( VOPT_VSCROLL );
1862  else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1863  else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1864  else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1865  else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= rOpt.GetGridColor();
1866  else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1867  else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1868  else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1869  else if ( aPropertyName == SC_UNO_VISAREASCREEN )
1870  {
1871  ScViewData& rViewData = pViewSh->GetViewData();
1872  vcl::Window* pActiveWin = rViewData.GetActiveWin();
1873  if ( pActiveWin )
1874  {
1875  tools::Rectangle aRect = pActiveWin->GetWindowExtentsRelative( nullptr );
1876  aRet <<= AWTRectangle( aRect );
1877  }
1878  }
1879  }
1880 
1881  return aRet;
1882 }
1883 
1884 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1885  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1886 {
1887  SolarMutexGuard aGuard;
1888  aPropertyChgListeners.push_back( xListener );
1889 }
1890 
1891 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1892  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1893 {
1894  SolarMutexGuard aGuard;
1895  auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener);
1896  if (it != aPropertyChgListeners.end())
1897  aPropertyChgListeners.erase(it);
1898 }
1899 
1900 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
1901  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1902 {
1903 }
1904 
1905 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
1906  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1907 {
1908 }
1909 
1911 {
1912  beans::PropertyChangeEvent aEvent;
1913  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1914  for (const auto& rListener : aPropertyChgListeners)
1915  rListener->propertyChange( aEvent );
1916 }
1917 
1918 // XRangeSelection
1919 
1921  const uno::Sequence<beans::PropertyValue>& aArguments )
1922 {
1923  SolarMutexGuard aGuard;
1924  ScTabViewShell* pViewSh = GetViewShell();
1925  if (!pViewSh)
1926  return;
1927 
1928  OUString aInitVal, aTitle;
1929  bool bCloseOnButtonUp = false;
1930  bool bSingleCell = false;
1931  bool bMultiSelection = false;
1932 
1933  OUString aStrVal;
1934  for (const beans::PropertyValue& rProp : aArguments)
1935  {
1936  OUString aPropName(rProp.Name);
1937 
1938  if (aPropName == SC_UNONAME_CLOSEONUP )
1939  bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1940  else if (aPropName == SC_UNONAME_TITLE )
1941  {
1942  if ( rProp.Value >>= aStrVal )
1943  aTitle = aStrVal;
1944  }
1945  else if (aPropName == SC_UNONAME_INITVAL )
1946  {
1947  if ( rProp.Value >>= aStrVal )
1948  aInitVal = aStrVal;
1949  }
1950  else if (aPropName == SC_UNONAME_SINGLECELL )
1951  bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1952  else if (aPropName == SC_UNONAME_MULTISEL )
1953  bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1954  }
1955 
1956  pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
1957 }
1958 
1960 {
1961  SolarMutexGuard aGuard;
1962  ScTabViewShell* pViewSh = GetViewShell();
1963  if (pViewSh)
1964  pViewSh->StopSimpleRefDialog();
1965 }
1966 
1968  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1969 {
1970  SolarMutexGuard aGuard;
1971  aRangeSelListeners.push_back( xListener );
1972 }
1973 
1975  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1976 {
1977  SolarMutexGuard aGuard;
1978  auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
1979  if (it != aRangeSelListeners.end())
1980  aRangeSelListeners.erase(it);
1981 }
1982 
1984  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1985 {
1986  SolarMutexGuard aGuard;
1987  aRangeChgListeners.push_back( xListener );
1988 }
1989 
1991  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1992 {
1993  SolarMutexGuard aGuard;
1994  auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
1995  if (it != aRangeChgListeners.end())
1996  aRangeChgListeners.erase(it);
1997 }
1998 
1999 void ScTabViewObj::RangeSelDone( const OUString& rText )
2000 {
2001  sheet::RangeSelectionEvent aEvent;
2002  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2003  aEvent.RangeDescriptor = rText;
2004 
2005  // copy on the stack because listener could remove itself
2006  auto const listeners(aRangeSelListeners);
2007 
2008  for (const auto& rListener : listeners)
2009  rListener->done( aEvent );
2010 }
2011 
2012 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2013 {
2014  sheet::RangeSelectionEvent aEvent;
2015  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2016  aEvent.RangeDescriptor = rText;
2017 
2018  // copy on the stack because listener could remove itself
2019  auto const listeners(aRangeSelListeners);
2020 
2021  for (const auto& rListener : listeners)
2022  rListener->aborted( aEvent );
2023 }
2024 
2025 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2026 {
2027  sheet::RangeSelectionEvent aEvent;
2028  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2029  aEvent.RangeDescriptor = rText;
2030 
2031  // copy on the stack because listener could remove itself
2032  auto const listener(aRangeChgListeners);
2033 
2034  for (const auto& rListener : listener)
2035  rListener->descriptorChanged( aEvent );
2036 }
2037 
2038 // XServiceInfo
2040 {
2041  return "ScTabViewObj";
2042 }
2043 
2044 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2045 {
2046  return cppu::supportsService(this, rServiceName);
2047 }
2048 
2049 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2050 {
2052 }
2053 
2054 // XUnoTunnel
2055 
2057 
2058 css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2059 {
2060  SolarMutexGuard aGuard;
2061  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2062  if (pShell)
2063  return pShell->GetEditView()->GetTransferable();
2064 
2065  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2066  if (pTextShell)
2067  {
2068  ScViewData& rViewData = GetViewShell()->GetViewData();
2069  ScDrawView* pView = rViewData.GetScDrawView();
2070  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2071  if (pOutView)
2072  return pOutView->GetEditView().GetTransferable();
2073  }
2074 
2075  ScDrawShell* pDrawShell = dynamic_cast<ScDrawShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2076  if (pDrawShell)
2077  return pDrawShell->GetDrawView()->CopyToTransferable();
2078 
2079  return GetViewShell()->CopyToTransferable();
2080 }
2081 
2082 void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans )
2083 {
2084  SolarMutexGuard aGuard;
2085  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2086  if (pShell)
2087  pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2088  else
2089  {
2090  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2091  if (pTextShell)
2092  {
2093  ScViewData& rViewData = GetViewShell()->GetViewData();
2094  ScDrawView* pView = rViewData.GetScDrawView();
2095  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2096  if ( pOutView )
2097  {
2098  pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2099  return;
2100  }
2101  }
2102 
2103  GetViewShell()->PasteFromTransferable( xTrans );
2104  }
2105 }
2106 
2107 namespace {
2108 
2109 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2110 {
2111  uno::Sequence<sal_Int32> aRet(rSelected.size());
2112  size_t i = 0;
2113  for (const auto& rTab : rSelected)
2114  {
2115  aRet[i] = static_cast<sal_Int32>(rTab);
2116  ++i;
2117  }
2118 
2119  return aRet;
2120 }
2121 
2122 }
2123 
2124 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2125 {
2126  ScTabViewShell* pViewSh = GetViewShell();
2127  if (!pViewSh)
2128  return uno::Sequence<sal_Int32>();
2129 
2130  ScViewData& rViewData = pViewSh->GetViewData();
2131 
2132  // #i95280# when printing from the shell, the view is never activated,
2133  // so Excel view settings must also be evaluated here.
2134  ScExtDocOptions* pExtOpt = rViewData.GetDocument().GetExtDocOptions();
2135  if (pExtOpt && pExtOpt->IsChanged())
2136  {
2137  pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2138  pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2139  pExtOpt->SetChanged(false);
2140  }
2141 
2142  return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2143 }
2144 
2146  SfxBaseController(pViewSh),
2147  mpViewShell(pViewSh)
2148 {
2149  if (mpViewShell)
2151 }
2152 
2154 {
2155  if (mpViewShell)
2157 }
2158 
2160 {
2161  SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2162  return SfxBaseController::queryInterface(rType);
2163 }
2164 
2165 void ScPreviewObj::acquire() noexcept
2166 {
2167  SfxBaseController::acquire();
2168 }
2169 
2170 void ScPreviewObj::release() noexcept
2171 {
2172  SfxBaseController::release();
2173 }
2174 
2176 {
2177  if (rHint.GetId() == SfxHintId::Dying)
2178  mpViewShell = nullptr;
2179 }
2180 
2181 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2182 {
2183  ScPreview* p = mpViewShell ? mpViewShell->GetPreview() : nullptr;
2184  if (!p)
2185  return uno::Sequence<sal_Int32>();
2186 
2187  return toSequence(p->GetSelectedTabs());
2188 }
2189 
2190 /* 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:78
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3108
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:2058
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:1974
#define SC_UNONAME_MULTISEL
Definition: unonames.hxx:644
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:2012
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:718
void ReadExtOptions(const ScExtDocOptions &rOpt)
Definition: viewdata.cxx:3500
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:241
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:2165
#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:2448
#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:1983
bool PaintExtras()
Definition: tabview3.cxx:2759
#define OLD_UNO_HORSCROLL
Definition: unonames.hxx:583
#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:1920
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:958
bool MousePressed(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1134
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:1588
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:712
Reference< XInterface > xTarget
virtual OUString SAL_CALL getImplementationName() override
Definition: viewuno.cxx:2039
bool IsMouseListening() const
Definition: viewuno.cxx:1118
SdrObject * GetObj(size_t nNum) const
virtual Size GetSizePixel() const
size_t GetObjCount() const
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:2941
rtl::Reference< ScViewPaneObj > GetObjectByIndex_Impl(sal_uInt16 nIndex) const
Definition: viewuno.cxx:982
const ContentProperties & rData
virtual void SAL_CALL removeEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1327
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:585
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:1400
SdrMark * GetMark(size_t nNum) const
ScDocument & GetDocument() const
Definition: viewdata.hxx:379
void SheetChanged(bool bSameTabButMoved)
Definition: viewuno.cxx:534
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:1541
EditView * GetEditView()
Definition: editsh.hxx:68
void Invalidate(sal_uInt16 nId)
#define SC_UNONAME_SINGLECELL
Definition: unonames.hxx:643
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: viewuno.cxx:2044
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:2175
css::chart::ChartAxisLabelPosition ePos
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1400
const ScRangeList & GetRangeList() const
Definition: cellsuno.hxx:243
static bool lcl_TabInRanges(SCTAB nTab, const ScRangeList &rRanges)
Definition: viewuno.cxx:602
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:821
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: viewuno.cxx:1827
SCTAB nPreviousTab
Definition: viewuno.hxx:157
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:2159
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:1340
#define SC_UNO_SHOWGRID
Definition: unonames.hxx:548
void InvalidateBorder()
constexpr OUStringLiteral SCTABVIEWOBJ_SERVICE
Definition: viewuno.cxx:115
SfxShell * GetShell(sal_uInt16 nIdx) const
virtual css::uno::Reference< css::uno::XInterface > getUnoShape()
SdrPage * getSdrPageFromSdrObject() const
void SetObjMode(ScVObjType eObj, ScVObjMode eMode)
Definition: viewopti.hxx:90
ScPreviewObj(ScPreviewShell *pViewSh)
Definition: viewuno.cxx:2145
void SetZoom(sal_Int16 Zoom)
Definition: viewuno.cxx:1372
virtual void SAL_CALL insertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &xTrans) override
Definition: viewuno.cxx:2082
void RangeSelChanged(const OUString &rText)
Definition: viewuno.cxx:2025
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2683
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:2170
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:1566
bool MouseReleased(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1224
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3939
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:672
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:1283
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3136
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:2049
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2688
virtual void SAL_CALL addEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1317
#define OLD_UNO_VERTSCROLL
Definition: unonames.hxx:587
SdrObject * GetMarkedSdrObj() const
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:714
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:428
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1058
T * get() const
vcl::Window * GetWindowByPos(ScSplitPos ePos) const
Definition: tabview.hxx:371
virtual sal_Bool SAL_CALL hasElements() override
Definition: viewuno.cxx:974
#define SC_UNO_SHOWDRAW
Definition: unonames.hxx:546
virtual sal_Int32 SAL_CALL getCount() override
Definition: viewuno.cxx:941
#define SC_UNONAME_TITLE
Definition: unonames.hxx:641
void EndActivationListening()
Definition: viewuno.cxx:1300
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:1706
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:2375
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:1905
bool bFilteredRangeSelection
Definition: viewuno.hxx:159
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: viewuno.cxx:933
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:2756
sal_Int16 SCCOL
Definition: types.hxx:21
virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1625
virtual void SAL_CALL abortRangeSelection() override
Definition: viewuno.cxx:1959
#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:727
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:1967
sal_Int16 GetZoom() const
Definition: viewuno.cxx:1361
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:3124
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:595
virtual ~ScPreviewObj() override
Definition: viewuno.cxx:2153
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:2578
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
virtual sal_Bool SAL_CALL getIsWindowSplit() override
Definition: viewuno.cxx:1483
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:1600
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1900
void RangeSelDone(const OUString &rText)
Definition: viewuno.cxx:1999
#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:1029
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:2181
const OUString * GetScript(ScSheetEventId nEvent) const
Definition: sheetevents.cxx:99
rtl::Reference< ScTransferObj > CopyToTransferable()
Definition: viewfun3.cxx:430
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:1641
virtual sal_Int32 SAL_CALL getSplitHorizontal() override
Definition: viewuno.cxx:1515
virtual css::uno::Any SAL_CALL getSelection() override
Definition: viewuno.cxx:850
#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:1990
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:582
SdrPage * GetPage() const
#define SC_UNO_HIDESPELL
Definition: unonames.hxx:540
void PasteFromTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable)
Definition: viewfun3.cxx:620
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:659
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:321
virtual bool IsDesignMode() const override
really derive cell from range?
Definition: cellsuno.hxx:634
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:1698
void * p
Reference< XComponentContext > getProcessComponentContext()
virtual void SAL_CALL removeActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1350
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:1067
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2124
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:896
virtual sal_Int32 SAL_CALL getSplitVertical() override
Definition: viewuno.cxx:1528
virtual void SAL_CALL acquire() noexcept override
Definition: viewuno.cxx:423
#define SC_UNONAME_CLOSEONUP
Definition: unonames.hxx:642
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:916
void VisAreaChanged()
Definition: viewuno.cxx:1910
virtual sal_Bool SAL_CALL hasFrozenPanes() override
Definition: viewuno.cxx:1499
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:584
#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:77
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:646
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:1043
ScSheetEventId
Definition: sheetevents.hxx:27
bool bDrawSelModeSet
Definition: viewuno.hxx:158
ScTabViewObj()=delete
#define SC_UNONAME_INITVAL
Definition: unonames.hxx:640
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:1891
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: viewuno.cxx:573
virtual void SAL_CALL removeSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1632
static void lcl_ShowObject(ScTabViewShell &rViewSh, const ScDrawView &rDrawView, const SdrObject *pSelObj)
Definition: viewuno.cxx:613
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:1884
void SetZoomType(sal_Int16 ZoomType)
Definition: viewuno.cxx:1429
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:586
sal_uInt16 GetPageCount() const
virtual css::uno::Type SAL_CALL getElementType() override
Definition: viewuno.cxx:968
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