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 }
1401 
1402 sal_Int16 ScTabViewObj::GetZoomType() const
1403 {
1404  sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1405  ScTabViewShell* pViewSh = GetViewShell();
1406  if (pViewSh)
1407  {
1408  SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1409  switch (eZoomType)
1410  {
1411  case SvxZoomType::PERCENT:
1412  aZoomType = view::DocumentZoomType::BY_VALUE;
1413  break;
1414  case SvxZoomType::OPTIMAL:
1415  aZoomType = view::DocumentZoomType::OPTIMAL;
1416  break;
1417  case SvxZoomType::WHOLEPAGE:
1418  aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1419  break;
1420  case SvxZoomType::PAGEWIDTH:
1421  aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1422  break;
1423  case SvxZoomType::PAGEWIDTH_NOBORDER:
1424  aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1425  break;
1426  }
1427  }
1428  return aZoomType;
1429 }
1430 
1431 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1432 {
1433  ScTabViewShell* pViewSh = GetViewShell();
1434  if (!pViewSh)
1435  return;
1436 
1437  ScDBFunc* pView = pViewSh->GetViewData().GetView();
1438  if (!pView)
1439  return;
1440 
1441  SvxZoomType eZoomType;
1442  switch (aZoomType)
1443  {
1444  case view::DocumentZoomType::BY_VALUE:
1445  eZoomType = SvxZoomType::PERCENT;
1446  break;
1447  case view::DocumentZoomType::OPTIMAL:
1448  eZoomType = SvxZoomType::OPTIMAL;
1449  break;
1450  case view::DocumentZoomType::ENTIRE_PAGE:
1451  eZoomType = SvxZoomType::WHOLEPAGE;
1452  break;
1453  case view::DocumentZoomType::PAGE_WIDTH:
1454  eZoomType = SvxZoomType::PAGEWIDTH;
1455  break;
1456  case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1457  eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1458  break;
1459  default:
1460  eZoomType = SvxZoomType::OPTIMAL;
1461  }
1462  sal_Int16 nZoom(GetZoom());
1463  sal_Int16 nOldZoom(nZoom);
1464  if ( eZoomType == SvxZoomType::PERCENT )
1465  {
1466  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1467  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1468  }
1469  else
1470  nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1471 
1472  switch ( eZoomType )
1473  {
1474  case SvxZoomType::WHOLEPAGE:
1475  case SvxZoomType::PAGEWIDTH:
1476  pView->SetZoomType( eZoomType, true );
1477  break;
1478 
1479  default:
1480  pView->SetZoomType( SvxZoomType::PERCENT, true );
1481  }
1482  SetZoom( nZoom );
1483 }
1484 
1486 {
1487  SolarMutexGuard aGuard;
1488  // what menu slot SID_WINDOW_SPLIT does
1489 
1490  ScTabViewShell* pViewSh = GetViewShell();
1491  if (pViewSh)
1492  {
1493  ScViewData& rViewData = pViewSh->GetViewData();
1494  return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1495  rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1496  }
1497 
1498  return false;
1499 }
1500 
1502 {
1503  SolarMutexGuard aGuard;
1504  // what menu slot SID_WINDOW_FIX does
1505 
1506  ScTabViewShell* pViewSh = GetViewShell();
1507  if (pViewSh)
1508  {
1509  ScViewData& rViewData = pViewSh->GetViewData();
1510  return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1511  rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1512  }
1513 
1514  return false;
1515 }
1516 
1518 {
1519  SolarMutexGuard aGuard;
1520  ScTabViewShell* pViewSh = GetViewShell();
1521  if (pViewSh)
1522  {
1523  ScViewData& rViewData = pViewSh->GetViewData();
1524  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1525  return rViewData.GetHSplitPos();
1526  }
1527  return 0;
1528 }
1529 
1531 {
1532  SolarMutexGuard aGuard;
1533  ScTabViewShell* pViewSh = GetViewShell();
1534  if (pViewSh)
1535  {
1536  ScViewData& rViewData = pViewSh->GetViewData();
1537  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1538  return rViewData.GetVSplitPos();
1539  }
1540  return 0;
1541 }
1542 
1543 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1544 {
1545  SolarMutexGuard aGuard;
1546  ScTabViewShell* pViewSh = GetViewShell();
1547  if (pViewSh)
1548  {
1549  ScViewData& rViewData = pViewSh->GetViewData();
1550  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1551  {
1552  tools::Long nSplit = rViewData.GetHSplitPos();
1553 
1555  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1556  ePos = SC_SPLIT_TOPLEFT;
1557 
1558  SCCOL nCol;
1559  SCROW nRow;
1560  rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1561  if ( nCol > 0 )
1562  return nCol;
1563  }
1564  }
1565  return 0;
1566 }
1567 
1568 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow()
1569 {
1570  SolarMutexGuard aGuard;
1571  ScTabViewShell* pViewSh = GetViewShell();
1572  if (pViewSh)
1573  {
1574  ScViewData& rViewData = pViewSh->GetViewData();
1575  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1576  {
1577  tools::Long nSplit = rViewData.GetVSplitPos();
1578 
1579  // split vertically
1580  SCCOL nCol;
1581  SCROW nRow;
1582  rViewData.GetPosFromPixel( 0, nSplit, SC_SPLIT_TOPLEFT, nCol, nRow, false );
1583  if ( nRow > 0 )
1584  return nRow;
1585  }
1586  }
1587  return 0;
1588 }
1589 
1590 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1591 {
1592  SolarMutexGuard aGuard;
1593  ScTabViewShell* pViewSh = GetViewShell();
1594  if (pViewSh)
1595  {
1596  pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ) );
1597  pViewSh->FreezeSplitters( false );
1598  pViewSh->InvalidateSplit();
1599  }
1600 }
1601 
1602 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1603 {
1604  SolarMutexGuard aGuard;
1605  ScTabViewShell* pViewSh = GetViewShell();
1606  if (!pViewSh)
1607  return;
1608 
1609  // first, remove them all -> no stress with scrolling in the meantime
1610 
1611  pViewSh->RemoveSplit();
1612 
1613  Point aWinStart;
1614  vcl::Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1615  if (pWin)
1616  aWinStart = pWin->GetPosPixel();
1617 
1618  ScViewData& rViewData = pViewSh->GetViewData();
1619  Point aSplit(rViewData.GetScrPos( static_cast<SCCOL>(nColumns), static_cast<SCROW>(nRows), SC_SPLIT_BOTTOMLEFT, true ));
1620  aSplit += aWinStart;
1621 
1622  pViewSh->SplitAtPixel( aSplit );
1623  pViewSh->FreezeSplitters( true );
1624  pViewSh->InvalidateSplit();
1625 }
1626 
1628  const uno::Reference<view::XSelectionChangeListener>& xListener )
1629 {
1630  SolarMutexGuard aGuard;
1631  aSelectionChgListeners.push_back( xListener );
1632 }
1633 
1635  const uno::Reference< view::XSelectionChangeListener >& xListener )
1636 {
1637  SolarMutexGuard aGuard;
1638  auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener);
1639  if (it != aSelectionChgListeners.end())
1640  aSelectionChgListeners.erase(it);
1641 }
1642 
1644 {
1645  // Selection changed so end any style preview
1646  // Note: executing this slot through the dispatcher
1647  // will cause the style dialog to be raised so we go
1648  // direct here
1649  ScFormatShell aShell( &GetViewShell()->GetViewData() );
1650  SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1651  SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1652  aShell.ExecuteStyle( aReq );
1653  lang::EventObject aEvent;
1654  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1655  for (const auto& rListener : aSelectionChgListeners)
1656  rListener->selectionChanged( aEvent );
1657 
1658  // handle sheet events
1659  ScTabViewShell* pViewSh = GetViewShell();
1660  ScViewData& rViewData = pViewSh->GetViewData();
1661  ScDocShell* pDocSh = rViewData.GetDocShell();
1662  ScDocument& rDoc = pDocSh->GetDocument();
1663  SCTAB nTab = rViewData.GetTabNo();
1664  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1665  if (pEvents)
1666  {
1667  const OUString* pScript = pEvents->GetScript(ScSheetEventId::SELECT);
1668  if (pScript)
1669  {
1670  // the macro parameter is the selection as returned by getSelection
1671  uno::Sequence<uno::Any> aParams(1);
1672  aParams[0] = getSelection();
1673  uno::Any aRet;
1674  uno::Sequence<sal_Int16> aOutArgsIndex;
1675  uno::Sequence<uno::Any> aOutArgs;
1676  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1677  }
1678  }
1679 
1680  SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
1681 
1682  if ( mbLeftMousePressed ) // selection still in progress
1683  return;
1684 
1685  try
1686  {
1687  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1688  uno::Sequence< uno::Any > aArgs( 1 );
1689  aArgs[ 0 ] = getSelection();
1690  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1691  }
1692  catch( uno::Exception& )
1693  {
1694  }
1695 }
1696 
1697 // XPropertySet (view options)
1699 
1700 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1701 {
1702  SolarMutexGuard aGuard;
1703  static uno::Reference<beans::XPropertySetInfo> aRef(
1705  return aRef;
1706 }
1707 
1709  const OUString& aPropertyName, const uno::Any& aValue )
1710 {
1711  SolarMutexGuard aGuard;
1712 
1713  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1714  {
1716  return;
1717  }
1718 
1719  ScTabViewShell* pViewSh = GetViewShell();
1720  if (!pViewSh)
1721  return;
1722 
1723  ScViewData& rViewData = pViewSh->GetViewData();
1724  const ScViewOptions& rOldOpt = pViewSh->GetViewData().GetOptions();
1725  ScViewOptions aNewOpt(rOldOpt);
1726 
1727  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1729  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1731  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1733  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1735  else if ( aPropertyName == SC_UNO_SHOWANCHOR )
1737  else if ( aPropertyName == SC_UNO_SHOWFORM )
1739  else if ( aPropertyName == SC_UNO_SHOWGRID )
1741  else if ( aPropertyName == SC_UNO_SHOWHELP )
1743  else if ( aPropertyName == SC_UNO_SHOWNOTES )
1745  else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
1747  else if ( aPropertyName == SC_UNO_SHOWZERO )
1749  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1751  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1753  else if ( aPropertyName == SC_UNO_SHOWOBJ )
1754  {
1755  sal_Int16 nIntVal = 0;
1756  if ( aValue >>= nIntVal )
1757  {
1758  //#i80528# adapt to new range eventually
1759  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1760 
1761  aNewOpt.SetObjMode( VOBJ_TYPE_OLE, static_cast<ScVObjMode>(nIntVal));
1762  }
1763  }
1764  else if ( aPropertyName == SC_UNO_SHOWCHARTS )
1765  {
1766  sal_Int16 nIntVal = 0;
1767  if ( aValue >>= nIntVal )
1768  {
1769  //#i80528# adapt to new range eventually
1770  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1771 
1772  aNewOpt.SetObjMode( VOBJ_TYPE_CHART, static_cast<ScVObjMode>(nIntVal));
1773  }
1774  }
1775  else if ( aPropertyName == SC_UNO_SHOWDRAW )
1776  {
1777  sal_Int16 nIntVal = 0;
1778  if ( aValue >>= nIntVal )
1779  {
1780  //#i80528# adapt to new range eventually
1781  if(sal_Int16(VOBJ_MODE_HIDE) < nIntVal) nIntVal = sal_Int16(VOBJ_MODE_SHOW);
1782 
1783  aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, static_cast<ScVObjMode>(nIntVal));
1784  }
1785  }
1786  else if ( aPropertyName == SC_UNO_GRIDCOLOR )
1787  {
1788  Color nIntVal;
1789  if ( aValue >>= nIntVal )
1790  aNewOpt.SetGridColor( nIntVal, OUString() );
1791  }
1792  else if ( aPropertyName == SC_UNO_ZOOMTYPE )
1793  {
1794  sal_Int16 nIntVal = 0;
1795  if ( aValue >>= nIntVal )
1796  SetZoomType(nIntVal);
1797  }
1798  else if ( aPropertyName == SC_UNO_ZOOMVALUE )
1799  {
1800  sal_Int16 nIntVal = 0;
1801  if ( aValue >>= nIntVal )
1802  SetZoom(nIntVal);
1803  }
1804 
1805  // Options are set on the view and document (for new views),
1806  // so that they remain during saving.
1809 
1810  if ( aNewOpt == rOldOpt )
1811  return;
1812 
1813  rViewData.SetOptions( aNewOpt );
1814  rViewData.GetDocument().SetViewOptions( aNewOpt );
1815  rViewData.GetDocShell()->SetDocumentModified();
1816 
1817  pViewSh->UpdateFixPos();
1818  pViewSh->PaintGrid();
1819  pViewSh->PaintTop();
1820  pViewSh->PaintLeft();
1821  pViewSh->PaintExtras();
1822  pViewSh->InvalidateBorder();
1823 
1824  SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1825  rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> check in menu
1826  rBindings.Invalidate( FID_TOGGLESYNTAX );
1827 }
1828 
1829 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1830 {
1831  SolarMutexGuard aGuard;
1832  uno::Any aRet;
1833 
1834  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1835  {
1836  aRet <<= bFilteredRangeSelection;
1837  return aRet;
1838  }
1839 
1840  ScTabViewShell* pViewSh = GetViewShell();
1841  if (pViewSh)
1842  {
1843  const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1844 
1845  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1846  aRet <<= rOpt.GetOption( VOPT_HEADER );
1847  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1848  aRet <<= rOpt.GetOption( VOPT_HSCROLL );
1849  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1850  aRet <<= rOpt.GetOption( VOPT_OUTLINER );
1851  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1852  aRet <<= rOpt.GetOption( VOPT_TABCONTROLS );
1853  else if ( aPropertyName == SC_UNO_SHOWANCHOR ) aRet <<= rOpt.GetOption( VOPT_ANCHOR );
1854  else if ( aPropertyName == SC_UNO_SHOWFORM ) aRet <<= rOpt.GetOption( VOPT_FORMULAS );
1855  else if ( aPropertyName == SC_UNO_SHOWGRID ) aRet <<= rOpt.GetOption( VOPT_GRID );
1856  else if ( aPropertyName == SC_UNO_SHOWHELP ) aRet <<= rOpt.GetOption( VOPT_HELPLINES );
1857  else if ( aPropertyName == SC_UNO_SHOWNOTES ) aRet <<= rOpt.GetOption( VOPT_NOTES );
1858  else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= rOpt.GetOption( VOPT_PAGEBREAKS );
1859  else if ( aPropertyName == SC_UNO_SHOWZERO ) aRet <<= rOpt.GetOption( VOPT_NULLVALS );
1860  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1861  aRet <<= rOpt.GetOption( VOPT_SYNTAX );
1862  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1863  aRet <<= rOpt.GetOption( VOPT_VSCROLL );
1864  else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1865  else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1866  else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1867  else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= rOpt.GetGridColor();
1868  else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1869  else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1870  else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1871  else if ( aPropertyName == SC_UNO_VISAREASCREEN )
1872  {
1873  ScViewData& rViewData = pViewSh->GetViewData();
1874  vcl::Window* pActiveWin = rViewData.GetActiveWin();
1875  if ( pActiveWin )
1876  {
1877  tools::Rectangle aRect = pActiveWin->GetWindowExtentsRelative( nullptr );
1878  aRet <<= AWTRectangle( aRect );
1879  }
1880  }
1881  }
1882 
1883  return aRet;
1884 }
1885 
1886 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1887  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1888 {
1889  SolarMutexGuard aGuard;
1890  aPropertyChgListeners.push_back( xListener );
1891 }
1892 
1893 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1894  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1895 {
1896  SolarMutexGuard aGuard;
1897  auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener);
1898  if (it != aPropertyChgListeners.end())
1899  aPropertyChgListeners.erase(it);
1900 }
1901 
1902 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
1903  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1904 {
1905 }
1906 
1907 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
1908  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1909 {
1910 }
1911 
1913 {
1914  beans::PropertyChangeEvent aEvent;
1915  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1916  for (const auto& rListener : aPropertyChgListeners)
1917  rListener->propertyChange( aEvent );
1918 }
1919 
1920 // XRangeSelection
1921 
1923  const uno::Sequence<beans::PropertyValue>& aArguments )
1924 {
1925  SolarMutexGuard aGuard;
1926  ScTabViewShell* pViewSh = GetViewShell();
1927  if (!pViewSh)
1928  return;
1929 
1930  OUString aInitVal, aTitle;
1931  bool bCloseOnButtonUp = false;
1932  bool bSingleCell = false;
1933  bool bMultiSelection = false;
1934 
1935  OUString aStrVal;
1936  for (const beans::PropertyValue& rProp : aArguments)
1937  {
1938  OUString aPropName(rProp.Name);
1939 
1940  if (aPropName == SC_UNONAME_CLOSEONUP )
1941  bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1942  else if (aPropName == SC_UNONAME_TITLE )
1943  {
1944  if ( rProp.Value >>= aStrVal )
1945  aTitle = aStrVal;
1946  }
1947  else if (aPropName == SC_UNONAME_INITVAL )
1948  {
1949  if ( rProp.Value >>= aStrVal )
1950  aInitVal = aStrVal;
1951  }
1952  else if (aPropName == SC_UNONAME_SINGLECELL )
1953  bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1954  else if (aPropName == SC_UNONAME_MULTISEL )
1955  bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
1956  }
1957 
1958  pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
1959 }
1960 
1962 {
1963  SolarMutexGuard aGuard;
1964  ScTabViewShell* pViewSh = GetViewShell();
1965  if (pViewSh)
1966  pViewSh->StopSimpleRefDialog();
1967 }
1968 
1970  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1971 {
1972  SolarMutexGuard aGuard;
1973  aRangeSelListeners.push_back( xListener );
1974 }
1975 
1977  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1978 {
1979  SolarMutexGuard aGuard;
1980  auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
1981  if (it != aRangeSelListeners.end())
1982  aRangeSelListeners.erase(it);
1983 }
1984 
1986  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1987 {
1988  SolarMutexGuard aGuard;
1989  aRangeChgListeners.push_back( xListener );
1990 }
1991 
1993  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1994 {
1995  SolarMutexGuard aGuard;
1996  auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
1997  if (it != aRangeChgListeners.end())
1998  aRangeChgListeners.erase(it);
1999 }
2000 
2001 void ScTabViewObj::RangeSelDone( const OUString& rText )
2002 {
2003  sheet::RangeSelectionEvent aEvent;
2004  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2005  aEvent.RangeDescriptor = rText;
2006 
2007  // copy on the stack because listener could remove itself
2008  auto const listeners(aRangeSelListeners);
2009 
2010  for (const auto& rListener : listeners)
2011  rListener->done( aEvent );
2012 }
2013 
2014 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2015 {
2016  sheet::RangeSelectionEvent aEvent;
2017  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2018  aEvent.RangeDescriptor = rText;
2019 
2020  // copy on the stack because listener could remove itself
2021  auto const listeners(aRangeSelListeners);
2022 
2023  for (const auto& rListener : listeners)
2024  rListener->aborted( aEvent );
2025 }
2026 
2027 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2028 {
2029  sheet::RangeSelectionEvent aEvent;
2030  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2031  aEvent.RangeDescriptor = rText;
2032 
2033  // copy on the stack because listener could remove itself
2034  auto const listener(aRangeChgListeners);
2035 
2036  for (const auto& rListener : listener)
2037  rListener->descriptorChanged( aEvent );
2038 }
2039 
2040 // XServiceInfo
2042 {
2043  return "ScTabViewObj";
2044 }
2045 
2046 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2047 {
2048  return cppu::supportsService(this, rServiceName);
2049 }
2050 
2051 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2052 {
2054 }
2055 
2056 // XUnoTunnel
2057 
2059 
2060 css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2061 {
2062  SolarMutexGuard aGuard;
2063  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2064  if (pShell)
2065  return pShell->GetEditView()->GetTransferable();
2066 
2067  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2068  if (pTextShell)
2069  {
2070  ScViewData& rViewData = GetViewShell()->GetViewData();
2071  ScDrawView* pView = rViewData.GetScDrawView();
2072  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2073  if (pOutView)
2074  return pOutView->GetEditView().GetTransferable();
2075  }
2076 
2077  ScDrawShell* pDrawShell = dynamic_cast<ScDrawShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2078  if (pDrawShell)
2079  return pDrawShell->GetDrawView()->CopyToTransferable();
2080 
2082  uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2083  return xTransferable;
2084 }
2085 
2086 void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans )
2087 {
2088  SolarMutexGuard aGuard;
2089  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2090  if (pShell)
2091  pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2092  else
2093  {
2094  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2095  if (pTextShell)
2096  {
2097  ScViewData& rViewData = GetViewShell()->GetViewData();
2098  ScDrawView* pView = rViewData.GetScDrawView();
2099  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2100  if ( pOutView )
2101  {
2102  pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2103  return;
2104  }
2105  }
2106 
2107  GetViewShell()->PasteFromTransferable( xTrans );
2108  }
2109 }
2110 
2111 namespace {
2112 
2113 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2114 {
2115  uno::Sequence<sal_Int32> aRet(rSelected.size());
2116  size_t i = 0;
2117  for (const auto& rTab : rSelected)
2118  {
2119  aRet[i] = static_cast<sal_Int32>(rTab);
2120  ++i;
2121  }
2122 
2123  return aRet;
2124 }
2125 
2126 }
2127 
2128 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2129 {
2130  ScTabViewShell* pViewSh = GetViewShell();
2131  if (!pViewSh)
2132  return uno::Sequence<sal_Int32>();
2133 
2134  ScViewData& rViewData = pViewSh->GetViewData();
2135 
2136  // #i95280# when printing from the shell, the view is never activated,
2137  // so Excel view settings must also be evaluated here.
2138  ScExtDocOptions* pExtOpt = rViewData.GetDocument().GetExtDocOptions();
2139  if (pExtOpt && pExtOpt->IsChanged())
2140  {
2141  pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2142  pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2143  pExtOpt->SetChanged(false);
2144  }
2145 
2146  return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2147 }
2148 
2150  SfxBaseController(pViewSh),
2151  mpViewShell(pViewSh)
2152 {
2153  if (mpViewShell)
2155 }
2156 
2158 {
2159  if (mpViewShell)
2161 }
2162 
2164 {
2165  SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2166  return SfxBaseController::queryInterface(rType);
2167 }
2168 
2170 {
2171  SfxBaseController::acquire();
2172 }
2173 
2175 {
2176  SfxBaseController::release();
2177 }
2178 
2180 {
2181  if (rHint.GetId() == SfxHintId::Dying)
2182  mpViewShell = nullptr;
2183 }
2184 
2185 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2186 {
2187  ScPreview* p = mpViewShell ? mpViewShell->GetPreview() : nullptr;
2188  if (!p)
2189  return uno::Sequence<sal_Int32>();
2190 
2191  return toSequence(p->GetSelectedTabs());
2192 }
2193 
2194 /* 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:77
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3046
virtual Point GetPosPixel() const
SfxViewFrame * GetViewFrame() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:403
#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:2060
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:1976
#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:1906
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:2014
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:710
virtual void SAL_CALL acquire() override
Definition: viewuno.cxx:2169
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:336
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:181
#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:2435
#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:1985
bool PaintExtras()
Definition: tabview3.cxx:2748
#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:1682
bool IsChanged() const
Definition: scextopt.cxx:160
virtual void SAL_CALL startRangeSelection(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: viewuno.cxx:1922
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:1590
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:704
Reference< XInterface > xTarget
virtual OUString SAL_CALL getImplementationName() override
Definition: viewuno.cxx:2041
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:2819
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:2621
virtual void SAL_CALL setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn) override
Definition: viewuno.cxx:191
void Unmark()
Definition: tabview3.cxx:1718
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:1402
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:1543
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:2046
UNO3_GETIMPLEMENTATION_IMPL(ScTabViewObj)
EmbeddedObjectRef * pObject
SC_DLLPUBLIC void SetCursor(SCCOL nPosX, SCROW nPosY, bool bNew=false)
Definition: tabview3.cxx:358
virtual void Notify(SfxBroadcaster &, const SfxHint &rHint) override
Definition: viewuno.cxx:2179
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:1829
SCTAB nPreviousTab
Definition: viewuno.hxx:158
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:2163
#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:755
Reference< XController > xController
void PaintLeft()
Definition: tabview3.cxx:2697
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:2149
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:2086
void RangeSelChanged(const OUString &rText)
Definition: viewuno.cxx:2027
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:1741
int nCount
virtual sal_Bool SAL_CALL isFormDesignMode() override
Definition: viewuno.cxx:325
virtual sal_Int32 SAL_CALL getSplitRow() override
Definition: viewuno.cxx:1568
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:191
SCTAB Tab() const
Definition: address.hxx:271
void SetCursorOnly(bool bSet)
Definition: cellsuno.cxx:1720
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:667
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:332
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:91
void PaintTop()
Definition: tabview3.cxx:2632
#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:535
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: viewuno.cxx:2051
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:719
virtual void SAL_CALL release() override
Definition: viewuno.cxx:2174
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:413
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1059
T * get() const
vcl::Window * GetWindowByPos(ScSplitPos ePos) const
Definition: tabview.hxx:370
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:1147
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:1708
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:1907
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:1627
virtual void SAL_CALL abortRangeSelection() override
Definition: viewuno.cxx:1961
#define SC_MOD()
Definition: scmod.hxx:253
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:1943
const SdrMarkList & GetMarkedObjectList() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1793
SC_DLLPUBLIC const ScAppOptions & GetAppOptions()
Definition: scmod.cxx:732
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:596
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:1969
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:428
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:2105
SC_DLLPUBLIC tools::Rectangle GetMMRect(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero=true) const
Definition: documen3.cxx:1972
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:2157
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:2061
static ScViewData * GetViewData()
Definition: docsh4.cxx:2540
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
virtual sal_Bool SAL_CALL getIsWindowSplit() override
Definition: viewuno.cxx:1485
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:1602
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1902
void RangeSelDone(const OUString &rText)
Definition: viewuno.cxx:2001
#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:2185
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:1643
virtual sal_Int32 SAL_CALL getSplitHorizontal() override
Definition: viewuno.cxx:1517
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:1992
void StartSimpleRefDialog(const OUString &rTitle, const OUString &rInitVal, bool bCloseOnButtonUp, bool bSingleCell, bool bMultiSelection)
Definition: tabvwsh4.cxx:1112
ScDrawView * GetScDrawView()
Definition: tabview.hxx:340
#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:619
#define SC_UNO_OUTLSYMB
Definition: unonames.hxx:539
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:654
FuPoor * GetDrawFuncPtr()
Definition: tabview.hxx:320
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:1700
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:216
#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:2128
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:892
virtual sal_Int32 SAL_CALL getSplitVertical() override
Definition: viewuno.cxx:1530
#define SC_UNONAME_CLOSEONUP
Definition: unonames.hxx:639
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:911
void VisAreaChanged()
Definition: viewuno.cxx:1912
virtual sal_Bool SAL_CALL hasFrozenPanes() override
Definition: viewuno.cxx:1501
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:994
Color const & GetGridColor(OUString *pStrName=nullptr) const
Definition: viewopti.cxx:121
SdrPageView * GetSdrPageView() const
css::uno::Reference< css::datatransfer::XTransferable > CopyToTransferable()
Definition: drawvie4.cxx:374
void SetZoomType(SvxZoomType eNew, bool bAll)
Definition: tabview5.cxx:408
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:76
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:341
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:249
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: viewuno.cxx:1893
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:1634
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:1886
void SetZoomType(sal_Int16 ZoomType)
Definition: viewuno.cxx:1431
void SplitAtPixel(const Point &rPixel)
Definition: tabview.cxx:2090
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:316
virtual ~ScTabViewObj() override
Definition: viewuno.cxx:450