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