update dev300-m58
[ooovba.git] / sc / source / ui / unoobj / viewuno.cxx
blob8efc810ac964d650555d7a7c0d2c444c6357a698
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewuno.cxx,v $
10 * $Revision: 1.37.24.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <svx/fmdpage.hxx>
37 #include <svx/svditer.hxx>
38 #include <svx/svdmark.hxx>
39 #include <svx/svdouno.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/svdpagv.hxx>
42 #include <svx/svdview.hxx>
43 #include <svx/unoshape.hxx>
44 #include <svx/unoshcol.hxx>
45 #include <svx/fmshell.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <sfx2/dispatch.hxx>
48 #include <sfx2/printer.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/viewfrm.hxx>
51 #include <rtl/uuid.h>
52 #include <toolkit/helper/convert.hxx>
54 #include "drawsh.hxx"
55 #include "drtxtob.hxx"
56 #include "transobj.hxx"
57 #include "editsh.hxx"
58 #include "viewuno.hxx"
59 #include "cellsuno.hxx"
60 #include "miscuno.hxx"
61 #include "tabvwsh.hxx"
62 #include "docsh.hxx"
63 #include "drwlayer.hxx"
64 #include "drawview.hxx"
65 #include "fupoor.hxx"
66 #include "sc.hrc"
67 #include "unoguard.hxx"
68 #include "unonames.hxx"
69 #include "scmod.hxx"
70 #include "appoptio.hxx"
71 #include "gridwin.hxx"
72 #include <com/sun/star/view/DocumentZoomType.hpp>
73 #include "AccessibilityHints.hxx"
74 #include <com/sun/star/awt/MouseButton.hpp>
75 #include <com/sun/star/document/XVbaEventsHelper.hpp>
76 #include <com/sun/star/document/VbaEventId.hpp>
77 #include <svx/sdrhittesthelper.hxx>
79 using namespace com::sun::star;
80 using namespace com::sun::star::document::VbaEventId;
82 //------------------------------------------------------------------------
84 //! Clipping-Markierungen
86 // alles ohne Which-ID, Map nur fuer PropertySetInfo
88 const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap()
90 static SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] =
92 {MAP_CHAR_LEN(OLD_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
93 {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0},
94 {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
95 {MAP_CHAR_LEN(SC_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0},
96 {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
97 {MAP_CHAR_LEN(SC_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0},
98 {MAP_CHAR_LEN(SC_UNO_HIDESPELL), 0, &getBooleanCppuType(), 0, 0}, /* deprecated #i91949 */
99 {MAP_CHAR_LEN(OLD_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0},
100 {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
101 {MAP_CHAR_LEN(SC_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0},
102 {MAP_CHAR_LEN(OLD_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
103 {MAP_CHAR_LEN(OLD_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
104 {MAP_CHAR_LEN(SC_UNO_SHOWANCHOR), 0, &getBooleanCppuType(), 0, 0},
105 {MAP_CHAR_LEN(SC_UNO_SHOWCHARTS), 0, &getCppuType((sal_Int16*)0), 0, 0},
106 {MAP_CHAR_LEN(SC_UNO_SHOWDRAW), 0, &getCppuType((sal_Int16*)0), 0, 0},
107 {MAP_CHAR_LEN(SC_UNO_SHOWFORM), 0, &getBooleanCppuType(), 0, 0},
108 {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0},
109 {MAP_CHAR_LEN(SC_UNO_SHOWHELP), 0, &getBooleanCppuType(), 0, 0},
110 {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0},
111 {MAP_CHAR_LEN(SC_UNO_SHOWOBJ), 0, &getCppuType((sal_Int16*)0), 0, 0},
112 {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0},
113 {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0},
114 {MAP_CHAR_LEN(SC_UNO_SHOWSOLID), 0, &getBooleanCppuType(), 0, 0},
115 {MAP_CHAR_LEN(OLD_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0},
116 {MAP_CHAR_LEN(OLD_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0},
117 {MAP_CHAR_LEN(SC_UNO_VISAREA), 0, &getCppuType((awt::Rectangle*)0), 0, 0},
118 {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0},
119 {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE), 0, &getCppuType((sal_Int16*)0), 0, 0},
120 {0,0,0,0,0,0}
122 return aViewOptPropertyMap_Impl;
125 //------------------------------------------------------------------------
127 SV_IMPL_PTRARR( XRangeSelectionListenerArr_Impl, XRangeSelectionListenerPtr );
128 SV_IMPL_PTRARR( XRangeSelectionChangeListenerArr_Impl, XRangeSelectionChangeListenerPtr );
129 SV_IMPL_PTRARR( XSelectionChangeListenerArr_Impl, XSelectionChangeListenerPtr );
130 SV_IMPL_PTRARR( XViewPropertyChangeListenerArr_Impl, XViewPropertyChangeListenerPtr );
131 SV_IMPL_PTRARR( XMouseClickHandlerArr_Impl, XMouseClickHandlerPtr );
132 SV_IMPL_PTRARR( XActivationEventListenerArr_Impl, XActivationEventListenerPtr );
134 #define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView"
135 #define SCVIEWSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetViewSettings"
137 SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
139 //------------------------------------------------------------------------
141 ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, USHORT nP) :
142 pViewShell( pViewSh ),
143 nPane( nP )
145 if (pViewShell)
146 StartListening(*pViewShell);
149 ScViewPaneBase::~ScViewPaneBase()
151 if (pViewShell)
152 EndListening(*pViewShell);
155 void ScViewPaneBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
157 if ( rHint.ISA( SfxSimpleHint ) &&
158 ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
159 pViewShell = NULL;
162 uno::Any SAL_CALL ScViewPaneBase::queryInterface( const uno::Type& rType )
163 throw(uno::RuntimeException)
165 SC_QUERYINTERFACE( sheet::XViewPane )
166 SC_QUERYINTERFACE( sheet::XCellRangeReferrer )
167 SC_QUERYINTERFACE( view::XFormLayerAccess )
168 SC_QUERYINTERFACE( view::XControlAccess )
169 SC_QUERYINTERFACE( lang::XServiceInfo )
170 SC_QUERYINTERFACE( lang::XTypeProvider )
172 return uno::Any(); // OWeakObject is in derived objects
175 uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes() throw(uno::RuntimeException)
177 static uno::Sequence<uno::Type> aTypes;
178 if ( aTypes.getLength() == 0 )
180 aTypes.realloc(5);
181 uno::Type* pPtr = aTypes.getArray();
182 pPtr[0] = getCppuType((const uno::Reference<sheet::XViewPane>*)0);
183 pPtr[1] = getCppuType((const uno::Reference<sheet::XCellRangeReferrer>*)0);
184 pPtr[2] = getCppuType((const uno::Reference<view::XFormLayerAccess>*)0);
185 pPtr[3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
186 pPtr[4] = getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
188 return aTypes;
191 uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId()
192 throw(uno::RuntimeException)
194 static uno::Sequence< sal_Int8 > aId;
195 if( aId.getLength() == 0 )
197 aId.realloc( 16 );
198 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
200 return aId;
203 // XViewPane
205 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException)
207 ScUnoGuard aGuard;
208 if (pViewShell)
210 ScViewData* pViewData = pViewShell->GetViewData();
211 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
212 pViewData->GetActivePart() :
213 (ScSplitPos) nPane;
214 ScHSplitPos eWhichH = WhichH( eWhich );
216 return pViewData->GetPosX( eWhichH );
218 DBG_ERROR("keine View ?!?"); //! Exception?
219 return 0;
222 void SAL_CALL ScViewPaneBase::setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn )
223 throw(uno::RuntimeException)
225 ScUnoGuard aGuard;
226 if (pViewShell)
228 ScViewData* pViewData = pViewShell->GetViewData();
229 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
230 pViewData->GetActivePart() :
231 (ScSplitPos) nPane;
232 ScHSplitPos eWhichH = WhichH( eWhich );
234 long nDeltaX = ((long)nFirstVisibleColumn) - pViewData->GetPosX( eWhichH );
235 pViewShell->ScrollX( nDeltaX, eWhichH );
239 sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException)
241 ScUnoGuard aGuard;
242 if (pViewShell)
244 ScViewData* pViewData = pViewShell->GetViewData();
245 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
246 pViewData->GetActivePart() :
247 (ScSplitPos) nPane;
248 ScVSplitPos eWhichV = WhichV( eWhich );
250 return pViewData->GetPosY( eWhichV );
252 DBG_ERROR("keine View ?!?"); //! Exception?
253 return 0;
256 void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
257 throw(uno::RuntimeException)
259 ScUnoGuard aGuard;
260 if (pViewShell)
262 ScViewData* pViewData = pViewShell->GetViewData();
263 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
264 pViewData->GetActivePart() :
265 (ScSplitPos) nPane;
266 ScVSplitPos eWhichV = WhichV( eWhich );
268 long nDeltaY = ((long)nFirstVisibleRow) - pViewData->GetPosY( eWhichV );
269 pViewShell->ScrollY( nDeltaY, eWhichV );
273 table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange() throw(uno::RuntimeException)
275 ScUnoGuard aGuard;
276 table::CellRangeAddress aAdr;
277 if (pViewShell)
279 ScViewData* pViewData = pViewShell->GetViewData();
280 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
281 pViewData->GetActivePart() :
282 (ScSplitPos) nPane;
283 ScHSplitPos eWhichH = WhichH( eWhich );
284 ScVSplitPos eWhichV = WhichV( eWhich );
286 // VisibleCellsX gibt nur komplett sichtbare Zellen,
287 // VisibleRange in Excel auch teilweise sichtbare.
288 //! anpassen ???
290 SCCOL nVisX = pViewData->VisibleCellsX( eWhichH );
291 SCROW nVisY = pViewData->VisibleCellsY( eWhichV );
292 if (!nVisX) nVisX = 1; // irgendwas muss ja im Range sein
293 if (!nVisY) nVisY = 1;
294 aAdr.Sheet = pViewData->GetTabNo();
295 aAdr.StartColumn = pViewData->GetPosX( eWhichH );
296 aAdr.StartRow = pViewData->GetPosY( eWhichV );
297 aAdr.EndColumn = aAdr.StartColumn + nVisX - 1;
298 aAdr.EndRow = aAdr.StartRow + nVisY - 1;
300 return aAdr;
303 // XCellRangeSource
305 uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells()
306 throw(uno::RuntimeException)
308 ScUnoGuard aGuard;
309 if (pViewShell)
311 ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
313 table::CellRangeAddress aAdr(getVisibleRange()); //! Hilfsfunktion mit ScRange?
314 ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet,
315 (SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet );
316 if ( aRange.aStart == aRange.aEnd )
317 return new ScCellObj( pDocSh, aRange.aStart );
318 else
319 return new ScCellRangeObj( pDocSh, aRange );
322 return NULL;
325 namespace
327 bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, USHORT _nPane, FmFormShell*& _rpFormShell, Window*& _rpWindow, SdrView*& _rpSdrView )
329 if ( !_pViewShell )
330 return false;
332 ScViewData* pViewData = _pViewShell->GetViewData();
333 ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ?
334 pViewData->GetActivePart() :
335 (ScSplitPos) _nPane;
336 _rpWindow = _pViewShell->GetWindowByPos( eWhich );
337 _rpSdrView = _pViewShell->GetSdrView();
338 _rpFormShell = _pViewShell->GetFormShell();
339 return ( _rpFormShell != NULL ) && ( _rpSdrView != NULL )&& ( _rpWindow != NULL );
343 // XFormLayerAccess
344 uno::Reference< form::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& _Form ) throw (uno::RuntimeException)
346 ScUnoGuard aGuard;
348 uno::Reference< form::XFormController > xController;
350 Window* pWindow( NULL );
351 SdrView* pSdrView( NULL );
352 FmFormShell* pFormShell( NULL );
353 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
354 xController = pFormShell->GetFormController( _Form, *pSdrView, *pWindow );
356 return xController;
359 ::sal_Bool SAL_CALL ScViewPaneBase::isFormDesignMode( ) throw (uno::RuntimeException)
361 ScUnoGuard aGuard;
363 sal_Bool bIsFormDesignMode( sal_True );
365 FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : NULL );
366 if ( pFormShell )
367 bIsFormDesignMode = pFormShell->IsDesignMode();
369 return bIsFormDesignMode;
372 void SAL_CALL ScViewPaneBase::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
374 ScUnoGuard aGuard;
376 Window* pWindow( NULL );
377 SdrView* pSdrView( NULL );
378 FmFormShell* pFormShell( NULL );
379 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
380 pFormShell->SetDesignMode( _DesignMode );
383 // XControlAccess
385 uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl(
386 const uno::Reference<awt::XControlModel>& xModel )
387 throw(container::NoSuchElementException, uno::RuntimeException)
389 ScUnoGuard aGuard;
391 uno::Reference<awt::XControl> xRet;
393 Window* pWindow( NULL );
394 SdrView* pSdrView( NULL );
395 FmFormShell* pFormShell( NULL );
396 if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
397 pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xRet );
399 if ( !xRet.is() )
400 throw container::NoSuchElementException(); // no control found
402 return xRet;
405 awt::Rectangle ScViewPaneBase::GetVisArea() const
407 awt::Rectangle aVisArea;
408 if (pViewShell)
410 ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
411 pViewShell->GetViewData()->GetActivePart() :
412 (ScSplitPos) nPane;
413 ScGridWindow* pWindow = (ScGridWindow*)pViewShell->GetWindowByPos(eWhich);
414 ScDocument* pDoc = pViewShell->GetViewData()->GetDocument();
415 if (pWindow && pDoc)
417 ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ?
418 SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
419 ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ?
420 SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
421 ScAddress aCell(pViewShell->GetViewData()->GetPosX(eWhichH),
422 pViewShell->GetViewData()->GetPosY(eWhichV),
423 pViewShell->GetViewData()->GetTabNo());
424 Rectangle aVisRect(pDoc->GetMMRect(aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab()));
426 aVisRect.SetSize(pWindow->PixelToLogic(pWindow->GetSizePixel(), pWindow->GetDrawMapMode(sal_True)));
428 aVisArea = AWTRectangle(aVisRect);
431 return aVisArea;
434 //------------------------------------------------------------------------
436 ScViewPaneObj::ScViewPaneObj(ScTabViewShell* pViewSh, USHORT nP) :
437 ScViewPaneBase( pViewSh, nP )
441 ScViewPaneObj::~ScViewPaneObj()
445 uno::Any SAL_CALL ScViewPaneObj::queryInterface( const uno::Type& rType )
446 throw(uno::RuntimeException)
448 // ScViewPaneBase has everything except OWeakObject
450 uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
451 if (!aRet.hasValue())
452 aRet = OWeakObject::queryInterface( rType );
453 return aRet;
456 void SAL_CALL ScViewPaneObj::acquire() throw()
458 OWeakObject::acquire();
461 void SAL_CALL ScViewPaneObj::release() throw()
463 OWeakObject::release();
466 // To process sheet compatibile event
467 typedef ::cppu::WeakImplHelper2< awt::XEnhancedMouseClickHandler, view::XSelectionChangeListener > TabViewEventListener_BASE;
468 class ScTabViewEventListener: public TabViewEventListener_BASE
470 private:
471 uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper;
472 ScTabViewObj* pViewObj;
474 public:
475 ScTabViewEventListener( ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper);
476 ~ScTabViewEventListener();
477 // XEnhancedMouseClickHandler
478 virtual sal_Bool SAL_CALL mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
479 virtual sal_Bool SAL_CALL mouseReleased( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
481 // XSelectionChangeListener
482 virtual void SAL_CALL selectionChanged( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
483 // XEventListener
484 virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
487 ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj* pObj, uno::Reference< document::XVbaEventsHelper >& rVbaEventsHelper):
488 pViewObj( pObj ),xVbaEventsHelper( rVbaEventsHelper )
492 ScTabViewEventListener::~ScTabViewEventListener()
496 void SAL_CALL ScTabViewEventListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
500 sal_Bool SAL_CALL ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException)
502 sal_Bool result = sal_False;
503 // process BeforeDoubleClick and BeforeRightClick events
504 if( e.ClickCount == 2 || e.Buttons == ::com::sun::star::awt::MouseButton::RIGHT )
506 // ensure the target is a cell
507 uno::Reference< table::XCell > xCell( e.Target, uno::UNO_QUERY );
508 if( xCell.is() && xVbaEventsHelper.is() && pViewObj)
510 uno::Sequence< uno::Any > aArgs(1);
511 aArgs[0] = pViewObj->getSelection();
512 sal_Int32 nEventId = VBAEVENT_WORKSHEET_BEFORERIGHTCLICK;
513 if( e.ClickCount == 2 )
514 nEventId = VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK;
516 result = xVbaEventsHelper->ProcessCompatibleVbaEvent( nEventId, aArgs );
517 // TODO: process Cancel argument
520 return result;
523 sal_Bool SAL_CALL ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent&/*e*/) throw (uno::RuntimeException)
525 return sal_False;
528 void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
530 if ( xVbaEventsHelper.is() && pViewObj)
532 uno::Sequence< uno::Any > aArgs(1);
533 aArgs[0] = pViewObj->getSelection();
534 xVbaEventsHelper->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_SELECTIONCHANGE, aArgs );
538 //------------------------------------------------------------------------
540 // Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
542 //UNUSED2008-05 ScTabViewObj::ScTabViewObj() :
543 //UNUSED2008-05 ScViewPaneBase( NULL, SC_VIEWPANE_ACTIVE ),
544 //UNUSED2008-05 SfxBaseController( NULL ),
545 //UNUSED2008-05 aPropSet( lcl_GetViewOptPropertyMap() ),
546 //UNUSED2008-05 aMouseClickHandlers( 0 ),
547 //UNUSED2008-05 aActivationListeners( 0 ),
548 //UNUSED2008-05 bDrawSelModeSet(sal_False),
549 //UNUSED2008-05 bFilteredRangeSelection(sal_True)
550 //UNUSED2008-05 {
551 //UNUSED2008-05 }
553 ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
554 ScViewPaneBase( pViewSh, SC_VIEWPANE_ACTIVE ),
555 SfxBaseController( pViewSh ),
556 aPropSet( lcl_GetViewOptPropertyMap() ),
557 aMouseClickHandlers( 0 ),
558 aActivationListeners( 0 ),
559 bDrawSelModeSet(sal_False),
560 bFilteredRangeSelection(sal_True)
562 if( pViewSh )
564 ScViewData* pViewData = pViewSh->GetViewData();
565 if( pViewData )
567 uno::Reference< document::XVbaEventsHelper > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY );
568 ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper );
569 uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY );
570 addEnhancedMouseClickHandler( aMouseClickHandler );
571 uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY );
572 addSelectionChangeListener( aSelectionChangeListener );
577 ScTabViewObj::~ScTabViewObj()
579 //! Listening oder so
580 if (aMouseClickHandlers.Count())
582 acquire();
583 EndMouseListening();
585 if (aActivationListeners.Count())
587 acquire();
588 EndActivationListening();
592 uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
593 throw(uno::RuntimeException)
595 SC_QUERYINTERFACE( sheet::XSpreadsheetView )
596 SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster )
597 SC_QUERYINTERFACE( sheet::XActivationBroadcaster )
598 SC_QUERYINTERFACE( container::XEnumerationAccess )
599 SC_QUERYINTERFACE( container::XIndexAccess )
600 SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
601 SC_QUERYINTERFACE( view::XSelectionSupplier )
602 SC_QUERYINTERFACE( beans::XPropertySet )
603 SC_QUERYINTERFACE( sheet::XViewSplitable )
604 SC_QUERYINTERFACE( sheet::XViewFreezable )
605 SC_QUERYINTERFACE( sheet::XRangeSelection )
606 SC_QUERYINTERFACE( lang::XUnoTunnel )
607 SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
609 uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
610 if (!aRet.hasValue())
611 aRet = SfxBaseController::queryInterface( rType );
612 return aRet;
615 void SAL_CALL ScTabViewObj::acquire() throw()
617 SfxBaseController::acquire();
620 void SAL_CALL ScTabViewObj::release() throw()
622 SfxBaseController::release();
625 void ScTabViewObj::SheetChanged()
627 if (aActivationListeners.Count() > 0 && GetViewShell())
629 sheet::ActivationEvent aEvent;
630 uno::Reference< sheet::XSpreadsheetView > xView(this);
631 uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
632 aEvent.Source = xSource;
633 aEvent.ActiveSheet = new ScTableSheetObj(GetViewShell()->GetViewData()->GetDocShell(), GetViewShell()->GetViewData()->GetTabNo());
634 for ( USHORT n=0; n<aActivationListeners.Count(); n++ )
638 (*aActivationListeners[n])->activeSpreadsheetChanged( aEvent );
640 catch( uno::Exception& )
642 aActivationListeners.DeleteAndDestroy( n );
643 --n; // because it will be increased again in the loop
649 uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() throw(uno::RuntimeException)
651 static uno::Sequence<uno::Type> aTypes;
652 if ( aTypes.getLength() == 0 )
654 uno::Sequence<uno::Type> aViewPaneTypes(ScViewPaneBase::getTypes());
655 long nViewPaneLen = aViewPaneTypes.getLength();
656 const uno::Type* pViewPanePtr = aViewPaneTypes.getConstArray();
658 uno::Sequence<uno::Type> aControllerTypes(SfxBaseController::getTypes());
659 long nControllerLen = aControllerTypes.getLength();
660 const uno::Type* pControllerPtr = aControllerTypes.getConstArray();
662 long nParentLen = nViewPaneLen + nControllerLen;
664 aTypes.realloc( nParentLen + 12 );
665 uno::Type* pPtr = aTypes.getArray();
666 pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetView>*)0);
667 pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
668 pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XIndexAccess>*)0);
669 pPtr[nParentLen + 3] = getCppuType((const uno::Reference<view::XSelectionSupplier>*)0);
670 pPtr[nParentLen + 4] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
671 pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XViewSplitable>*)0);
672 pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XViewFreezable>*)0);
673 pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XRangeSelection>*)0);
674 pPtr[nParentLen + 8] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
675 pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XEnhancedMouseClickBroadcaster>*)0);
676 pPtr[nParentLen + 10] = getCppuType((const uno::Reference<sheet::XActivationBroadcaster>*)0);
677 pPtr[nParentLen + 11] = getCppuType((const uno::Reference<datatransfer::XTransferableSupplier>*)0);
679 long i;
680 for (i=0; i<nViewPaneLen; i++)
681 pPtr[i] = pViewPanePtr[i]; // parent types first
682 for (i=0; i<nControllerLen; i++)
683 pPtr[nViewPaneLen+i] = pControllerPtr[i];
685 return aTypes;
688 uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
689 throw(uno::RuntimeException)
691 static uno::Sequence< sal_Int8 > aId;
692 if( aId.getLength() == 0 )
694 aId.realloc( 16 );
695 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
697 return aId;
700 // XDocumentView
702 BOOL lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
704 ULONG nCount = rRanges.Count();
705 for (ULONG i=0; i<nCount; i++)
707 const ScRange* pRange = rRanges.GetObject(i);
708 if ( nTab >= pRange->aStart.Tab() && nTab <= pRange->aEnd.Tab() )
709 return TRUE;
711 return FALSE;
714 void lcl_ShowObject( ScTabViewShell& rViewSh, ScDrawView& rDrawView, SdrObject* pSelObj )
716 BOOL bFound = FALSE;
717 SCTAB nObjectTab = 0;
719 SdrModel* pModel = rDrawView.GetModel();
720 USHORT nPageCount = pModel->GetPageCount();
721 for (USHORT i=0; i<nPageCount && !bFound; i++)
723 SdrPage* pPage = pModel->GetPage(i);
724 if (pPage)
726 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
727 SdrObject* pObject = aIter.Next();
728 while (pObject && !bFound)
730 if ( pObject == pSelObj )
732 bFound = TRUE;
733 nObjectTab = static_cast<SCTAB>(i);
735 pObject = aIter.Next();
740 if (bFound)
742 rViewSh.SetTabNo( nObjectTab );
743 rViewSh.ScrollToObject( pSelObj );
747 sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
748 throw(lang::IllegalArgumentException, uno::RuntimeException)
750 ScUnoGuard aGuard;
751 ScTabViewShell* pViewSh = GetViewShell();
753 if ( !pViewSh )
754 return FALSE;
756 //! Type of aSelection can be some specific interface instead of XInterface
758 BOOL bRet = FALSE;
759 uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
760 if ( !xInterface.is() ) //clear all selections
762 ScDrawView* pDrawView = pViewSh->GetScDrawView();
763 if (pDrawView)
765 pDrawView->ScEndTextEdit();
766 pDrawView->UnmarkAll();
768 else //#102232#; if there is no DrawView remove range selection
769 pViewSh->Unmark();
770 bRet = TRUE;
773 if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
775 pViewSh->SetDrawSelMode(sal_False);
776 pViewSh->UpdateLayerLocks();
777 bDrawSelModeSet = sal_False;
780 if (bRet)
781 return bRet;
784 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
785 uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
786 uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
787 SvxShape* pShapeImp = SvxShape::getImplementation( xShapeSel );
789 if (pRangesImp) // Zell-Ranges
791 ScViewData* pViewData = pViewSh->GetViewData();
792 if ( pViewData->GetDocShell() == pRangesImp->GetDocShell() )
794 // Zuerst evtl. Drawing-Selektion aufheben
795 // (MarkListHasChanged hebt Tabellen-Selektion auf)
797 ScDrawView* pDrawView = pViewSh->GetScDrawView();
798 if (pDrawView)
800 pDrawView->ScEndTextEdit();
801 pDrawView->UnmarkAll();
803 FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
804 if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
806 // Slot der Zeichenfunktion nochmal ausfuehren -> abschalten
807 SfxDispatcher* pDisp = pViewSh->GetDispatcher();
808 if (pDisp)
809 pDisp->Execute( pFunc->GetSlotID(), SFX_CALLMODE_SYNCHRON );
811 pViewSh->SetDrawShell(FALSE);
812 pViewSh->SetDrawSelMode(FALSE); // nach dem Dispatcher-Execute
814 // Ranges selektieren
816 const ScRangeList& rRanges = pRangesImp->GetRangeList();
817 ULONG nRangeCount = rRanges.Count();
818 // for empty range list, remove selection (cursor remains where it was)
819 if ( nRangeCount == 0 )
820 pViewSh->Unmark();
821 else if ( nRangeCount == 1 )
822 pViewSh->MarkRange( *rRanges.GetObject(0) );
823 else
825 // Mehrfachselektion
827 const ScRange* pFirst = rRanges.GetObject(0);
828 if ( pFirst && !lcl_TabInRanges( pViewData->GetTabNo(), rRanges ) )
829 pViewSh->SetTabNo( pFirst->aStart.Tab() );
830 pViewSh->DoneBlockMode();
831 pViewSh->InitOwnBlockMode();
832 pViewData->GetMarkData().MarkFromRangeList( rRanges, TRUE );
833 pViewSh->MarkDataChanged();
834 pViewData->GetDocShell()->PostPaintGridAll(); // Markierung (alt&neu)
835 if ( pFirst )
837 pViewSh->AlignToCursor( pFirst->aStart.Col(), pFirst->aStart.Row(),
838 SC_FOLLOW_JUMP );
839 pViewSh->SetCursor( pFirst->aStart.Col(), pFirst->aStart.Row() );
842 //! Methode an der View, um RangeList zu selektieren
844 bRet = TRUE;
847 else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer
849 ScDrawView* pDrawView = pViewSh->GetScDrawView();
850 if (pDrawView)
852 pDrawView->ScEndTextEdit();
853 pDrawView->UnmarkAll();
855 if (pShapeImp) // einzelnes Shape
857 SdrObject *pObj = pShapeImp->GetSdrObject();
858 if (pObj)
860 lcl_ShowObject( *pViewSh, *pDrawView, pObj );
861 SdrPageView* pPV = pDrawView->GetSdrPageView();
862 if ( pPV && pObj->GetPage() == pPV->GetPage() )
864 pDrawView->MarkObj( pObj, pPV );
865 bRet = TRUE;
869 else // Shape-Collection (xShapeColl ist nicht 0)
871 // Es wird auf die Tabelle des ersten Objekts umgeschaltet,
872 // und alle Objekte selektiert, die auf dieser Tabelle liegen
873 //! Exception, wenn Objekte auf verschiedenen Tabellen?
875 SdrPageView* pPV = NULL;
876 long nCount = xShapeColl->getCount();
877 if (nCount)
879 sal_Bool bAllMarked(sal_True);
880 for ( long i = 0; i < nCount; i++ )
882 uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
883 if (xShapeInt.is())
885 SvxShape* pShape = SvxShape::getImplementation( xShapeInt );
886 if (pShape)
888 SdrObject *pObj = pShape->GetSdrObject();
889 if (pObj)
891 if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
893 pViewSh->SetDrawSelMode(sal_True);
894 pViewSh->UpdateLayerLocks();
895 bDrawSelModeSet = sal_True;
897 if (!pPV) // erstes Objekt
899 lcl_ShowObject( *pViewSh, *pDrawView, pObj );
900 pPV = pDrawView->GetSdrPageView();
902 if ( pPV && pObj->GetPage() == pPV->GetPage() )
904 if (pDrawView->IsObjMarkable( pObj, pPV ))
905 pDrawView->MarkObj( pObj, pPV );
906 else
907 bAllMarked = sal_False;
913 if (bAllMarked)
914 bRet = TRUE;
916 else
917 bRet = TRUE; // empty XShapes (all shapes are deselected)
920 if (bRet)
921 pViewSh->SetDrawShell(TRUE);
925 if (!bRet)
926 throw lang::IllegalArgumentException();
928 return bRet;
931 uno::Any SAL_CALL ScTabViewObj::getSelection() throw(uno::RuntimeException)
933 ScUnoGuard aGuard;
934 ScTabViewShell* pViewSh = GetViewShell();
935 ScCellRangesBase* pObj = NULL;
936 if (pViewSh)
938 // Ist auf dem Drawing-Layer etwas selektiert?
940 SdrView* pDrawView = pViewSh->GetSdrView();
941 if (pDrawView)
943 const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
944 ULONG nMarkCount = rMarkList.GetMarkCount();
945 if (nMarkCount)
947 // ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw)
948 // Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein
950 SvxShapeCollection* pShapes = new SvxShapeCollection();
951 uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pShapes));
953 for (ULONG i=0; i<nMarkCount; i++)
955 SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
956 if (pDrawObj)
958 uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
959 if (xShape.is())
960 pShapes->add(xShape);
963 return uno::makeAny(xRet);
967 // sonst Tabellen-(Zellen-)Selektion
969 ScViewData* pViewData = pViewSh->GetViewData();
970 ScDocShell* pDocSh = pViewData->GetDocShell();
972 const ScMarkData& rMark = pViewData->GetMarkData();
973 SCTAB nTabs = rMark.GetSelectCount();
975 ScRange aRange;
976 ScMarkType eMarkType = pViewData->GetSimpleArea(aRange);
978 if (!bFilteredRangeSelection)
980 if (eMarkType == SC_MARK_SIMPLE_FILTERED)
981 eMarkType = SC_MARK_SIMPLE;
982 else if (eMarkType == SC_MARK_FILTERED)
983 eMarkType = SC_MARK_MULTI;
986 if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
988 if (aRange.aStart == aRange.aEnd)
989 pObj = new ScCellObj( pDocSh, aRange.aStart );
990 else
991 pObj = new ScCellRangeObj( pDocSh, aRange );
993 else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
995 ScMarkData aFilteredMark( rMark );
996 ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
997 ScRangeList aRangeList;
998 aFilteredMark.FillRangeListWithMarks( &aRangeList, FALSE);
999 // Theoretically a selection may start and end on a filtered row.
1000 switch (aRangeList.Count())
1002 case 0:
1003 // No unfiltered row, we have to return some object, so
1004 // here is one with no ranges.
1005 pObj = new ScCellRangesObj( pDocSh, aRangeList );
1006 break;
1007 case 1:
1009 const ScRange& rRange = *(aRangeList.GetObject(0));
1010 if (rRange.aStart == rRange.aEnd)
1011 pObj = new ScCellObj( pDocSh, rRange.aStart );
1012 else
1013 pObj = new ScCellRangeObj( pDocSh, rRange );
1015 break;
1016 default:
1017 pObj = new ScCellRangesObj( pDocSh, aRangeList );
1020 else // Mehrfachselektion
1022 ScRangeListRef xRanges;
1023 pViewData->GetMultiArea( xRanges );
1025 // bei mehreren Tabellen Ranges kopieren
1026 //! sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren?
1027 if ( nTabs > 1 )
1028 rMark.ExtendRangeListTables( xRanges );
1030 pObj = new ScCellRangesObj( pDocSh, *xRanges );
1033 if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
1035 // remember if the selection was from the cursor position without anything selected
1036 // (used when rendering the selection)
1038 pObj->SetCursorOnly( TRUE );
1042 return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
1046 #if 0
1047 // XPrintable
1049 rtl::OUString ScTabViewObj::getPrinterName(void) const
1051 ScUnoGuard aGuard;
1052 ScTabViewShell* pViewSh = GetViewShell();
1053 if (pViewSh)
1055 SfxPrinter* pPrinter = pViewSh->GetPrinter(TRUE);
1056 if (pPrinter)
1057 return pPrinter->GetName();
1060 DBG_ERROR("getPrinterName: keine View oder kein Printer");
1061 return rtl::OUString();
1064 void ScTabViewObj::setPrinterName(const rtl::OUString& PrinterName)
1066 ScUnoGuard aGuard;
1067 // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl
1069 ScTabViewShell* pViewSh = GetViewShell();
1070 if (pViewSh)
1072 SfxPrinter* pPrinter = pViewSh->GetPrinter(TRUE);
1073 if (pPrinter)
1075 String aString(PrinterName);
1076 SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString );
1077 if (pNewPrinter->IsKnown())
1078 pViewSh->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
1079 else
1080 delete pNewPrinter;
1085 XPropertySetRef ScTabViewObj::createPrintOptions(void)
1087 ScUnoGuard aGuard;
1088 return new ScPrintSettingsObj; //! ScPrintSettingsObj implementieren!
1091 void ScTabViewObj::print(const XPropertySetRef& xOptions)
1093 ScUnoGuard aGuard;
1094 ScTabViewShell* pViewSh = GetViewShell();
1095 if (pViewSh)
1097 //! xOptions auswerten (wie denn?)
1099 SfxRequest aReq( SID_PRINTDOCDIRECT, SFX_CALLMODE_SYNCHRON, pViewSh->GetPool() );
1100 pViewSh->ExecuteSlot( aReq );
1103 #endif
1105 // XEnumerationAccess
1107 uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
1108 throw(uno::RuntimeException)
1110 ScUnoGuard aGuard;
1111 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetViewPanesEnumeration")));
1114 // XIndexAccess
1116 sal_Int32 SAL_CALL ScTabViewObj::getCount() throw(uno::RuntimeException)
1118 ScUnoGuard aGuard;
1119 ScTabViewShell* pViewSh = GetViewShell();
1120 USHORT nPanes = 0;
1121 if (pViewSh)
1123 nPanes = 1;
1124 ScViewData* pViewData = pViewSh->GetViewData();
1125 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1126 nPanes *= 2;
1127 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1128 nPanes *= 2;
1130 return nPanes;
1133 uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
1134 throw(lang::IndexOutOfBoundsException,
1135 lang::WrappedTargetException, uno::RuntimeException)
1137 ScUnoGuard aGuard;
1138 uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((USHORT)nIndex));
1139 if (xPane.is())
1140 return uno::makeAny(xPane);
1141 else
1142 throw lang::IndexOutOfBoundsException();
1143 // return uno::Any();
1146 uno::Type SAL_CALL ScTabViewObj::getElementType() throw(uno::RuntimeException)
1148 ScUnoGuard aGuard;
1149 return getCppuType((uno::Reference<sheet::XViewPane>*)0);
1152 sal_Bool SAL_CALL ScTabViewObj::hasElements() throw(uno::RuntimeException)
1154 ScUnoGuard aGuard;
1155 return ( getCount() != 0 );
1158 // XSpreadsheetView
1160 ScViewPaneObj* ScTabViewObj::GetObjectByIndex_Impl(USHORT nIndex) const
1162 static ScSplitPos ePosHV[4] =
1163 { SC_SPLIT_TOPLEFT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMRIGHT };
1165 ScTabViewShell* pViewSh = GetViewShell();
1166 if (pViewSh)
1168 ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default Position
1169 BOOL bError = FALSE;
1170 ScViewData* pViewData = pViewSh->GetViewData();
1171 BOOL bHor = ( pViewData->GetHSplitMode() != SC_SPLIT_NONE );
1172 BOOL bVer = ( pViewData->GetVSplitMode() != SC_SPLIT_NONE );
1173 if ( bHor && bVer )
1175 // links oben, links unten, rechts oben, rechts unten - wie in Excel
1176 if ( nIndex < 4 )
1177 eWhich = ePosHV[nIndex];
1178 else
1179 bError = TRUE;
1181 else if ( bHor )
1183 if ( nIndex > 1 )
1184 bError = TRUE;
1185 else if ( nIndex == 1 )
1186 eWhich = SC_SPLIT_BOTTOMRIGHT;
1187 // sonst SC_SPLIT_BOTTOMLEFT
1189 else if ( bVer )
1191 if ( nIndex > 1 )
1192 bError = TRUE;
1193 else if ( nIndex == 0 )
1194 eWhich = SC_SPLIT_TOPLEFT;
1195 // sonst SC_SPLIT_BOTTOMLEFT
1197 else if ( nIndex > 0 )
1198 bError = TRUE; // nicht geteilt: nur 0 gueltig
1200 if (!bError)
1201 return new ScViewPaneObj( pViewSh, sal::static_int_cast<USHORT>(eWhich) );
1204 return NULL;
1207 uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1208 throw(uno::RuntimeException)
1210 ScUnoGuard aGuard;
1211 ScTabViewShell* pViewSh = GetViewShell();
1212 if (pViewSh)
1214 ScViewData* pData = pViewSh->GetViewData();
1215 SCTAB nTab = pData->GetTabNo();
1216 return new ScTableSheetObj( pData->GetDocShell(), nTab );
1218 return NULL;
1221 void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1222 throw(uno::RuntimeException)
1224 ScUnoGuard aGuard;
1226 ScTabViewShell* pViewSh = GetViewShell();
1227 if ( pViewSh && xActiveSheet.is() )
1229 // XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein
1231 ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xActiveSheet );
1232 if ( pRangesImp && pViewSh->GetViewData()->GetDocShell() == pRangesImp->GetDocShell() )
1234 const ScRangeList& rRanges = pRangesImp->GetRangeList();
1235 if ( rRanges.Count() == 1 )
1237 SCTAB nNewTab = rRanges.GetObject(0)->aStart.Tab();
1238 if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) )
1239 pViewSh->SetTabNo( nNewTab );
1245 uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1247 uno::Reference< uno::XInterface > xTarget;
1248 if (GetViewShell())
1250 SCsCOL nX;
1251 SCsROW nY;
1252 ScViewData* pData = GetViewShell()->GetViewData();
1253 ScSplitPos eSplitMode = pData->GetActivePart();
1254 SCTAB nTab(pData->GetTabNo());
1255 pData->GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1257 ScAddress aCellPos (nX, nY, nTab);
1258 ScCellObj* pCellObj = new ScCellObj(pData->GetDocShell(), aCellPos);
1260 xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1262 ScDocument* pDoc = pData->GetDocument();
1263 if (pDoc && pDoc->GetDrawLayer())
1265 SdrPage* pDrawPage = NULL;
1266 ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1267 if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1268 pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1270 SdrView* pDrawView = GetViewShell()->GetSdrView();
1272 if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1274 Window* pActiveWin = pData->GetActiveWin();
1275 Point aPos = pActiveWin->PixelToLogic(rPoint);
1277 USHORT nHitLog = (USHORT) pActiveWin->PixelToLogic(
1278 Size(pDrawView->GetHitTolerancePixel(),0)).Width();
1280 sal_uInt32 nCount(pDrawPage->GetObjCount());
1281 sal_Bool bFound(sal_False);
1282 sal_uInt32 i(0);
1283 while (i < nCount && !bFound)
1285 SdrObject* pObj = pDrawPage->GetObj(i);
1286 if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), 0, false))
1288 xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1289 bFound = sal_True;
1291 ++i;
1296 return xTarget;
1299 sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1300 throw (::uno::RuntimeException)
1302 sal_Bool bReturn(sal_False);
1304 if (aMouseClickHandlers.Count())
1306 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1308 if (xTarget.is())
1310 awt::EnhancedMouseEvent aMouseEvent;
1312 aMouseEvent.Buttons = e.Buttons;
1313 aMouseEvent.X = e.X;
1314 aMouseEvent.Y = e.Y;
1315 aMouseEvent.ClickCount = e.ClickCount;
1316 aMouseEvent.PopupTrigger = e.PopupTrigger;
1317 aMouseEvent.Target = xTarget;
1319 for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ )
1323 if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent ))
1324 bReturn = sal_True;
1326 catch ( uno::Exception& )
1328 aMouseClickHandlers.DeleteAndDestroy(n);
1329 --n; // because it will be increased again in the loop
1334 return bReturn;
1337 sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1338 throw (uno::RuntimeException)
1340 sal_Bool bReturn(sal_False);
1342 if (aMouseClickHandlers.Count())
1344 uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1346 if (xTarget.is())
1348 awt::EnhancedMouseEvent aMouseEvent;
1350 aMouseEvent.Buttons = e.Buttons;
1351 aMouseEvent.X = e.X;
1352 aMouseEvent.Y = e.Y;
1353 aMouseEvent.ClickCount = e.ClickCount;
1354 aMouseEvent.PopupTrigger = e.PopupTrigger;
1355 aMouseEvent.Target = xTarget;
1357 for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ )
1361 if (!(*aMouseClickHandlers[n])->mouseReleased( aMouseEvent ))
1362 bReturn = sal_True;
1364 catch ( uno::Exception& )
1366 aMouseClickHandlers.DeleteAndDestroy(n);
1367 --n; // because it will be increased again in the loop
1372 return bReturn;
1375 // XEnhancedMouseClickBroadcaster
1377 void ScTabViewObj::StartMouseListening()
1381 void ScTabViewObj::EndMouseListening()
1383 USHORT nCount(aMouseClickHandlers.Count());
1384 lang::EventObject aEvent;
1385 aEvent.Source = (cppu::OWeakObject*)this;
1386 for ( USHORT n=0; n<nCount; n++ )
1390 (*aMouseClickHandlers[n])->disposing(aEvent);
1392 catch ( uno::Exception& )
1396 aMouseClickHandlers.DeleteAndDestroy(0, nCount);
1399 void ScTabViewObj::StartActivationListening()
1403 void ScTabViewObj::EndActivationListening()
1405 USHORT nCount = aActivationListeners.Count();
1406 lang::EventObject aEvent;
1407 aEvent.Source = (cppu::OWeakObject*)this;
1408 for ( USHORT n=0; n<nCount; n++ )
1412 (*aActivationListeners[n])->disposing(aEvent);
1414 catch ( uno::Exception& )
1418 aActivationListeners.DeleteAndDestroy(0, nCount);
1421 void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1422 throw (uno::RuntimeException)
1424 ScUnoGuard aGuard;
1426 if (aListener.is())
1428 USHORT nCount = aMouseClickHandlers.Count();
1429 uno::Reference<awt::XEnhancedMouseClickHandler> *pObj =
1430 new uno::Reference<awt::XEnhancedMouseClickHandler>( aListener );
1431 aMouseClickHandlers.Insert( pObj, nCount );
1433 if (aMouseClickHandlers.Count() == 1 && nCount == 0) // only if a listener added
1434 StartMouseListening();
1438 void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1439 throw (uno::RuntimeException)
1441 ScUnoGuard aGuard;
1442 USHORT nCount = aMouseClickHandlers.Count();
1443 for ( USHORT n=nCount; n--; )
1445 uno::Reference<awt::XEnhancedMouseClickHandler> *pObj = aMouseClickHandlers[n];
1446 if ( *pObj == aListener )
1447 aMouseClickHandlers.DeleteAndDestroy( n );
1449 if ((aMouseClickHandlers.Count() == 0) && (nCount > 0)) // only if last listener removed
1450 EndMouseListening();
1453 // XActivationBroadcaster
1455 void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1456 throw (uno::RuntimeException)
1458 ScUnoGuard aGuard;
1460 if (aListener.is())
1462 USHORT nCount = aActivationListeners.Count();
1463 uno::Reference<sheet::XActivationEventListener> *pObj =
1464 new uno::Reference<sheet::XActivationEventListener>( aListener );
1465 aActivationListeners.Insert( pObj, nCount );
1467 if (aActivationListeners.Count() == 1 && nCount == 0) // only if a listener added
1468 StartActivationListening();
1472 void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1473 throw (uno::RuntimeException)
1475 ScUnoGuard aGuard;
1476 USHORT nCount = aActivationListeners.Count();
1477 for ( USHORT n=nCount; n--; )
1479 uno::Reference<sheet::XActivationEventListener> *pObj = aActivationListeners[n];
1480 if ( *pObj == aListener )
1481 aActivationListeners.DeleteAndDestroy( n );
1483 if ((aActivationListeners.Count() == 0) && (nCount > 0)) // only if last listener removed
1484 EndActivationListening();
1487 // PageBreakMode / Zoom sind Properties
1489 #if 0
1491 BOOL ScTabViewObj::getPagebreakMode(void) const
1493 ScUnoGuard aGuard;
1494 ScTabViewShell* pViewSh = GetViewShell();
1495 if (pViewSh)
1496 return pViewSh->GetViewData()->IsPagebreakMode();
1497 return FALSE;
1500 void ScTabViewObj::setPagebreakMode(BOOL PagebreakMode)
1502 ScUnoGuard aGuard;
1503 ScTabViewShell* pViewSh = GetViewShell();
1504 if (pViewSh)
1505 pViewSh->SetPagebreakMode(PagebreakMode);
1508 #endif
1510 INT16 ScTabViewObj::GetZoom(void) const
1512 ScTabViewShell* pViewSh = GetViewShell();
1513 if (pViewSh)
1515 const Fraction& rZoomY = pViewSh->GetViewData()->GetZoomY(); // Y wird angezeigt
1516 return (INT16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator());
1518 return 0;
1521 void ScTabViewObj::SetZoom(INT16 nZoom)
1523 ScTabViewShell* pViewSh = GetViewShell();
1524 if (pViewSh)
1526 if ( nZoom != GetZoom() && nZoom != 0 )
1528 if (!pViewSh->GetViewData()->IsPagebreakMode())
1530 ScModule* pScMod = SC_MOD();
1531 ScAppOptions aNewOpt(pScMod->GetAppOptions());
1532 aNewOpt.SetZoom( nZoom );
1533 aNewOpt.SetZoomType( pViewSh->GetViewData()->GetView()->GetZoomType() );
1534 pScMod->SetAppOptions( aNewOpt );
1537 Fraction aFract( nZoom, 100 );
1538 pViewSh->SetZoom( aFract, aFract, TRUE );
1539 pViewSh->PaintGrid();
1540 pViewSh->PaintTop();
1541 pViewSh->PaintLeft();
1542 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1543 pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1547 INT16 ScTabViewObj::GetZoomType(void) const
1549 INT16 aZoomType = view::DocumentZoomType::OPTIMAL;
1550 ScTabViewShell* pViewSh = GetViewShell();
1551 if (pViewSh)
1553 SvxZoomType eZoomType = pViewSh->GetViewData()->GetView()->GetZoomType();
1554 switch (eZoomType)
1556 case SVX_ZOOM_PERCENT:
1557 aZoomType = view::DocumentZoomType::BY_VALUE;
1558 break;
1559 case SVX_ZOOM_OPTIMAL:
1560 aZoomType = view::DocumentZoomType::OPTIMAL;
1561 break;
1562 case SVX_ZOOM_WHOLEPAGE:
1563 aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1564 break;
1565 case SVX_ZOOM_PAGEWIDTH:
1566 aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1567 break;
1568 case SVX_ZOOM_PAGEWIDTH_NOBORDER:
1569 aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1570 break;
1573 return aZoomType;
1576 void ScTabViewObj::SetZoomType(INT16 aZoomType)
1578 ScTabViewShell* pViewSh = GetViewShell();
1579 if (pViewSh)
1581 ScDBFunc* pView = pViewSh->GetViewData()->GetView();
1582 if (pView)
1584 SvxZoomType eZoomType;
1585 switch (aZoomType)
1587 case view::DocumentZoomType::BY_VALUE:
1588 eZoomType = SVX_ZOOM_PERCENT;
1589 break;
1590 case view::DocumentZoomType::OPTIMAL:
1591 eZoomType = SVX_ZOOM_OPTIMAL;
1592 break;
1593 case view::DocumentZoomType::ENTIRE_PAGE:
1594 eZoomType = SVX_ZOOM_WHOLEPAGE;
1595 break;
1596 case view::DocumentZoomType::PAGE_WIDTH:
1597 eZoomType = SVX_ZOOM_PAGEWIDTH;
1598 break;
1599 case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1600 eZoomType = SVX_ZOOM_PAGEWIDTH_NOBORDER;
1601 break;
1602 default:
1603 eZoomType = SVX_ZOOM_OPTIMAL;
1605 sal_Int16 nZoom(GetZoom());
1606 sal_Int16 nOldZoom(nZoom);
1607 if ( eZoomType == SVX_ZOOM_PERCENT )
1609 if ( nZoom < MINZOOM ) nZoom = MINZOOM;
1610 if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
1612 else
1613 nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1615 switch ( eZoomType )
1617 case SVX_ZOOM_WHOLEPAGE:
1618 case SVX_ZOOM_PAGEWIDTH:
1619 pView->SetZoomType( eZoomType, TRUE );
1620 break;
1622 default:
1623 pView->SetZoomType( SVX_ZOOM_PERCENT, TRUE );
1625 SetZoom( nZoom );
1630 sal_Bool SAL_CALL ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException)
1632 ScUnoGuard aGuard;
1633 // wie Menue-Slot SID_WINDOW_SPLIT
1635 ScTabViewShell* pViewSh = GetViewShell();
1636 if (pViewSh)
1638 ScViewData* pViewData = pViewSh->GetViewData();
1639 return ( pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
1640 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL );
1643 return FALSE;
1646 sal_Bool SAL_CALL ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException)
1648 ScUnoGuard aGuard;
1649 // wie Menue-Slot SID_WINDOW_FIX
1651 ScTabViewShell* pViewSh = GetViewShell();
1652 if (pViewSh)
1654 ScViewData* pViewData = pViewSh->GetViewData();
1655 return ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
1656 pViewData->GetVSplitMode() == SC_SPLIT_FIX );
1659 return FALSE;
1662 sal_Int32 SAL_CALL ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException)
1664 ScUnoGuard aGuard;
1665 ScTabViewShell* pViewSh = GetViewShell();
1666 if (pViewSh)
1668 ScViewData* pViewData = pViewSh->GetViewData();
1669 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1670 return pViewData->GetHSplitPos();
1672 return 0;
1675 sal_Int32 SAL_CALL ScTabViewObj::getSplitVertical() throw(uno::RuntimeException)
1677 ScUnoGuard aGuard;
1678 ScTabViewShell* pViewSh = GetViewShell();
1679 if (pViewSh)
1681 ScViewData* pViewData = pViewSh->GetViewData();
1682 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1683 return pViewData->GetVSplitPos();
1685 return 0;
1688 sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn() throw(uno::RuntimeException)
1690 ScUnoGuard aGuard;
1691 ScTabViewShell* pViewSh = GetViewShell();
1692 if (pViewSh)
1694 ScViewData* pViewData = pViewSh->GetViewData();
1695 if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1697 long nSplit = pViewData->GetHSplitPos();
1699 ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
1700 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1701 ePos = SC_SPLIT_TOPLEFT;
1703 SCsCOL nCol;
1704 SCsROW nRow;
1705 pViewData->GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, FALSE );
1706 if ( nCol > 0 )
1707 return nCol;
1710 return 0;
1713 sal_Int32 SAL_CALL ScTabViewObj::getSplitRow() throw(uno::RuntimeException)
1715 ScUnoGuard aGuard;
1716 ScTabViewShell* pViewSh = GetViewShell();
1717 if (pViewSh)
1719 ScViewData* pViewData = pViewSh->GetViewData();
1720 if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1722 long nSplit = pViewData->GetVSplitPos();
1724 ScSplitPos ePos = SC_SPLIT_TOPLEFT; // es ist vertikal geteilt
1725 SCsCOL nCol;
1726 SCsROW nRow;
1727 pViewData->GetPosFromPixel( 0, nSplit, ePos, nCol, nRow, FALSE );
1728 if ( nRow > 0 )
1729 return nRow;
1732 return 0;
1735 void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1736 throw(uno::RuntimeException)
1738 ScUnoGuard aGuard;
1739 ScTabViewShell* pViewSh = GetViewShell();
1740 if (pViewSh)
1742 pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ), TRUE, TRUE );
1743 pViewSh->FreezeSplitters( FALSE );
1744 pViewSh->InvalidateSplit();
1748 void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1749 throw(uno::RuntimeException)
1751 ScUnoGuard aGuard;
1752 ScTabViewShell* pViewSh = GetViewShell();
1753 if (pViewSh)
1755 // erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae.
1757 pViewSh->RemoveSplit();
1759 Point aWinStart;
1760 Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1761 if (pWin)
1762 aWinStart = pWin->GetPosPixel();
1764 ScViewData* pViewData = pViewSh->GetViewData();
1765 Point aSplit(pViewData->GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, TRUE ));
1766 aSplit += aWinStart;
1768 pViewSh->SplitAtPixel( aSplit, TRUE, TRUE );
1769 pViewSh->FreezeSplitters( TRUE );
1770 pViewSh->InvalidateSplit();
1774 void SAL_CALL ScTabViewObj::addSelectionChangeListener(
1775 const uno::Reference<view::XSelectionChangeListener>& xListener )
1776 throw(uno::RuntimeException)
1778 ScUnoGuard aGuard;
1779 uno::Reference<view::XSelectionChangeListener>* pObj =
1780 new uno::Reference<view::XSelectionChangeListener>( xListener );
1781 aSelectionListeners.Insert( pObj, aSelectionListeners.Count() );
1784 void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
1785 const uno::Reference< view::XSelectionChangeListener >& xListener )
1786 throw(uno::RuntimeException)
1788 ScUnoGuard aGuard;
1789 USHORT nCount = aSelectionListeners.Count();
1790 for ( USHORT n=nCount; n--; )
1792 uno::Reference<view::XSelectionChangeListener> *pObj = aSelectionListeners[n];
1793 if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface?
1795 aSelectionListeners.DeleteAndDestroy( n );
1796 break;
1801 void ScTabViewObj::SelectionChanged()
1803 lang::EventObject aEvent;
1804 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1805 for ( USHORT n=0; n<aSelectionListeners.Count(); n++ )
1806 (*aSelectionListeners[n])->selectionChanged( aEvent );
1810 // XPropertySet (View-Optionen)
1811 //! auch an der Applikation anbieten?
1813 uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1814 throw(uno::RuntimeException)
1816 ScUnoGuard aGuard;
1817 static uno::Reference<beans::XPropertySetInfo> aRef(
1818 new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
1819 return aRef;
1822 void SAL_CALL ScTabViewObj::setPropertyValue(
1823 const rtl::OUString& aPropertyName, const uno::Any& aValue )
1824 throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1825 lang::IllegalArgumentException, lang::WrappedTargetException,
1826 uno::RuntimeException)
1828 ScUnoGuard aGuard;
1829 String aString(aPropertyName);
1831 if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
1833 bFilteredRangeSelection = ScUnoHelpFunctions::GetBoolFromAny(aValue);
1834 return;
1837 ScTabViewShell* pViewSh = GetViewShell();
1838 if (pViewSh)
1840 ScViewData* pViewData = pViewSh->GetViewData();
1841 const ScViewOptions& rOldOpt = pViewSh->GetViewData()->GetOptions();
1842 ScViewOptions aNewOpt(rOldOpt);
1844 if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
1845 aNewOpt.SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1846 else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
1847 aNewOpt.SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1848 else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
1849 aNewOpt.SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1850 else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
1851 aNewOpt.SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1852 else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) )
1853 aNewOpt.SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1854 else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) )
1855 aNewOpt.SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1856 else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) )
1857 aNewOpt.SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1858 else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) )
1859 aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1860 else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) )
1861 aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1862 else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) )
1863 aNewOpt.SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1864 else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) )
1865 aNewOpt.SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1866 else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) )
1867 aNewOpt.SetOption( VOPT_SOLIDHANDLES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1868 else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
1869 aNewOpt.SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1870 else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
1871 aNewOpt.SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1872 else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) )
1874 sal_Int16 nIntVal = 0;
1875 if ( aValue >>= nIntVal )
1877 //#i80528# adapt to new range eventually
1878 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1880 aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
1883 else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) )
1885 sal_Int16 nIntVal = 0;
1886 if ( aValue >>= nIntVal )
1888 //#i80528# adapt to new range eventually
1889 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1891 aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
1894 else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) )
1896 sal_Int16 nIntVal = 0;
1897 if ( aValue >>= nIntVal )
1899 //#i80528# adapt to new range eventually
1900 if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1902 aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
1905 else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) )
1907 sal_Int32 nIntVal = 0;
1908 if ( aValue >>= nIntVal )
1909 aNewOpt.SetGridColor( nIntVal, String() );
1911 else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) )
1913 sal_Int16 nIntVal = 0;
1914 if ( aValue >>= nIntVal )
1915 SetZoomType(nIntVal);
1917 else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) )
1919 sal_Int16 nIntVal = 0;
1920 if ( aValue >>= nIntVal )
1921 SetZoom(nIntVal);
1924 // Optionen werden an der View und am Dokument (fuer neue Views) gesetzt,
1925 // damit sie beim Speichern erhalten bleiben.
1926 //! An der App (Module) braeuchte man noch eine Extra-Moeglichkeit,
1927 //! das einzustellen (fuer neue Dokumente)
1929 if ( aNewOpt != rOldOpt )
1931 pViewData->SetOptions( aNewOpt );
1932 pViewData->GetDocument()->SetViewOptions( aNewOpt );
1933 pViewData->GetDocShell()->SetDocumentModified(); //! wirklich?
1935 pViewSh->UpdateFixPos();
1936 pViewSh->PaintGrid();
1937 pViewSh->PaintTop();
1938 pViewSh->PaintLeft();
1939 pViewSh->PaintExtras();
1940 pViewSh->InvalidateBorder();
1942 SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
1943 rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
1944 rBindings.Invalidate( FID_TOGGLESYNTAX );
1949 uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aPropertyName )
1950 throw(beans::UnknownPropertyException, lang::WrappedTargetException,
1951 uno::RuntimeException)
1953 ScUnoGuard aGuard;
1954 String aString(aPropertyName);
1955 uno::Any aRet;
1957 if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
1959 ScUnoHelpFunctions::SetBoolInAny(aRet, bFilteredRangeSelection);
1960 return aRet;
1963 ScTabViewShell* pViewSh = GetViewShell();
1964 if (pViewSh)
1966 const ScViewOptions& rOpt = pViewSh->GetViewData()->GetOptions();
1968 if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
1969 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HEADER ) );
1970 else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
1971 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HSCROLL ) );
1972 else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
1973 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_OUTLINER ) );
1974 else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
1975 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_TABCONTROLS ) );
1976 else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_ANCHOR ) );
1977 else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_FORMULAS ) );
1978 else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_GRID ) );
1979 else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HELPLINES ) );
1980 else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NOTES ) );
1981 else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_PAGEBREAKS ) );
1982 else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NULLVALS ) );
1983 else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SOLIDHANDLES ) );
1984 else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
1985 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SYNTAX ) );
1986 else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
1987 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_VSCROLL ) );
1988 else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
1989 else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
1990 else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
1991 else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) ) aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() );
1992 else if ( aString.EqualsAscii( SC_UNO_VISAREA ) ) aRet <<= GetVisArea();
1993 else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) aRet <<= GetZoomType();
1994 else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) aRet <<= GetZoom();
1997 return aRet;
2000 void SAL_CALL ScTabViewObj::addPropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
2001 const uno::Reference<beans::XPropertyChangeListener >& xListener )
2002 throw(beans::UnknownPropertyException,
2003 lang::WrappedTargetException,
2004 uno::RuntimeException)
2006 ScUnoGuard aGuard;
2007 uno::Reference<beans::XPropertyChangeListener>* pObj =
2008 new uno::Reference<beans::XPropertyChangeListener>( xListener );
2009 aPropertyChgListeners.Insert( pObj, aPropertyChgListeners.Count() );
2012 void SAL_CALL ScTabViewObj::removePropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
2013 const uno::Reference<beans::XPropertyChangeListener >& xListener )
2014 throw(beans::UnknownPropertyException,
2015 lang::WrappedTargetException,
2016 uno::RuntimeException)
2018 ScUnoGuard aGuard;
2019 USHORT nCount = aPropertyChgListeners.Count();
2020 for ( USHORT n=nCount; n--; )
2022 uno::Reference<beans::XPropertyChangeListener> *pObj = aPropertyChgListeners[n];
2023 if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface?
2025 aPropertyChgListeners.DeleteAndDestroy( n );
2026 break;
2031 void SAL_CALL ScTabViewObj::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
2032 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2033 throw(beans::UnknownPropertyException,
2034 lang::WrappedTargetException,
2035 uno::RuntimeException)
2039 void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
2040 const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2041 throw(beans::UnknownPropertyException,
2042 lang::WrappedTargetException,
2043 uno::RuntimeException)
2047 void ScTabViewObj::VisAreaChanged()
2049 beans::PropertyChangeEvent aEvent;
2050 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2051 for ( USHORT n=0; n<aPropertyChgListeners.Count(); n++ )
2052 (*aPropertyChgListeners[n])->propertyChange( aEvent );
2055 // XRangeSelection
2057 void SAL_CALL ScTabViewObj::startRangeSelection(
2058 const uno::Sequence<beans::PropertyValue>& aArguments )
2059 throw(uno::RuntimeException)
2061 ScUnoGuard aGuard;
2062 ScTabViewShell* pViewSh = GetViewShell();
2063 if (pViewSh)
2065 String aInitVal, aTitle;
2066 BOOL bCloseOnButtonUp = FALSE;
2067 BOOL bSingleCell = FALSE;
2068 BOOL bMultiSelection = FALSE;
2070 rtl::OUString aStrVal;
2071 const beans::PropertyValue* pPropArray = aArguments.getConstArray();
2072 long nPropCount = aArguments.getLength();
2073 for (long i = 0; i < nPropCount; i++)
2075 const beans::PropertyValue& rProp = pPropArray[i];
2076 String aPropName(rProp.Name);
2078 if (aPropName.EqualsAscii( SC_UNONAME_CLOSEONUP ))
2079 bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2080 else if (aPropName.EqualsAscii( SC_UNONAME_TITLE ))
2082 if ( rProp.Value >>= aStrVal )
2083 aTitle = String( aStrVal );
2085 else if (aPropName.EqualsAscii( SC_UNONAME_INITVAL ))
2087 if ( rProp.Value >>= aStrVal )
2088 aInitVal = String( aStrVal );
2090 else if (aPropName.EqualsAscii( SC_UNONAME_SINGLECELL ))
2091 bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2092 else if (aPropName.EqualsAscii( SC_UNONAME_MULTISEL ))
2093 bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2096 pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
2100 void SAL_CALL ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException)
2102 ScUnoGuard aGuard;
2103 ScTabViewShell* pViewSh = GetViewShell();
2104 if (pViewSh)
2105 pViewSh->StopSimpleRefDialog();
2108 void SAL_CALL ScTabViewObj::addRangeSelectionListener(
2109 const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2110 throw(uno::RuntimeException)
2112 ScUnoGuard aGuard;
2113 uno::Reference<sheet::XRangeSelectionListener>* pObj =
2114 new uno::Reference<sheet::XRangeSelectionListener>( xListener );
2115 aRangeSelListeners.Insert( pObj, aRangeSelListeners.Count() );
2118 void SAL_CALL ScTabViewObj::removeRangeSelectionListener(
2119 const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2120 throw(uno::RuntimeException)
2122 ScUnoGuard aGuard;
2123 USHORT nCount = aRangeSelListeners.Count();
2124 for ( USHORT n=nCount; n--; )
2126 uno::Reference<sheet::XRangeSelectionListener> *pObj = aRangeSelListeners[n];
2127 if ( *pObj == xListener )
2129 aRangeSelListeners.DeleteAndDestroy( n );
2130 break;
2135 void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener(
2136 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2137 throw(uno::RuntimeException)
2139 ScUnoGuard aGuard;
2140 uno::Reference<sheet::XRangeSelectionChangeListener>* pObj =
2141 new uno::Reference<sheet::XRangeSelectionChangeListener>( xListener );
2142 aRangeChgListeners.Insert( pObj, aRangeChgListeners.Count() );
2145 void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener(
2146 const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2147 throw(uno::RuntimeException)
2149 ScUnoGuard aGuard;
2150 USHORT nCount = aRangeChgListeners.Count();
2151 for ( USHORT n=nCount; n--; )
2153 uno::Reference<sheet::XRangeSelectionChangeListener> *pObj = aRangeChgListeners[n];
2154 if ( *pObj == xListener )
2156 aRangeChgListeners.DeleteAndDestroy( n );
2157 break;
2162 void ScTabViewObj::RangeSelDone( const String& rText )
2164 sheet::RangeSelectionEvent aEvent;
2165 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2166 aEvent.RangeDescriptor = rtl::OUString( rText );
2168 for ( USHORT n=0; n<aRangeSelListeners.Count(); n++ )
2169 (*aRangeSelListeners[n])->done( aEvent );
2172 void ScTabViewObj::RangeSelAborted( const String& rText )
2174 sheet::RangeSelectionEvent aEvent;
2175 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2176 aEvent.RangeDescriptor = rtl::OUString( rText );
2178 for ( USHORT n=0; n<aRangeSelListeners.Count(); n++ )
2179 (*aRangeSelListeners[n])->aborted( aEvent );
2182 void ScTabViewObj::RangeSelChanged( const String& rText )
2184 sheet::RangeSelectionEvent aEvent;
2185 aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2186 aEvent.RangeDescriptor = rtl::OUString( rText );
2188 for ( USHORT n=0; n<aRangeChgListeners.Count(); n++ )
2189 (*aRangeChgListeners[n])->descriptorChanged( aEvent );
2192 // XServiceInfo
2194 rtl::OUString SAL_CALL ScTabViewObj::getImplementationName() throw(uno::RuntimeException)
2196 return rtl::OUString::createFromAscii( "ScTabViewObj" );
2199 sal_Bool SAL_CALL ScTabViewObj::supportsService( const rtl::OUString& rServiceName )
2200 throw(uno::RuntimeException)
2202 String aServiceStr( rServiceName );
2203 return aServiceStr.EqualsAscii( SCTABVIEWOBJ_SERVICE ) ||
2204 aServiceStr.EqualsAscii( SCVIEWSETTINGS_SERVICE );
2207 uno::Sequence<rtl::OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2208 throw(uno::RuntimeException)
2210 uno::Sequence<rtl::OUString> aRet(2);
2211 rtl::OUString* pArray = aRet.getArray();
2212 pArray[0] = rtl::OUString::createFromAscii( SCTABVIEWOBJ_SERVICE );
2213 pArray[1] = rtl::OUString::createFromAscii( SCVIEWSETTINGS_SERVICE );
2214 return aRet;
2217 // XUnoTunnel
2219 sal_Int64 SAL_CALL ScTabViewObj::getSomething(
2220 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
2222 if ( rId.getLength() == 16 &&
2223 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2224 rId.getConstArray(), 16 ) )
2226 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2228 return 0;
2231 // static
2232 const uno::Sequence<sal_Int8>& ScTabViewObj::getUnoTunnelId()
2234 static uno::Sequence<sal_Int8> * pSeq = 0;
2235 if( !pSeq )
2237 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
2238 if( !pSeq )
2240 static uno::Sequence< sal_Int8 > aSeq( 16 );
2241 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2242 pSeq = &aSeq;
2245 return *pSeq;
2248 // static
2249 ScTabViewObj* ScTabViewObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
2251 ScTabViewObj* pRet = NULL;
2252 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
2253 if (xUT.is())
2254 pRet = reinterpret_cast<ScTabViewObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
2255 return pRet;
2258 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable( ) throw (::com::sun::star::uno::RuntimeException)
2260 ScUnoGuard aGuard;
2261 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2262 if (pShell)
2263 return pShell->GetEditView()->GetTransferable();
2265 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2266 if (pTextShell)
2268 ScViewData* pViewData = GetViewShell()->GetViewData();
2269 ScDrawView* pView = pViewData->GetScDrawView();
2270 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2271 if (pOutView)
2272 return pOutView->GetEditView().GetTransferable();
2275 ScDrawShell* pDrawShell = PTR_CAST( ScDrawShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2276 if (pDrawShell)
2277 return pDrawShell->GetDrawView()->CopyToTransferable();
2279 ScTransferObj* pObj = GetViewShell()->CopyToTransferable();
2280 uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2281 return xTransferable;
2284 void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException)
2286 ScUnoGuard aGuard;
2287 ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2288 if (pShell)
2289 pShell->GetEditView()->InsertText( xTrans, ::rtl::OUString(), FALSE );
2290 else
2292 ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2293 if (pTextShell)
2295 ScViewData* pViewData = GetViewShell()->GetViewData();
2296 ScDrawView* pView = pViewData->GetScDrawView();
2297 OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2298 if ( pOutView )
2300 pOutView->GetEditView().InsertText( xTrans, ::rtl::OUString(), FALSE );
2301 return;
2305 GetViewShell()->PasteFromTransferable( xTrans );
2309 //------------------------------------------------------------------------