fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / unoobj / viewuno.cxx
blob45e0621974883ac12488a8a2ad55b821e240cb98
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/awt/MouseButton.hpp>
21 #include <com/sun/star/drawing/ShapeCollection.hpp>
22 #include <com/sun/star/script/vba/VBAEventId.hpp>
23 #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
24 #include <com/sun/star/view/DocumentZoomType.hpp>
26 #include <editeng/outliner.hxx>
27 #include <svx/fmdpage.hxx>
28 #include <svx/svditer.hxx>
29 #include <svx/svdmark.hxx>
30 #include <svx/svdouno.hxx>
31 #include <svx/svdpage.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <svx/svdview.hxx>
34 #include <svx/unoshape.hxx>
35 #include <svx/fmshell.hxx>
36 #include <sfx2/bindings.hxx>
37 #include <sfx2/dispatch.hxx>
38 #include <sfx2/printer.hxx>
39 #include <sfx2/request.hxx>
40 #include <sfx2/viewfrm.hxx>
41 #include <comphelper/servicehelper.hxx>
42 #include <cppuhelper/supportsservice.hxx>
43 #include <toolkit/helper/convert.hxx>
44 #include <vcl/svapp.hxx>
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 "AccessibilityHints.hxx"
67 #include "scextopt.hxx"
68 #include "preview.hxx"
69 #include <svx/sdrhittesthelper.hxx>
70 #include "formatsh.hxx"
71 #include <sfx2/app.hxx>
73 using namespace com::sun::star;
75 //! Clipping-Markierungen
77 // alles ohne Which-ID, Map nur fuer PropertySetInfo
79 static const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap()
81 static const SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] =
83 {OUString(OLD_UNO_COLROWHDR), 0, cppu::UnoType<bool>::get(), 0, 0},
84 {OUString(SC_UNO_GRIDCOLOR), 0, cppu::UnoType<sal_Int32>::get(), 0, 0},
85 {OUString(SC_UNO_COLROWHDR), 0, cppu::UnoType<bool>::get(), 0, 0},
86 {OUString(SC_UNO_HORSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
87 {OUString(SC_UNO_SHEETTABS), 0, cppu::UnoType<bool>::get(), 0, 0},
88 {OUString(SC_UNO_VERTSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
89 {OUString(SC_UNO_HIDESPELL), 0, cppu::UnoType<bool>::get(), 0, 0}, /* deprecated #i91949 */
90 {OUString(OLD_UNO_HORSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
91 {OUString(SC_UNO_OUTLSYMB), 0, cppu::UnoType<bool>::get(), 0, 0},
92 {OUString(SC_UNO_VALUEHIGH), 0, cppu::UnoType<bool>::get(), 0, 0},
93 {OUString(OLD_UNO_OUTLSYMB), 0, cppu::UnoType<bool>::get(), 0, 0},
94 {OUString(OLD_UNO_SHEETTABS), 0, cppu::UnoType<bool>::get(), 0, 0},
95 {OUString(SC_UNO_SHOWANCHOR), 0, cppu::UnoType<bool>::get(), 0, 0},
96 {OUString(SC_UNO_SHOWCHARTS), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
97 {OUString(SC_UNO_SHOWDRAW), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
98 {OUString(SC_UNO_SHOWFORM), 0, cppu::UnoType<bool>::get(), 0, 0},
99 {OUString(SC_UNO_SHOWGRID), 0, cppu::UnoType<bool>::get(), 0, 0},
100 {OUString(SC_UNO_SHOWHELP), 0, cppu::UnoType<bool>::get(), 0, 0},
101 {OUString(SC_UNO_SHOWNOTES), 0, cppu::UnoType<bool>::get(), 0, 0},
102 {OUString(SC_UNO_SHOWOBJ), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
103 {OUString(SC_UNO_SHOWPAGEBR), 0, cppu::UnoType<bool>::get(), 0, 0},
104 {OUString(SC_UNO_SHOWZERO), 0, cppu::UnoType<bool>::get(), 0, 0},
105 {OUString(OLD_UNO_VALUEHIGH), 0, cppu::UnoType<bool>::get(), 0, 0},
106 {OUString(OLD_UNO_VERTSCROLL), 0, cppu::UnoType<bool>::get(), 0, 0},
107 {OUString(SC_UNO_VISAREA), 0, cppu::UnoType<awt::Rectangle>::get(), 0, 0},
108 {OUString(SC_UNO_ZOOMTYPE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
109 {OUString(SC_UNO_ZOOMVALUE), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
110 {OUString(SC_UNO_VISAREASCREEN),0, cppu::UnoType<awt::Rectangle>::get(), 0, 0},
111 { OUString(), 0, css::uno::Type(), 0, 0 }
113 return aViewOptPropertyMap_Impl;
116 #define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView"
117 #define SCVIEWSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetViewSettings"
119 SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
121 ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP) :
122 pViewShell( pViewSh ),
123 nPane( nP )
125 if (pViewShell)
126 StartListening(*pViewShell);
129 ScViewPaneBase::~ScViewPaneBase()
131 SolarMutexGuard g;
133 if (pViewShell)
134 EndListening(*pViewShell);
137 void ScViewPaneBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
139 const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
140 if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DYING )
141 pViewShell = NULL;
144 uno::Any SAL_CALL ScViewPaneBase::queryInterface( const uno::Type& rType )
145 throw(uno::RuntimeException, std::exception)
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 )
154 return uno::Any(); // OWeakObject is in derived objects
157 uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes() throw(uno::RuntimeException, std::exception)
159 static uno::Sequence<uno::Type> aTypes;
160 if ( aTypes.getLength() == 0 )
162 aTypes.realloc(5);
163 uno::Type* pPtr = aTypes.getArray();
164 pPtr[0] = cppu::UnoType<sheet::XViewPane>::get();
165 pPtr[1] = cppu::UnoType<sheet::XCellRangeReferrer>::get();
166 pPtr[2] = cppu::UnoType<view::XFormLayerAccess>::get();
167 pPtr[3] = cppu::UnoType<lang::XServiceInfo>::get();
168 pPtr[4] = cppu::UnoType<lang::XTypeProvider>::get();
170 return aTypes;
173 uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId()
174 throw(uno::RuntimeException, std::exception)
176 return css::uno::Sequence<sal_Int8>();
179 // XViewPane
181 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException, std::exception)
183 SolarMutexGuard aGuard;
184 if (pViewShell)
186 ScViewData& rViewData = pViewShell->GetViewData();
187 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
188 rViewData.GetActivePart() :
189 (ScSplitPos) nPane;
190 ScHSplitPos eWhichH = WhichH( eWhich );
192 return rViewData.GetPosX( eWhichH );
194 OSL_FAIL("keine View ?!?"); //! Exception?
195 return 0;
198 void SAL_CALL ScViewPaneBase::setFirstVisibleColumn(sal_Int32 nFirstVisibleColumn)
199 throw(uno::RuntimeException, std::exception)
201 SolarMutexGuard aGuard;
202 if (pViewShell)
204 ScViewData& rViewData = pViewShell->GetViewData();
205 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
206 rViewData.GetActivePart() :
207 (ScSplitPos) nPane;
208 ScHSplitPos eWhichH = WhichH( eWhich );
210 long nDeltaX = ((long)nFirstVisibleColumn) - rViewData.GetPosX( eWhichH );
211 pViewShell->ScrollX( nDeltaX, eWhichH );
215 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException, std::exception)
217 SolarMutexGuard aGuard;
218 if (pViewShell)
220 ScViewData& rViewData = pViewShell->GetViewData();
221 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
222 rViewData.GetActivePart() :
223 (ScSplitPos) nPane;
224 ScVSplitPos eWhichV = WhichV( eWhich );
226 return rViewData.GetPosY( eWhichV );
228 OSL_FAIL("keine View ?!?"); //! Exception?
229 return 0;
232 void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
233 throw(uno::RuntimeException, std::exception)
235 SolarMutexGuard aGuard;
236 if (pViewShell)
238 ScViewData& rViewData = pViewShell->GetViewData();
239 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
240 rViewData.GetActivePart() :
241 (ScSplitPos) nPane;
242 ScVSplitPos eWhichV = WhichV( eWhich );
244 long nDeltaY = ((long)nFirstVisibleRow) - rViewData.GetPosY( eWhichV );
245 pViewShell->ScrollY( nDeltaY, eWhichV );
249 table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange()
250 throw(uno::RuntimeException, std::exception)
252 SolarMutexGuard aGuard;
253 table::CellRangeAddress aAdr;
254 if (pViewShell)
256 ScViewData& rViewData = pViewShell->GetViewData();
257 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
258 rViewData.GetActivePart() :
259 (ScSplitPos) nPane;
260 ScHSplitPos eWhichH = WhichH( eWhich );
261 ScVSplitPos eWhichV = WhichV( eWhich );
263 // VisibleCellsX gibt nur komplett sichtbare Zellen,
264 // VisibleRange in Excel auch teilweise sichtbare.
265 //! anpassen ???
267 SCCOL nVisX = rViewData.VisibleCellsX( eWhichH );
268 SCROW nVisY = rViewData.VisibleCellsY( eWhichV );
269 if (!nVisX) nVisX = 1; // irgendwas muss ja im Range sein
270 if (!nVisY) nVisY = 1;
271 aAdr.Sheet = rViewData.GetTabNo();
272 aAdr.StartColumn = rViewData.GetPosX( eWhichH );
273 aAdr.StartRow = rViewData.GetPosY( eWhichV );
274 aAdr.EndColumn = aAdr.StartColumn + nVisX - 1;
275 aAdr.EndRow = aAdr.StartRow + nVisY - 1;
277 return aAdr;
280 // XCellRangeSource
282 uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells()
283 throw(uno::RuntimeException, std::exception)
285 SolarMutexGuard aGuard;
286 if (pViewShell)
288 ScDocShell* pDocSh = pViewShell->GetViewData().GetDocShell();
290 table::CellRangeAddress aAdr(getVisibleRange()); //! Hilfsfunktion mit ScRange?
291 ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet,
292 (SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet );
293 if ( aRange.aStart == aRange.aEnd )
294 return new ScCellObj( pDocSh, aRange.aStart );
295 else
296 return new ScCellRangeObj( pDocSh, aRange );
299 return NULL;
302 namespace
304 bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, sal_uInt16 _nPane, FmFormShell*& _rpFormShell, vcl::Window*& _rpWindow, SdrView*& _rpSdrView )
306 if ( !_pViewShell )
307 return false;
309 ScViewData& rViewData = _pViewShell->GetViewData();
310 ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ?
311 rViewData.GetActivePart() :
312 (ScSplitPos) _nPane;
313 _rpWindow = _pViewShell->GetWindowByPos( eWhich );
314 _rpSdrView = _pViewShell->GetSdrView();
315 _rpFormShell = _pViewShell->GetFormShell();
316 return ( _rpFormShell != NULL ) && ( _rpSdrView != NULL )&& ( _rpWindow != NULL );
320 // XFormLayerAccess
321 uno::Reference< form::runtime::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& _Form ) throw (uno::RuntimeException, std::exception)
323 SolarMutexGuard aGuard;
325 uno::Reference< form::runtime::XFormController > xController;
327 vcl::Window* pWindow( NULL );
328 SdrView* pSdrView( NULL );
329 FmFormShell* pFormShell( NULL );
330 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
331 xController = FmFormShell::GetFormController( _Form, *pSdrView, *pWindow );
333 return xController;
336 sal_Bool SAL_CALL ScViewPaneBase::isFormDesignMode( ) throw (uno::RuntimeException, std::exception)
338 SolarMutexGuard aGuard;
340 bool bIsFormDesignMode( true );
342 FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : NULL );
343 if ( pFormShell )
344 bIsFormDesignMode = pFormShell->IsDesignMode();
346 return bIsFormDesignMode;
349 void SAL_CALL ScViewPaneBase::setFormDesignMode( sal_Bool _DesignMode ) throw (uno::RuntimeException, std::exception)
351 SolarMutexGuard aGuard;
353 vcl::Window* pWindow( NULL );
354 SdrView* pSdrView( NULL );
355 FmFormShell* pFormShell( NULL );
356 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
357 pFormShell->SetDesignMode( _DesignMode );
360 // XControlAccess
362 uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl(
363 const uno::Reference<awt::XControlModel>& xModel )
364 throw(container::NoSuchElementException, uno::RuntimeException, std::exception)
366 SolarMutexGuard aGuard;
368 uno::Reference<awt::XControl> xRet;
370 vcl::Window* pWindow( NULL );
371 SdrView* pSdrView( NULL );
372 FmFormShell* pFormShell( NULL );
373 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
374 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xRet );
376 if ( !xRet.is() )
377 throw container::NoSuchElementException(); // no control found
379 return xRet;
382 awt::Rectangle ScViewPaneBase::GetVisArea() const
384 awt::Rectangle aVisArea;
385 if (pViewShell)
387 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
388 pViewShell->GetViewData().GetActivePart() :
389 (ScSplitPos) nPane;
390 ScGridWindow* pWindow = static_cast<ScGridWindow*>(pViewShell->GetWindowByPos(eWhich));
391 ScDocument* pDoc = pViewShell->GetViewData().GetDocument();
392 if (pWindow && pDoc)
394 ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ?
395 SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
396 ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ?
397 SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
398 ScAddress aCell(pViewShell->GetViewData().GetPosX(eWhichH),
399 pViewShell->GetViewData().GetPosY(eWhichV),
400 pViewShell->GetViewData().GetTabNo());
401 Rectangle aCellRect( pDoc->GetMMRect( aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) );
402 Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), pWindow->GetDrawMapMode( true ) ) );
403 Point aVisPos( aCellRect.TopLeft() );
404 if ( pDoc->IsLayoutRTL( aCell.Tab() ) )
406 aVisPos = aCellRect.TopRight();
407 aVisPos.X() -= aVisSize.Width();
409 Rectangle aVisRect( aVisPos, aVisSize );
410 aVisArea = AWTRectangle(aVisRect);
413 return aVisArea;
416 ScViewPaneObj::ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP) :
417 ScViewPaneBase( pViewSh, nP )
421 ScViewPaneObj::~ScViewPaneObj()
425 uno::Any SAL_CALL ScViewPaneObj::queryInterface( const uno::Type& rType )
426 throw(uno::RuntimeException, std::exception)
428 // ScViewPaneBase has everything except OWeakObject
430 uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
431 if (!aRet.hasValue())
432 aRet = OWeakObject::queryInterface( rType );
433 return aRet;
436 void SAL_CALL ScViewPaneObj::acquire() throw()
438 OWeakObject::acquire();
441 void SAL_CALL ScViewPaneObj::release() throw()
443 OWeakObject::release();
446 // Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
448 ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
449 ScViewPaneBase( pViewSh, SC_VIEWPANE_ACTIVE ),
450 SfxBaseController( pViewSh ),
451 aPropSet( lcl_GetViewOptPropertyMap() ),
452 aMouseClickHandlers( 0 ),
453 aActivationListeners( 0 ),
454 nPreviousTab( 0 ),
455 bDrawSelModeSet(false),
456 bFilteredRangeSelection(false),
457 mbLeftMousePressed(false),
458 mbPendingSelectionChanged(false)
460 if (pViewSh)
461 nPreviousTab = pViewSh->GetViewData().GetTabNo();
464 ScTabViewObj::~ScTabViewObj()
466 //! Listening oder so
467 if (!aMouseClickHandlers.empty())
469 acquire();
470 EndMouseListening();
472 if (!aActivationListeners.empty())
474 acquire();
475 EndActivationListening();
479 uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
480 throw(uno::RuntimeException, std::exception)
482 SC_QUERYINTERFACE( sheet::XSpreadsheetView )
483 SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster )
484 SC_QUERYINTERFACE( sheet::XActivationBroadcaster )
485 SC_QUERYINTERFACE( container::XEnumerationAccess )
486 SC_QUERYINTERFACE( container::XIndexAccess )
487 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
488 SC_QUERYINTERFACE( view::XSelectionSupplier )
489 SC_QUERYINTERFACE( beans::XPropertySet )
490 SC_QUERYINTERFACE( sheet::XViewSplitable )
491 SC_QUERYINTERFACE( sheet::XViewFreezable )
492 SC_QUERYINTERFACE( sheet::XRangeSelection )
493 SC_QUERYINTERFACE( lang::XUnoTunnel )
494 SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
495 SC_QUERYINTERFACE( sheet::XSelectedSheetsSupplier )
497 uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
498 if (!aRet.hasValue())
499 aRet = SfxBaseController::queryInterface( rType );
500 return aRet;
503 void SAL_CALL ScTabViewObj::acquire() throw()
505 SfxBaseController::acquire();
508 void SAL_CALL ScTabViewObj::release() throw()
510 SfxBaseController::release();
513 static void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent )
515 ScDocument& rDoc = pDocSh->GetDocument();
516 // when deleting a sheet, nPreviousTab can be invalid
517 // (could be handled with reference updates)
518 if (!rDoc.HasTable(nTab))
519 return;
521 const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
522 if (pEvents)
524 const OUString* pScript = pEvents->GetScript(nEvent);
525 if (pScript)
527 uno::Any aRet;
528 uno::Sequence<uno::Any> aParams;
529 uno::Sequence<sal_Int16> aOutArgsIndex;
530 uno::Sequence<uno::Any> aOutArgs;
531 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
535 // execute VBA event handlers
538 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
539 // the parameter is the clicked object, as in the mousePressed call above
540 uno::Sequence< uno::Any > aArgs( 1 );
541 aArgs[ 0 ] <<= nTab;
542 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
544 catch( uno::Exception& )
549 void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
551 if ( !GetViewShell() )
552 return;
554 ScViewData& rViewData = GetViewShell()->GetViewData();
555 ScDocShell* pDocSh = rViewData.GetDocShell();
556 if (!aActivationListeners.empty())
558 sheet::ActivationEvent aEvent;
559 uno::Reference< sheet::XSpreadsheetView > xView(this);
560 uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
561 aEvent.Source = xSource;
562 aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, rViewData.GetTabNo());
563 for (XActivationEventListenerVector::iterator it = aActivationListeners.begin(); it != aActivationListeners.end(); )
567 (*it)->activeSpreadsheetChanged( aEvent );
568 ++it;
570 catch( uno::Exception& )
572 it = aActivationListeners.erase( it);
577 /* Handle sheet events, but do not trigger event handlers, if the old
578 active sheet gets re-activated after inserting/deleting/moving a sheet. */
579 SCTAB nNewTab = rViewData.GetTabNo();
580 if ( !bSameTabButMoved && (nNewTab != nPreviousTab) )
582 lcl_CallActivate( pDocSh, nPreviousTab, SC_SHEETEVENT_UNFOCUS );
583 lcl_CallActivate( pDocSh, nNewTab, SC_SHEETEVENT_FOCUS );
585 nPreviousTab = nNewTab;
588 uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() throw(uno::RuntimeException, std::exception)
590 static uno::Sequence<uno::Type> aTypes;
591 if ( aTypes.getLength() == 0 )
593 uno::Sequence<uno::Type> aViewPaneTypes(ScViewPaneBase::getTypes());
594 long nViewPaneLen = aViewPaneTypes.getLength();
595 const uno::Type* pViewPanePtr = aViewPaneTypes.getConstArray();
597 uno::Sequence<uno::Type> aControllerTypes(SfxBaseController::getTypes());
598 long nControllerLen = aControllerTypes.getLength();
599 const uno::Type* pControllerPtr = aControllerTypes.getConstArray();
601 long nParentLen = nViewPaneLen + nControllerLen;
603 aTypes.realloc( nParentLen + 12 );
604 uno::Type* pPtr = aTypes.getArray();
605 pPtr[nParentLen + 0] = cppu::UnoType<sheet::XSpreadsheetView>::get();
606 pPtr[nParentLen + 1] = cppu::UnoType<container::XEnumerationAccess>::get();
607 pPtr[nParentLen + 2] = cppu::UnoType<container::XIndexAccess>::get();
608 pPtr[nParentLen + 3] = cppu::UnoType<view::XSelectionSupplier>::get();
609 pPtr[nParentLen + 4] = cppu::UnoType<beans::XPropertySet>::get();
610 pPtr[nParentLen + 5] = cppu::UnoType<sheet::XViewSplitable>::get();
611 pPtr[nParentLen + 6] = cppu::UnoType<sheet::XViewFreezable>::get();
612 pPtr[nParentLen + 7] = cppu::UnoType<sheet::XRangeSelection>::get();
613 pPtr[nParentLen + 8] = cppu::UnoType<lang::XUnoTunnel>::get();
614 pPtr[nParentLen + 9] = cppu::UnoType<sheet::XEnhancedMouseClickBroadcaster>::get();
615 pPtr[nParentLen + 10] = cppu::UnoType<sheet::XActivationBroadcaster>::get();
616 pPtr[nParentLen + 11] = cppu::UnoType<datatransfer::XTransferableSupplier>::get();
618 long i;
619 for (i=0; i<nViewPaneLen; i++)
620 pPtr[i] = pViewPanePtr[i]; // parent types first
621 for (i=0; i<nControllerLen; i++)
622 pPtr[nViewPaneLen+i] = pControllerPtr[i];
624 return aTypes;
627 uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
628 throw(uno::RuntimeException, std::exception)
630 return css::uno::Sequence<sal_Int8>();
633 // XDocumentView
635 static bool lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
637 for (size_t i = 0, nCount = rRanges.size(); i < nCount; ++i)
639 const ScRange* pRange = rRanges[ i ];
640 if ( nTab >= pRange->aStart.Tab() && nTab <= pRange->aEnd.Tab() )
641 return true;
643 return false;
646 static void lcl_ShowObject( ScTabViewShell& rViewSh, ScDrawView& rDrawView, SdrObject* pSelObj )
648 bool bFound = false;
649 SCTAB nObjectTab = 0;
651 SdrModel* pModel = rDrawView.GetModel();
652 sal_uInt16 nPageCount = pModel->GetPageCount();
653 for (sal_uInt16 i=0; i<nPageCount && !bFound; i++)
655 SdrPage* pPage = pModel->GetPage(i);
656 if (pPage)
658 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
659 SdrObject* pObject = aIter.Next();
660 while (pObject && !bFound)
662 if ( pObject == pSelObj )
664 bFound = true;
665 nObjectTab = static_cast<SCTAB>(i);
667 pObject = aIter.Next();
672 if (bFound)
674 rViewSh.SetTabNo( nObjectTab );
675 rViewSh.ScrollToObject( pSelObj );
679 sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
680 throw(lang::IllegalArgumentException, uno::RuntimeException,
681 std::exception)
683 SolarMutexGuard aGuard;
684 ScTabViewShell* pViewSh = GetViewShell();
686 if ( !pViewSh )
687 return false;
689 //! Type of aSelection can be some specific interface instead of XInterface
691 bool bRet = false;
692 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
693 if ( !xInterface.is() ) //clear all selections
695 ScDrawView* pDrawView = pViewSh->GetScDrawView();
696 if (pDrawView)
698 pDrawView->ScEndTextEdit();
699 pDrawView->UnmarkAll();
701 else //#102232#; if there is no DrawView remove range selection
702 pViewSh->Unmark();
703 bRet = true;
706 if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
708 pViewSh->SetDrawSelMode(false);
709 pViewSh->UpdateLayerLocks();
710 bDrawSelModeSet = false;
713 if (bRet)
714 return bRet;
716 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
717 uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
718 uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
719 SvxShape* pShapeImp = SvxShape::getImplementation( xShapeSel );
721 if (pRangesImp) // Zell-Ranges
723 ScViewData& rViewData = pViewSh->GetViewData();
724 if ( rViewData.GetDocShell() == pRangesImp->GetDocShell() )
726 // Zuerst evtl. Drawing-Selektion aufheben
727 // (MarkListHasChanged hebt Tabellen-Selektion auf)
729 ScDrawView* pDrawView = pViewSh->GetScDrawView();
730 if (pDrawView)
732 pDrawView->ScEndTextEdit();
733 pDrawView->UnmarkAll();
735 FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
736 if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
738 // Slot der Zeichenfunktion nochmal ausfuehren -> abschalten
739 SfxDispatcher* pDisp = pViewSh->GetDispatcher();
740 if (pDisp)
741 pDisp->Execute( pFunc->GetSlotID(), SfxCallMode::SYNCHRON );
743 pViewSh->SetDrawShell(false);
744 pViewSh->SetDrawSelMode(false); // nach dem Dispatcher-Execute
746 // Ranges selektieren
748 const ScRangeList& rRanges = pRangesImp->GetRangeList();
749 size_t nRangeCount = rRanges.size();
750 // for empty range list, remove selection (cursor remains where it was)
751 if ( nRangeCount == 0 )
752 pViewSh->Unmark();
753 else if ( nRangeCount == 1 )
754 pViewSh->MarkRange( *rRanges[ 0 ] );
755 else
757 // Mehrfachselektion
759 const ScRange* pFirst = rRanges[ 0 ];
760 if ( pFirst && !lcl_TabInRanges( rViewData.GetTabNo(), rRanges ) )
761 pViewSh->SetTabNo( pFirst->aStart.Tab() );
762 pViewSh->DoneBlockMode();
763 pViewSh->InitOwnBlockMode();
764 rViewData.GetMarkData().MarkFromRangeList( rRanges, true );
765 pViewSh->MarkDataChanged();
766 rViewData.GetDocShell()->PostPaintGridAll(); // Markierung (alt&neu)
767 if ( pFirst )
769 pViewSh->AlignToCursor( pFirst->aStart.Col(), pFirst->aStart.Row(),
770 SC_FOLLOW_JUMP );
771 pViewSh->SetCursor( pFirst->aStart.Col(), pFirst->aStart.Row() );
774 //! Methode an der View, um RangeList zu selektieren
776 bRet = true;
779 else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer
781 ScDrawView* pDrawView = pViewSh->GetScDrawView();
782 if (pDrawView)
784 pDrawView->ScEndTextEdit();
785 pDrawView->UnmarkAll();
787 if (pShapeImp) // einzelnes Shape
789 SdrObject *pObj = pShapeImp->GetSdrObject();
790 if (pObj)
792 lcl_ShowObject( *pViewSh, *pDrawView, pObj );
793 SdrPageView* pPV = pDrawView->GetSdrPageView();
794 if ( pPV && pObj->GetPage() == pPV->GetPage() )
796 pDrawView->MarkObj( pObj, pPV );
797 bRet = true;
801 else // Shape-Collection (xShapeColl ist nicht 0)
803 // Es wird auf die Tabelle des ersten Objekts umgeschaltet,
804 // und alle Objekte selektiert, die auf dieser Tabelle liegen
805 //! Exception, wenn Objekte auf verschiedenen Tabellen?
807 long nCount = xShapeColl->getCount();
808 if (nCount)
810 SdrPageView* pPV = NULL;
811 bool bAllMarked(true);
812 for ( long i = 0; i < nCount; i++ )
814 uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
815 if (xShapeInt.is())
817 SvxShape* pShape = SvxShape::getImplementation( xShapeInt );
818 if (pShape)
820 SdrObject *pObj = pShape->GetSdrObject();
821 if (pObj)
823 if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
825 pViewSh->SetDrawSelMode(true);
826 pViewSh->UpdateLayerLocks();
827 bDrawSelModeSet = true;
829 if (!pPV) // erstes Objekt
831 lcl_ShowObject( *pViewSh, *pDrawView, pObj );
832 pPV = pDrawView->GetSdrPageView();
834 if ( pPV && pObj->GetPage() == pPV->GetPage() )
836 if (pDrawView->IsObjMarkable( pObj, pPV ))
837 pDrawView->MarkObj( pObj, pPV );
838 else
839 bAllMarked = false;
845 if (bAllMarked)
846 bRet = true;
848 else
849 bRet = true; // empty XShapes (all shapes are deselected)
852 if (bRet)
853 pViewSh->SetDrawShell(true);
857 if (!bRet)
858 throw lang::IllegalArgumentException();
860 return bRet;
863 uno::Any SAL_CALL ScTabViewObj::getSelection()
864 throw(uno::RuntimeException, std::exception)
866 SolarMutexGuard aGuard;
867 ScTabViewShell* pViewSh = GetViewShell();
868 ScCellRangesBase* pObj = NULL;
869 if (pViewSh)
871 // Ist auf dem Drawing-Layer etwas selektiert?
873 SdrView* pDrawView = pViewSh->GetSdrView();
874 if (pDrawView)
876 const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
877 const size_t nMarkCount = rMarkList.GetMarkCount();
878 if (nMarkCount)
880 // ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw)
881 // Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein
883 uno::Reference< drawing::XShapes > xShapes = drawing::ShapeCollection::create(
884 comphelper::getProcessComponentContext());
886 uno::Reference<uno::XInterface> xRet(xShapes);
888 for (size_t i=0; i<nMarkCount; ++i)
890 SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
891 if (pDrawObj)
893 uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
894 if (xShape.is())
895 xShapes->add(xShape);
898 return uno::makeAny(xRet);
902 // sonst Tabellen-(Zellen-)Selektion
904 ScViewData& rViewData = pViewSh->GetViewData();
905 ScDocShell* pDocSh = rViewData.GetDocShell();
907 const ScMarkData& rMark = rViewData.GetMarkData();
908 SCTAB nTabs = rMark.GetSelectCount();
910 ScRange aRange;
911 ScMarkType eMarkType = rViewData.GetSimpleArea(aRange);
912 if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
914 if (aRange.aStart == aRange.aEnd)
915 pObj = new ScCellObj( pDocSh, aRange.aStart );
916 else
917 pObj = new ScCellRangeObj( pDocSh, aRange );
919 else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
921 ScMarkData aFilteredMark( rMark );
922 ScViewUtil::UnmarkFiltered( aFilteredMark, &pDocSh->GetDocument());
923 ScRangeList aRangeList;
924 aFilteredMark.FillRangeListWithMarks( &aRangeList, false);
925 // Theoretically a selection may start and end on a filtered row.
926 switch ( aRangeList.size() )
928 case 0:
929 // No unfiltered row, we have to return some object, so
930 // here is one with no ranges.
931 pObj = new ScCellRangesObj( pDocSh, aRangeList );
932 break;
933 case 1:
935 const ScRange& rRange = *(aRangeList[ 0 ]);
936 if (rRange.aStart == rRange.aEnd)
937 pObj = new ScCellObj( pDocSh, rRange.aStart );
938 else
939 pObj = new ScCellRangeObj( pDocSh, rRange );
941 break;
942 default:
943 pObj = new ScCellRangesObj( pDocSh, aRangeList );
946 else // Mehrfachselektion
948 ScRangeListRef xRanges;
949 rViewData.GetMultiArea( xRanges );
951 // bei mehreren Tabellen Ranges kopieren
952 //! sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren?
953 if ( nTabs > 1 )
954 rMark.ExtendRangeListTables( xRanges );
956 pObj = new ScCellRangesObj( pDocSh, *xRanges );
959 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
961 // remember if the selection was from the cursor position without anything selected
962 // (used when rendering the selection)
964 pObj->SetCursorOnly( true );
968 return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
971 // XEnumerationAccess
973 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
974 throw(uno::RuntimeException, std::exception)
976 SolarMutexGuard aGuard;
977 return new ScIndexEnumeration(this, OUString("com.sun.star.sheet.SpreadsheetViewPanesEnumeration"));
980 // XIndexAccess
982 sal_Int32 SAL_CALL ScTabViewObj::getCount() throw(uno::RuntimeException, std::exception)
984 SolarMutexGuard aGuard;
985 ScTabViewShell* pViewSh = GetViewShell();
986 sal_uInt16 nPanes = 0;
987 if (pViewSh)
989 nPanes = 1;
990 ScViewData& rViewData = pViewSh->GetViewData();
991 if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
992 nPanes *= 2;
993 if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
994 nPanes *= 2;
996 return nPanes;
999 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
1000 throw(lang::IndexOutOfBoundsException,
1001 lang::WrappedTargetException, uno::RuntimeException, std::exception)
1003 SolarMutexGuard aGuard;
1004 uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((sal_uInt16)nIndex));
1005 if (xPane.is())
1006 return uno::makeAny(xPane);
1007 else
1008 throw lang::IndexOutOfBoundsException();
1009 // return uno::Any();
1012 uno::Type SAL_CALL ScTabViewObj::getElementType() throw(uno::RuntimeException, std::exception)
1014 SolarMutexGuard aGuard;
1015 return cppu::UnoType<sheet::XViewPane>::get();
1018 sal_Bool SAL_CALL ScTabViewObj::hasElements() throw(uno::RuntimeException, std::exception)
1020 SolarMutexGuard aGuard;
1021 return ( getCount() != 0 );
1024 // XSpreadsheetView
1026 ScViewPaneObj* ScTabViewObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) const
1028 static const ScSplitPos ePosHV[4] =
1029 { SC_SPLIT_TOPLEFT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMRIGHT };
1031 ScTabViewShell* pViewSh = GetViewShell();
1032 if (pViewSh)
1034 ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default Position
1035 bool bError = false;
1036 ScViewData& rViewData = pViewSh->GetViewData();
1037 bool bHor = ( rViewData.GetHSplitMode() != SC_SPLIT_NONE );
1038 bool bVer = ( rViewData.GetVSplitMode() != SC_SPLIT_NONE );
1039 if ( bHor && bVer )
1041 // links oben, links unten, rechts oben, rechts unten - wie in Excel
1042 if ( nIndex < 4 )
1043 eWhich = ePosHV[nIndex];
1044 else
1045 bError = true;
1047 else if ( bHor )
1049 if ( nIndex > 1 )
1050 bError = true;
1051 else if ( nIndex == 1 )
1052 eWhich = SC_SPLIT_BOTTOMRIGHT;
1053 // sonst SC_SPLIT_BOTTOMLEFT
1055 else if ( bVer )
1057 if ( nIndex > 1 )
1058 bError = true;
1059 else if ( nIndex == 0 )
1060 eWhich = SC_SPLIT_TOPLEFT;
1061 // sonst SC_SPLIT_BOTTOMLEFT
1063 else if ( nIndex > 0 )
1064 bError = true; // nicht geteilt: nur 0 gueltig
1066 if (!bError)
1067 return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) );
1070 return NULL;
1073 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1074 throw(uno::RuntimeException, std::exception)
1076 SolarMutexGuard aGuard;
1077 ScTabViewShell* pViewSh = GetViewShell();
1078 if (pViewSh)
1080 ScViewData& rViewData = pViewSh->GetViewData();
1081 SCTAB nTab = rViewData.GetTabNo();
1082 return new ScTableSheetObj( rViewData.GetDocShell(), nTab );
1084 return NULL;
1087 // support expand (but not replace) the active sheet
1088 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1089 throw(uno::RuntimeException, std::exception)
1091 SolarMutexGuard aGuard;
1093 ScTabViewShell* pViewSh = GetViewShell();
1094 if ( pViewSh && xActiveSheet.is() )
1096 // XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein
1098 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xActiveSheet );
1099 if ( pRangesImp && pViewSh->GetViewData().GetDocShell() == pRangesImp->GetDocShell() )
1101 const ScRangeList& rRanges = pRangesImp->GetRangeList();
1102 if ( rRanges.size() == 1 )
1104 SCTAB nNewTab = rRanges[ 0 ]->aStart.Tab();
1105 if ( pViewSh->GetViewData().GetDocument()->HasTable(nNewTab) )
1106 pViewSh->SetTabNo( nNewTab );
1112 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1114 uno::Reference< uno::XInterface > xTarget;
1115 if (GetViewShell())
1117 SCsCOL nX;
1118 SCsROW nY;
1119 ScViewData& rData = GetViewShell()->GetViewData();
1120 ScSplitPos eSplitMode = rData.GetActivePart();
1121 SCTAB nTab(rData.GetTabNo());
1122 rData.GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1124 ScAddress aCellPos (nX, nY, nTab);
1125 ScCellObj* pCellObj = new ScCellObj(rData.GetDocShell(), aCellPos);
1127 xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1129 ScDocument* pDoc = rData.GetDocument();
1130 if (pDoc && pDoc->GetDrawLayer())
1132 SdrPage* pDrawPage = NULL;
1133 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1134 if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1135 pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1137 SdrView* pDrawView = GetViewShell()->GetSdrView();
1139 if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1141 vcl::Window* pActiveWin = rData.GetActiveWin();
1142 Point aPos = pActiveWin->PixelToLogic(rPoint);
1144 sal_uInt16 nHitLog = (sal_uInt16) pActiveWin->PixelToLogic(
1145 Size(pDrawView->GetHitTolerancePixel(),0)).Width();
1147 const size_t nCount(pDrawPage->GetObjCount());
1148 bool bFound(false);
1149 for (size_t i = 0; i < nCount && !bFound; ++i)
1151 SdrObject* pObj = pDrawPage->GetObj(i);
1152 if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), 0, false))
1154 xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1155 bFound = true;
1161 return xTarget;
1164 bool ScTabViewObj::IsMouseListening() const
1166 if ( !aMouseClickHandlers.empty() )
1167 return true;
1169 // also include sheet events, because MousePressed must be called for them
1170 ScViewData& rViewData = GetViewShell()->GetViewData();
1171 ScDocument* pDoc = rViewData.GetDocument();
1172 SCTAB nTab = rViewData.GetTabNo();
1173 return
1174 pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) ||
1175 pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ) ||
1176 pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_SELECT, true );
1180 bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1181 throw (::uno::RuntimeException)
1183 bool bReturn(false);
1184 if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
1185 mbLeftMousePressed = true;
1187 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1188 if (!aMouseClickHandlers.empty() && xTarget.is())
1190 awt::EnhancedMouseEvent aMouseEvent;
1192 aMouseEvent.Buttons = e.Buttons;
1193 aMouseEvent.X = e.X;
1194 aMouseEvent.Y = e.Y;
1195 aMouseEvent.ClickCount = e.ClickCount;
1196 aMouseEvent.PopupTrigger = e.PopupTrigger;
1197 aMouseEvent.Target = xTarget;
1198 aMouseEvent.Modifiers = e.Modifiers;
1200 for (XMouseClickHandlerVector::iterator it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1204 if (!(*it)->mousePressed( aMouseEvent ))
1205 bReturn = true;
1206 ++it;
1208 catch ( uno::Exception& )
1210 it = aMouseClickHandlers.erase(it);
1215 // handle sheet events
1216 bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1217 bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1218 if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1220 sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK;
1222 ScTabViewShell* pViewSh = GetViewShell();
1223 ScViewData& rViewData = pViewSh->GetViewData();
1224 ScDocShell* pDocSh = rViewData.GetDocShell();
1225 ScDocument& rDoc = pDocSh->GetDocument();
1226 SCTAB nTab = rViewData.GetTabNo();
1227 const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1228 if (pEvents)
1230 const OUString* pScript = pEvents->GetScript(nEvent);
1231 if (pScript)
1233 // the macro parameter is the clicked object, as in the mousePressed call above
1234 uno::Sequence<uno::Any> aParams(1);
1235 aParams[0] <<= xTarget;
1237 uno::Any aRet;
1238 uno::Sequence<sal_Int16> aOutArgsIndex;
1239 uno::Sequence<uno::Any> aOutArgs;
1241 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1243 // look for a boolean return value of true
1244 bool bRetValue = false;
1245 if (aRet >>= bRetValue)
1247 if (bRetValue)
1248 bReturn = true;
1253 // execute VBA event handler
1254 if (!bReturn && xTarget.is()) try
1256 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1257 // the parameter is the clicked object, as in the mousePressed call above
1258 uno::Sequence< uno::Any > aArgs( 1 );
1259 aArgs[ 0 ] <<= xTarget;
1260 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1262 catch( util::VetoException& )
1264 bReturn = true;
1266 catch( uno::Exception& )
1271 return bReturn;
1274 bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1275 throw (uno::RuntimeException)
1277 if ( e.Buttons == ::com::sun::star::awt::MouseButton::LEFT )
1281 mbPendingSelectionChanged = false;
1282 ScTabViewShell* pViewSh = GetViewShell();
1283 ScViewData& rViewData = pViewSh->GetViewData();
1284 ScDocShell* pDocSh = rViewData.GetDocShell();
1285 ScDocument& rDoc = pDocSh->GetDocument();
1286 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1287 uno::Sequence< uno::Any > aArgs( 1 );
1288 aArgs[ 0 ] <<= getSelection();
1289 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
1291 catch( uno::Exception& )
1294 mbLeftMousePressed = false;
1297 bool bReturn(false);
1299 if (!aMouseClickHandlers.empty())
1301 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1303 if (xTarget.is())
1305 awt::EnhancedMouseEvent aMouseEvent;
1307 aMouseEvent.Buttons = e.Buttons;
1308 aMouseEvent.X = e.X;
1309 aMouseEvent.Y = e.Y;
1310 aMouseEvent.ClickCount = e.ClickCount;
1311 aMouseEvent.PopupTrigger = e.PopupTrigger;
1312 aMouseEvent.Target = xTarget;
1313 aMouseEvent.Modifiers = e.Modifiers;
1315 for (XMouseClickHandlerVector::iterator it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1319 if (!(*it)->mouseReleased( aMouseEvent ))
1320 bReturn = true;
1321 ++it;
1323 catch ( uno::Exception& )
1325 it = aMouseClickHandlers.erase(it);
1330 return bReturn;
1333 // XEnhancedMouseClickBroadcaster
1335 void ScTabViewObj::EndMouseListening()
1337 lang::EventObject aEvent;
1338 aEvent.Source = (cppu::OWeakObject*)this;
1339 for (const XMouseClickHandlerUnoRef rListener : aMouseClickHandlers)
1343 rListener->disposing(aEvent);
1345 catch ( uno::Exception& )
1349 aMouseClickHandlers.clear();
1352 void ScTabViewObj::EndActivationListening()
1354 lang::EventObject aEvent;
1355 aEvent.Source = (cppu::OWeakObject*)this;
1356 for (const XActivationEventListenerUnoRef rListener : aActivationListeners)
1360 rListener->disposing(aEvent);
1362 catch ( uno::Exception& )
1366 aActivationListeners.clear();
1369 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1370 throw (uno::RuntimeException, std::exception)
1372 SolarMutexGuard aGuard;
1374 if (aListener.is())
1376 uno::Reference<awt::XEnhancedMouseClickHandler> *pObj =
1377 new uno::Reference<awt::XEnhancedMouseClickHandler>( aListener );
1378 aMouseClickHandlers.push_back( pObj );
1382 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1383 throw (uno::RuntimeException, std::exception)
1385 SolarMutexGuard aGuard;
1386 sal_uInt16 nCount = aMouseClickHandlers.size();
1387 for (XMouseClickHandlerVector::iterator it = aMouseClickHandlers.begin(); it != aMouseClickHandlers.end(); )
1389 if ( *it == aListener )
1390 it = aMouseClickHandlers.erase(it);
1391 else
1392 ++it;
1394 if ((aMouseClickHandlers.size() == 0) && (nCount > 0)) // only if last listener removed
1395 EndMouseListening();
1398 // XActivationBroadcaster
1400 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1401 throw (uno::RuntimeException, std::exception)
1403 SolarMutexGuard aGuard;
1405 if (aListener.is())
1407 uno::Reference<sheet::XActivationEventListener> *pObj =
1408 new uno::Reference<sheet::XActivationEventListener>( aListener );
1409 aActivationListeners.push_back( pObj );
1413 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1414 throw (uno::RuntimeException, std::exception)
1416 SolarMutexGuard aGuard;
1417 sal_uInt16 nCount = aActivationListeners.size();
1418 for (XActivationEventListenerVector::iterator it = aActivationListeners.begin(); it != aActivationListeners.end(); )
1420 if ( *it == aListener )
1421 it = aActivationListeners.erase(it);
1422 else
1423 ++it;
1425 if ((aActivationListeners.size() == 0) && (nCount > 0)) // only if last listener removed
1426 EndActivationListening();
1429 sal_Int16 ScTabViewObj::GetZoom() const
1431 ScTabViewShell* pViewSh = GetViewShell();
1432 if (pViewSh)
1434 const Fraction& rZoomY = pViewSh->GetViewData().GetZoomY(); // Y wird angezeigt
1435 return (sal_Int16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator());
1437 return 0;
1440 void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1442 ScTabViewShell* pViewSh = GetViewShell();
1443 if (pViewSh)
1445 if ( nZoom != GetZoom() && nZoom != 0 )
1447 if (!pViewSh->GetViewData().IsPagebreakMode())
1449 ScModule* pScMod = SC_MOD();
1450 ScAppOptions aNewOpt(pScMod->GetAppOptions());
1451 aNewOpt.SetZoom( nZoom );
1452 aNewOpt.SetZoomType( pViewSh->GetViewData().GetView()->GetZoomType() );
1453 pScMod->SetAppOptions( aNewOpt );
1456 Fraction aFract( nZoom, 100 );
1457 pViewSh->SetZoom( aFract, aFract, true );
1458 pViewSh->PaintGrid();
1459 pViewSh->PaintTop();
1460 pViewSh->PaintLeft();
1461 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1462 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1466 sal_Int16 ScTabViewObj::GetZoomType() const
1468 sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1469 ScTabViewShell* pViewSh = GetViewShell();
1470 if (pViewSh)
1472 SvxZoomType eZoomType = pViewSh->GetViewData().GetView()->GetZoomType();
1473 switch (eZoomType)
1475 case SvxZoomType::PERCENT:
1476 aZoomType = view::DocumentZoomType::BY_VALUE;
1477 break;
1478 case SvxZoomType::OPTIMAL:
1479 aZoomType = view::DocumentZoomType::OPTIMAL;
1480 break;
1481 case SvxZoomType::WHOLEPAGE:
1482 aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1483 break;
1484 case SvxZoomType::PAGEWIDTH:
1485 aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1486 break;
1487 case SvxZoomType::PAGEWIDTH_NOBORDER:
1488 aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1489 break;
1492 return aZoomType;
1495 void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1497 ScTabViewShell* pViewSh = GetViewShell();
1498 if (pViewSh)
1500 ScDBFunc* pView = pViewSh->GetViewData().GetView();
1501 if (pView)
1503 SvxZoomType eZoomType;
1504 switch (aZoomType)
1506 case view::DocumentZoomType::BY_VALUE:
1507 eZoomType = SvxZoomType::PERCENT;
1508 break;
1509 case view::DocumentZoomType::OPTIMAL:
1510 eZoomType = SvxZoomType::OPTIMAL;
1511 break;
1512 case view::DocumentZoomType::ENTIRE_PAGE:
1513 eZoomType = SvxZoomType::WHOLEPAGE;
1514 break;
1515 case view::DocumentZoomType::PAGE_WIDTH:
1516 eZoomType = SvxZoomType::PAGEWIDTH;
1517 break;
1518 case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1519 eZoomType = SvxZoomType::PAGEWIDTH_NOBORDER;
1520 break;
1521 default:
1522 eZoomType = SvxZoomType::OPTIMAL;
1524 sal_Int16 nZoom(GetZoom());
1525 sal_Int16 nOldZoom(nZoom);
1526 if ( eZoomType == SvxZoomType::PERCENT )
1528 if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1529 if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1531 else
1532 nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1534 switch ( eZoomType )
1536 case SvxZoomType::WHOLEPAGE:
1537 case SvxZoomType::PAGEWIDTH:
1538 pView->SetZoomType( eZoomType, true );
1539 break;
1541 default:
1542 pView->SetZoomType( SvxZoomType::PERCENT, true );
1544 SetZoom( nZoom );
1549 sal_Bool SAL_CALL ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException, std::exception)
1551 SolarMutexGuard aGuard;
1552 // wie Menue-Slot SID_WINDOW_SPLIT
1554 ScTabViewShell* pViewSh = GetViewShell();
1555 if (pViewSh)
1557 ScViewData& rViewData = pViewSh->GetViewData();
1558 return ( rViewData.GetHSplitMode() == SC_SPLIT_NORMAL ||
1559 rViewData.GetVSplitMode() == SC_SPLIT_NORMAL );
1562 return false;
1565 sal_Bool SAL_CALL ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException, std::exception)
1567 SolarMutexGuard aGuard;
1568 // wie Menue-Slot SID_WINDOW_FIX
1570 ScTabViewShell* pViewSh = GetViewShell();
1571 if (pViewSh)
1573 ScViewData& rViewData = pViewSh->GetViewData();
1574 return ( rViewData.GetHSplitMode() == SC_SPLIT_FIX ||
1575 rViewData.GetVSplitMode() == SC_SPLIT_FIX );
1578 return false;
1581 sal_Int32 SAL_CALL ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException, std::exception)
1583 SolarMutexGuard aGuard;
1584 ScTabViewShell* pViewSh = GetViewShell();
1585 if (pViewSh)
1587 ScViewData& rViewData = pViewSh->GetViewData();
1588 if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1589 return rViewData.GetHSplitPos();
1591 return 0;
1594 sal_Int32 SAL_CALL ScTabViewObj::getSplitVertical() throw(uno::RuntimeException, std::exception)
1596 SolarMutexGuard aGuard;
1597 ScTabViewShell* pViewSh = GetViewShell();
1598 if (pViewSh)
1600 ScViewData& rViewData = pViewSh->GetViewData();
1601 if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1602 return rViewData.GetVSplitPos();
1604 return 0;
1607 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn()
1608 throw(uno::RuntimeException, std::exception)
1610 SolarMutexGuard aGuard;
1611 ScTabViewShell* pViewSh = GetViewShell();
1612 if (pViewSh)
1614 ScViewData& rViewData = pViewSh->GetViewData();
1615 if ( rViewData.GetHSplitMode() != SC_SPLIT_NONE )
1617 long nSplit = rViewData.GetHSplitPos();
1619 ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
1620 if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1621 ePos = SC_SPLIT_TOPLEFT;
1623 SCsCOL nCol;
1624 SCsROW nRow;
1625 rViewData.GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, false );
1626 if ( nCol > 0 )
1627 return nCol;
1630 return 0;
1633 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow() throw(uno::RuntimeException, std::exception)
1635 SolarMutexGuard aGuard;
1636 ScTabViewShell* pViewSh = GetViewShell();
1637 if (pViewSh)
1639 ScViewData& rViewData = pViewSh->GetViewData();
1640 if ( rViewData.GetVSplitMode() != SC_SPLIT_NONE )
1642 long nSplit = rViewData.GetVSplitPos();
1644 ScSplitPos ePos = SC_SPLIT_TOPLEFT; // es ist vertikal geteilt
1645 SCsCOL nCol;
1646 SCsROW nRow;
1647 rViewData.GetPosFromPixel( 0, nSplit, ePos, nCol, nRow, false );
1648 if ( nRow > 0 )
1649 return nRow;
1652 return 0;
1655 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1656 throw(uno::RuntimeException, std::exception)
1658 SolarMutexGuard aGuard;
1659 ScTabViewShell* pViewSh = GetViewShell();
1660 if (pViewSh)
1662 pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ), true, true );
1663 pViewSh->FreezeSplitters( false );
1664 pViewSh->InvalidateSplit();
1668 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1669 throw(uno::RuntimeException, std::exception)
1671 SolarMutexGuard aGuard;
1672 ScTabViewShell* pViewSh = GetViewShell();
1673 if (pViewSh)
1675 // erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae.
1677 pViewSh->RemoveSplit();
1679 Point aWinStart;
1680 vcl::Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1681 if (pWin)
1682 aWinStart = pWin->GetPosPixel();
1684 ScViewData& rViewData = pViewSh->GetViewData();
1685 Point aSplit(rViewData.GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, true ));
1686 aSplit += aWinStart;
1688 pViewSh->SplitAtPixel( aSplit, true, true );
1689 pViewSh->FreezeSplitters( true );
1690 pViewSh->InvalidateSplit();
1694 void SAL_CALL ScTabViewObj::addSelectionChangeListener(
1695 const uno::Reference<view::XSelectionChangeListener>& xListener )
1696 throw (uno::RuntimeException, std::exception)
1698 SolarMutexGuard aGuard;
1699 uno::Reference<view::XSelectionChangeListener>* pObj =
1700 new uno::Reference<view::XSelectionChangeListener>( xListener );
1701 aSelectionChgListeners.push_back( pObj );
1704 void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
1705 const uno::Reference< view::XSelectionChangeListener >& xListener )
1706 throw(uno::RuntimeException, std::exception)
1708 SolarMutexGuard aGuard;
1709 for (XSelectionChangeListenerVector::iterator it = aSelectionChgListeners.begin();
1710 it != aSelectionChgListeners.end(); ++it )
1712 if ( *it == xListener ) //! wozu der Mumpitz mit queryInterface?
1714 aSelectionChgListeners.erase(it);
1715 break;
1720 void ScTabViewObj::SelectionChanged()
1722 // Selection changed so end any style preview
1723 // Note: executing this slot through the dispatcher
1724 // will cause the style dialog to be raised so we go
1725 // direct here
1726 ScFormatShell aShell( &GetViewShell()->GetViewData() );
1727 SfxAllItemSet reqList( SfxGetpApp()->GetPool() );
1728 SfxRequest aReq( SID_STYLE_END_PREVIEW, SfxCallMode::SLOT, reqList );
1729 aShell.ExecuteStyle( aReq );
1730 lang::EventObject aEvent;
1731 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1732 for (const XSelectionChangeListenerUnoRef rListener : aSelectionChgListeners)
1733 rListener->selectionChanged( aEvent );
1735 // handle sheet events
1736 ScTabViewShell* pViewSh = GetViewShell();
1737 ScViewData& rViewData = pViewSh->GetViewData();
1738 ScDocShell* pDocSh = rViewData.GetDocShell();
1739 ScDocument& rDoc = pDocSh->GetDocument();
1740 SCTAB nTab = rViewData.GetTabNo();
1741 const ScSheetEvents* pEvents = rDoc.GetSheetEvents(nTab);
1742 if (pEvents)
1744 const OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_SELECT);
1745 if (pScript)
1747 // the macro parameter is the selection as returned by getSelection
1748 uno::Sequence<uno::Any> aParams(1);
1749 aParams[0] = getSelection();
1750 uno::Any aRet;
1751 uno::Sequence<sal_Int16> aOutArgsIndex;
1752 uno::Sequence<uno::Any> aOutArgs;
1753 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1756 if ( !mbLeftMousePressed ) // selection still in progress
1758 mbPendingSelectionChanged = false;
1761 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( rDoc.GetVbaEventProcessor(), uno::UNO_SET_THROW );
1762 uno::Sequence< uno::Any > aArgs( 1 );
1763 aArgs[ 0 ] <<= getSelection();
1764 xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
1766 catch( uno::Exception& )
1770 else
1772 mbPendingSelectionChanged = true;
1776 // XPropertySet (View-Optionen)
1777 //! auch an der Applikation anbieten?
1779 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1780 throw(uno::RuntimeException, std::exception)
1782 SolarMutexGuard aGuard;
1783 static uno::Reference<beans::XPropertySetInfo> aRef(
1784 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
1785 return aRef;
1788 void SAL_CALL ScTabViewObj::setPropertyValue(
1789 const OUString& aPropertyName, const uno::Any& aValue )
1790 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1791 lang::IllegalArgumentException, lang::WrappedTargetException,
1792 uno::RuntimeException, std::exception)
1794 SolarMutexGuard aGuard;
1795 OUString aString(aPropertyName);
1797 if ( aString == SC_UNO_FILTERED_RANGE_SELECTION )
1799 bFilteredRangeSelection = ScUnoHelpFunctions::GetBoolFromAny(aValue);
1800 return;
1803 ScTabViewShell* pViewSh = GetViewShell();
1804 if (pViewSh)
1806 ScViewData& rViewData = pViewSh->GetViewData();
1807 const ScViewOptions& rOldOpt = pViewSh->GetViewData().GetOptions();
1808 ScViewOptions aNewOpt(rOldOpt);
1810 if ( aString == SC_UNO_COLROWHDR || aString == OLD_UNO_COLROWHDR )
1811 aNewOpt.SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1812 else if ( aString == SC_UNO_HORSCROLL || aString == OLD_UNO_HORSCROLL )
1813 aNewOpt.SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1814 else if ( aString == SC_UNO_OUTLSYMB || aString == OLD_UNO_OUTLSYMB )
1815 aNewOpt.SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1816 else if ( aString == SC_UNO_SHEETTABS || aString == OLD_UNO_SHEETTABS )
1817 aNewOpt.SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1818 else if ( aString == SC_UNO_SHOWANCHOR )
1819 aNewOpt.SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1820 else if ( aString == SC_UNO_SHOWFORM )
1821 aNewOpt.SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1822 else if ( aString == SC_UNO_SHOWGRID )
1823 aNewOpt.SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1824 else if ( aString == SC_UNO_SHOWHELP )
1825 aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1826 else if ( aString == SC_UNO_SHOWNOTES )
1827 aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1828 else if ( aString == SC_UNO_SHOWPAGEBR )
1829 aNewOpt.SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1830 else if ( aString == SC_UNO_SHOWZERO )
1831 aNewOpt.SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1832 else if ( aString == SC_UNO_VALUEHIGH || aString == OLD_UNO_VALUEHIGH )
1833 aNewOpt.SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1834 else if ( aString == SC_UNO_VERTSCROLL || aString == OLD_UNO_VERTSCROLL )
1835 aNewOpt.SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1836 else if ( aString == SC_UNO_SHOWOBJ )
1838 sal_Int16 nIntVal = 0;
1839 if ( aValue >>= nIntVal )
1841 //#i80528# adapt to new range eventually
1842 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1844 aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
1847 else if ( aString == SC_UNO_SHOWCHARTS )
1849 sal_Int16 nIntVal = 0;
1850 if ( aValue >>= nIntVal )
1852 //#i80528# adapt to new range eventually
1853 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1855 aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
1858 else if ( aString == SC_UNO_SHOWDRAW )
1860 sal_Int16 nIntVal = 0;
1861 if ( aValue >>= nIntVal )
1863 //#i80528# adapt to new range eventually
1864 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1866 aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
1869 else if ( aString == SC_UNO_GRIDCOLOR )
1871 sal_Int32 nIntVal = 0;
1872 if ( aValue >>= nIntVal )
1873 aNewOpt.SetGridColor( nIntVal, OUString() );
1875 else if ( aString == SC_UNO_ZOOMTYPE )
1877 sal_Int16 nIntVal = 0;
1878 if ( aValue >>= nIntVal )
1879 SetZoomType(nIntVal);
1881 else if ( aString == SC_UNO_ZOOMVALUE )
1883 sal_Int16 nIntVal = 0;
1884 if ( aValue >>= nIntVal )
1885 SetZoom(nIntVal);
1888 // Optionen werden an der View und am Dokument (fuer neue Views) gesetzt,
1889 // damit sie beim Speichern erhalten bleiben.
1890 //! An der App (Module) braeuchte man noch eine Extra-Moeglichkeit,
1891 //! das einzustellen (fuer neue Dokumente)
1893 if ( aNewOpt != rOldOpt )
1895 rViewData.SetOptions( aNewOpt );
1896 rViewData.GetDocument()->SetViewOptions( aNewOpt );
1897 rViewData.GetDocShell()->SetDocumentModified(); //! wirklich?
1899 pViewSh->UpdateFixPos();
1900 pViewSh->PaintGrid();
1901 pViewSh->PaintTop();
1902 pViewSh->PaintLeft();
1903 pViewSh->PaintExtras();
1904 pViewSh->InvalidateBorder();
1906 SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1907 rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
1908 rBindings.Invalidate( FID_TOGGLESYNTAX );
1913 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const OUString& aPropertyName )
1914 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1915 uno::RuntimeException, std::exception)
1917 SolarMutexGuard aGuard;
1918 OUString aString(aPropertyName);
1919 uno::Any aRet;
1921 if ( aString == SC_UNO_FILTERED_RANGE_SELECTION )
1923 ScUnoHelpFunctions::SetBoolInAny(aRet, bFilteredRangeSelection);
1924 return aRet;
1927 ScTabViewShell* pViewSh = GetViewShell();
1928 if (pViewSh)
1930 const ScViewOptions& rOpt = pViewSh->GetViewData().GetOptions();
1932 if ( aString == SC_UNO_COLROWHDR || aString == OLD_UNO_COLROWHDR )
1933 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HEADER ) );
1934 else if ( aString == SC_UNO_HORSCROLL || aString == OLD_UNO_HORSCROLL )
1935 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HSCROLL ) );
1936 else if ( aString == SC_UNO_OUTLSYMB || aString == OLD_UNO_OUTLSYMB )
1937 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_OUTLINER ) );
1938 else if ( aString == SC_UNO_SHEETTABS || aString == OLD_UNO_SHEETTABS )
1939 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_TABCONTROLS ) );
1940 else if ( aString == SC_UNO_SHOWANCHOR ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_ANCHOR ) );
1941 else if ( aString == SC_UNO_SHOWFORM ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_FORMULAS ) );
1942 else if ( aString == SC_UNO_SHOWGRID ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_GRID ) );
1943 else if ( aString == SC_UNO_SHOWHELP ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HELPLINES ) );
1944 else if ( aString == SC_UNO_SHOWNOTES ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NOTES ) );
1945 else if ( aString == SC_UNO_SHOWPAGEBR ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_PAGEBREAKS ) );
1946 else if ( aString == SC_UNO_SHOWZERO ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NULLVALS ) );
1947 else if ( aString == SC_UNO_VALUEHIGH || aString == OLD_UNO_VALUEHIGH )
1948 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SYNTAX ) );
1949 else if ( aString == SC_UNO_VERTSCROLL || aString == OLD_UNO_VERTSCROLL )
1950 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_VSCROLL ) );
1951 else if ( aString == SC_UNO_SHOWOBJ ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1952 else if ( aString == SC_UNO_SHOWCHARTS ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1953 else if ( aString == SC_UNO_SHOWDRAW ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1954 else if ( aString == SC_UNO_GRIDCOLOR ) aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() );
1955 else if ( aString == SC_UNO_VISAREA ) aRet <<= GetVisArea();
1956 else if ( aString == SC_UNO_ZOOMTYPE ) aRet <<= GetZoomType();
1957 else if ( aString == SC_UNO_ZOOMVALUE ) aRet <<= GetZoom();
1958 else if ( aString == SC_UNO_VISAREASCREEN )
1960 ScViewData& rViewData = pViewSh->GetViewData();
1961 vcl::Window* pActiveWin = rViewData.GetActiveWin();
1962 if ( pActiveWin )
1964 Rectangle aRect = pActiveWin->GetWindowExtentsRelative( NULL );
1965 aRet <<= AWTRectangle( aRect );
1970 return aRet;
1973 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const OUString& /* aPropertyName */,
1974 const uno::Reference<beans::XPropertyChangeListener >& xListener )
1975 throw (beans::UnknownPropertyException,
1976 lang::WrappedTargetException,
1977 uno::RuntimeException,
1978 std::exception)
1980 SolarMutexGuard aGuard;
1981 uno::Reference<beans::XPropertyChangeListener>* pObj =
1982 new uno::Reference<beans::XPropertyChangeListener>( xListener );
1983 aPropertyChgListeners.push_back( pObj );
1986 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const OUString& /* aPropertyName */,
1987 const uno::Reference<beans::XPropertyChangeListener >& xListener )
1988 throw(beans::UnknownPropertyException,
1989 lang::WrappedTargetException,
1990 uno::RuntimeException, std::exception)
1992 SolarMutexGuard aGuard;
1993 for (XViewPropertyChangeListenerVector::iterator it = aPropertyChgListeners.begin();
1994 it != aPropertyChgListeners.end(); ++it )
1996 if ( *it == xListener ) //! wozu der Mumpitz mit queryInterface?
1998 aPropertyChgListeners.erase(it);
1999 break;
2004 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const OUString& /* PropertyName */,
2005 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2006 throw(beans::UnknownPropertyException,
2007 lang::WrappedTargetException,
2008 uno::RuntimeException, std::exception)
2012 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const OUString& /* PropertyName */,
2013 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2014 throw(beans::UnknownPropertyException,
2015 lang::WrappedTargetException,
2016 uno::RuntimeException, std::exception)
2020 void ScTabViewObj::VisAreaChanged()
2022 beans::PropertyChangeEvent aEvent;
2023 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2024 for (const XViewPropertyChangeListenerUnoRef rListener : aPropertyChgListeners)
2025 rListener->propertyChange( aEvent );
2028 // XRangeSelection
2030 void SAL_CALL ScTabViewObj::startRangeSelection(
2031 const uno::Sequence<beans::PropertyValue>& aArguments )
2032 throw(uno::RuntimeException, std::exception)
2034 SolarMutexGuard aGuard;
2035 ScTabViewShell* pViewSh = GetViewShell();
2036 if (pViewSh)
2038 OUString aInitVal, aTitle;
2039 bool bCloseOnButtonUp = false;
2040 bool bSingleCell = false;
2041 bool bMultiSelection = false;
2043 OUString aStrVal;
2044 const beans::PropertyValue* pPropArray = aArguments.getConstArray();
2045 long nPropCount = aArguments.getLength();
2046 for (long i = 0; i < nPropCount; i++)
2048 const beans::PropertyValue& rProp = pPropArray[i];
2049 OUString aPropName(rProp.Name);
2051 if (aPropName == SC_UNONAME_CLOSEONUP )
2052 bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2053 else if (aPropName == SC_UNONAME_TITLE )
2055 if ( rProp.Value >>= aStrVal )
2056 aTitle = aStrVal;
2058 else if (aPropName == SC_UNONAME_INITVAL )
2060 if ( rProp.Value >>= aStrVal )
2061 aInitVal = aStrVal;
2063 else if (aPropName == SC_UNONAME_SINGLECELL )
2064 bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2065 else if (aPropName == SC_UNONAME_MULTISEL )
2066 bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2069 pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
2073 void SAL_CALL ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException, std::exception)
2075 SolarMutexGuard aGuard;
2076 ScTabViewShell* pViewSh = GetViewShell();
2077 if (pViewSh)
2078 pViewSh->StopSimpleRefDialog();
2081 void SAL_CALL ScTabViewObj::addRangeSelectionListener(
2082 const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2083 throw (uno::RuntimeException, std::exception)
2085 SolarMutexGuard aGuard;
2086 uno::Reference<sheet::XRangeSelectionListener>* pObj =
2087 new uno::Reference<sheet::XRangeSelectionListener>( xListener );
2088 aRangeSelListeners.push_back( pObj );
2091 void SAL_CALL ScTabViewObj::removeRangeSelectionListener(
2092 const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2093 throw(uno::RuntimeException, std::exception)
2095 SolarMutexGuard aGuard;
2096 for (XRangeSelectionListenerVector::iterator it = aRangeSelListeners.begin();
2097 it != aRangeSelListeners.end(); ++it )
2099 if ( *it == xListener )
2101 aRangeSelListeners.erase(it);
2102 break;
2107 void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener(
2108 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2109 throw (uno::RuntimeException, std::exception)
2111 SolarMutexGuard aGuard;
2112 uno::Reference<sheet::XRangeSelectionChangeListener>* pObj =
2113 new uno::Reference<sheet::XRangeSelectionChangeListener>( xListener );
2114 aRangeChgListeners.push_back( pObj );
2117 void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener(
2118 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2119 throw(uno::RuntimeException, std::exception)
2121 SolarMutexGuard aGuard;
2122 for (XRangeSelectionChangeListenerVector::iterator it = aRangeChgListeners.begin();
2123 it != aRangeChgListeners.end(); ++it )
2125 if ( *it == xListener )
2127 aRangeChgListeners.erase(it);
2128 break;
2133 void ScTabViewObj::RangeSelDone( const OUString& rText )
2135 sheet::RangeSelectionEvent aEvent;
2136 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2137 aEvent.RangeDescriptor = OUString( rText );
2139 // copy on the stack because listener could remove itself
2140 XRangeSelectionListenerVector const listeners(aRangeSelListeners);
2142 for (const XRangeSelectionListenerUnoRef rListener : listeners)
2143 rListener->done( aEvent );
2146 void ScTabViewObj::RangeSelAborted( const OUString& rText )
2148 sheet::RangeSelectionEvent aEvent;
2149 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2150 aEvent.RangeDescriptor = OUString( rText );
2152 // copy on the stack because listener could remove itself
2153 XRangeSelectionListenerVector const listeners(aRangeSelListeners);
2155 for (const XRangeSelectionListenerUnoRef rListener : listeners)
2156 rListener->aborted( aEvent );
2159 void ScTabViewObj::RangeSelChanged( const OUString& rText )
2161 sheet::RangeSelectionEvent aEvent;
2162 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2163 aEvent.RangeDescriptor = OUString( rText );
2165 // copy on the stack because listener could remove itself
2166 XRangeSelectionChangeListenerVector const listener(aRangeChgListeners);
2168 for (const XRangeSelectionChangeListenerUnoRef rListener : listener)
2169 rListener->descriptorChanged( aEvent );
2172 // XServiceInfo
2173 OUString SAL_CALL ScTabViewObj::getImplementationName() throw(uno::RuntimeException, std::exception)
2175 return OUString( "ScTabViewObj" );
2178 sal_Bool SAL_CALL ScTabViewObj::supportsService( const OUString& rServiceName )
2179 throw(uno::RuntimeException, std::exception)
2181 return cppu::supportsService(this, rServiceName);
2184 uno::Sequence<OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2185 throw(uno::RuntimeException, std::exception)
2187 uno::Sequence<OUString> aRet(2);
2188 OUString* pArray = aRet.getArray();
2189 pArray[0] = SCTABVIEWOBJ_SERVICE;
2190 pArray[1] = SCVIEWSETTINGS_SERVICE;
2191 return aRet;
2194 // XUnoTunnel
2196 sal_Int64 SAL_CALL ScTabViewObj::getSomething(
2197 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception)
2199 if ( rId.getLength() == 16 &&
2200 0 == memcmp( getUnoTunnelId().getConstArray(),
2201 rId.getConstArray(), 16 ) )
2203 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2205 return 0;
2208 namespace
2210 class theScTabViewObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScTabViewObjUnoTunnelId> {};
2213 const uno::Sequence<sal_Int8>& ScTabViewObj::getUnoTunnelId()
2215 return theScTabViewObjUnoTunnelId::get().getSeq();
2218 ScTabViewObj* ScTabViewObj::getImplementation(const uno::Reference<uno::XInterface>& rObj)
2220 ScTabViewObj* pRet = NULL;
2221 uno::Reference<lang::XUnoTunnel> xUT(rObj, uno::UNO_QUERY);
2222 if (xUT.is())
2223 pRet = reinterpret_cast<ScTabViewObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
2224 return pRet;
2227 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable()
2228 throw (::com::sun::star::uno::RuntimeException,
2229 std::exception)
2231 SolarMutexGuard aGuard;
2232 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2233 if (pShell)
2234 return pShell->GetEditView()->GetTransferable();
2236 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2237 if (pTextShell)
2239 ScViewData& rViewData = GetViewShell()->GetViewData();
2240 ScDrawView* pView = rViewData.GetScDrawView();
2241 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2242 if (pOutView)
2243 return pOutView->GetEditView().GetTransferable();
2246 ScDrawShell* pDrawShell = PTR_CAST( ScDrawShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2247 if (pDrawShell)
2248 return pDrawShell->GetDrawView()->CopyToTransferable();
2250 ScTransferObj* pObj = GetViewShell()->CopyToTransferable();
2251 uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2252 return xTransferable;
2255 void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans )
2256 throw (::com::sun::star::datatransfer::UnsupportedFlavorException,
2257 ::com::sun::star::uno::RuntimeException,
2258 std::exception)
2260 SolarMutexGuard aGuard;
2261 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2262 if (pShell)
2263 pShell->GetEditView()->InsertText( xTrans, OUString(), false );
2264 else
2266 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2267 if (pTextShell)
2269 ScViewData& rViewData = GetViewShell()->GetViewData();
2270 ScDrawView* pView = rViewData.GetScDrawView();
2271 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2272 if ( pOutView )
2274 pOutView->GetEditView().InsertText( xTrans, OUString(), false );
2275 return;
2279 GetViewShell()->PasteFromTransferable( xTrans );
2283 namespace {
2285 uno::Sequence<sal_Int32> toSequence(const ScMarkData::MarkedTabsType& rSelected)
2287 uno::Sequence<sal_Int32> aRet(rSelected.size());
2288 ScMarkData::MarkedTabsType::const_iterator itr = rSelected.begin(), itrEnd = rSelected.end();
2289 for (size_t i = 0; itr != itrEnd; ++itr, ++i)
2290 aRet[i] = static_cast<sal_Int32>(*itr);
2292 return aRet;
2297 uno::Sequence<sal_Int32> ScTabViewObj::getSelectedSheets()
2298 throw (uno::RuntimeException, std::exception)
2300 ScTabViewShell* pViewSh = GetViewShell();
2301 if (!pViewSh)
2302 return uno::Sequence<sal_Int32>();
2304 ScViewData& rViewData = pViewSh->GetViewData();
2306 // #i95280# when printing from the shell, the view is never activated,
2307 // so Excel view settings must also be evaluated here.
2308 ScExtDocOptions* pExtOpt = rViewData.GetDocument()->GetExtDocOptions();
2309 if (pExtOpt && pExtOpt->IsChanged())
2311 pViewSh->GetViewData().ReadExtOptions(*pExtOpt); // Excel view settings
2312 pViewSh->SetTabNo(pViewSh->GetViewData().GetTabNo(), true);
2313 pExtOpt->SetChanged(false);
2316 return toSequence(rViewData.GetMarkData().GetSelectedTabs());
2319 ScPreviewObj::ScPreviewObj(ScPreviewShell* pViewSh) :
2320 SfxBaseController(pViewSh),
2321 mpViewShell(pViewSh)
2323 if (mpViewShell)
2324 StartListening(*mpViewShell);
2327 ScPreviewObj::~ScPreviewObj()
2329 if (mpViewShell)
2330 EndListening(*mpViewShell);
2333 uno::Any ScPreviewObj::queryInterface(const uno::Type& rType)
2334 throw(uno::RuntimeException, std::exception)
2336 SC_QUERYINTERFACE(sheet::XSelectedSheetsSupplier)
2337 return SfxBaseController::queryInterface(rType);
2340 void ScPreviewObj::acquire() throw()
2342 SfxBaseController::acquire();
2345 void ScPreviewObj::release() throw()
2347 SfxBaseController::release();
2350 void ScPreviewObj::Notify(SfxBroadcaster&, const SfxHint& rHint)
2352 const SfxSimpleHint* p = dynamic_cast<const SfxSimpleHint*>(&rHint);
2353 if (p && p->GetId() == SFX_HINT_DYING)
2354 mpViewShell = NULL;
2357 uno::Sequence<sal_Int32> ScPreviewObj::getSelectedSheets()
2358 throw (uno::RuntimeException, std::exception)
2360 ScPreview* p = mpViewShell->GetPreview();
2361 if (!p)
2362 return uno::Sequence<sal_Int32>();
2364 return toSequence(p->GetSelectedTabs());
2367 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */