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