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