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  {
82  {OUString(OLD_UNO_COLROWHDR), 0, cppu::UnoType<bool>::get(), 0, 0},
83  {OUString(SC_UNO_GRIDCOLOR), 0, cppu::UnoType<sal_Int32>::get(), 0, 0},
84  {OUString(SC_UNO_COLROWHDR), 0, cppu::UnoType<bool>::get(), 0, 0},
85  {OUString(SC_UNO_HORSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
86  {OUString(SC_UNO_SHEETTABS), 0, cppu::UnoType<bool>::get(), 0, 0},
87  {OUString(SC_UNO_VERTSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
88  {OUString(SC_UNO_HIDESPELL), 0, cppu::UnoType<bool>::get(), 0, 0}, /* deprecated #i91949 */
89  {OUString(OLD_UNO_HORSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
90  {OUString(SC_UNO_OUTLSYMB), 0, cppu::UnoType<bool>::get(), 0, 0},
91  {OUString(SC_UNO_VALUEHIGH), 0, cppu::UnoType<bool>::get(), 0, 0},
92  {OUString(OLD_UNO_OUTLSYMB), 0, cppu::UnoType<bool>::get(), 0, 0},
93  {OUString(OLD_UNO_SHEETTABS), 0, cppu::UnoType<bool>::get(), 0, 0},
94  {OUString(SC_UNO_SHOWANCHOR), 0, cppu::UnoType<bool>::get(), 0, 0},
95  {OUString(SC_UNO_SHOWCHARTS), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
96  {OUString(SC_UNO_SHOWDRAW), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
97  {OUString(SC_UNO_SHOWFORM), 0, cppu::UnoType<bool>::get(), 0, 0},
98  {OUString(SC_UNO_SHOWGRID), 0, cppu::UnoType<bool>::get(), 0, 0},
99  {OUString(SC_UNO_SHOWHELP), 0, cppu::UnoType<bool>::get(), 0, 0},
100  {OUString(SC_UNO_SHOWNOTES), 0, cppu::UnoType<bool>::get(), 0, 0},
101  {OUString(SC_UNO_SHOWOBJ), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
102  {OUString(SC_UNO_SHOWPAGEBR), 0, cppu::UnoType<bool>::get(), 0, 0},
103  {OUString(SC_UNO_SHOWZERO), 0, cppu::UnoType<bool>::get(), 0, 0},
104  {OUString(OLD_UNO_VALUEHIGH), 0, cppu::UnoType<bool>::get(), 0, 0},
105  {OUString(OLD_UNO_VERTSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
106  {OUString(SC_UNO_VISAREA), 0, cppu::UnoType<awt::Rectangle>::get(), 0, 0},
107  {OUString(SC_UNO_ZOOMTYPE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
108  {OUString(SC_UNO_ZOOMVALUE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
110  { OUString(), 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  long nDeltaX = static_cast<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  long nDeltaY = static_cast<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* pDoc = pViewShell->GetViewData().GetDocument();
380  if (pWindow && pDoc)
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( pDoc->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 ( pDoc->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  long nCount = xShapeColl->getCount();
770  if (nCount)
771  {
772  SdrPageView* pPV = nullptr;
773  bool bAllMarked(true);
774  for ( 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  {
1055  // XSpreadsheet and ScCellRangesBase -> has to be the same sheet
1056 
1057  ScCellRangesBase* pRangesImp = comphelper::getUnoTunnelImplementation<ScCellRangesBase>( xActiveSheet );
1058  if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == pRangesImp->GetDocShell() )
1059  {
1060  const ScRangeList& rRanges = pRangesImp->GetRangeList();
1061  if ( rRanges.size() == 1 )
1062  {
1063  SCTAB nNewTab = rRanges[ 0 ].aStart.Tab();
1064  if ( pViewSh->GetViewData().GetDocument()->HasTable(nNewTab) )
1065  pViewSh->SetTabNo( nNewTab );
1066  }
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* pDoc = rData.GetDocument();
1089  if (pDoc && pDoc->GetDrawLayer())
1090  {
1091  SdrPage* pDrawPage = nullptr;
1092  ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1093  if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1094  pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1095 
1096  SdrView* pDrawView = GetViewShell()->GetScDrawView();
1097 
1098  if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1099  {
1100  vcl::Window* pActiveWin = rData.GetActiveWin();
1101  Point aPos = pActiveWin->PixelToLogic(rPoint);
1102 
1103  sal_uInt16 nHitLog = static_cast<sal_uInt16>(pActiveWin->PixelToLogic(
1104  Size(pDrawView->GetHitTolerancePixel(),0)).Width());
1105 
1106  const size_t nCount(pDrawPage->GetObjCount());
1107  bool bFound(false);
1108  for (size_t i = 0; i < nCount && !bFound; ++i)
1109  {
1110  SdrObject* pObj = pDrawPage->GetObj(i);
1111  if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), nullptr, false))
1112  {
1113  xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1114  bFound = true;
1115  }
1116  }
1117  }
1118  }
1119  }
1120  return xTarget;
1121 }
1122 
1124 {
1125  if ( !aMouseClickHandlers.empty() )
1126  return true;
1127 
1128  // also include sheet events, because MousePressed must be called for them
1129  ScViewData& rViewData = GetViewShell()->GetViewData();
1130  ScDocument* pDoc = rViewData.GetDocument();
1131  SCTAB nTab = rViewData.GetTabNo();
1132  return
1133  pDoc->HasSheetEventScript( nTab, ScSheetEventId::RIGHTCLICK, true ) ||
1134  pDoc->HasSheetEventScript( nTab, ScSheetEventId::DOUBLECLICK, true ) ||
1135  pDoc->HasSheetEventScript( nTab, ScSheetEventId::SELECT, true );
1136 
1137 }
1138 
1139 bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1140 {
1141  bool bReturn(false);
1142  if ( e.Buttons == css::awt::MouseButton::LEFT )
1143  mbLeftMousePressed = true;
1144 
1145  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1146  if (!aMouseClickHandlers.empty() && xTarget.is())
1147  {
1148  awt::EnhancedMouseEvent aMouseEvent;
1149 
1150  aMouseEvent.Buttons = e.Buttons;
1151  aMouseEvent.X = e.X;
1152  aMouseEvent.Y = e.Y;
1153  aMouseEvent.ClickCount = e.ClickCount;
1154  aMouseEvent.PopupTrigger = e.PopupTrigger;
1155  aMouseEvent.Target = xTarget;
1156  aMouseEvent.Modifiers = e.Modifiers;
1157 
1158  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1159  {
1160  try
1161  {
1162  if (!(*it)->mousePressed( aMouseEvent ))
1163  bReturn = true;
1164  ++it;
1165  }
1166  catch ( uno::Exception& )
1167  {
1168  it = aMouseClickHandlers.erase(it);
1169  }
1170  }
1171  }
1172 
1173  // handle sheet events
1174  bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1175  bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1176  if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1177  {
1179 
1180  ScTabViewShell* pViewSh = GetViewShell();
1181  ScViewData& rViewData = pViewSh->GetViewData();
1182  ScDocShell* pDocSh = rViewData.GetDocShell();
1183  ScDocument& rDoc = pDocSh->GetDocument();
1184  SCTAB nTab = rViewData.GetTabNo();
1185  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1186  if (pEvents)
1187  {
1188  const OUString* pScript = pEvents->GetScript(nEvent);
1189  if (pScript)
1190  {
1191  // the macro parameter is the clicked object, as in the mousePressed call above
1192  uno::Sequence<uno::Any> aParams(1);
1193  aParams[0] <<= xTarget;
1194 
1195  uno::Any aRet;
1196  uno::Sequence<sal_Int16> aOutArgsIndex;
1197  uno::Sequence<uno::Any> aOutArgs;
1198 
1199  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1200 
1201  // look for a boolean return value of true
1202  bool bRetValue = false;
1203  if ((aRet >>= bRetValue) && bRetValue)
1204  bReturn = true;
1205  }
1206  }
1207 
1208  // execute VBA event handler
1209  if (!bReturn && xTarget.is()) try
1210  {
1211  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1212  // the parameter is the clicked object, as in the mousePressed call above
1213  uno::Sequence< uno::Any > aArgs( 1 );
1214  aArgs[ 0 ] <<= xTarget;
1215  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1216  }
1217  catch( util::VetoException& )
1218  {
1219  bReturn = true;
1220  }
1221  catch( uno::Exception& )
1222  {
1223  }
1224  }
1225 
1226  return bReturn;
1227 }
1228 
1229 bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1230 {
1231  if ( e.Buttons == css::awt::MouseButton::LEFT )
1232  {
1233  try
1234  {
1235  ScTabViewShell* pViewSh = GetViewShell();
1236  ScViewData& rViewData = pViewSh->GetViewData();
1237  ScDocShell* pDocSh = rViewData.GetDocShell();
1238  ScDocument& rDoc = pDocSh->GetDocument();
1239  uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1240  uno::Sequence< uno::Any > aArgs( 1 );
1241  aArgs[ 0 ] = getSelection();
1242  xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( ScSheetEventId::SELECT ), aArgs );
1243  }
1244  catch( uno::Exception& )
1245  {
1246  }
1247  mbLeftMousePressed = false;
1248  }
1249 
1250  bool bReturn(false);
1251 
1252  if (!aMouseClickHandlers.empty())
1253  {
1254  uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1255 
1256  if (xTarget.is())
1257  {
1258  awt::EnhancedMouseEvent aMouseEvent;
1259 
1260  aMouseEvent.Buttons = e.Buttons;
1261  aMouseEvent.X = e.X;
1262  aMouseEvent.Y = e.Y;
1263  aMouseEvent.ClickCount = e.ClickCount;
1264  aMouseEvent.PopupTrigger = e.PopupTrigger;
1265  aMouseEvent.Target = xTarget;
1266  aMouseEvent.Modifiers = e.Modifiers;
1267 
1268  for (auto it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1269  {
1270  try
1271  {
1272  if (!(*it)->mouseReleased( aMouseEvent ))
1273  bReturn = true;
1274  ++it;
1275  }
1276  catch ( uno::Exception& )
1277  {
1278  it = aMouseClickHandlers.erase(it);
1279  }
1280  }
1281  }
1282  }
1283  return bReturn;
1284 }
1285 
1286 // XEnhancedMouseClickBroadcaster
1287 
1289 {
1290  lang::EventObject aEvent;
1291  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1292  for (const auto& rListener : aMouseClickHandlers)
1293  {
1294  try
1295  {
1296  rListener->disposing(aEvent);
1297  }
1298  catch ( uno::Exception& )
1299  {
1300  }
1301  }
1302  aMouseClickHandlers.clear();
1303 }
1304 
1306 {
1307  lang::EventObject aEvent;
1308  aEvent.Source = static_cast<cppu::OWeakObject*>(this);
1309  for (const auto& rListener : aActivationListeners)
1310  {
1311  try
1312  {
1313  rListener->disposing(aEvent);
1314  }
1315  catch ( uno::Exception& )
1316  {
1317  }
1318  }
1319  aActivationListeners.clear();
1320 }
1321 
1322 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1323 {
1324  SolarMutexGuard aGuard;
1325 
1326  if (aListener.is())
1327  {
1328  aMouseClickHandlers.push_back( aListener );
1329  }
1330 }
1331 
1332 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1333 {
1334  SolarMutexGuard aGuard;
1335  sal_uInt16 nCount = aMouseClickHandlers.size();
1336  aMouseClickHandlers.erase(
1337  std::remove(aMouseClickHandlers.begin(), aMouseClickHandlers.end(), aListener),
1338  aMouseClickHandlers.end());
1339  if (aMouseClickHandlers.empty() && (nCount > 0)) // only if last listener removed
1341 }
1342 
1343 // XActivationBroadcaster
1344 
1345 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1346 {
1347  SolarMutexGuard aGuard;
1348 
1349  if (aListener.is())
1350  {
1351  aActivationListeners.push_back( aListener );
1352  }
1353 }
1354 
1355 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1356 {
1357  SolarMutexGuard aGuard;
1358  sal_uInt16 nCount = aActivationListeners.size();
1359  aActivationListeners.erase(
1360  std::remove(aActivationListeners.begin(), aActivationListeners.end(), aListener),
1361  aActivationListeners.end());
1362  if (aActivationListeners.empty() && (nCount > 0)) // only if last listener removed
1364 }
1365 
1366 sal_Int16 ScTabViewObj::GetZoom() const
1367 {
1368  ScTabViewShell* pViewSh = GetViewShell();
1369  if (pViewSh)
1370  {
1371  const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y will be shown
1372  return static_cast<sal_Int16>(long( rZoomY * 100 ));
1373  }
1374  return 0;
1375 }
1376 
1377 void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1378 {
1379  ScTabViewShell* pViewSh = GetViewShell();
1380  if (pViewSh)
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 
1403 sal_Int16 ScTabViewObj::GetZoomType() const
1404 {
1405  sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1406  ScTabViewShell* pViewSh = GetViewShell();
1407  if (pViewSh)
1408  {
1409  SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1410  switch (eZoomType)
1411  {
1412  case SvxZoomType::PERCENT:
1413  aZoomType = view::DocumentZoomType::BY_VALUE;
1414  break;
1415  case SvxZoomType::OPTIMAL:
1416  aZoomType = view::DocumentZoomType::OPTIMAL;
1417  break;
1418  case SvxZoomType::WHOLEPAGE:
1419  aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1420  break;
1421  case SvxZoomType::PAGEWIDTH:
1422  aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1423  break;
1424  case SvxZoomType::PAGEWIDTH_NOBORDER:
1425  aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1426  break;
1427  }
1428  }
1429  return aZoomType;
1430 }
1431 
1432 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1433 {
1434  ScTabViewShell* pViewSh = GetViewShell();
1435  if (pViewSh)
1436  {
1437  ScDBFunc* pView = pViewSh->GetViewData().GetView();
1438  if (pView)
1439  {
1440  SvxZoomType eZoomType;
1441  switch (aZoomType)
1442  {
1443  case view::DocumentZoomType::BY_VALUE:
1444  eZoomType = SvxZoomType::PERCENT;
1445  break;
1446  case view::DocumentZoomType::OPTIMAL:
1447  eZoomType = SvxZoomType::OPTIMAL;
1448  break;
1449  case view::DocumentZoomType::ENTIRE_PAGE:
1450  eZoomType = SvxZoomType::WHOLEPAGE;
1451  break;
1452  case view::DocumentZoomType::PAGE_WIDTH:
1453  eZoomType = SvxZoomType::PAGEWIDTH;
1454  break;
1455  case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1456  eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1457  break;
1458  default:
1459  eZoomType = SvxZoomType::OPTIMAL;
1460  }
1461  sal_Int16 nZoom(GetZoom());
1462  sal_Int16 nOldZoom(nZoom);
1463  if ( eZoomType == SvxZoomType::PERCENT )
1464  {
1465  if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1466  if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1467  }
1468  else
1469  nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1470 
1471  switch ( eZoomType )
1472  {
1473  case SvxZoomType::WHOLEPAGE:
1474  case SvxZoomType::PAGEWIDTH:
1475  pView->SetZoomType( eZoomType, true );
1476  break;
1477 
1478  default:
1479  pView->SetZoomType( SvxZoomType::PERCENT, true );
1480  }
1481  SetZoom( nZoom );
1482  }
1483  }
1484 }
1485 
1487 {
1488  SolarMutexGuard aGuard;
1489  // what menu slot SID_WINDOW_SPLIT does
1490 
1491  ScTabViewShell* pViewSh = GetViewShell();
1492  if (pViewSh)
1493  {
1494  ScViewData& rViewData = pViewSh->GetViewData();
1495  return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1496  rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1497  }
1498 
1499  return false;
1500 }
1501 
1503 {
1504  SolarMutexGuard aGuard;
1505  // what menu slot SID_WINDOW_FIX does
1506 
1507  ScTabViewShell* pViewSh = GetViewShell();
1508  if (pViewSh)
1509  {
1510  ScViewData& rViewData = pViewSh->GetViewData();
1511  return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1512  rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1513  }
1514 
1515  return false;
1516 }
1517 
1519 {
1520  SolarMutexGuard aGuard;
1521  ScTabViewShell* pViewSh = GetViewShell();
1522  if (pViewSh)
1523  {
1524  ScViewData& rViewData = pViewSh->GetViewData();
1525  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1526  return rViewData.GetHSplitPos();
1527  }
1528  return 0;
1529 }
1530 
1532 {
1533  SolarMutexGuard aGuard;
1534  ScTabViewShell* pViewSh = GetViewShell();
1535  if (pViewSh)
1536  {
1537  ScViewData& rViewData = pViewSh->GetViewData();
1538  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1539  return rViewData.GetVSplitPos();
1540  }
1541  return 0;
1542 }
1543 
1544 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1545 {
1546  SolarMutexGuard aGuard;
1547  ScTabViewShell* pViewSh = GetViewShell();
1548  if (pViewSh)
1549  {
1550  ScViewData& rViewData = pViewSh->GetViewData();
1551  if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1552  {
1553  long nSplit = rViewData.GetHSplitPos();
1554 
1556  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1557  ePos = SC_SPLIT_TOPLEFT;
1558 
1559  SCCOL nCol;
1560  SCROW nRow;
1561  rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1562  if ( nCol > 0 )
1563  return nCol;
1564  }
1565  }
1566  return 0;
1567 }
1568 
1569 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow()
1570 {
1571  SolarMutexGuard aGuard;
1572  ScTabViewShell* pViewSh = GetViewShell();
1573  if (pViewSh)
1574  {
1575  ScViewData& rViewData = pViewSh->GetViewData();
1576  if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1577  {
1578  long nSplit = rViewData.GetVSplitPos();
1579 
1580  // split vertically
1581  SCCOL nCol;
1582  SCROW nRow;
1583  rViewData.GetPosFromPixel( 0, nSplit, SC_SPLIT_TOPLEFT, nCol, nRow, false );
1584  if ( nRow > 0 )
1585  return nRow;
1586  }
1587  }
1588  return 0;
1589 }
1590 
1591 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1592 {
1593  SolarMutexGuard aGuard;
1594  ScTabViewShell* pViewSh = GetViewShell();
1595  if (pViewSh)
1596  {
1597  pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ) );
1598  pViewSh->FreezeSplitters( false );
1599  pViewSh->InvalidateSplit();
1600  }
1601 }
1602 
1603 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1604 {
1605  SolarMutexGuard aGuard;
1606  ScTabViewShell* pViewSh = GetViewShell();
1607  if (pViewSh)
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 }
1627 
1629  const uno::Reference<view::XSelectionChangeListener>& xListener )
1630 {
1631  SolarMutexGuard aGuard;
1632  aSelectionChgListeners.push_back( xListener );
1633 }
1634 
1636  const uno::Reference< view::XSelectionChangeListener >& xListener )
1637 {
1638  SolarMutexGuard aGuard;
1639  auto it = std::find(aSelectionChgListeners.begin(), aSelectionChgListeners.end(), xListener);
1640  if (it != aSelectionChgListeners.end())
1641  aSelectionChgListeners.erase(it);
1642 }
1643 
1645 {
1646  // Selection changed so end any style preview
1647  // Note: executing this slot through the dispatcher
1648  // will cause the style dialog to be raised so we go
1649  // direct here
1650  ScFormatShell aShell( &GetViewShell()->GetViewData() );
1651  SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1652  SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1653  aShell.ExecuteStyle( aReq );
1654  lang::EventObject aEvent;
1655  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1656  for (const auto& rListener : aSelectionChgListeners)
1657  rListener->selectionChanged( aEvent );
1658 
1659  // handle sheet events
1660  ScTabViewShell* pViewSh = GetViewShell();
1661  ScViewData& rViewData = pViewSh->GetViewData();
1662  ScDocShell* pDocSh = rViewData.GetDocShell();
1663  ScDocument& rDoc = pDocSh->GetDocument();
1664  SCTAB nTab = rViewData.GetTabNo();
1665  const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1666  if (pEvents)
1667  {
1668  const OUString* pScript = pEvents->GetScript(ScSheetEventId::SELECT);
1669  if (pScript)
1670  {
1671  // the macro parameter is the selection as returned by getSelection
1672  uno::Sequence<uno::Any> aParams(1);
1673  aParams[0] = getSelection();
1674  uno::Any aRet;
1675  uno::Sequence<sal_Int16> aOutArgsIndex;
1676  uno::Sequence<uno::Any> aOutArgs;
1677  /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1678  }
1679  }
1680 
1681  SfxApplication::Get()->Broadcast( SfxHint( SfxHintId::ScSelectionChanged ) );
1682 
1683  if ( !mbLeftMousePressed ) // selection still in progress
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 
1698 // XPropertySet (view options)
1700 
1701 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1702 {
1703  SolarMutexGuard aGuard;
1704  static uno::Reference<beans::XPropertySetInfo> aRef(
1706  return aRef;
1707 }
1708 
1710  const OUString& aPropertyName, const uno::Any& aValue )
1711 {
1712  SolarMutexGuard aGuard;
1713 
1714  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1715  {
1717  return;
1718  }
1719 
1720  ScTabViewShell* pViewSh = GetViewShell();
1721  if (pViewSh)
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  {
1812  rViewData.SetOptions( aNewOpt );
1813  rViewData.GetDocument()->SetViewOptions( aNewOpt );
1814  rViewData.GetDocShell()->SetDocumentModified();
1815 
1816  pViewSh->UpdateFixPos();
1817  pViewSh->PaintGrid();
1818  pViewSh->PaintTop();
1819  pViewSh->PaintLeft();
1820  pViewSh->PaintExtras();
1821  pViewSh->InvalidateBorder();
1822 
1823  SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1824  rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> check in menu
1825  rBindings.Invalidate( FID_TOGGLESYNTAX );
1826  }
1827  }
1828 }
1829 
1830 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1831 {
1832  SolarMutexGuard aGuard;
1833  uno::Any aRet;
1834 
1835  if ( aPropertyName == SC_UNO_FILTERED_RANGE_SELECTION )
1836  {
1837  aRet <<= bFilteredRangeSelection;
1838  return aRet;
1839  }
1840 
1841  ScTabViewShell* pViewSh = GetViewShell();
1842  if (pViewSh)
1843  {
1844  const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1845 
1846  if ( aPropertyName == SC_UNO_COLROWHDR || aPropertyName == OLD_UNO_COLROWHDR )
1847  aRet <<= rOpt.GetOption( VOPT_HEADER );
1848  else if ( aPropertyName == SC_UNO_HORSCROLL || aPropertyName == OLD_UNO_HORSCROLL )
1849  aRet <<= rOpt.GetOption( VOPT_HSCROLL );
1850  else if ( aPropertyName == SC_UNO_OUTLSYMB || aPropertyName == OLD_UNO_OUTLSYMB )
1851  aRet <<= rOpt.GetOption( VOPT_OUTLINER );
1852  else if ( aPropertyName == SC_UNO_SHEETTABS || aPropertyName == OLD_UNO_SHEETTABS )
1853  aRet <<= rOpt.GetOption( VOPT_TABCONTROLS );
1854  else if ( aPropertyName == SC_UNO_SHOWANCHOR ) aRet <<= rOpt.GetOption( VOPT_ANCHOR );
1855  else if ( aPropertyName == SC_UNO_SHOWFORM ) aRet <<= rOpt.GetOption( VOPT_FORMULAS );
1856  else if ( aPropertyName == SC_UNO_SHOWGRID ) aRet <<= rOpt.GetOption( VOPT_GRID );
1857  else if ( aPropertyName == SC_UNO_SHOWHELP ) aRet <<= rOpt.GetOption( VOPT_HELPLINES );
1858  else if ( aPropertyName == SC_UNO_SHOWNOTES ) aRet <<= rOpt.GetOption( VOPT_NOTES );
1859  else if ( aPropertyName == SC_UNO_SHOWPAGEBR ) aRet <<= rOpt.GetOption( VOPT_PAGEBREAKS );
1860  else if ( aPropertyName == SC_UNO_SHOWZERO ) aRet <<= rOpt.GetOption( VOPT_NULLVALS );
1861  else if ( aPropertyName == SC_UNO_VALUEHIGH || aPropertyName == OLD_UNO_VALUEHIGH )
1862  aRet <<= rOpt.GetOption( VOPT_SYNTAX );
1863  else if ( aPropertyName == SC_UNO_VERTSCROLL || aPropertyName == OLD_UNO_VERTSCROLL )
1864  aRet <<= rOpt.GetOption( VOPT_VSCROLL );
1865  else if ( aPropertyName == SC_UNO_SHOWOBJ ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1866  else if ( aPropertyName == SC_UNO_SHOWCHARTS ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1867  else if ( aPropertyName == SC_UNO_SHOWDRAW ) aRet <<= static_cast<sal_Int16>( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1868  else if ( aPropertyName == SC_UNO_GRIDCOLOR ) aRet <<= rOpt.GetGridColor();
1869  else if ( aPropertyName == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1870  else if ( aPropertyName == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1871  else if ( aPropertyName == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1872  else if ( aPropertyName == SC_UNO_VISAREASCREEN )
1873  {
1874  ScViewData& rViewData = pViewSh->GetViewData();
1875  vcl::Window* pActiveWin = rViewData.GetActiveWin();
1876  if ( pActiveWin )
1877  {
1878  tools::Rectangle aRect = pActiveWin->GetWindowExtentsRelative( nullptr );
1879  aRet <<= AWTRectangle( aRect );
1880  }
1881  }
1882  }
1883 
1884  return aRet;
1885 }
1886 
1887 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1888  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1889 {
1890  SolarMutexGuard aGuard;
1891  aPropertyChgListeners.push_back( xListener );
1892 }
1893 
1894 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1895  const uno::Reference<beans::XPropertyChangeListener >& xListener )
1896 {
1897  SolarMutexGuard aGuard;
1898  auto it = std::find(aPropertyChgListeners.begin(), aPropertyChgListeners.end(), xListener);
1899  if (it != aPropertyChgListeners.end())
1900  aPropertyChgListeners.erase(it);
1901 }
1902 
1903 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
1904  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1905 {
1906 }
1907 
1908 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
1909  const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
1910 {
1911 }
1912 
1914 {
1915  beans::PropertyChangeEvent aEvent;
1916  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1917  for (const auto& rListener : aPropertyChgListeners)
1918  rListener->propertyChange( aEvent );
1919 }
1920 
1921 // XRangeSelection
1922 
1924  const uno::Sequence<beans::PropertyValue>& aArguments )
1925 {
1926  SolarMutexGuard aGuard;
1927  ScTabViewShell* pViewSh = GetViewShell();
1928  if (pViewSh)
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 }
1961 
1963 {
1964  SolarMutexGuard aGuard;
1965  ScTabViewShell* pViewSh = GetViewShell();
1966  if (pViewSh)
1967  pViewSh->StopSimpleRefDialog();
1968 }
1969 
1971  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1972 {
1973  SolarMutexGuard aGuard;
1974  aRangeSelListeners.push_back( xListener );
1975 }
1976 
1978  const uno::Reference<sheet::XRangeSelectionListener>& xListener )
1979 {
1980  SolarMutexGuard aGuard;
1981  auto it = std::find(aRangeSelListeners.begin(), aRangeSelListeners.end(), xListener);
1982  if (it != aRangeSelListeners.end())
1983  aRangeSelListeners.erase(it);
1984 }
1985 
1987  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1988 {
1989  SolarMutexGuard aGuard;
1990  aRangeChgListeners.push_back( xListener );
1991 }
1992 
1994  const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
1995 {
1996  SolarMutexGuard aGuard;
1997  auto it = std::find(aRangeChgListeners.begin(), aRangeChgListeners.end(), xListener);
1998  if (it != aRangeChgListeners.end())
1999  aRangeChgListeners.erase(it);
2000 }
2001 
2002 void ScTabViewObj::RangeSelDone( const OUString& rText )
2003 {
2004  sheet::RangeSelectionEvent aEvent;
2005  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2006  aEvent.RangeDescriptor = rText;
2007 
2008  // copy on the stack because listener could remove itself
2009  auto const listeners(aRangeSelListeners);
2010 
2011  for (const auto& rListener : listeners)
2012  rListener->done( aEvent );
2013 }
2014 
2015 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2016 {
2017  sheet::RangeSelectionEvent aEvent;
2018  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2019  aEvent.RangeDescriptor = rText;
2020 
2021  // copy on the stack because listener could remove itself
2022  auto const listeners(aRangeSelListeners);
2023 
2024  for (const auto& rListener : listeners)
2025  rListener->aborted( aEvent );
2026 }
2027 
2028 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2029 {
2030  sheet::RangeSelectionEvent aEvent;
2031  aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2032  aEvent.RangeDescriptor = rText;
2033 
2034  // copy on the stack because listener could remove itself
2035  auto const listener(aRangeChgListeners);
2036 
2037  for (const auto& rListener : listener)
2038  rListener->descriptorChanged( aEvent );
2039 }
2040 
2041 // XServiceInfo
2043 {
2044  return "ScTabViewObj";
2045 }
2046 
2047 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2048 {
2049  return cppu::supportsService(this, rServiceName);
2050 }
2051 
2052 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2053 {
2055 }
2056 
2057 // XUnoTunnel
2058 
2060 
2061 css::uno::Reference< css::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2062 {
2063  SolarMutexGuard aGuard;
2064  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2065  if (pShell)
2066  return pShell->GetEditView()->GetTransferable();
2067 
2068  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2069  if (pTextShell)
2070  {
2071  ScViewData& rViewData = GetViewShell()->GetViewData();
2072  ScDrawView* pView = rViewData.GetScDrawView();
2073  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2074  if (pOutView)
2075  return pOutView->GetEditView().GetTransferable();
2076  }
2077 
2078  ScDrawShell* pDrawShell = dynamic_cast<ScDrawShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2079  if (pDrawShell)
2080  return pDrawShell->GetDrawView()->CopyToTransferable();
2081 
2083  uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2084  return xTransferable;
2085 }
2086 
2087 void SAL_CALL ScTabViewObj::insertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& xTrans )
2088 {
2089  SolarMutexGuard aGuard;
2090  ScEditShell* pShell = dynamic_cast<ScEditShell*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2091  if (pShell)
2092  pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2093  else
2094  {
2095  ScDrawTextObjectBar* pTextShell = dynamic_cast<ScDrawTextObjectBar*>( GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2096  if (pTextShell)
2097  {
2098  ScViewData& rViewData = GetViewShell()->GetViewData();
2099  ScDrawView* pView = rViewData.GetScDrawView();
2100  OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2101  if ( pOutView )
2102  {
2103  pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2104  return;
2105  }
2106  }
2107 
2108  GetViewShell()->PasteFromTransferable( xTrans );
2109  }
2110 }
2111 
2112 namespace {
2113 
2114 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2115 {
2116  uno::Sequence<sal_Int32> aRet(rSelected.size());
2117  size_t i = 0;
2118  for (const auto& rTab : rSelected)
2119  {
2120  aRet[i] = static_cast<sal_Int32>(rTab);
2121  ++i;
2122  }
2123 
2124  return aRet;
2125 }
2126 
2127 }
2128 
2129 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2130 {
2131  ScTabViewShell* pViewSh = GetViewShell();
2132  if (!pViewSh)
2133  return uno::Sequence<sal_Int32>();
2134 
2135  ScViewData& rViewData = pViewSh->GetViewData();
2136 
2137  // #i95280# when printing from the shell, the view is never activated,
2138  // so Excel view settings must also be evaluated here.
2139  ScExtDocOptions* pExtOpt = rViewData.GetDocument()->GetExtDocOptions();
2140  if (pExtOpt && pExtOpt->IsChanged())
2141  {
2142  pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2143  pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2144  pExtOpt->SetChanged(false);
2145  }
2146 
2147  return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2148 }
2149 
2151  SfxBaseController(pViewSh),
2152  mpViewShell(pViewSh)
2153 {
2154  if (mpViewShell)
2156 }
2157 
2159 {
2160  if (mpViewShell)
2162 }
2163 
2165 {
2166  SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2167  return SfxBaseController::queryInterface(rType);
2168 }
2169 
2171 {
2172  SfxBaseController::acquire();
2173 }
2174 
2176 {
2177  SfxBaseController::release();
2178 }
2179 
2181 {
2182  if (rHint.GetId() == SfxHintId::Dying)
2183  mpViewShell = nullptr;
2184 }
2185 
2186 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2187 {
2188  ScPreview* p = mpViewShell ? mpViewShell->GetPreview() : nullptr;
2189  if (!p)
2190  return uno::Sequence<sal_Int32>();
2191 
2192  return toSequence(p->GetSelectedTabs());
2193 }
2194 
2195 /* 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:76
ScMarkData & GetMarkData()
Definition: viewdata.cxx:3053
virtual Point GetPosPixel() const
SfxViewFrame * GetViewFrame() const
ScDBFunc * GetView() const
Definition: viewdata.hxx:356
long Width() const
SvxZoomType GetZoomType() const
Definition: tabview5.cxx:404
#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:2061
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:1977
#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:2015
ScVSplitPos WhichV(ScSplitPos ePos)
Definition: viewdata.hxx:714
virtual void SAL_CALL acquire() override
Definition: viewuno.cxx:2170
void ReadExtOptions(const ScExtDocOptions &rOpt)
Definition: viewdata.cxx:3441
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:2440
#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:1986
bool PaintExtras()
Definition: tabview3.cxx:2741
#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:1675
bool IsChanged() const
Definition: scextopt.cxx:160
virtual void SAL_CALL startRangeSelection(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: viewuno.cxx:1923
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:1139
virtual void SAL_CALL splitAtPosition(sal_Int32 nPixelX, sal_Int32 nPixelY) override
Definition: viewuno.cxx:1591
ScHSplitPos WhichH(ScSplitPos ePos)
Definition: viewdata.hxx:708
Reference< XInterface > xTarget
virtual OUString SAL_CALL getImplementationName() override
Definition: viewuno.cxx:2042
bool IsMouseListening() const
Definition: viewuno.cxx:1123
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:1332
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:2614
virtual void SAL_CALL setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn) override
Definition: viewuno.cxx:191
void Unmark()
Definition: tabview3.cxx:1711
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:1403
SdrMark * GetMark(size_t nNum) const
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:1544
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:2047
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:2180
css::chart::ChartAxisLabelPosition ePos
SCCOL GetPosX(ScHSplitPos eWhich, SCTAB nForTab=-1) const
Definition: viewdata.cxx:1344
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:1830
SCTAB nPreviousTab
Definition: viewuno.hxx:158
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: viewuno.cxx:2164
#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:2690
virtual void SAL_CALL addActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1345
#define SC_UNO_SHOWGRID
Definition: unonames.hxx:545
void InvalidateBorder()
SfxShell * GetShell(sal_uInt16 nIdx) const
virtual css::uno::Reference< css::uno::XInterface > getUnoShape()
void GetPosFromPixel(long nClickX, long nClickY, ScSplitPos eWhich, SCCOL &rPosX, SCROW &rPosY, bool bTestMerge=true, bool bRepair=false, SCTAB nForTab=-1)
Definition: viewdata.cxx:2700
SdrPage * getSdrPageFromSdrObject() const
void SetObjMode(ScVObjType eObj, ScVObjMode eMode)
Definition: viewopti.hxx:90
ScPreviewObj(ScPreviewShell *pViewSh)
Definition: viewuno.cxx:2150
void SetZoom(sal_Int16 Zoom)
Definition: viewuno.cxx:1377
virtual void SAL_CALL insertTransferable(const css::uno::Reference< css::datatransfer::XTransferable > &xTrans) override
Definition: viewuno.cxx:2087
void RangeSelChanged(const OUString &rText)
Definition: viewuno.cxx:2028
SCCOL VisibleCellsX(ScHSplitPos eWhichX) const
Definition: viewdata.cxx:2627
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:1734
int nCount
virtual sal_Bool SAL_CALL isFormDesignMode() override
Definition: viewuno.cxx:325
virtual sal_Int32 SAL_CALL getSplitRow() override
Definition: viewuno.cxx:1569
bool MouseReleased(const css::awt::MouseEvent &e)
Definition: viewuno.cxx:1229
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
void SetOptions(const ScViewOptions &rOpt)
Definition: viewdata.cxx:3886
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:190
SCTAB Tab() const
Definition: address.hxx:271
void SetCursorOnly(bool bSet)
Definition: cellsuno.cxx:1723
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:653
ScDocument * GetDocument() const
Definition: viewdata.cxx:859
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:1358
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:416
#define SC_UNO_VISAREA
Definition: unonames.hxx:568
const Fraction & GetZoomY() const
Definition: viewdata.hxx:460
bool HasObjects() const
Definition: drwlayer.cxx:365
void EndMouseListening()
Definition: viewuno.cxx:1288
ScDrawView * GetScDrawView()
Definition: viewdata.cxx:3081
ScViewData & GetViewData()
Definition: tabview.hxx:332
sal_uInt16 GetSlotID() const
Definition: fupoor.hxx:91
void PaintTop()
Definition: tabview3.cxx:2625
#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:536
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: viewuno.cxx:2052
SCROW VisibleCellsY(ScVSplitPos eWhichY) const
Definition: viewdata.cxx:2632
virtual void SAL_CALL addEnhancedMouseClickHandler(const css::uno::Reference< css::awt::XEnhancedMouseClickHandler > &aListener) override
Definition: viewuno.cxx:1322
#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:2175
void SetZoom(const Fraction &rNewX, const Fraction &rNewY, bool bAll)
Definition: tabview5.cxx:414
SC_DLLPUBLIC ScDrawLayer * GetDrawLayer()
Definition: document.hxx:1062
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:1305
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:1709
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:2319
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:1908
bool bFilteredRangeSelection
Definition: viewuno.hxx:160
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: viewuno.cxx:937
sal_Int16 SCCOL
Definition: types.hxx:22
virtual void SAL_CALL addSelectionChangeListener(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener) override
Definition: viewuno.cxx:1628
virtual void SAL_CALL abortRangeSelection() override
Definition: viewuno.cxx:1962
#define SC_MOD()
Definition: scmod.hxx:253
SfxBindings & GetBindings()
#define SC_UNO_GRIDCOLOR
Definition: unonames.hxx:536
SC_DLLPUBLIC void SetViewOptions(const ScViewOptions &rOpt)
Definition: documen3.cxx:1924
const SdrMarkList & GetMarkedObjectList() const
SC_DLLPUBLIC void SetTabNo(SCTAB nTab, bool bNew=false, bool bExtendSelection=false, bool bSameTabButMoved=false)
Definition: tabview3.cxx:1786
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
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:1970
sal_Int16 GetZoom() const
Definition: viewuno.cxx:1366
unsigned char sal_Bool
ScMarkType GetSimpleArea(SCCOL &rStartCol, SCROW &rStartRow, SCTAB &rStartTab, SCCOL &rEndCol, SCROW &rEndRow, SCTAB &rEndTab) const
Definition: viewdata.cxx:1173
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:3069
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:1953
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:2158
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:2542
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &...rSn)
virtual sal_Bool SAL_CALL getIsWindowSplit() override
Definition: viewuno.cxx:1486
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:1603
const SvXMLTokenMapEntry aTypes[]
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: viewuno.cxx:1903
void RangeSelDone(const OUString &rText)
Definition: viewuno.cxx:2002
#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
virtual SdrLayerID GetLayer() const
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedSheets() override
Definition: viewuno.cxx:2186
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:1644
virtual sal_Int32 SAL_CALL getSplitHorizontal() override
Definition: viewuno.cxx:1518
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:1993
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:620
#define SC_UNO_OUTLSYMB
Definition: unonames.hxx:539
const ScSheetEvents * GetSheetEvents(SCTAB nTab) const
Definition: documen3.cxx:640
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
static void UnmarkFiltered(ScMarkData &rMark, const ScDocument *pDoc)
Definition: viewutil.cxx:223
const ScViewOptions & GetOptions() const
Definition: viewdata.hxx:537
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
XPrintable?
Definition: viewuno.cxx:1701
void * p
Reference< XComponentContext > getProcessComponentContext()
virtual void SAL_CALL removeActivationEventListener(const css::uno::Reference< css::sheet::XActivationEventListener > &aListener) override
Definition: viewuno.cxx:1355
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:2129
SdrEndTextEditKind ScEndTextEdit()
Definition: drawview.cxx:892
long GetVSplitPos() const
Definition: viewdata.hxx:419
virtual sal_Int32 SAL_CALL getSplitVertical() override
Definition: viewuno.cxx:1531
#define SC_UNONAME_CLOSEONUP
Definition: unonames.hxx:639
void AlignToCursor(SCCOL nCurX, SCROW nCurY, ScFollowMode eMode, const ScSplitPos *pWhich=nullptr)
Definition: tabview3.cxx:904
void VisAreaChanged()
Definition: viewuno.cxx:1913
virtual sal_Bool SAL_CALL hasFrozenPanes() override
Definition: viewuno.cxx:1502
SC_DLLPUBLIC bool IsLayoutRTL(SCTAB nTab) const
Definition: document.cxx:993
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:409
void GetMultiArea(ScRangeListRef &rRange) const
Definition: viewdata.cxx:1196
long GetHSplitPos() const
Definition: viewdata.hxx:418
#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:75
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:342
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:1894
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:1635
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:1887
void SetZoomType(sal_Int16 ZoomType)
Definition: viewuno.cxx:1432
void SplitAtPixel(const Point &rPixel)
Definition: tabview.cxx:2094
AnyEventRef aEvent
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:417
tools::Rectangle GetWindowExtentsRelative(vcl::Window *pRelativeWindow) const
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