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 #define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView"
116 #define SCVIEWSETTINGS_SERVICE "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 );
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, 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() throw()
424 {
425  OWeakObject::acquire();
426 }
427 
428 void SAL_CALL ScViewPaneObj::release() throw()
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() throw()
489 {
490  SfxBaseController::acquire();
491 }
492 
493 void SAL_CALL ScTabViewObj::release() throw()
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::getUnoTunnelImplementation<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::getUnoTunnelImplementation<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  SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShapeInt );
780  if (pShape)
781  {
782  SdrObject *pObj = pShape->GetSdrObject();
783  if (pObj)
784  {
785  if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
786  {
787  pViewSh->SetDrawSelMode(true);
788  pViewSh->UpdateLayerLocks();
789  bDrawSelModeSet = true;
790  }
791  if (!pPV) // first object
792  {
793  lcl_ShowObject( *pViewSh, *pDrawView, pObj );
794  pPV = pDrawView->GetSdrPageView();
795  }
796  if ( pPV && pObj->getSdrPageFromSdrObject() == pPV->GetPage() )
797  {
798  if (pDrawView->IsObjMarkable( pObj, pPV ))
799  pDrawView->MarkObj( pObj, pPV );
800  else
801  bAllMarked = false;
802  }
803  }
804  }
805  }
806  }
807  if (bAllMarked)
808  bRet = true;
809  }
810  else
811  bRet = true; // empty XShapes (all shapes are deselected)
812  }
813 
814  if (bRet)
815  pViewSh->SetDrawShell(true);
816  }
817  }
818 
819  if (!bRet)
820  throw lang::IllegalArgumentException();
821 
822  return bRet;
823 }
824 
825 uno::Reference<drawing::XShapes> ScTabViewShell::getSelectedXShapes()
826 {
827  uno::Reference<drawing::XShapes> xShapes;
828  SdrView* pSdrView = GetScDrawView();
829  if (pSdrView)
830  {
831  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
832  const size_t nMarkCount = rMarkList.GetMarkCount();
833  if (nMarkCount)
834  {
835  // generate ShapeCollection (like in SdXImpressView::getSelection in Draw)
836  // XInterfaceRef will be returned and it has to be UsrObject-XInterface
837  xShapes = drawing::ShapeCollection::create(comphelper::getProcessComponentContext());
838 
839  for (size_t i = 0; i < nMarkCount; ++i)
840  {
841  SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
842  if (pDrawObj)
843  {
844  uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
845  if (xShape.is())
846  xShapes->add(xShape);
847  }
848  }
849  }
850  }
851  return xShapes;
852 }
853 
855 {
856  SolarMutexGuard aGuard;
857  ScTabViewShell* pViewSh = GetViewShell();
858  ScCellRangesBase* pObj = nullptr;
859  if (pViewSh)
860  {
861  // is something selected in drawing layer?
862  uno::Reference<uno::XInterface> xRet(pViewSh->getSelectedXShapes());
863  if (xRet.is())
864  return uno::makeAny(xRet);
865 
866  // otherwise sheet (cell) selection
867 
868  ScViewData& rViewData = pViewSh->GetViewData();
869  ScDocShell* pDocSh = rViewData.GetDocShell();
870 
871  const ScMarkData& rMark = rViewData.GetMarkData();
872  SCTAB nTabs = rMark.GetSelectCount();
873 
874  ScRange aRange;
875  ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
876  if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
877  {
878  if (aRange.aStart == aRange.aEnd)
879  pObj = new ScCellObj( pDocSh, aRange.aStart );
880  else
881  pObj = new ScCellRangeObj( pDocSh, aRange );
882  }
883  else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
884  {
885  ScMarkData aFilteredMark( rMark );
886  ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
887  ScRangeList aRangeList;
888  aFilteredMark.FillRangeListWithMarks( &aRangeList, false);
889  // Theoretically a selection may start and end on a filtered row.
890  switch ( aRangeList.size() )
891  {
892  case 0:
893  // No unfiltered row, we have to return some object, so
894  // here is one with no ranges.
895  pObj = new ScCellRangesObj( pDocSh, aRangeList );
896  break;
897  case 1:
898  {
899  const ScRange& rRange = aRangeList[ 0 ];
900  if (rRange.aStart == rRange.aEnd)
901  pObj = new ScCellObj( pDocSh, rRange.aStart );
902  else
903  pObj = new ScCellRangeObj( pDocSh, rRange );
904  }
905  break;
906  default:
907  pObj = new ScCellRangesObj( pDocSh, aRangeList );
908  }
909  }
910  else // multiselection
911  {
912  ScRangeListRef xRanges;
913  rViewData.GetMultiArea( xRanges );
914 
915  // if there are more sheets, copy ranges
917  if ( nTabs > 1 )
918  rMark.ExtendRangeListTables( xRanges.get() );
919 
920  pObj = new ScCellRangesObj( pDocSh, *xRanges );
921  }
922 
923  if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
924  {
925  // remember if the selection was from the cursor position without anything selected
926  // (used when rendering the selection)
927 
928  pObj->SetCursorOnly( true );
929  }
930  }
931 
932  return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
933 }
934 
935 // XEnumerationAccess
936 
937 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
938 {
939  SolarMutexGuard aGuard;
940  return new ScIndexEnumeration(this, "com.sun.star.sheet.SpreadsheetViewPanesEnumeration");
941 }
942 
943 // XIndexAccess
944 
945 sal_Int32 SAL_CALL ScTabViewObj::getCount()
946 {
947  SolarMutexGuard aGuard;
948  ScTabViewShell* pViewSh = GetViewShell();
949  sal_uInt16 nPanes = 0;
950  if (pViewSh)
951  {
952  nPanes = 1;
953  ScViewData& rViewData = pViewSh->GetViewData();
954  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
955  nPanes *= 2;
956  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
957  nPanes *= 2;
958  }
959  return nPanes;
960 }
961 
962 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
963 {
964  SolarMutexGuard aGuard;
965  uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl(static_cast<sal_uInt16>(nIndex)));
966  if (!xPane.is())
967  throw lang::IndexOutOfBoundsException();
968 
969  return uno::makeAny(xPane);
970 }
971 
973 {
974  SolarMutexGuard aGuard;
976 }
977 
979 {
980  SolarMutexGuard aGuard;
981  return ( getCount() != 0 );
982 }
983 
984 // XSpreadsheetView
985 
987 {
988  static const ScSplitPos ePosHV[4] =
990 
991  ScTabViewShell* pViewSh = GetViewShell();
992  if (pViewSh)
993  {
994  ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default position
995  bool bError = false;
996  ScViewData& rViewData = pViewSh->GetViewData();
997  bool bHor = ( rViewData.GetHSplitMode() != SC_SPLIT_NONE );
998  bool bVer = ( rViewData.GetVSplitMode() != SC_SPLIT_NONE );
999  if ( bHor && bVer )
1000  {
1001  // bottom left, bottom right, top left, top right - like in Excel
1002  if ( nIndex < 4 )
1003  eWhich = ePosHV[nIndex];
1004  else
1005  bError = true;
1006  }
1007  else if ( bHor )
1008  {
1009  if ( nIndex > 1 )
1010  bError = true;
1011  else if ( nIndex == 1 )
1012  eWhich = SC_SPLIT_BOTTOMRIGHT;
1013  // otherwise SC_SPLIT_BOTTOMLEFT
1014  }
1015  else if ( bVer )
1016  {
1017  if ( nIndex > 1 )
1018  bError = true;
1019  else if ( nIndex == 0 )
1020  eWhich = SC_SPLIT_TOPLEFT;
1021  // otherwise SC_SPLIT_BOTTOMLEFT
1022  }
1023  else if ( nIndex > 0 )
1024  bError = true; // not split: only 0 is valid
1025 
1026  if (!bError)
1027  return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) );
1028  }
1029 
1030  return nullptr;
1031 }
1032 
1033 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1034 {
1035  SolarMutexGuard aGuard;
1036  ScTabViewShell* pViewSh = GetViewShell();
1037  if (pViewSh)
1038  {
1039  ScViewData& rViewData = pViewSh->GetViewData();
1040  SCTAB nTab = rViewData.GetTabNo();
1041  return new ScTableSheetObj( rViewData.GetDocShell(), nTab );
1042  }
1043  return nullptr;
1044 }
1045 
1046 // support expand (but not replace) the active sheet
1047 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1048 {
1049  SolarMutexGuard aGuard;
1050  comphelper::ProfileZone aZone("setActiveSheet");
1051 
1052  ScTabViewShell* pViewSh = GetViewShell();
1053  if ( !(pViewSh && xActiveSheet.is()) )
1054  return;
1055 
1056  // XSpreadsheet and ScCellRangesBase -> has to be the same sheet
1057 
1058  ScCellRangesBase* pRangesImp = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( xActiveSheet );
1059  if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == pRangesImp->GetDocShell() )
1060  {
1061  const ScRangeList& rRanges = pRangesImp->GetRangeList();
1062  if ( rRanges.size() == 1 )
1063  {
1064  SCTAB nNewTab = rRanges[ 0 ].aStart.Tab();
1065  if ( pViewSh->GetViewData().GetDocument().HasTable(nNewTab) )
1066  pViewSh->SetTabNo( nNewTab );
1067  }
1068  }
1069 }
1070 
1071 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1072 {
1073  uno::Reference< uno::XInterface > xTarget;
1074  if (GetViewShell())
1075  {
1076  SCCOL nX;
1077  SCROW nY;
1079  ScSplitPos eSplitMode = rData.GetActivePart();
1080  SCTAB nTab(rData.GetTabNo());
1081  rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1082 
1083  ScAddress aCellPos (nX, nY, nTab);
1084  ScCellObj* pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos);
1085 
1086  xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1087 
1088  ScDocument& rDoc = rData.GetDocument();
1089  if (ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer())
1090  {
1091  SdrPage* pDrawPage = nullptr;
1092  if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1093  pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1094 
1095  SdrView* pDrawView = GetViewShell()->GetScDrawView();
1096 
1097  if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1098  {
1099  vcl::Window* pActiveWin = rData.GetActiveWin();
1100  Point aPos = pActiveWin->PixelToLogic(rPoint);
1101 
1102  sal_uInt16 nHitLog = static_cast<sal_uInt16>(pActiveWin->PixelToLogic(
1103  Size(pDrawView->GetHitTolerancePixel(),0)).Width());
1104 
1105  const size_t nCount(pDrawPage->GetObjCount());
1106  bool bFound(false);
1107  for (size_t i = 0; i < nCount && !bFound; ++i)
1108  {
1109  SdrObject* pObj = pDrawPage->GetObj(i);
1110  if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), nullptr, false))
1111  {
1112  xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1113  bFound = true;
1114  }
1115  }
1116  }
1117  }
1118  }
1119  return xTarget;
1120 }
1121 
1123 {
1124  if ( !aMouseClickHandlers.empty() )
1125  return true;
1126 
1127  // also include sheet events, because MousePressed must be called for them
1128  ScViewData& rViewData = GetViewShell()->GetViewData();
1129  ScDocument& rDoc = rViewData.GetDocument();
1130  SCTAB nTab = rViewData.GetTabNo();
1131  return
1132  rDoc.HasSheetEventScript( nTab, ScSheetEventId::RIGHTCLICK, true ) ||
1133  rDoc.HasSheetEventScript( nTab, ScSheetEventId::DOUBLECLICK, true ) ||
1134  rDoc.HasSheetEventScript( nTab, ScSheetEventId::SELECT, true );
1135 
1136 }
1137 
1138 bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1139 {
1140  bool bReturn(false);
1141  if ( e.Buttons == css::awt::MouseButton::LEFT )
1142  mbLeftMousePressed = true;
1143 
1144  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1145  if (!aMouseClickHandlers.empty() && xTarget.is())
1146  {
1147  awt::EnhancedMouseEvent aMouseEvent;
1148 
1149  aMouseEvent.Buttons = e.Buttons;
1150  aMouseEvent.X = e.X;
1151  aMouseEvent.Y = e.Y;
1152  aMouseEvent.ClickCount = e.ClickCount;
1153  aMouseEvent.PopupTrigger = e.PopupTrigger;
1154  aMouseEvent.Target = xTarget;
1155  aMouseEvent.Modifiers = e.Modifiers;
1156 
1157  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1158  {
1159  try
1160  {
1161  if (!(*it)->mousePressed( aMouseEvent ))
1162  bReturn = true;
1163  ++it;
1164  }
1165  catch ( uno::Exception& )
1166  {
1167  it = aMouseClickHandlers.erase(it);
1168  }
1169  }
1170  }
1171 
1172  // handle sheet events
1173  bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1174  bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1175  if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1176  {
1178 
1179  ScTabViewShell* pViewSh = GetViewShell();
1180  ScViewData& rViewData = pViewSh->GetViewData();
1181  ScDocShell* pDocSh = rViewData.GetDocShell();
1182  ScDocument& rDoc = pDocSh->GetDocument();
1183  SCTAB nTab = rViewData.GetTabNo();
1184  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1185  if (pEvents)
1186  {
1187  const OUString* pScript = pEvents->GetScript(nEvent);
1188  if (pScript)
1189  {
1190  // the macro parameter is the clicked object, as in the mousePressed call above
1191  uno::Sequence<uno::Any> aParams(1);
1192  aParams[0] <<= xTarget;
1193 
1194  uno::Any aRet;
1195  uno::Sequence<sal_Int16> aOutArgsIndex;
1196  uno::Sequence<uno::Any> aOutArgs;
1197 
1198  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1199 
1200  // look for a boolean return value of true
1201  bool bRetValue = false;
1202  if ((aRet >>= bRetValue) && bRetValue)
1203  bReturn = true;
1204  }
1205  }
1206 
1207  // execute VBA event handler
1208  if (!bReturn && xTarget.is()) try
1209  {
1210  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1211  // the parameter is the clicked object, as in the mousePressed call above
1212  uno::Sequence< uno::Any > aArgs( 1 );
1213  aArgs[ 0 ] <<= xTarget;
1214  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1215  }
1216  catch( util::VetoException& )
1217  {
1218  bReturn = true;
1219  }
1220  catch( uno::Exception& )
1221  {
1222  }
1223  }
1224 
1225  return bReturn;
1226 }
1227 
1228 bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1229 {
1230  if ( e.Buttons == css::awt::MouseButton::LEFT )
1231  {
1232  try
1233  {
1234  ScTabViewShell* pViewSh = GetViewShell();
1235  ScViewData& rViewData = pViewSh->GetViewData();
1236  ScDocShell* pDocSh = rViewData.GetDocShell();
1237  ScDocument& rDoc = pDocSh->GetDocument();
1238  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1239  uno::Sequence< uno::Any > aArgs( 1 );
1240  aArgs[ 0 ] = getSelection();
1241  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1242  }
1243  catch( uno::Exception& )
1244  {
1245  }
1246  mbLeftMousePressed = false;
1247  }
1248 
1249  bool bReturn(false);
1250 
1251  if (!aMouseClickHandlers.empty())
1252  {
1253  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1254 
1255  if (xTarget.is())
1256  {
1257  awt::EnhancedMouseEvent aMouseEvent;
1258 
1259  aMouseEvent.Buttons = e.Buttons;
1260  aMouseEvent.X = e.X;
1261  aMouseEvent.Y = e.Y;
1262  aMouseEvent.ClickCount = e.ClickCount;
1263  aMouseEvent.PopupTrigger = e.PopupTrigger;
1264  aMouseEvent.Target = xTarget;
1265  aMouseEvent.Modifiers = e.Modifiers;
1266 
1267  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1268  {
1269  try
1270  {
1271  if (!(*it)->mouseReleased( aMouseEvent ))
1272  bReturn = true;
1273  ++it;
1274  }
1275  catch ( uno::Exception& )
1276  {
1277  it = aMouseClickHandlers.erase(it);
1278  }
1279  }
1280  }
1281  }
1282  return bReturn;
1283 }
1284 
1285 // XEnhancedMouseClickBroadcaster
1286 
1288 {
1289  lang::EventObject aEvent;
1290  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1291  for (const auto& rListener : aMouseClickHandlers)
1292  {
1293  try
1294  {
1295  rListener->disposing(aEvent);
1296  }
1297  catch ( uno::Exception& )
1298  {
1299  }
1300  }
1301  aMouseClickHandlers.clear();
1302 }
1303 
1305 {
1306  lang::EventObject aEvent;
1307  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1308  for (const auto& rListener : aActivationListeners)
1309  {
1310  try
1311  {
1312  rListener->disposing(aEvent);
1313  }
1314  catch ( uno::Exception& )
1315  {
1316  }
1317  }
1318  aActivationListeners.clear();
1319 }
1320 
1321 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1322 {
1323  SolarMutexGuard aGuard;
1324 
1325  if (aListener.is())
1326  {
1327  aMouseClickHandlers.push_back( aListener );
1328  }
1329 }
1330 
1331 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1332 {
1333  SolarMutexGuard aGuard;
1334  sal_uInt16 nCount = aMouseClickHandlers.size();
1335  aMouseClickHandlers.erase(
1336  std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
1337  aMouseClickHandlers.end());
1338  if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
1340 }
1341 
1342 // XActivationBroadcaster
1343 
1344 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1345 {
1346  SolarMutexGuard aGuard;
1347 
1348  if (aListener.is())
1349  {
1350  aActivationListeners.push_back( aListener );
1351  }
1352 }
1353 
1354 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1355 {
1356  SolarMutexGuard aGuard;
1357  sal_uInt16 nCount = aActivationListeners.size();
1358  aActivationListeners.erase(
1359  std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
1360  aActivationListeners.end());
1361  if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
1363 }
1364 
1365 sal_Int16 ScTabViewObj::GetZoom() const
1366 {
1367  ScTabViewShell* pViewSh = GetViewShell();
1368  if (pViewSh)
1369  {
1370  const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y will be shown
1371  return static_cast<sal_Int16>(tools::Long( rZoomY * 100 ));
1372  }
1373  return 0;
1374 }
1375 
1376 void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1377 {
1378  ScTabViewShell* pViewSh = GetViewShell();
1379  if (!pViewSh)
1380  return;
1381 
1382  if ( nZoom != GetZoom() && nZoom != 0 )
1383  {
1384  if (!pViewSh->GetViewData().IsPagebreakMode())
1385  {
1386  ScModule* pScMod = SC_MOD();
1387  ScAppOptions aNewOpt(pScMod->GetAppOptions());
1388  aNewOpt.SetZoom( nZoom );
1389  aNewOpt.SetZoomType( pViewSh->GetViewData().GetView()->GetZoomType() );
1390  pScMod->SetAppOptions( aNewOpt );
1391  }
1392  }
1393  Fraction aFract( nZoom, 100 );
1394  pViewSh->SetZoom( aFract, aFract, true );
1395  pViewSh->PaintGrid();
1396  pViewSh->PaintTop();
1397  pViewSh->PaintLeft();
1398  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1399  pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1400  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_IN);
1401  pViewSh->GetViewFrame()->GetBindings().Invalidate(SID_ZOOM_OUT);
1402 }
1403 
1404 sal_Int16 ScTabViewObj::GetZoomType() const
1405 {
1406  sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1407  ScTabViewShell* pViewSh = GetViewShell();
1408  if (pViewSh)
1409  {
1410  SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1411  switch (eZoomType)
1412  {
1413  case SvxZoomType::PERCENT:
1414  aZoomType = view::DocumentZoomType::BY_VALUE;
1415  break;
1416  case SvxZoomType::OPTIMAL:
1417  aZoomType = view::DocumentZoomType::OPTIMAL;
1418  break;
1419  case SvxZoomType::WHOLEPAGE:
1420  aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1421  break;
1422  case SvxZoomType::PAGEWIDTH:
1423  aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1424  break;
1425  case SvxZoomType::PAGEWIDTH_NOBORDER:
1426  aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1427  break;
1428  }
1429  }
1430  return aZoomType;
1431 }
1432 
1433 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1434 {
1435  ScTabViewShell* pViewSh = GetViewShell();
1436  if (!pViewSh)
1437  return;
1438 
1439  ScDBFunc* pView = pViewSh->GetViewData().GetView();
1440  if (!pView)
1441  return;
1442 
1443  SvxZoomType eZoomType;
1444  switch (aZoomType)
1445  {
1446  case view::DocumentZoomType::BY_VALUE:
1447  eZoomType = SvxZoomType::PERCENT;
1448  break;
1449  case view::DocumentZoomType::OPTIMAL:
1450  eZoomType = SvxZoomType::OPTIMAL;
1451  break;
1452  case view::DocumentZoomType::ENTIRE_PAGE:
1453  eZoomType = SvxZoomType::WHOLEPAGE;
1454  break;
1455  case view::DocumentZoomType::PAGE_WIDTH:
1456  eZoomType = SvxZoomType::PAGEWIDTH;
1457  break;
1458  case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1459  eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1460  break;
1461  default:
1462  eZoomType = SvxZoomType::OPTIMAL;
1463  }
1464  sal_Int16 nZoom(GetZoom());
1465  sal_Int16 nOldZoom(nZoom);
1466  if ( eZoomType == SvxZoomType::PERCENT )
1467  {
1468  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1469  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1470  }
1471  else
1472  nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1473 
1474  switch ( eZoomType )
1475  {
1476  case SvxZoomType::WHOLEPAGE:
1477  case SvxZoomType::PAGEWIDTH:
1478  pView->SetZoomType( eZoomType, true );
1479  break;
1480 
1481  default:
1482  pView->SetZoomType( SvxZoomType::PERCENT, true );
1483  }
1484  SetZoom( nZoom );
1485 }
1486 
1488 {
1489  SolarMutexGuard aGuard;
1490  // what menu slot SID_WINDOW_SPLIT does
1491 
1492  ScTabViewShell* pViewSh = GetViewShell();
1493  if (pViewSh)
1494  {
1495  ScViewData& rViewData = pViewSh->GetViewData();
1496  return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1497  rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1498  }
1499 
1500  return false;
1501 }
1502 
1504 {
1505  SolarMutexGuard aGuard;
1506  // what menu slot SID_WINDOW_FIX does
1507 
1508  ScTabViewShell* pViewSh = GetViewShell();
1509  if (pViewSh)
1510  {
1511  ScViewData& rViewData = pViewSh->GetViewData();
1512  return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1513  rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1514  }
1515 
1516  return false;
1517 }
1518 
1520 {
1521  SolarMutexGuard aGuard;
1522  ScTabViewShell* pViewSh = GetViewShell();
1523  if (pViewSh)
1524  {
1525  ScViewData& rViewData = pViewSh->GetViewData();
1526  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1527  return rViewData.GetHSplitPos();
1528  }
1529  return 0;
1530 }
1531 
1533 {
1534  SolarMutexGuard aGuard;
1535  ScTabViewShell* pViewSh = GetViewShell();
1536  if (pViewSh)
1537  {
1538  ScViewData& rViewData = pViewSh->GetViewData();
1539  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1540  return rViewData.GetVSplitPos();
1541  }
1542  return 0;
1543 }
1544 
1545 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1546 {
1547  SolarMutexGuard aGuard;
1548  ScTabViewShell* pViewSh = GetViewShell();
1549  if (pViewSh)
1550  {
1551  ScViewData& rViewData = pViewSh->GetViewData();
1552  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1553  {
1554  tools::Long nSplit = rViewData.GetHSplitPos();
1555 
1557  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1558  ePos = SC_SPLIT_TOPLEFT;
1559 
1560  SCCOL nCol;
1561  SCROW nRow;
1562  rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1563  if ( nCol > 0 )
1564  return nCol;
1565  }
1566  }
1567  return 0;
1568 }
1569 
1570 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow()
1571 {
1572  SolarMutexGuard aGuard;
1573  ScTabViewShell* pViewSh = GetViewShell();
1574  if (pViewSh)
1575  {
1576  ScViewData& rViewData = pViewSh->GetViewData();
1577  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1578  {
1579  tools::Long nSplit = rViewData.GetVSplitPos();
1580 
1581  // split vertically
1582  SCCOL nCol;
1583  SCROW nRow;
1584  rViewData.GetPosFromPixel( 0, nSplit, SC_SPLIT_TOPLEFT, nCol, nRow, false );
1585  if ( nRow > 0 )
1586  return nRow;
1587  }
1588  }
1589  return 0;
1590 }
1591 
1592 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1593 {
1594  SolarMutexGuard aGuard;
1595  ScTabViewShell* pViewSh = GetViewShell();
1596  if (pViewSh)
1597  {
1598  pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ) );
1599  pViewSh->FreezeSplitters( false );
1600  pViewSh->InvalidateSplit();
1601  }
1602 }
1603 
1604 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1605 {
1606  SolarMutexGuard aGuard;
1607  ScTabViewShell* pViewSh = GetViewShell();
1608  if (!pViewSh)
1609  return;
1610 
1611  // first, remove them all -> no stress with scrolling in the meantime
1612 
1613  pViewSh->RemoveSplit();
1614 
1615  Point aWinStart;
1616  vcl::Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1617  if (pWin)
1618  aWinStart = pWin->GetPosPixel();
1619 
1620  ScViewData& rViewData = pViewSh->GetViewData();
1621  Point aSplit(rViewData.GetScrPos( static_cast<SCCOL>(nColumns), static_cast<SCROW>(nRows), SC_SPLIT_BOTTOMLEFT, true ));
1622  aSplit += aWinStart;
1623 
1624  pViewSh->SplitAtPixel( aSplit );
1625  pViewSh->FreezeSplitters( true );
1626  pViewSh->InvalidateSplit();
1627 }
1628 
1630  const uno::Reference<view::XSelectionChangeListener>& xListener )
1631 {
1632  SolarMutexGuard aGuard;
1633  aSelectionChgListeners.push_back( xListener );
1634 }
1635 
1637  const uno::Reference< view::XSelectionChangeListener >& xListener )
1638 {
1639  SolarMutexGuard aGuard;
1640  auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener);
1641  if (it != aSelectionChgListeners.end())
1642  aSelectionChgListeners.erase(it);
1643 }
1644 
1646 {
1647  // Selection changed so end any style preview
1648  // Note: executing this slot through the dispatcher
1649  // will cause the style dialog to be raised so we go
1650  // direct here
1651  ScFormatShell aShell( GetViewShell()->GetViewData() );
1652  SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1653  SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1654  aShell.ExecuteStyle( aReq );
1655  lang::EventObject aEvent;
1656  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1657  for (const auto& rListener : aSelectionChgListeners)
1658  rListener->selectionChanged( aEvent );
1659 
1660  // handle sheet events
1661  ScTabViewShell* pViewSh = GetViewShell();
1662  ScViewData& rViewData = pViewSh->GetViewData();
1663  ScDocShell* pDocSh = rViewData.GetDocShell();
1664  ScDocument& rDoc = pDocSh->GetDocument();
1665  SCTAB nTab = rViewData.GetTabNo();
1666  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1667  if (pEvents)
1668  {
1669  const OUString* pScript = pEvents->GetScript(ScSheetEventId::SELECT);
1670  if (pScript)
1671  {
1672  // the macro parameter is the selection as returned by getSelection
1673  uno::Sequence<uno::Any> aParams(1);
1674  aParams[0] = getSelection();
1675  uno::Any aRet;
1676  uno::Sequence<sal_Int16> aOutArgsIndex;
1677  uno::Sequence<uno::Any> aOutArgs;
1678  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1679  }
1680  }
1681 
1682  SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
1683 
1684  if ( mbLeftMousePressed ) // selection still in progress
1685  return;
1686 
1687  try
1688  {
1689  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1690  uno::Sequence< uno::Any > aArgs( 1 );
1691  aArgs[ 0 ] = getSelection();
1692  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1693  }
1694  catch( uno::Exception& )
1695  {
1696  }
1697 }
1698 
1699 // XPropertySet (view options)
1701 
1702 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1703 {
1704  SolarMutexGuard aGuard;
1705  static uno::Reference<beans::XPropertySetInfo> aRef(
1707  return aRef;
1708 }
1709 
1711  const OUString& aPropertyName, const uno::Any& aValue )
1712 {
1713  SolarMutexGuard aGuard;
1714 
1715  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1716  {
1718  return;
1719  }
1720 
1721  ScTabViewShell* pViewSh = GetViewShell();
1722  if (!pViewSh)
1723  return;
1724 
1725  ScViewData& rViewData = pViewSh->GetViewData();
1726  const ScViewOptions& rOldOpt = pViewSh->GetViewData().GetOptions();
1727  ScViewOptions aNewOpt(rOldOpt);
1728 
1729  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1731  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1733  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1735  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1737  else if ( aPropertyName == SC_UNO_SHOWANCHOR )
1739  else if ( aPropertyName == SC_UNO_SHOWFORM )
1741  else if ( aPropertyName == SC_UNO_SHOWGRID )
1743  else if ( aPropertyName == SC_UNO_SHOWHELP )
1745  else if ( aPropertyName == SC_UNO_SHOWNOTES )
1747  else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
1749  else if ( aPropertyName == SC_UNO_SHOWZERO )
1751  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1753  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1755  else if ( aPropertyName == SC_UNO_SHOWOBJ )
1756  {
1757  sal_Int16 nIntVal = 0;
1758  if ( aValue >>= nIntVal )
1759  {
1760  //#i80528# adapt to new range eventually
1761  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1762 
1763  aNewOpt.SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
1764  }
1765  }
1766  else if ( aPropertyName == SC_UNO_SHOWCHARTS )
1767  {
1768  sal_Int16 nIntVal = 0;
1769  if ( aValue >>= nIntVal )
1770  {
1771  //#i80528# adapt to new range eventually
1772  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1773 
1774  aNewOpt.SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
1775  }
1776  }
1777  else if ( aPropertyName == SC_UNO_SHOWDRAW )
1778  {
1779  sal_Int16 nIntVal = 0;
1780  if ( aValue >>= nIntVal )
1781  {
1782  //#i80528# adapt to new range eventually
1783  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1784 
1785  aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
1786  }
1787  }
1788  else if ( aPropertyName == SC_UNO_GRIDCOLOR )
1789  {
1790  Color nIntVal;
1791  if ( aValue >>= nIntVal )
1792  aNewOpt.SetGridColor( nIntVal, OUString() );
1793  }
1794  else if ( aPropertyName == SC_UNO_ZOOMTYPE )
1795  {
1796  sal_Int16 nIntVal = 0;
1797  if ( aValue >>= nIntVal )
1798  SetZoomType(nIntVal);
1799  }
1800  else if ( aPropertyName == SC_UNO_ZOOMVALUE )
1801  {
1802  sal_Int16 nIntVal = 0;
1803  if ( aValue >>= nIntVal )
1804  SetZoom(nIntVal);
1805  }
1806 
1807  // Options are set on the view and document (for new views),
1808  // so that they remain during saving.
1811 
1812  if ( aNewOpt == rOldOpt )
1813  return;
1814 
1815  rViewData.SetOptions( aNewOpt );
1816  rViewData.GetDocument().SetViewOptions( aNewOpt );
1817  rViewData.GetDocShell()->SetDocumentModified();
1818 
1819  pViewSh->UpdateFixPos();
1820  pViewSh->PaintGrid();
1821  pViewSh->PaintTop();
1822  pViewSh->PaintLeft();
1823  pViewSh->PaintExtras();
1824  pViewSh->InvalidateBorder();
1825 
1826  SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1827  rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> check in menu
1828  rBindings.Invalidate( FID_TOGGLESYNTAX );
1829 }
1830 
1831 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1832 {
1833  SolarMutexGuard aGuard;
1834  uno::Any aRet;
1835 
1836  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1837  {
1838  aRet <<= bFilteredRangeSelection;
1839  return aRet;
1840  }
1841 
1842  ScTabViewShell* pViewSh = GetViewShell();
1843  if (pViewSh)
1844  {
1845  const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1846 
1847  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1848  aRet <<= rOpt.GetOption( VOPT_HEADER );
1849  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1850  aRet <<= rOpt.GetOption( VOPT_HSCROLL );
1851  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1852  aRet <<= rOpt.GetOption( VOPT_OUTLINER );
1853  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1854  aRet <<= rOpt.GetOption( VOPT_TABCONTROLS );
1855  else if ( aPropertyName == SC_UNO_SHOWANCHOR ) aRet <<= rOpt.GetOption( VOPT_ANCHOR );
1856  else if ( aPropertyName == SC_UNO_SHOWFORM ) aRet <<= rOpt.GetOption( VOPT_FORMULAS );
1857  else if ( aPropertyName == SC_UNO_SHOWGRID ) aRet <<= rOpt.GetOption( VOPT_GRID );
1858  else if ( aPropertyName == SC_UNO_SHOWHELP ) aRet <<= rOpt.GetOption( VOPT_HELPLINES );
1859  else if ( aPropertyName == SC_UNO_SHOWNOTES ) aRet <<= rOpt.GetOption( VOPT_NOTES );
1860  else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= rOpt.GetOption( VOPT_PAGEBREAKS );
1861  else if ( aPropertyName == SC_UNO_SHOWZERO ) aRet <<= rOpt.GetOption( VOPT_NULLVALS );
1862  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1863  aRet <<= rOpt.GetOption( VOPT_SYNTAX );
1864  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1865  aRet <<= rOpt.GetOption( VOPT_VSCROLL );
1866  else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1867  else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1868  else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1869  else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= rOpt.GetGridColor();
1870  else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1871  else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1872  else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1873  else if ( aPropertyName == SC_UNO_VISAREASCREEN )
1874  {
1875  ScViewData& rViewData = pViewSh->GetViewData();
1876  vcl::Window* pActiveWin = rViewData.GetActiveWin();
1877  if ( pActiveWin )
1878  {
1879  tools::Rectangle aRect = pActiveWin->GetWindowExtentsRelative( nullptr );
1880  aRet <<= AWTRectangle( aRect );
1881  }
1882  }
1883  }
1884 
1885  return aRet;
1886 }
1887 
1888 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1889  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1890 {
1891  SolarMutexGuard aGuard;
1892  aPropertyChgListeners.push_back( xListener );
1893 }
1894 
1895 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1896  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1897 {
1898  SolarMutexGuard aGuard;
1899  auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener);
1900  if (it != aPropertyChgListeners.end())
1901  aPropertyChgListeners.erase(it);
1902 }
1903 
1904 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
1905  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1906 {
1907 }
1908 
1909 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
1910  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1911 {
1912 }
1913 
1915 {
1916  beans::PropertyChangeEvent aEvent;
1917  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1918  for (const auto& rListener : aPropertyChgListeners)
1919  rListener->propertyChange( aEvent );
1920 }
1921 
1922 // XRangeSelection
1923 
1925  const uno::Sequence<beans::PropertyValue>& aArguments )
1926 {
1927  SolarMutexGuard aGuard;
1928  ScTabViewShell* pViewSh = GetViewShell();
1929  if (!pViewSh)
1930  return;
1931 
1932  OUString aInitVal, aTitle;
1933  bool bCloseOnButtonUp = false;
1934  bool bSingleCell = false;
1935  bool bMultiSelection = false;
1936 
1937  OUString aStrVal;
1938  for (const beans::PropertyValue& rProp : aArguments)
1939  {
1940  OUString aPropName(rProp.Name);
1941 
1942  if (aPropName == SC_UNONAME_CLOSEONUP )
1943  bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1944  else if (aPropName == SC_UNONAME_TITLE )
1945  {
1946  if ( rProp.Value >>= aStrVal )
1947  aTitle = aStrVal;
1948  }
1949  else if (aPropName == SC_UNONAME_INITVAL )
1950  {
1951  if ( rProp.Value >>= aStrVal )
1952  aInitVal = aStrVal;
1953  }
1954  else if (aPropName == SC_UNONAME_SINGLECELL )
1955  bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1956  else if (aPropName == SC_UNONAME_MULTISEL )
1957  bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1958  }
1959 
1960  pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
1961 }
1962 
1964 {
1965  SolarMutexGuard aGuard;
1966  ScTabViewShell* pViewSh = GetViewShell();
1967  if (pViewSh)
1968  pViewSh->StopSimpleRefDialog();
1969 }
1970 
1972  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1973 {
1974  SolarMutexGuard aGuard;
1975  aRangeSelListeners.push_back( xListener );
1976 }
1977 
1979  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1980 {
1981  SolarMutexGuard aGuard;
1982  auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
1983  if (it != aRangeSelListeners.end())
1984  aRangeSelListeners.erase(it);
1985 }
1986 
1988  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1989 {
1990  SolarMutexGuard aGuard;
1991  aRangeChgListeners.push_back( xListener );
1992 }
1993 
1995  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1996 {
1997  SolarMutexGuard aGuard;
1998  auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
1999  if (it != aRangeChgListeners.end())
2000  aRangeChgListeners.erase(it);
2001 }
2002 
2003 void ScTabViewObj::RangeSelDone( const OUString& rText )
2004 {
2005  sheet::RangeSelectionEvent aEvent;
2006  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2007  aEvent.RangeDescriptor = rText;
2008 
2009  // copy on the stack because listener could remove itself
2010  auto const listeners(aRangeSelListeners);
2011 
2012  for (const auto& rListener : listeners)
2013  rListener->done( aEvent );
2014 }
2015 
2016 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2017 {
2018  sheet::RangeSelectionEvent aEvent;
2019  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2020  aEvent.RangeDescriptor = rText;
2021 
2022  // copy on the stack because listener could remove itself
2023  auto const listeners(aRangeSelListeners);
2024 
2025  for (const auto& rListener : listeners)
2026  rListener->aborted( aEvent );
2027 }
2028 
2029 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2030 {
2031  sheet::RangeSelectionEvent aEvent;
2032  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2033  aEvent.RangeDescriptor = rText;
2034 
2035  // copy on the stack because listener could remove itself
2036  auto const listener(aRangeChgListeners);
2037 
2038  for (const auto& rListener : listener)
2039  rListener->descriptorChanged( aEvent );
2040 }
2041 
2042 // XServiceInfo
2044 {
2045  return "ScTabViewObj";
2046 }
2047 
2048 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2049 {
2050  return cppu::supportsService(this, rServiceName);
2051 }
2052 
2053 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2054 {
2056 }
2057 
2058 // XUnoTunnel
2059 
2061 
2062 css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2063 {
2064  SolarMutexGuard aGuard;
2065  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2066  if (pShell)
2067  return pShell->GetEditView()->GetTransferable();
2068 
2069  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2070  if (pTextShell)
2071  {
2072  ScViewData& rViewData = GetViewShell()->GetViewData();
2073  ScDrawView* pView = rViewData.GetScDrawView();
2074  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2075  if (pOutView)
2076  return pOutView->GetEditView().GetTransferable();
2077  }
2078 
2079  ScDrawShell* pDrawShell = dynamic_cast<ScDrawShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2080  if (pDrawShell)
2081  return pDrawShell->GetDrawView()->CopyToTransferable();
2082 
2084  uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2085  return xTransferable;
2086 }
2087 
2088 void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans )
2089 {
2090  SolarMutexGuard aGuard;
2091  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2092  if (pShell)
2093  pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2094  else
2095  {
2096  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2097  if (pTextShell)
2098  {
2099  ScViewData& rViewData = GetViewShell()->GetViewData();
2100  ScDrawView* pView = rViewData.GetScDrawView();
2101  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2102  if ( pOutView )
2103  {
2104  pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2105  return;
2106  }
2107  }
2108 
2109  GetViewShell()->PasteFromTransferable( xTrans );
2110  }
2111 }
2112 
2113 namespace {
2114 
2115 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2116 {
2117  uno::Sequence<sal_Int32> aRet(rSelected.size());
2118  size_t i = 0;
2119  for (const auto& rTab : rSelected)
2120  {
2121  aRet[i] = static_cast<sal_Int32>(rTab);
2122  ++i;
2123  }
2124 
2125  return aRet;
2126 }
2127 
2128 }
2129 
2130 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2131 {
2132  ScTabViewShell* pViewSh = GetViewShell();
2133  if (!pViewSh)
2134  return uno::Sequence<sal_Int32>();
2135 
2136  ScViewData& rViewData = pViewSh->GetViewData();
2137 
2138  // #i95280# when printing from the shell, the view is never activated,
2139  // so Excel view settings must also be evaluated here.
2140  ScExtDocOptions* pExtOpt = rViewData.GetDocument().GetExtDocOptions();
2141  if (pExtOpt && pExtOpt->IsChanged())
2142  {
2143  pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2144  pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2145  pExtOpt->SetChanged(false);
2146  }
2147 
2148  return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2149 }
2150 
2152  SfxBaseController(pViewSh),
2153  mpViewShell(pViewSh)
2154 {
2155  if (mpViewShell)
2157 }
2158 
2160 {
2161  if (mpViewShell)
2163 }
2164 
2166 {
2167  SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2168  return SfxBaseController::queryInterface(rType);
2169 }
2170 
2172 {
2173  SfxBaseController::acquire();
2174 }
2175 
2177 {
2178  SfxBaseController::release();
2179 }
2180 
2182 {
2183  if (rHint.GetId() == SfxHintId::Dying)
2184  mpViewShell = nullptr;
2185 }
2186 
2187 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2188 {
2189  ScPreview* p = mpViewShell ? mpViewShell->GetPreview() : nullptr;
2190  if (!p)
2191  return uno::Sequence<sal_Int32>();
2192 
2193  return toSequence(p->GetSelectedTabs());
2194 }
2195 
2196 /* 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:3046
virtual Point GetPosPixel() const
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:408
#define SC_UNO_COLROWHDR
Definition: unonames.hxx:535
void SetOption(ScViewOption eOpt, bool bNew)
Definition: viewopti.hxx:87
#define SC_UNO_SHOWCHARTS
Definition: unonames.hxx:542
#define SCVIEWSETTINGS_SERVICE
Definition: viewuno.cxx:116
virtual css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL getTransferable() override
Definition: viewuno.cxx:2062
bool mbLeftMousePressed
Definition: viewuno.hxx:171
bool hasValue()
std::vector< css::uno::Reference< css::beans::XPropertyChangeListener > > aPropertyChgListeners
Definition: viewuno.hxx:153
virtual void SAL_CALL removeRangeSelectionListener(const css::uno::Reference< css::sheet::XRangeSelectionListener > &aListener) override
Definition: viewuno.cxx:1978
#define SC_UNONAME_MULTISEL
Definition: unonames.hxx:641
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:413
ScAddress aStart
Definition: address.hxx:500
ScDocShell * GetDocShell() const
Definition: viewdata.hxx:354
void FreezeSplitters(bool bFreeze, SplitMethod eSplitMethod=SC_SPLIT_METHOD_CURSOR, SCCOLROW nFreezeIndex=-1)
Definition: tabview.cxx:1910
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:43
void RangeSelAborted(const OUString &rText)
Definition: viewuno.cxx:2016
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:710
virtual void SAL_CALL acquire() override
Definition: viewuno.cxx:2171
void ReadExtOptions(const ScExtDocOptions &rOpt)
Definition: viewdata.cxx:3431
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:335
MapMode GetDrawMapMode(bool bForce=false)
MapMode for the drawinglayer objects.
Definition: gridwin3.cxx:246
SCROW Row() const
Definition: address.hxx:262
ScVSplitPos
Definition: viewdata.hxx:47
ScDocShell * GetDocShell() const
Definition: cellsuno.hxx:242
virtual void SAL_CALL release() override
Definition: viewuno.cxx:428
static void lcl_CallActivate(ScDocShell *pDocSh, SCTAB nTab, ScSheetEventId nEvent)
Definition: viewuno.cxx:498
void PostPaintGridAll()
Definition: docsh3.cxx:180
#define SC_UNO_SHOWFORM
Definition: unonames.hxx:544
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:2432
#define SC_UNO_ZOOMVALUE
Definition: unonames.hxx:570
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:1987
bool PaintExtras()
Definition: tabview3.cxx:2751
#define OLD_UNO_HORSCROLL
Definition: unonames.hxx:580
#define SCTABVIEWOBJ_SERVICE
Definition: viewuno.cxx:115
#define SC_UNO_VALUEHIGH
Definition: unonames.hxx:551
void MarkRange(const ScRange &rRange, bool bSetCursor=true, bool bContinue=false)
Definition: tabview3.cxx:1683
bool IsChanged() const
Definition: scextopt.cxx:160
virtual void SAL_CALL startRangeSelection(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: viewuno.cxx:1924
SfxDispatcher * GetDispatcher()
ScViewPaneObj * GetObjectByIndex_Impl(sal_uInt16 nIndex) const
Definition: viewuno.cxx:986
#define SC_UNO_SHOWHELP
Definition: unonames.hxx:546
std::vector< css::uno::Reference< css::awt::XEnhancedMouseClickHandler > > aMouseClickHandlers
Definition: viewuno.hxx:155
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: viewuno.cxx:962
bool MousePressed(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1138
long Long
virtual void SAL_CALL splitAtPosition(sal_Int32 nPixelX, sal_Int32 nPixelY) override
Definition: viewuno.cxx:1592
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:704
Reference< XInterface > xTarget
virtual OUString SAL_CALL getImplementationName() override
Definition: viewuno.cxx:2043
bool IsMouseListening() const
Definition: viewuno.cxx:1122
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:387
void SetDocumentModified()
Definition: docsh.cxx:2820
const ContentProperties & rData
virtual void SAL_CALL removeEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1331
std::vector< css::uno::Reference< css::sheet::XRangeSelectionChangeListener > > aRangeChgListeners
Definition: viewuno.hxx:151
SCTAB GetTabNo() const
Definition: viewdata.hxx:395
#define OLD_UNO_SHEETTABS
Definition: unonames.hxx:582
constexpr SdrLayerID SC_LAYER_BACK(1)
void PaintGrid()
Definition: tabview3.cxx:2624
virtual void SAL_CALL setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn) override
Definition: viewuno.cxx:191
void Unmark()
Definition: tabview3.cxx:1719
ScAddress aEnd
Definition: address.hxx:501
Extended options held by an ScDocument containing additional settings for filters.
Definition: scextopt.hxx:77
ScSplitPos GetActivePart() const
Definition: viewdata.hxx:398
sal_Int16 GetZoomType() const
Definition: viewuno.cxx:1404
SdrMark * GetMark(size_t nNum) const
ScDocument & GetDocument() const
Definition: viewdata.hxx:380
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:1545
EditView * GetEditView()
Definition: editsh.hxx:63
void Invalidate(sal_uInt16 nId)
#define SC_UNONAME_SINGLECELL
Definition: unonames.hxx:640
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: viewuno.cxx:2048
UNO3_GETIMPLEMENTATION_IMPL(ScTabViewObj)
EmbeddedObjectRef * pObject
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:359
virtual void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: viewuno.cxx:2181
css::chart::ChartAxisLabelPosition ePos
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1341
const ScRangeList & GetRangeList() const
Definition: cellsuno.hxx:244
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:157
static const SfxItemPropertyMapEntry * lcl_GetViewOptPropertyMap()
Clipping Marks.
Definition: viewuno.cxx:78
SfxHintId GetId() const
#define SC_UNO_SHOWOBJ
Definition: unonames.hxx:548
void MarkFromRangeList(const ScRangeList &rList, bool bReset)
Definition: markdata.cxx:334
ScSplitPos
Definition: viewdata.hxx:45
SfxApplication * SfxGetpApp()
ScViewPaneObj(ScTabViewShell *pViewSh, sal_uInt16 nP)
Definition: viewuno.cxx:404
css::uno::Reference< css::drawing::XShapes > getSelectedXShapes()
Definition: viewuno.cxx:825
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: viewuno.cxx:1831
SCTAB nPreviousTab
Definition: viewuno.hxx:158
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:2165
#define SC_VIEWPANE_ACTIVE
Definition: viewuno.hxx:52
ScDrawView * GetDrawView()
Definition: drawsh5.cxx:680
virtual ~ScViewPaneObj() override
Definition: viewuno.cxx:409
void UpdateFixPos()
Definition: tabview.cxx:757
Reference< XController > xController
void PaintLeft()
Definition: tabview3.cxx:2700
tools::Long GetVSplitPos() const
Definition: viewdata.hxx:419
virtual void SAL_CALL addActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1344
#define SC_UNO_SHOWGRID
Definition: unonames.hxx:545
void InvalidateBorder()
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:2151
void SetZoom(sal_Int16 Zoom)
Definition: viewuno.cxx:1376
virtual void SAL_CALL insertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &xTrans) override
Definition: viewuno.cxx:2088
void RangeSelChanged(const OUString &rText)
Definition: viewuno.cxx:2029
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2621
std::vector< css::uno::Reference< css::view::XSelectionChangeListener > > aSelectionChgListeners
Definition: viewuno.hxx:147
bool IsMultiMarked() const
Definition: markdata.hxx:83
SCTAB GetSelectCount() const
Definition: markdata.cxx:195
void MarkDataChanged()
Definition: tabview3.cxx:1742
int nCount
virtual sal_Bool SAL_CALL isFormDesignMode() override
Definition: viewuno.cxx:325
virtual sal_Int32 SAL_CALL getSplitRow() override
Definition: viewuno.cxx:1570
bool MouseReleased(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1228
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3870
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:189
SCTAB Tab() const
Definition: address.hxx:271
void SetCursorOnly(bool bSet)
Definition: cellsuno.cxx:1719
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:666
void DoneBlockMode(bool bContinue=false)
Definition: tabview2.cxx:408
css::awt::Rectangle GetVisArea() const
Definition: viewuno.cxx:370
#define SC_UNO_SHOWPAGEBR
Definition: unonames.hxx:549
void UnmarkAll()
SCROW GetPosY(ScVSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1355
tools::Rectangle GetWindowExtentsRelative(const vcl::Window *pRelativeWindow) const
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:416
#define SC_UNO_VISAREA
Definition: unonames.hxx:568
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
void EndMouseListening()
Definition: viewuno.cxx:1287
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3074
ScViewData & GetViewData()
Definition: tabview.hxx:334
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:91
void PaintTop()
Definition: tabview3.cxx:2635
#define SC_QUERYINTERFACE(x)
Definition: miscuno.hxx:87
EditView & GetEditView() const
ScPreview * GetPreview()
Definition: prevwsh.hxx:117
void ScrollToObject(const SdrObject *pDrawObj)
Definition: tabview5.cxx:540
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: viewuno.cxx:2053
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2626
virtual void SAL_CALL addEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1321
#define OLD_UNO_VERTSCROLL
Definition: unonames.hxx:584
SdrObject * GetMarkedSdrObj() const
SC_DLLPUBLIC void SetAppOptions(const ScAppOptions &rOpt)
Definition: scmod.cxx:715
virtual void SAL_CALL release() override
Definition: viewuno.cxx:2176
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:418
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1056
T * get() const
vcl::Window * GetWindowByPos(ScSplitPos ePos) const
Definition: tabview.hxx:372
virtual sal_Bool SAL_CALL hasElements() override
Definition: viewuno.cxx:978
#define SC_UNO_SHOWDRAW
Definition: unonames.hxx:543
virtual sal_Int32 SAL_CALL getCount() override
Definition: viewuno.cxx:945
#define SC_UNONAME_TITLE
Definition: unonames.hxx:638
void EndActivationListening()
Definition: viewuno.cxx:1304
void StopSimpleRefDialog()
Definition: tabvwsh4.cxx:1144
bool IsMarked() const
Definition: markdata.hxx:82
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:1710
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:2313
void ExtendRangeListTables(ScRangeList *pList) const
Definition: markdata.cxx:447
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:149
ScMarkType
States GetSimpleArea() returns for the underlying selection marks, so the caller can react if the res...
Definition: viewdata.hxx:61
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1909
bool bFilteredRangeSelection
Definition: viewuno.hxx:160
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: viewuno.cxx:937
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:2694
sal_Int16 SCCOL
Definition: types.hxx:22
virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1629
virtual void SAL_CALL abortRangeSelection() override
Definition: viewuno.cxx:1963
#define SC_MOD()
Definition: scmod.hxx:250
SfxBindings & GetBindings()
tools::Long GetHSplitPos() const
Definition: viewdata.hxx:418
#define SC_UNO_GRIDCOLOR
Definition: unonames.hxx:536
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1942
const SdrMarkList & GetMarkedObjectList() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1794
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:728
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:465
tools::Long Width() const
void SetDrawShell(bool bActive)
Definition: tabvwsh4.cxx:593
size_t size() const
Definition: rangelst.hxx:90
virtual void SAL_CALL addRangeSelectionListener(const css::uno::Reference< css::sheet::XRangeSelectionListener > &aListener) override
Definition: viewuno.cxx:1971
sal_Int16 GetZoom() const
Definition: viewuno.cxx:1365
float u
unsigned char sal_Bool
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1170
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:541
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:3062
const OutlinerView * GetTextEditOutlinerView() const
virtual sal_Int32 SAL_CALL getFirstVisibleColumn() override
Definition: viewuno.cxx:174
ScTransferObj * CopyToTransferable()
Definition: viewfun3.cxx:429
virtual void SAL_CALL acquire() override
Definition: viewuno.cxx:488
const ScMarkData::MarkedTabsType & GetSelectedTabs() const
Definition: preview.hxx:161
ScPreviewShell * mpViewShell
Definition: viewuno.hxx:291
css::uno::Type const & get()
void InsertText(const OUString &rNew, bool bSelect=false)
#define SC_SIMPLE_SERVICE_INFO(ClassName, ClassNameAscii, ServiceAscii)
Definition: miscuno.hxx:64
void InvalidateSplit()
Definition: tabview.cxx:2109
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1971
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void InitOwnBlockMode()
Definition: tabview2.cxx:331
#define SC_UNO_SHOWZERO
Definition: unonames.hxx:550
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:2159
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument &rDoc)
Definition: viewutil.cxx:223
sal_uInt16 CalcZoom(SvxZoomType eType, sal_uInt16 nOldZoom)
Definition: tabview2.cxx:1180
ScTabViewShell * GetViewShell() const
Definition: viewuno.hxx:75
#define SC_UNO_VISAREASCREEN
Definition: unonames.hxx:573
void RemoveSplit()
Definition: tabview.cxx:2065
static ScViewData * GetViewData()
Definition: docsh4.cxx:2544
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
virtual sal_Bool SAL_CALL getIsWindowSplit() override
Definition: viewuno.cxx:1487
Base class for all functions.
Definition: fupoor.hxx:40
void SetZoom(sal_uInt16 nNew)
Definition: appoptio.hxx:42
#define SC_UNO_ZOOMTYPE
Definition: unonames.hxx:569
virtual void SAL_CALL freezeAtPosition(sal_Int32 nColumns, sal_Int32 nRows) override
Definition: viewuno.cxx:1604
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1904
void RangeSelDone(const OUString &rText)
Definition: viewuno.cxx:2003
#define SC_UNO_HORSCROLL
Definition: unonames.hxx:538
SCCOL Col() const
Definition: address.hxx:267
virtual css::uno::Reference< css::sheet::XSpreadsheet > SAL_CALL getActiveSheet() override
Definition: viewuno.cxx:1033
ScDBFunc * GetView() const
Definition: viewdata.cxx:852
virtual SdrLayerID GetLayer() const
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2187
const OUString * GetScript(ScSheetEventId nEvent) const
Definition: sheetevents.cxx:99
Point PixelToLogic(const Point &rDevicePt) const
SfxItemPropertySet aPropSet
Definition: viewuno.hxx:145
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:46
SdrObject * Next()
void SetDesignMode(bool _bDesignMode)
sal_Int32 SCROW
Definition: types.hxx:18
void SelectionChanged()
Definition: viewuno.cxx:1645
virtual sal_Int32 SAL_CALL getSplitHorizontal() override
Definition: viewuno.cxx:1519
virtual css::uno::Any SAL_CALL getSelection() override
Definition: viewuno.cxx:854
#define SC_UNO_SHEETTABS
Definition: unonames.hxx:540
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:1994
void StartSimpleRefDialog(const OUString &rTitle, const OUString &rInitVal, bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection)
Definition: tabvwsh4.cxx:1109
ScDrawView * GetScDrawView()
Definition: tabview.hxx:342
#define OLD_UNO_COLROWHDR
Definition: unonames.hxx:579
SdrPage * GetPage() const
#define SC_UNO_HIDESPELL
Definition: unonames.hxx:537
void PasteFromTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &rxTransferable)
Definition: viewfun3.cxx:620
#define SC_UNO_OUTLSYMB
Definition: unonames.hxx:539
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:653
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:322
virtual bool IsDesignMode() const override
really derive cell from range?
Definition: cellsuno.hxx:628
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:537
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPrintable?
Definition: viewuno.cxx:1702
void * p
Reference< XComponentContext > getProcessComponentContext()
virtual void SAL_CALL removeActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1354
const ScDocument & GetDocument() const
Definition: docsh.hxx:217
#define SC_UNO_SHOWNOTES
Definition: unonames.hxx:547
css::uno::Reference< css::uno::XInterface > GetClickedObject(const Point &rPoint) const
Definition: viewuno.cxx:1071
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2130
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:892
virtual sal_Int32 SAL_CALL getSplitVertical() override
Definition: viewuno.cxx:1532
#define SC_UNONAME_CLOSEONUP
Definition: unonames.hxx:639
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:912
void VisAreaChanged()
Definition: viewuno.cxx:1914
virtual sal_Bool SAL_CALL hasFrozenPanes() override
Definition: viewuno.cxx:1503
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:992
Color const & GetGridColor(OUString *pStrName=nullptr) const
Definition: viewopti.cxx:117
SdrPageView * GetSdrPageView() const
css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable()
Definition: drawvie4.cxx:374
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:413
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1193
#define OLD_UNO_OUTLSYMB
Definition: unonames.hxx:581
#define SC_UNO_FILTERED_RANGE_SELECTION
Definition: unonames.hxx:572
#define SC_QUERY_MULTIPLE(x, y)
Definition: miscuno.hxx:94
#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:552
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
virtual void SAL_CALL release() override
Definition: viewuno.cxx:493
void UpdateLayerLocks()
Definition: tabview5.cxx:346
bool IsPagebreakMode() const
Definition: viewdata.hxx:425
virtual void SAL_CALL setActiveSheet(const css::uno::Reference< css::sheet::XSpreadsheet > &xActiveSheet) override
Definition: viewuno.cxx:1047
ScSheetEventId
Definition: sheetevents.hxx:28
bool bDrawSelModeSet
Definition: viewuno.hxx:159
ScTabViewObj()=delete
#define SC_UNONAME_INITVAL
Definition: unonames.hxx:637
std::set< SCTAB > MarkedTabsType
Definition: markdata.hxx:46
virtual void SAL_CALL acquire() override
Definition: viewuno.cxx:423
SdrModel * GetModel() const
void ExecuteStyle(SfxRequest &rReq)
Definition: formatsh.cxx:248
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: viewuno.cxx:1895
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:1636
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:1888
void SetZoomType(sal_Int16 ZoomType)
Definition: viewuno.cxx:1433
void SplitAtPixel(const Point &rPixel)
Definition: tabview.cxx:2094
AnyEventRef aEvent
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:417
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
#define OLD_UNO_VALUEHIGH
Definition: unonames.hxx:583
sal_uInt16 GetPageCount() const
virtual css::uno::Type SAL_CALL getElementType() override
Definition: viewuno.cxx:972
sal_Int16 SCTAB
Definition: types.hxx:23
virtual ~ScViewPaneBase() override
Definition: viewuno.cxx:128
void SetDrawSelMode(bool bNew)
Definition: tabview.hxx:318
virtual ~ScTabViewObj() override
Definition: viewuno.cxx:450