1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
52 #include <toolkit/helper/convert.hxx>
55 #include "drtxtob.hxx"
56 #include "transobj.hxx"
58 #include "viewuno.hxx"
59 #include "cellsuno.hxx"
60 #include "miscuno.hxx"
61 #include "tabvwsh.hxx"
63 #include "drwlayer.hxx"
64 #include "drawview.hxx"
67 #include "unoguard.hxx"
68 #include "unonames.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>
78 using namespace com::sun::star
;
79 using namespace com::sun::star::document::VbaEventId
;
81 //------------------------------------------------------------------------
83 //! Clipping-Markierungen
85 // alles ohne Which-ID, Map nur fuer PropertySetInfo
87 const SfxItemPropertyMap
* lcl_GetViewOptPropertyMap()
89 static SfxItemPropertyMap aViewOptPropertyMap_Impl
[] =
91 {MAP_CHAR_LEN(OLD_UNO_COLROWHDR
), 0, &getBooleanCppuType(), 0, 0},
92 {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR
), 0, &getCppuType((sal_Int32
*)0), 0, 0},
93 {MAP_CHAR_LEN(SC_UNO_COLROWHDR
), 0, &getBooleanCppuType(), 0, 0},
94 {MAP_CHAR_LEN(SC_UNO_HORSCROLL
), 0, &getBooleanCppuType(), 0, 0},
95 {MAP_CHAR_LEN(SC_UNO_SHEETTABS
), 0, &getBooleanCppuType(), 0, 0},
96 {MAP_CHAR_LEN(SC_UNO_VERTSCROLL
), 0, &getBooleanCppuType(), 0, 0},
97 {MAP_CHAR_LEN(SC_UNO_HIDESPELL
), 0, &getBooleanCppuType(), 0, 0}, /* deprecated #i91949 */
98 {MAP_CHAR_LEN(OLD_UNO_HORSCROLL
), 0, &getBooleanCppuType(), 0, 0},
99 {MAP_CHAR_LEN(SC_UNO_OUTLSYMB
), 0, &getBooleanCppuType(), 0, 0},
100 {MAP_CHAR_LEN(SC_UNO_VALUEHIGH
), 0, &getBooleanCppuType(), 0, 0},
101 {MAP_CHAR_LEN(OLD_UNO_OUTLSYMB
), 0, &getBooleanCppuType(), 0, 0},
102 {MAP_CHAR_LEN(OLD_UNO_SHEETTABS
), 0, &getBooleanCppuType(), 0, 0},
103 {MAP_CHAR_LEN(SC_UNO_SHOWANCHOR
), 0, &getBooleanCppuType(), 0, 0},
104 {MAP_CHAR_LEN(SC_UNO_SHOWCHARTS
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
105 {MAP_CHAR_LEN(SC_UNO_SHOWDRAW
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
106 {MAP_CHAR_LEN(SC_UNO_SHOWFORM
), 0, &getBooleanCppuType(), 0, 0},
107 {MAP_CHAR_LEN(SC_UNO_SHOWGRID
), 0, &getBooleanCppuType(), 0, 0},
108 {MAP_CHAR_LEN(SC_UNO_SHOWHELP
), 0, &getBooleanCppuType(), 0, 0},
109 {MAP_CHAR_LEN(SC_UNO_SHOWNOTES
), 0, &getBooleanCppuType(), 0, 0},
110 {MAP_CHAR_LEN(SC_UNO_SHOWOBJ
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
111 {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR
), 0, &getBooleanCppuType(), 0, 0},
112 {MAP_CHAR_LEN(SC_UNO_SHOWZERO
), 0, &getBooleanCppuType(), 0, 0},
113 {MAP_CHAR_LEN(SC_UNO_SHOWSOLID
), 0, &getBooleanCppuType(), 0, 0},
114 {MAP_CHAR_LEN(OLD_UNO_VALUEHIGH
), 0, &getBooleanCppuType(), 0, 0},
115 {MAP_CHAR_LEN(OLD_UNO_VERTSCROLL
), 0, &getBooleanCppuType(), 0, 0},
116 {MAP_CHAR_LEN(SC_UNO_VISAREA
), 0, &getCppuType((awt::Rectangle
*)0), 0, 0},
117 {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
118 {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE
), 0, &getCppuType((sal_Int16
*)0), 0, 0},
121 return aViewOptPropertyMap_Impl
;
124 //------------------------------------------------------------------------
126 SV_IMPL_PTRARR( XRangeSelectionListenerArr_Impl
, XRangeSelectionListenerPtr
);
127 SV_IMPL_PTRARR( XRangeSelectionChangeListenerArr_Impl
, XRangeSelectionChangeListenerPtr
);
128 SV_IMPL_PTRARR( XSelectionChangeListenerArr_Impl
, XSelectionChangeListenerPtr
);
129 SV_IMPL_PTRARR( XViewPropertyChangeListenerArr_Impl
, XViewPropertyChangeListenerPtr
);
130 SV_IMPL_PTRARR( XMouseClickHandlerArr_Impl
, XMouseClickHandlerPtr
);
131 SV_IMPL_PTRARR( XActivationEventListenerArr_Impl
, XActivationEventListenerPtr
);
133 #define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView"
134 #define SCVIEWSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetViewSettings"
136 SC_SIMPLE_SERVICE_INFO( ScViewPaneBase
, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
138 //------------------------------------------------------------------------
140 ScViewPaneBase::ScViewPaneBase(ScTabViewShell
* pViewSh
, USHORT nP
) :
141 pViewShell( pViewSh
),
145 StartListening(*pViewShell
);
148 ScViewPaneBase::~ScViewPaneBase()
151 EndListening(*pViewShell
);
154 void ScViewPaneBase::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
156 if ( rHint
.ISA( SfxSimpleHint
) &&
157 ((const SfxSimpleHint
&)rHint
).GetId() == SFX_HINT_DYING
)
161 uno::Any SAL_CALL
ScViewPaneBase::queryInterface( const uno::Type
& rType
)
162 throw(uno::RuntimeException
)
164 SC_QUERYINTERFACE( sheet::XViewPane
)
165 SC_QUERYINTERFACE( sheet::XCellRangeReferrer
)
166 SC_QUERYINTERFACE( view::XFormLayerAccess
)
167 SC_QUERYINTERFACE( view::XControlAccess
)
168 SC_QUERYINTERFACE( lang::XServiceInfo
)
169 SC_QUERYINTERFACE( lang::XTypeProvider
)
171 return uno::Any(); // OWeakObject is in derived objects
174 uno::Sequence
<uno::Type
> SAL_CALL
ScViewPaneBase::getTypes() throw(uno::RuntimeException
)
176 static uno::Sequence
<uno::Type
> aTypes
;
177 if ( aTypes
.getLength() == 0 )
180 uno::Type
* pPtr
= aTypes
.getArray();
181 pPtr
[0] = getCppuType((const uno::Reference
<sheet::XViewPane
>*)0);
182 pPtr
[1] = getCppuType((const uno::Reference
<sheet::XCellRangeReferrer
>*)0);
183 pPtr
[2] = getCppuType((const uno::Reference
<view::XFormLayerAccess
>*)0);
184 pPtr
[3] = getCppuType((const uno::Reference
<lang::XServiceInfo
>*)0);
185 pPtr
[4] = getCppuType((const uno::Reference
<lang::XTypeProvider
>*)0);
190 uno::Sequence
<sal_Int8
> SAL_CALL
ScViewPaneBase::getImplementationId()
191 throw(uno::RuntimeException
)
193 static uno::Sequence
< sal_Int8
> aId
;
194 if( aId
.getLength() == 0 )
197 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
204 sal_Int32 SAL_CALL
ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException
)
209 ScViewData
* pViewData
= pViewShell
->GetViewData();
210 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
211 pViewData
->GetActivePart() :
213 ScHSplitPos eWhichH
= WhichH( eWhich
);
215 return pViewData
->GetPosX( eWhichH
);
217 DBG_ERROR("keine View ?!?"); //! Exception?
221 void SAL_CALL
ScViewPaneBase::setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn
)
222 throw(uno::RuntimeException
)
227 ScViewData
* pViewData
= pViewShell
->GetViewData();
228 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
229 pViewData
->GetActivePart() :
231 ScHSplitPos eWhichH
= WhichH( eWhich
);
233 long nDeltaX
= ((long)nFirstVisibleColumn
) - pViewData
->GetPosX( eWhichH
);
234 pViewShell
->ScrollX( nDeltaX
, eWhichH
);
238 sal_Int32 SAL_CALL
ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException
)
243 ScViewData
* pViewData
= pViewShell
->GetViewData();
244 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
245 pViewData
->GetActivePart() :
247 ScVSplitPos eWhichV
= WhichV( eWhich
);
249 return pViewData
->GetPosY( eWhichV
);
251 DBG_ERROR("keine View ?!?"); //! Exception?
255 void SAL_CALL
ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow
)
256 throw(uno::RuntimeException
)
261 ScViewData
* pViewData
= pViewShell
->GetViewData();
262 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
263 pViewData
->GetActivePart() :
265 ScVSplitPos eWhichV
= WhichV( eWhich
);
267 long nDeltaY
= ((long)nFirstVisibleRow
) - pViewData
->GetPosY( eWhichV
);
268 pViewShell
->ScrollY( nDeltaY
, eWhichV
);
272 table::CellRangeAddress SAL_CALL
ScViewPaneBase::getVisibleRange() throw(uno::RuntimeException
)
275 table::CellRangeAddress aAdr
;
278 ScViewData
* pViewData
= pViewShell
->GetViewData();
279 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
280 pViewData
->GetActivePart() :
282 ScHSplitPos eWhichH
= WhichH( eWhich
);
283 ScVSplitPos eWhichV
= WhichV( eWhich
);
285 // VisibleCellsX gibt nur komplett sichtbare Zellen,
286 // VisibleRange in Excel auch teilweise sichtbare.
289 SCCOL nVisX
= pViewData
->VisibleCellsX( eWhichH
);
290 SCROW nVisY
= pViewData
->VisibleCellsY( eWhichV
);
291 if (!nVisX
) nVisX
= 1; // irgendwas muss ja im Range sein
292 if (!nVisY
) nVisY
= 1;
293 aAdr
.Sheet
= pViewData
->GetTabNo();
294 aAdr
.StartColumn
= pViewData
->GetPosX( eWhichH
);
295 aAdr
.StartRow
= pViewData
->GetPosY( eWhichV
);
296 aAdr
.EndColumn
= aAdr
.StartColumn
+ nVisX
- 1;
297 aAdr
.EndRow
= aAdr
.StartRow
+ nVisY
- 1;
304 uno::Reference
<table::XCellRange
> SAL_CALL
ScViewPaneBase::getReferredCells()
305 throw(uno::RuntimeException
)
310 ScDocShell
* pDocSh
= pViewShell
->GetViewData()->GetDocShell();
312 table::CellRangeAddress
aAdr(getVisibleRange()); //! Hilfsfunktion mit ScRange?
313 ScRange
aRange( (SCCOL
)aAdr
.StartColumn
, (SCROW
)aAdr
.StartRow
, aAdr
.Sheet
,
314 (SCCOL
)aAdr
.EndColumn
, (SCROW
)aAdr
.EndRow
, aAdr
.Sheet
);
315 if ( aRange
.aStart
== aRange
.aEnd
)
316 return new ScCellObj( pDocSh
, aRange
.aStart
);
318 return new ScCellRangeObj( pDocSh
, aRange
);
326 bool lcl_prepareFormShellCall( ScTabViewShell
* _pViewShell
, USHORT _nPane
, FmFormShell
*& _rpFormShell
, Window
*& _rpWindow
, SdrView
*& _rpSdrView
)
331 ScViewData
* pViewData
= _pViewShell
->GetViewData();
332 ScSplitPos eWhich
= ( _nPane
== SC_VIEWPANE_ACTIVE
) ?
333 pViewData
->GetActivePart() :
335 _rpWindow
= _pViewShell
->GetWindowByPos( eWhich
);
336 _rpSdrView
= _pViewShell
->GetSdrView();
337 _rpFormShell
= _pViewShell
->GetFormShell();
338 return ( _rpFormShell
!= NULL
) && ( _rpSdrView
!= NULL
)&& ( _rpWindow
!= NULL
);
343 uno::Reference
< form::XFormController
> SAL_CALL
ScViewPaneBase::getFormController( const uno::Reference
< form::XForm
>& _Form
) throw (uno::RuntimeException
)
347 uno::Reference
< form::XFormController
> xController
;
349 Window
* pWindow( NULL
);
350 SdrView
* pSdrView( NULL
);
351 FmFormShell
* pFormShell( NULL
);
352 if ( lcl_prepareFormShellCall( pViewShell
, nPane
, pFormShell
, pWindow
, pSdrView
) )
353 xController
= pFormShell
->GetFormController( _Form
, *pSdrView
, *pWindow
);
358 ::sal_Bool SAL_CALL
ScViewPaneBase::isFormDesignMode( ) throw (uno::RuntimeException
)
362 sal_Bool
bIsFormDesignMode( sal_True
);
364 FmFormShell
* pFormShell( pViewShell
? pViewShell
->GetFormShell() : NULL
);
366 bIsFormDesignMode
= pFormShell
->IsDesignMode();
368 return bIsFormDesignMode
;
371 void SAL_CALL
ScViewPaneBase::setFormDesignMode( ::sal_Bool _DesignMode
) throw (uno::RuntimeException
)
375 Window
* pWindow( NULL
);
376 SdrView
* pSdrView( NULL
);
377 FmFormShell
* pFormShell( NULL
);
378 if ( lcl_prepareFormShellCall( pViewShell
, nPane
, pFormShell
, pWindow
, pSdrView
) )
379 pFormShell
->SetDesignMode( _DesignMode
);
384 uno::Reference
<awt::XControl
> SAL_CALL
ScViewPaneBase::getControl(
385 const uno::Reference
<awt::XControlModel
>& xModel
)
386 throw(container::NoSuchElementException
, uno::RuntimeException
)
390 uno::Reference
<awt::XControl
> xRet
;
392 Window
* pWindow( NULL
);
393 SdrView
* pSdrView( NULL
);
394 FmFormShell
* pFormShell( NULL
);
395 if ( lcl_prepareFormShellCall( pViewShell
, nPane
, pFormShell
, pWindow
, pSdrView
) )
396 pFormShell
->GetFormControl( xModel
, *pSdrView
, *pWindow
, xRet
);
399 throw container::NoSuchElementException(); // no control found
404 awt::Rectangle
ScViewPaneBase::GetVisArea() const
406 awt::Rectangle aVisArea
;
409 ScSplitPos eWhich
= ( nPane
== SC_VIEWPANE_ACTIVE
) ?
410 pViewShell
->GetViewData()->GetActivePart() :
412 ScGridWindow
* pWindow
= (ScGridWindow
*)pViewShell
->GetWindowByPos(eWhich
);
413 ScDocument
* pDoc
= pViewShell
->GetViewData()->GetDocument();
416 ScHSplitPos eWhichH
= ((eWhich
== SC_SPLIT_TOPLEFT
) || (eWhich
== SC_SPLIT_BOTTOMLEFT
)) ?
417 SC_SPLIT_LEFT
: SC_SPLIT_RIGHT
;
418 ScVSplitPos eWhichV
= ((eWhich
== SC_SPLIT_TOPLEFT
) || (eWhich
== SC_SPLIT_TOPRIGHT
)) ?
419 SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
;
420 ScAddress
aCell(pViewShell
->GetViewData()->GetPosX(eWhichH
),
421 pViewShell
->GetViewData()->GetPosY(eWhichV
),
422 pViewShell
->GetViewData()->GetTabNo());
423 Rectangle
aVisRect(pDoc
->GetMMRect(aCell
.Col(), aCell
.Row(), aCell
.Col(), aCell
.Row(), aCell
.Tab()));
425 aVisRect
.SetSize(pWindow
->PixelToLogic(pWindow
->GetSizePixel(), pWindow
->GetDrawMapMode(sal_True
)));
427 aVisArea
= AWTRectangle(aVisRect
);
433 //------------------------------------------------------------------------
435 ScViewPaneObj::ScViewPaneObj(ScTabViewShell
* pViewSh
, USHORT nP
) :
436 ScViewPaneBase( pViewSh
, nP
)
440 ScViewPaneObj::~ScViewPaneObj()
444 uno::Any SAL_CALL
ScViewPaneObj::queryInterface( const uno::Type
& rType
)
445 throw(uno::RuntimeException
)
447 // ScViewPaneBase has everything except OWeakObject
449 uno::Any
aRet(ScViewPaneBase::queryInterface( rType
));
450 if (!aRet
.hasValue())
451 aRet
= OWeakObject::queryInterface( rType
);
455 void SAL_CALL
ScViewPaneObj::acquire() throw()
457 OWeakObject::acquire();
460 void SAL_CALL
ScViewPaneObj::release() throw()
462 OWeakObject::release();
465 // To process sheet compatibile event
466 typedef ::cppu::WeakImplHelper2
< awt::XEnhancedMouseClickHandler
, view::XSelectionChangeListener
> TabViewEventListener_BASE
;
467 class ScTabViewEventListener
: public TabViewEventListener_BASE
470 uno::Reference
< document::XVbaEventsHelper
> xVbaEventsHelper
;
471 ScTabViewObj
* pViewObj
;
474 ScTabViewEventListener( ScTabViewObj
* pObj
, uno::Reference
< document::XVbaEventsHelper
>& rVbaEventsHelper
);
475 ~ScTabViewEventListener();
476 // XEnhancedMouseClickHandler
477 virtual sal_Bool SAL_CALL
mousePressed( const awt::EnhancedMouseEvent
& e
) throw (uno::RuntimeException
);
478 virtual sal_Bool SAL_CALL
mouseReleased( const awt::EnhancedMouseEvent
& e
) throw (uno::RuntimeException
);
480 // XSelectionChangeListener
481 virtual void SAL_CALL
selectionChanged( const lang::EventObject
& aEvent
) throw ( uno::RuntimeException
);
483 virtual void SAL_CALL
disposing( const lang::EventObject
& aEvent
) throw ( uno::RuntimeException
);
486 ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj
* pObj
, uno::Reference
< document::XVbaEventsHelper
>& rVbaEventsHelper
):
487 pViewObj( pObj
),xVbaEventsHelper( rVbaEventsHelper
)
491 ScTabViewEventListener::~ScTabViewEventListener()
495 void SAL_CALL
ScTabViewEventListener::disposing( const lang::EventObject
& /*aEvent*/ ) throw ( uno::RuntimeException
)
499 sal_Bool SAL_CALL
ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent
& e
) throw (uno::RuntimeException
)
501 sal_Bool result
= sal_False
;
502 // process BeforeDoubleClick and BeforeRightClick events
503 if( e
.ClickCount
== 2 || e
.Buttons
== ::com::sun::star::awt::MouseButton::RIGHT
)
505 // ensure the target is a cell
506 uno::Reference
< table::XCell
> xCell( e
.Target
, uno::UNO_QUERY
);
507 if( xCell
.is() && xVbaEventsHelper
.is() && pViewObj
)
509 uno::Sequence
< uno::Any
> aArgs(1);
510 aArgs
[0] = pViewObj
->getSelection();
511 sal_Int32 nEventId
= VBAEVENT_WORKSHEET_BEFORERIGHTCLICK
;
512 if( e
.ClickCount
== 2 )
513 nEventId
= VBAEVENT_WORKSHEET_BEFOREDOUBLECLICK
;
515 result
= xVbaEventsHelper
->ProcessCompatibleVbaEvent( nEventId
, aArgs
);
516 // TODO: process Cancel argument
522 sal_Bool SAL_CALL
ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent
&/*e*/) throw (uno::RuntimeException
)
527 void SAL_CALL
ScTabViewEventListener::selectionChanged( const lang::EventObject
& /*aEvent*/ ) throw ( uno::RuntimeException
)
529 if ( xVbaEventsHelper
.is() && pViewObj
)
531 uno::Sequence
< uno::Any
> aArgs(1);
532 aArgs
[0] = pViewObj
->getSelection();
533 xVbaEventsHelper
->ProcessCompatibleVbaEvent( VBAEVENT_WORKSHEET_SELECTIONCHANGE
, aArgs
);
537 //------------------------------------------------------------------------
539 // Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
541 //UNUSED2008-05 ScTabViewObj::ScTabViewObj() :
542 //UNUSED2008-05 ScViewPaneBase( NULL, SC_VIEWPANE_ACTIVE ),
543 //UNUSED2008-05 SfxBaseController( NULL ),
544 //UNUSED2008-05 aPropSet( lcl_GetViewOptPropertyMap() ),
545 //UNUSED2008-05 aMouseClickHandlers( 0 ),
546 //UNUSED2008-05 aActivationListeners( 0 ),
547 //UNUSED2008-05 bDrawSelModeSet(sal_False),
548 //UNUSED2008-05 bFilteredRangeSelection(sal_True)
552 ScTabViewObj::ScTabViewObj( ScTabViewShell
* pViewSh
) :
553 ScViewPaneBase( pViewSh
, SC_VIEWPANE_ACTIVE
),
554 SfxBaseController( pViewSh
),
555 aPropSet( lcl_GetViewOptPropertyMap() ),
556 aMouseClickHandlers( 0 ),
557 aActivationListeners( 0 ),
558 bDrawSelModeSet(sal_False
),
559 bFilteredRangeSelection(sal_True
)
563 ScViewData
* pViewData
= pViewSh
->GetViewData();
566 uno::Reference
< document::XVbaEventsHelper
> xVbaEventsHelper (pViewData
->GetDocument()->GetVbaEventsHelper(), uno::UNO_QUERY
);
567 ScTabViewEventListener
* pEventListener
= new ScTabViewEventListener( this, xVbaEventsHelper
);
568 uno::Reference
< awt::XEnhancedMouseClickHandler
> aMouseClickHandler( *pEventListener
, uno::UNO_QUERY
);
569 addEnhancedMouseClickHandler( aMouseClickHandler
);
570 uno::Reference
< view::XSelectionChangeListener
> aSelectionChangeListener( *pEventListener
, uno::UNO_QUERY
);
571 addSelectionChangeListener( aSelectionChangeListener
);
576 ScTabViewObj::~ScTabViewObj()
578 //! Listening oder so
579 if (aMouseClickHandlers
.Count())
584 if (aActivationListeners
.Count())
587 EndActivationListening();
591 uno::Any SAL_CALL
ScTabViewObj::queryInterface( const uno::Type
& rType
)
592 throw(uno::RuntimeException
)
594 SC_QUERYINTERFACE( sheet::XSpreadsheetView
)
595 SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster
)
596 SC_QUERYINTERFACE( sheet::XActivationBroadcaster
)
597 SC_QUERYINTERFACE( container::XEnumerationAccess
)
598 SC_QUERYINTERFACE( container::XIndexAccess
)
599 SC_QUERY_MULTIPLE( container::XElementAccess
, container::XIndexAccess
)
600 SC_QUERYINTERFACE( view::XSelectionSupplier
)
601 SC_QUERYINTERFACE( beans::XPropertySet
)
602 SC_QUERYINTERFACE( sheet::XViewSplitable
)
603 SC_QUERYINTERFACE( sheet::XViewFreezable
)
604 SC_QUERYINTERFACE( sheet::XRangeSelection
)
605 SC_QUERYINTERFACE( lang::XUnoTunnel
)
606 SC_QUERYINTERFACE( datatransfer::XTransferableSupplier
)
608 uno::Any
aRet(ScViewPaneBase::queryInterface( rType
));
609 if (!aRet
.hasValue())
610 aRet
= SfxBaseController::queryInterface( rType
);
614 void SAL_CALL
ScTabViewObj::acquire() throw()
616 SfxBaseController::acquire();
619 void SAL_CALL
ScTabViewObj::release() throw()
621 SfxBaseController::release();
624 void ScTabViewObj::SheetChanged()
626 if (aActivationListeners
.Count() > 0 && GetViewShell())
628 sheet::ActivationEvent aEvent
;
629 uno::Reference
< sheet::XSpreadsheetView
> xView(this);
630 uno::Reference
< uno::XInterface
> xSource(xView
, uno::UNO_QUERY
);
631 aEvent
.Source
= xSource
;
632 aEvent
.ActiveSheet
= new ScTableSheetObj(GetViewShell()->GetViewData()->GetDocShell(), GetViewShell()->GetViewData()->GetTabNo());
633 for ( USHORT n
=0; n
<aActivationListeners
.Count(); n
++ )
637 (*aActivationListeners
[n
])->activeSpreadsheetChanged( aEvent
);
639 catch( uno::Exception
& )
641 aActivationListeners
.DeleteAndDestroy( n
);
642 --n
; // because it will be increased again in the loop
648 uno::Sequence
<uno::Type
> SAL_CALL
ScTabViewObj::getTypes() throw(uno::RuntimeException
)
650 static uno::Sequence
<uno::Type
> aTypes
;
651 if ( aTypes
.getLength() == 0 )
653 uno::Sequence
<uno::Type
> aViewPaneTypes(ScViewPaneBase::getTypes());
654 long nViewPaneLen
= aViewPaneTypes
.getLength();
655 const uno::Type
* pViewPanePtr
= aViewPaneTypes
.getConstArray();
657 uno::Sequence
<uno::Type
> aControllerTypes(SfxBaseController::getTypes());
658 long nControllerLen
= aControllerTypes
.getLength();
659 const uno::Type
* pControllerPtr
= aControllerTypes
.getConstArray();
661 long nParentLen
= nViewPaneLen
+ nControllerLen
;
663 aTypes
.realloc( nParentLen
+ 12 );
664 uno::Type
* pPtr
= aTypes
.getArray();
665 pPtr
[nParentLen
+ 0] = getCppuType((const uno::Reference
<sheet::XSpreadsheetView
>*)0);
666 pPtr
[nParentLen
+ 1] = getCppuType((const uno::Reference
<container::XEnumerationAccess
>*)0);
667 pPtr
[nParentLen
+ 2] = getCppuType((const uno::Reference
<container::XIndexAccess
>*)0);
668 pPtr
[nParentLen
+ 3] = getCppuType((const uno::Reference
<view::XSelectionSupplier
>*)0);
669 pPtr
[nParentLen
+ 4] = getCppuType((const uno::Reference
<beans::XPropertySet
>*)0);
670 pPtr
[nParentLen
+ 5] = getCppuType((const uno::Reference
<sheet::XViewSplitable
>*)0);
671 pPtr
[nParentLen
+ 6] = getCppuType((const uno::Reference
<sheet::XViewFreezable
>*)0);
672 pPtr
[nParentLen
+ 7] = getCppuType((const uno::Reference
<sheet::XRangeSelection
>*)0);
673 pPtr
[nParentLen
+ 8] = getCppuType((const uno::Reference
<lang::XUnoTunnel
>*)0);
674 pPtr
[nParentLen
+ 9] = getCppuType((const uno::Reference
<sheet::XEnhancedMouseClickBroadcaster
>*)0);
675 pPtr
[nParentLen
+ 10] = getCppuType((const uno::Reference
<sheet::XActivationBroadcaster
>*)0);
676 pPtr
[nParentLen
+ 11] = getCppuType((const uno::Reference
<datatransfer::XTransferableSupplier
>*)0);
679 for (i
=0; i
<nViewPaneLen
; i
++)
680 pPtr
[i
] = pViewPanePtr
[i
]; // parent types first
681 for (i
=0; i
<nControllerLen
; i
++)
682 pPtr
[nViewPaneLen
+i
] = pControllerPtr
[i
];
687 uno::Sequence
<sal_Int8
> SAL_CALL
ScTabViewObj::getImplementationId()
688 throw(uno::RuntimeException
)
690 static uno::Sequence
< sal_Int8
> aId
;
691 if( aId
.getLength() == 0 )
694 rtl_createUuid( (sal_uInt8
*)aId
.getArray(), 0, sal_True
);
701 BOOL
lcl_TabInRanges( SCTAB nTab
, const ScRangeList
& rRanges
)
703 ULONG nCount
= rRanges
.Count();
704 for (ULONG i
=0; i
<nCount
; i
++)
706 const ScRange
* pRange
= rRanges
.GetObject(i
);
707 if ( nTab
>= pRange
->aStart
.Tab() && nTab
<= pRange
->aEnd
.Tab() )
713 void lcl_ShowObject( ScTabViewShell
& rViewSh
, ScDrawView
& rDrawView
, SdrObject
* pSelObj
)
716 SCTAB nObjectTab
= 0;
718 SdrModel
* pModel
= rDrawView
.GetModel();
719 USHORT nPageCount
= pModel
->GetPageCount();
720 for (USHORT i
=0; i
<nPageCount
&& !bFound
; i
++)
722 SdrPage
* pPage
= pModel
->GetPage(i
);
725 SdrObjListIter
aIter( *pPage
, IM_DEEPWITHGROUPS
);
726 SdrObject
* pObject
= aIter
.Next();
727 while (pObject
&& !bFound
)
729 if ( pObject
== pSelObj
)
732 nObjectTab
= static_cast<SCTAB
>(i
);
734 pObject
= aIter
.Next();
741 rViewSh
.SetTabNo( nObjectTab
);
742 rViewSh
.ScrollToObject( pSelObj
);
746 sal_Bool SAL_CALL
ScTabViewObj::select( const uno::Any
& aSelection
)
747 throw(lang::IllegalArgumentException
, uno::RuntimeException
)
750 ScTabViewShell
* pViewSh
= GetViewShell();
755 //! Type of aSelection can be some specific interface instead of XInterface
758 uno::Reference
<uno::XInterface
> xInterface(aSelection
, uno::UNO_QUERY
);
759 if ( !xInterface
.is() ) //clear all selections
761 ScDrawView
* pDrawView
= pViewSh
->GetScDrawView();
764 pDrawView
->ScEndTextEdit();
765 pDrawView
->UnmarkAll();
767 else //#102232#; if there is no DrawView remove range selection
772 if (bDrawSelModeSet
) // remove DrawSelMode if set by API; if necessary it will be set again later
774 pViewSh
->SetDrawSelMode(sal_False
);
775 pViewSh
->UpdateLayerLocks();
776 bDrawSelModeSet
= sal_False
;
783 ScCellRangesBase
* pRangesImp
= ScCellRangesBase::getImplementation( xInterface
);
784 uno::Reference
<drawing::XShapes
> xShapeColl( xInterface
, uno::UNO_QUERY
);
785 uno::Reference
<drawing::XShape
> xShapeSel( xInterface
, uno::UNO_QUERY
);
786 SvxShape
* pShapeImp
= SvxShape::getImplementation( xShapeSel
);
788 if (pRangesImp
) // Zell-Ranges
790 ScViewData
* pViewData
= pViewSh
->GetViewData();
791 if ( pViewData
->GetDocShell() == pRangesImp
->GetDocShell() )
793 // Zuerst evtl. Drawing-Selektion aufheben
794 // (MarkListHasChanged hebt Tabellen-Selektion auf)
796 ScDrawView
* pDrawView
= pViewSh
->GetScDrawView();
799 pDrawView
->ScEndTextEdit();
800 pDrawView
->UnmarkAll();
802 FuPoor
* pFunc
= pViewSh
->GetDrawFuncPtr();
803 if ( pFunc
&& pFunc
->GetSlotID() != SID_OBJECT_SELECT
)
805 // Slot der Zeichenfunktion nochmal ausfuehren -> abschalten
806 SfxDispatcher
* pDisp
= pViewSh
->GetDispatcher();
808 pDisp
->Execute( pFunc
->GetSlotID(), SFX_CALLMODE_SYNCHRON
);
810 pViewSh
->SetDrawShell(FALSE
);
811 pViewSh
->SetDrawSelMode(FALSE
); // nach dem Dispatcher-Execute
813 // Ranges selektieren
815 const ScRangeList
& rRanges
= pRangesImp
->GetRangeList();
816 ULONG nRangeCount
= rRanges
.Count();
817 // for empty range list, remove selection (cursor remains where it was)
818 if ( nRangeCount
== 0 )
820 else if ( nRangeCount
== 1 )
821 pViewSh
->MarkRange( *rRanges
.GetObject(0) );
826 const ScRange
* pFirst
= rRanges
.GetObject(0);
827 if ( pFirst
&& !lcl_TabInRanges( pViewData
->GetTabNo(), rRanges
) )
828 pViewSh
->SetTabNo( pFirst
->aStart
.Tab() );
829 pViewSh
->DoneBlockMode();
830 pViewSh
->InitOwnBlockMode();
831 pViewData
->GetMarkData().MarkFromRangeList( rRanges
, TRUE
);
832 pViewSh
->MarkDataChanged();
833 pViewData
->GetDocShell()->PostPaintGridAll(); // Markierung (alt&neu)
836 pViewSh
->AlignToCursor( pFirst
->aStart
.Col(), pFirst
->aStart
.Row(),
838 pViewSh
->SetCursor( pFirst
->aStart
.Col(), pFirst
->aStart
.Row() );
841 //! Methode an der View, um RangeList zu selektieren
846 else if ( pShapeImp
|| xShapeColl
.is() ) // Drawing-Layer
848 ScDrawView
* pDrawView
= pViewSh
->GetScDrawView();
851 pDrawView
->ScEndTextEdit();
852 pDrawView
->UnmarkAll();
854 if (pShapeImp
) // einzelnes Shape
856 SdrObject
*pObj
= pShapeImp
->GetSdrObject();
859 lcl_ShowObject( *pViewSh
, *pDrawView
, pObj
);
860 SdrPageView
* pPV
= pDrawView
->GetSdrPageView();
861 if ( pPV
&& pObj
->GetPage() == pPV
->GetPage() )
863 pDrawView
->MarkObj( pObj
, pPV
);
868 else // Shape-Collection (xShapeColl ist nicht 0)
870 // Es wird auf die Tabelle des ersten Objekts umgeschaltet,
871 // und alle Objekte selektiert, die auf dieser Tabelle liegen
872 //! Exception, wenn Objekte auf verschiedenen Tabellen?
874 SdrPageView
* pPV
= NULL
;
875 long nCount
= xShapeColl
->getCount();
878 sal_Bool
bAllMarked(sal_True
);
879 for ( long i
= 0; i
< nCount
; i
++ )
881 uno::Reference
<drawing::XShape
> xShapeInt(xShapeColl
->getByIndex(i
), uno::UNO_QUERY
);
884 SvxShape
* pShape
= SvxShape::getImplementation( xShapeInt
);
887 SdrObject
*pObj
= pShape
->GetSdrObject();
890 if (!bDrawSelModeSet
&& (pObj
->GetLayer() == SC_LAYER_BACK
))
892 pViewSh
->SetDrawSelMode(sal_True
);
893 pViewSh
->UpdateLayerLocks();
894 bDrawSelModeSet
= sal_True
;
896 if (!pPV
) // erstes Objekt
898 lcl_ShowObject( *pViewSh
, *pDrawView
, pObj
);
899 pPV
= pDrawView
->GetSdrPageView();
901 if ( pPV
&& pObj
->GetPage() == pPV
->GetPage() )
903 if (pDrawView
->IsObjMarkable( pObj
, pPV
))
904 pDrawView
->MarkObj( pObj
, pPV
);
906 bAllMarked
= sal_False
;
916 bRet
= TRUE
; // empty XShapes (all shapes are deselected)
920 pViewSh
->SetDrawShell(TRUE
);
925 throw lang::IllegalArgumentException();
930 uno::Any SAL_CALL
ScTabViewObj::getSelection() throw(uno::RuntimeException
)
933 ScTabViewShell
* pViewSh
= GetViewShell();
934 ScCellRangesBase
* pObj
= NULL
;
937 // Ist auf dem Drawing-Layer etwas selektiert?
939 SdrView
* pDrawView
= pViewSh
->GetSdrView();
942 const SdrMarkList
& rMarkList
= pDrawView
->GetMarkedObjectList();
943 ULONG nMarkCount
= rMarkList
.GetMarkCount();
946 // ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw)
947 // Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein
949 SvxShapeCollection
* pShapes
= new SvxShapeCollection();
950 uno::Reference
<uno::XInterface
> xRet(static_cast<cppu::OWeakObject
*>(pShapes
));
952 for (ULONG i
=0; i
<nMarkCount
; i
++)
954 SdrObject
* pDrawObj
= rMarkList
.GetMark(i
)->GetMarkedSdrObj();
957 uno::Reference
<drawing::XShape
> xShape( pDrawObj
->getUnoShape(), uno::UNO_QUERY
);
959 pShapes
->add(xShape
);
962 return uno::makeAny(xRet
);
966 // sonst Tabellen-(Zellen-)Selektion
968 ScViewData
* pViewData
= pViewSh
->GetViewData();
969 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
971 const ScMarkData
& rMark
= pViewData
->GetMarkData();
972 SCTAB nTabs
= rMark
.GetSelectCount();
975 ScMarkType eMarkType
= pViewData
->GetSimpleArea(aRange
);
977 if (!bFilteredRangeSelection
)
979 if (eMarkType
== SC_MARK_SIMPLE_FILTERED
)
980 eMarkType
= SC_MARK_SIMPLE
;
981 else if (eMarkType
== SC_MARK_FILTERED
)
982 eMarkType
= SC_MARK_MULTI
;
985 if ( nTabs
== 1 && (eMarkType
== SC_MARK_SIMPLE
) )
987 if (aRange
.aStart
== aRange
.aEnd
)
988 pObj
= new ScCellObj( pDocSh
, aRange
.aStart
);
990 pObj
= new ScCellRangeObj( pDocSh
, aRange
);
992 else if ( nTabs
== 1 && (eMarkType
== SC_MARK_SIMPLE_FILTERED
) )
994 ScMarkData
aFilteredMark( rMark
);
995 ScViewUtil::UnmarkFiltered( aFilteredMark
, pDocSh
->GetDocument());
996 ScRangeList aRangeList
;
997 aFilteredMark
.FillRangeListWithMarks( &aRangeList
, FALSE
);
998 // Theoretically a selection may start and end on a filtered row.
999 switch (aRangeList
.Count())
1002 // No unfiltered row, we have to return some object, so
1003 // here is one with no ranges.
1004 pObj
= new ScCellRangesObj( pDocSh
, aRangeList
);
1008 const ScRange
& rRange
= *(aRangeList
.GetObject(0));
1009 if (rRange
.aStart
== rRange
.aEnd
)
1010 pObj
= new ScCellObj( pDocSh
, rRange
.aStart
);
1012 pObj
= new ScCellRangeObj( pDocSh
, rRange
);
1016 pObj
= new ScCellRangesObj( pDocSh
, aRangeList
);
1019 else // Mehrfachselektion
1021 ScRangeListRef xRanges
;
1022 pViewData
->GetMultiArea( xRanges
);
1024 // bei mehreren Tabellen Ranges kopieren
1025 //! sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren?
1027 rMark
.ExtendRangeListTables( xRanges
);
1029 pObj
= new ScCellRangesObj( pDocSh
, *xRanges
);
1032 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() )
1034 // remember if the selection was from the cursor position without anything selected
1035 // (used when rendering the selection)
1037 pObj
->SetCursorOnly( TRUE
);
1041 return uno::makeAny(uno::Reference
<uno::XInterface
>(static_cast<cppu::OWeakObject
*>(pObj
)));
1048 rtl::OUString
ScTabViewObj::getPrinterName(void) const
1051 ScTabViewShell
* pViewSh
= GetViewShell();
1054 SfxPrinter
* pPrinter
= pViewSh
->GetPrinter(TRUE
);
1056 return pPrinter
->GetName();
1059 DBG_ERROR("getPrinterName: keine View oder kein Printer");
1060 return rtl::OUString();
1063 void ScTabViewObj::setPrinterName(const rtl::OUString
& PrinterName
)
1066 // Drucker setzen - wie in SfxViewShell::ExecPrint_Impl
1068 ScTabViewShell
* pViewSh
= GetViewShell();
1071 SfxPrinter
* pPrinter
= pViewSh
->GetPrinter(TRUE
);
1074 String
aString(PrinterName
);
1075 SfxPrinter
* pNewPrinter
= new SfxPrinter( pPrinter
->GetOptions().Clone(), aString
);
1076 if (pNewPrinter
->IsKnown())
1077 pViewSh
->SetPrinter( pNewPrinter
, SFX_PRINTER_PRINTER
);
1084 XPropertySetRef
ScTabViewObj::createPrintOptions(void)
1087 return new ScPrintSettingsObj
; //! ScPrintSettingsObj implementieren!
1090 void ScTabViewObj::print(const XPropertySetRef
& xOptions
)
1093 ScTabViewShell
* pViewSh
= GetViewShell();
1096 //! xOptions auswerten (wie denn?)
1098 SfxRequest
aReq( SID_PRINTDOCDIRECT
, SFX_CALLMODE_SYNCHRON
, pViewSh
->GetPool() );
1099 pViewSh
->ExecuteSlot( aReq
);
1104 // XEnumerationAccess
1106 uno::Reference
<container::XEnumeration
> SAL_CALL
ScTabViewObj::createEnumeration()
1107 throw(uno::RuntimeException
)
1110 return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetViewPanesEnumeration")));
1115 sal_Int32 SAL_CALL
ScTabViewObj::getCount() throw(uno::RuntimeException
)
1118 ScTabViewShell
* pViewSh
= GetViewShell();
1123 ScViewData
* pViewData
= pViewSh
->GetViewData();
1124 if ( pViewData
->GetHSplitMode() != SC_SPLIT_NONE
)
1126 if ( pViewData
->GetVSplitMode() != SC_SPLIT_NONE
)
1132 uno::Any SAL_CALL
ScTabViewObj::getByIndex( sal_Int32 nIndex
)
1133 throw(lang::IndexOutOfBoundsException
,
1134 lang::WrappedTargetException
, uno::RuntimeException
)
1137 uno::Reference
<sheet::XViewPane
> xPane(GetObjectByIndex_Impl((USHORT
)nIndex
));
1139 return uno::makeAny(xPane
);
1141 throw lang::IndexOutOfBoundsException();
1142 // return uno::Any();
1145 uno::Type SAL_CALL
ScTabViewObj::getElementType() throw(uno::RuntimeException
)
1148 return getCppuType((uno::Reference
<sheet::XViewPane
>*)0);
1151 sal_Bool SAL_CALL
ScTabViewObj::hasElements() throw(uno::RuntimeException
)
1154 return ( getCount() != 0 );
1159 ScViewPaneObj
* ScTabViewObj::GetObjectByIndex_Impl(USHORT nIndex
) const
1161 static ScSplitPos ePosHV
[4] =
1162 { SC_SPLIT_TOPLEFT
, SC_SPLIT_BOTTOMLEFT
, SC_SPLIT_TOPRIGHT
, SC_SPLIT_BOTTOMRIGHT
};
1164 ScTabViewShell
* pViewSh
= GetViewShell();
1167 ScSplitPos eWhich
= SC_SPLIT_BOTTOMLEFT
; // default Position
1168 BOOL bError
= FALSE
;
1169 ScViewData
* pViewData
= pViewSh
->GetViewData();
1170 BOOL bHor
= ( pViewData
->GetHSplitMode() != SC_SPLIT_NONE
);
1171 BOOL bVer
= ( pViewData
->GetVSplitMode() != SC_SPLIT_NONE
);
1174 // links oben, links unten, rechts oben, rechts unten - wie in Excel
1176 eWhich
= ePosHV
[nIndex
];
1184 else if ( nIndex
== 1 )
1185 eWhich
= SC_SPLIT_BOTTOMRIGHT
;
1186 // sonst SC_SPLIT_BOTTOMLEFT
1192 else if ( nIndex
== 0 )
1193 eWhich
= SC_SPLIT_TOPLEFT
;
1194 // sonst SC_SPLIT_BOTTOMLEFT
1196 else if ( nIndex
> 0 )
1197 bError
= TRUE
; // nicht geteilt: nur 0 gueltig
1200 return new ScViewPaneObj( pViewSh
, sal::static_int_cast
<USHORT
>(eWhich
) );
1206 uno::Reference
<sheet::XSpreadsheet
> SAL_CALL
ScTabViewObj::getActiveSheet()
1207 throw(uno::RuntimeException
)
1210 ScTabViewShell
* pViewSh
= GetViewShell();
1213 ScViewData
* pData
= pViewSh
->GetViewData();
1214 SCTAB nTab
= pData
->GetTabNo();
1215 return new ScTableSheetObj( pData
->GetDocShell(), nTab
);
1220 void SAL_CALL
ScTabViewObj::setActiveSheet( const uno::Reference
<sheet::XSpreadsheet
>& xActiveSheet
)
1221 throw(uno::RuntimeException
)
1225 ScTabViewShell
* pViewSh
= GetViewShell();
1226 if ( pViewSh
&& xActiveSheet
.is() )
1228 // XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein
1230 ScCellRangesBase
* pRangesImp
= ScCellRangesBase::getImplementation( xActiveSheet
);
1231 if ( pRangesImp
&& pViewSh
->GetViewData()->GetDocShell() == pRangesImp
->GetDocShell() )
1233 const ScRangeList
& rRanges
= pRangesImp
->GetRangeList();
1234 if ( rRanges
.Count() == 1 )
1236 SCTAB nNewTab
= rRanges
.GetObject(0)->aStart
.Tab();
1237 if ( pViewSh
->GetViewData()->GetDocument()->HasTable(nNewTab
) )
1238 pViewSh
->SetTabNo( nNewTab
);
1244 uno::Reference
< uno::XInterface
> ScTabViewObj::GetClickedObject(const Point
& rPoint
) const
1246 uno::Reference
< uno::XInterface
> xTarget
;
1251 ScViewData
* pData
= GetViewShell()->GetViewData();
1252 ScSplitPos eSplitMode
= pData
->GetActivePart();
1253 SCTAB
nTab(pData
->GetTabNo());
1254 pData
->GetPosFromPixel( rPoint
.X(), rPoint
.Y(), eSplitMode
, nX
, nY
);
1256 ScAddress
aCellPos (nX
, nY
, nTab
);
1257 ScCellObj
* pCellObj
= new ScCellObj(pData
->GetDocShell(), aCellPos
);
1259 xTarget
.set(uno::Reference
<table::XCell
>(pCellObj
), uno::UNO_QUERY
);
1261 ScDocument
* pDoc
= pData
->GetDocument();
1262 if (pDoc
&& pDoc
->GetDrawLayer())
1264 SdrPage
* pDrawPage
= NULL
;
1265 ScDrawLayer
* pDrawLayer
= pDoc
->GetDrawLayer();
1266 if (pDrawLayer
->HasObjects() && (pDrawLayer
->GetPageCount() > nTab
))
1267 pDrawPage
= pDrawLayer
->GetPage(static_cast<sal_uInt16
>(nTab
));
1269 SdrView
* pDrawView
= GetViewShell()->GetSdrView();
1271 if (pDrawPage
&& pDrawView
)
1273 Window
* pActiveWin
= pData
->GetActiveWin();
1274 Point aPos
= pActiveWin
->PixelToLogic(rPoint
);
1276 USHORT nHitLog
= (USHORT
) pActiveWin
->PixelToLogic(
1277 Size(pDrawView
->GetHitTolerancePixel(),0)).Width();
1279 sal_uInt32
nCount(pDrawPage
->GetObjCount());
1280 sal_Bool
bFound(sal_False
);
1282 while (i
< nCount
&& !bFound
)
1284 SdrObject
* pObj
= pDrawPage
->GetObj(i
);
1285 if (pObj
&& pObj
->IsHit(aPos
, nHitLog
))
1287 xTarget
.set(pObj
->getUnoShape(), uno::UNO_QUERY
);
1298 sal_Bool
ScTabViewObj::MousePressed( const awt::MouseEvent
& e
)
1299 throw (::uno::RuntimeException
)
1301 sal_Bool
bReturn(sal_False
);
1303 if (aMouseClickHandlers
.Count())
1305 uno::Reference
< uno::XInterface
> xTarget
= GetClickedObject(Point(e
.X
, e
.Y
));
1309 awt::EnhancedMouseEvent aMouseEvent
;
1311 aMouseEvent
.Buttons
= e
.Buttons
;
1312 aMouseEvent
.X
= e
.X
;
1313 aMouseEvent
.Y
= e
.Y
;
1314 aMouseEvent
.ClickCount
= e
.ClickCount
;
1315 aMouseEvent
.PopupTrigger
= e
.PopupTrigger
;
1316 aMouseEvent
.Target
= xTarget
;
1318 for ( USHORT n
=0; n
<aMouseClickHandlers
.Count(); n
++ )
1322 if (!(*aMouseClickHandlers
[n
])->mousePressed( aMouseEvent
))
1325 catch ( uno::Exception
& )
1327 aMouseClickHandlers
.DeleteAndDestroy(n
);
1328 --n
; // because it will be increased again in the loop
1336 sal_Bool
ScTabViewObj::MouseReleased( const awt::MouseEvent
& e
)
1337 throw (uno::RuntimeException
)
1339 sal_Bool
bReturn(sal_False
);
1341 if (aMouseClickHandlers
.Count())
1343 uno::Reference
< uno::XInterface
> xTarget
= GetClickedObject(Point(e
.X
, e
.Y
));
1347 awt::EnhancedMouseEvent aMouseEvent
;
1349 aMouseEvent
.Buttons
= e
.Buttons
;
1350 aMouseEvent
.X
= e
.X
;
1351 aMouseEvent
.Y
= e
.Y
;
1352 aMouseEvent
.ClickCount
= e
.ClickCount
;
1353 aMouseEvent
.PopupTrigger
= e
.PopupTrigger
;
1354 aMouseEvent
.Target
= xTarget
;
1356 for ( USHORT n
=0; n
<aMouseClickHandlers
.Count(); n
++ )
1360 if (!(*aMouseClickHandlers
[n
])->mouseReleased( aMouseEvent
))
1363 catch ( uno::Exception
& )
1365 aMouseClickHandlers
.DeleteAndDestroy(n
);
1366 --n
; // because it will be increased again in the loop
1374 // XEnhancedMouseClickBroadcaster
1376 void ScTabViewObj::StartMouseListening()
1380 void ScTabViewObj::EndMouseListening()
1382 USHORT
nCount(aMouseClickHandlers
.Count());
1383 lang::EventObject aEvent
;
1384 aEvent
.Source
= (cppu::OWeakObject
*)this;
1385 for ( USHORT n
=0; n
<nCount
; n
++ )
1389 (*aMouseClickHandlers
[n
])->disposing(aEvent
);
1391 catch ( uno::Exception
& )
1395 aMouseClickHandlers
.DeleteAndDestroy(0, nCount
);
1398 void ScTabViewObj::StartActivationListening()
1402 void ScTabViewObj::EndActivationListening()
1404 USHORT nCount
= aActivationListeners
.Count();
1405 lang::EventObject aEvent
;
1406 aEvent
.Source
= (cppu::OWeakObject
*)this;
1407 for ( USHORT n
=0; n
<nCount
; n
++ )
1411 (*aActivationListeners
[n
])->disposing(aEvent
);
1413 catch ( uno::Exception
& )
1417 aActivationListeners
.DeleteAndDestroy(0, nCount
);
1420 void SAL_CALL
ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference
< awt::XEnhancedMouseClickHandler
>& aListener
)
1421 throw (uno::RuntimeException
)
1427 USHORT nCount
= aMouseClickHandlers
.Count();
1428 uno::Reference
<awt::XEnhancedMouseClickHandler
> *pObj
=
1429 new uno::Reference
<awt::XEnhancedMouseClickHandler
>( aListener
);
1430 aMouseClickHandlers
.Insert( pObj
, nCount
);
1432 if (aMouseClickHandlers
.Count() == 1 && nCount
== 0) // only if a listener added
1433 StartMouseListening();
1437 void SAL_CALL
ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference
< awt::XEnhancedMouseClickHandler
>& aListener
)
1438 throw (uno::RuntimeException
)
1441 USHORT nCount
= aMouseClickHandlers
.Count();
1442 for ( USHORT n
=nCount
; n
--; )
1444 uno::Reference
<awt::XEnhancedMouseClickHandler
> *pObj
= aMouseClickHandlers
[n
];
1445 if ( *pObj
== aListener
)
1446 aMouseClickHandlers
.DeleteAndDestroy( n
);
1448 if ((aMouseClickHandlers
.Count() == 0) && (nCount
> 0)) // only if last listener removed
1449 EndMouseListening();
1452 // XActivationBroadcaster
1454 void SAL_CALL
ScTabViewObj::addActivationEventListener( const uno::Reference
< sheet::XActivationEventListener
>& aListener
)
1455 throw (uno::RuntimeException
)
1461 USHORT nCount
= aActivationListeners
.Count();
1462 uno::Reference
<sheet::XActivationEventListener
> *pObj
=
1463 new uno::Reference
<sheet::XActivationEventListener
>( aListener
);
1464 aActivationListeners
.Insert( pObj
, nCount
);
1466 if (aActivationListeners
.Count() == 1 && nCount
== 0) // only if a listener added
1467 StartActivationListening();
1471 void SAL_CALL
ScTabViewObj::removeActivationEventListener( const uno::Reference
< sheet::XActivationEventListener
>& aListener
)
1472 throw (uno::RuntimeException
)
1475 USHORT nCount
= aActivationListeners
.Count();
1476 for ( USHORT n
=nCount
; n
--; )
1478 uno::Reference
<sheet::XActivationEventListener
> *pObj
= aActivationListeners
[n
];
1479 if ( *pObj
== aListener
)
1480 aActivationListeners
.DeleteAndDestroy( n
);
1482 if ((aActivationListeners
.Count() == 0) && (nCount
> 0)) // only if last listener removed
1483 EndActivationListening();
1486 // PageBreakMode / Zoom sind Properties
1490 BOOL
ScTabViewObj::getPagebreakMode(void) const
1493 ScTabViewShell
* pViewSh
= GetViewShell();
1495 return pViewSh
->GetViewData()->IsPagebreakMode();
1499 void ScTabViewObj::setPagebreakMode(BOOL PagebreakMode
)
1502 ScTabViewShell
* pViewSh
= GetViewShell();
1504 pViewSh
->SetPagebreakMode(PagebreakMode
);
1509 INT16
ScTabViewObj::GetZoom(void) const
1511 ScTabViewShell
* pViewSh
= GetViewShell();
1514 const Fraction
& rZoomY
= pViewSh
->GetViewData()->GetZoomY(); // Y wird angezeigt
1515 return (INT16
)(( rZoomY
.GetNumerator() * 100 ) / rZoomY
.GetDenominator());
1520 void ScTabViewObj::SetZoom(INT16 nZoom
)
1522 ScTabViewShell
* pViewSh
= GetViewShell();
1525 if ( nZoom
!= GetZoom() && nZoom
!= 0 )
1527 if (!pViewSh
->GetViewData()->IsPagebreakMode())
1529 ScModule
* pScMod
= SC_MOD();
1530 ScAppOptions
aNewOpt(pScMod
->GetAppOptions());
1531 aNewOpt
.SetZoom( nZoom
);
1532 aNewOpt
.SetZoomType( pViewSh
->GetViewData()->GetView()->GetZoomType() );
1533 pScMod
->SetAppOptions( aNewOpt
);
1536 Fraction
aFract( nZoom
, 100 );
1537 pViewSh
->SetZoom( aFract
, aFract
, TRUE
);
1538 pViewSh
->PaintGrid();
1539 pViewSh
->PaintTop();
1540 pViewSh
->PaintLeft();
1541 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM
);
1542 pViewSh
->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER
);
1546 INT16
ScTabViewObj::GetZoomType(void) const
1548 INT16 aZoomType
= view::DocumentZoomType::OPTIMAL
;
1549 ScTabViewShell
* pViewSh
= GetViewShell();
1552 SvxZoomType eZoomType
= pViewSh
->GetViewData()->GetView()->GetZoomType();
1555 case SVX_ZOOM_PERCENT
:
1556 aZoomType
= view::DocumentZoomType::BY_VALUE
;
1558 case SVX_ZOOM_OPTIMAL
:
1559 aZoomType
= view::DocumentZoomType::OPTIMAL
;
1561 case SVX_ZOOM_WHOLEPAGE
:
1562 aZoomType
= view::DocumentZoomType::ENTIRE_PAGE
;
1564 case SVX_ZOOM_PAGEWIDTH
:
1565 aZoomType
= view::DocumentZoomType::PAGE_WIDTH
;
1567 case SVX_ZOOM_PAGEWIDTH_NOBORDER
:
1568 aZoomType
= view::DocumentZoomType::PAGE_WIDTH_EXACT
;
1575 void ScTabViewObj::SetZoomType(INT16 aZoomType
)
1577 ScTabViewShell
* pViewSh
= GetViewShell();
1580 ScDBFunc
* pView
= pViewSh
->GetViewData()->GetView();
1583 SvxZoomType eZoomType
;
1586 case view::DocumentZoomType::BY_VALUE
:
1587 eZoomType
= SVX_ZOOM_PERCENT
;
1589 case view::DocumentZoomType::OPTIMAL
:
1590 eZoomType
= SVX_ZOOM_OPTIMAL
;
1592 case view::DocumentZoomType::ENTIRE_PAGE
:
1593 eZoomType
= SVX_ZOOM_WHOLEPAGE
;
1595 case view::DocumentZoomType::PAGE_WIDTH
:
1596 eZoomType
= SVX_ZOOM_PAGEWIDTH
;
1598 case view::DocumentZoomType::PAGE_WIDTH_EXACT
:
1599 eZoomType
= SVX_ZOOM_PAGEWIDTH_NOBORDER
;
1602 eZoomType
= SVX_ZOOM_OPTIMAL
;
1604 sal_Int16
nZoom(GetZoom());
1605 sal_Int16
nOldZoom(nZoom
);
1606 if ( eZoomType
== SVX_ZOOM_PERCENT
)
1608 if ( nZoom
< MINZOOM
) nZoom
= MINZOOM
;
1609 if ( nZoom
> MAXZOOM
) nZoom
= MAXZOOM
;
1612 nZoom
= pView
->CalcZoom( eZoomType
, nOldZoom
);
1614 switch ( eZoomType
)
1616 case SVX_ZOOM_WHOLEPAGE
:
1617 case SVX_ZOOM_PAGEWIDTH
:
1618 pView
->SetZoomType( eZoomType
, TRUE
);
1622 pView
->SetZoomType( SVX_ZOOM_PERCENT
, TRUE
);
1629 sal_Bool SAL_CALL
ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException
)
1632 // wie Menue-Slot SID_WINDOW_SPLIT
1634 ScTabViewShell
* pViewSh
= GetViewShell();
1637 ScViewData
* pViewData
= pViewSh
->GetViewData();
1638 return ( pViewData
->GetHSplitMode() == SC_SPLIT_NORMAL
||
1639 pViewData
->GetVSplitMode() == SC_SPLIT_NORMAL
);
1645 sal_Bool SAL_CALL
ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException
)
1648 // wie Menue-Slot SID_WINDOW_FIX
1650 ScTabViewShell
* pViewSh
= GetViewShell();
1653 ScViewData
* pViewData
= pViewSh
->GetViewData();
1654 return ( pViewData
->GetHSplitMode() == SC_SPLIT_FIX
||
1655 pViewData
->GetVSplitMode() == SC_SPLIT_FIX
);
1661 sal_Int32 SAL_CALL
ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException
)
1664 ScTabViewShell
* pViewSh
= GetViewShell();
1667 ScViewData
* pViewData
= pViewSh
->GetViewData();
1668 if ( pViewData
->GetHSplitMode() != SC_SPLIT_NONE
)
1669 return pViewData
->GetHSplitPos();
1674 sal_Int32 SAL_CALL
ScTabViewObj::getSplitVertical() throw(uno::RuntimeException
)
1677 ScTabViewShell
* pViewSh
= GetViewShell();
1680 ScViewData
* pViewData
= pViewSh
->GetViewData();
1681 if ( pViewData
->GetVSplitMode() != SC_SPLIT_NONE
)
1682 return pViewData
->GetVSplitPos();
1687 sal_Int32 SAL_CALL
ScTabViewObj::getSplitColumn() throw(uno::RuntimeException
)
1690 ScTabViewShell
* pViewSh
= GetViewShell();
1693 ScViewData
* pViewData
= pViewSh
->GetViewData();
1694 if ( pViewData
->GetHSplitMode() != SC_SPLIT_NONE
)
1696 long nSplit
= pViewData
->GetHSplitPos();
1698 ScSplitPos ePos
= SC_SPLIT_BOTTOMLEFT
;
1699 if ( pViewData
->GetVSplitMode() != SC_SPLIT_NONE
)
1700 ePos
= SC_SPLIT_TOPLEFT
;
1704 pViewData
->GetPosFromPixel( nSplit
, 0, ePos
, nCol
, nRow
, FALSE
);
1712 sal_Int32 SAL_CALL
ScTabViewObj::getSplitRow() throw(uno::RuntimeException
)
1715 ScTabViewShell
* pViewSh
= GetViewShell();
1718 ScViewData
* pViewData
= pViewSh
->GetViewData();
1719 if ( pViewData
->GetVSplitMode() != SC_SPLIT_NONE
)
1721 long nSplit
= pViewData
->GetVSplitPos();
1723 ScSplitPos ePos
= SC_SPLIT_TOPLEFT
; // es ist vertikal geteilt
1726 pViewData
->GetPosFromPixel( 0, nSplit
, ePos
, nCol
, nRow
, FALSE
);
1734 void SAL_CALL
ScTabViewObj::splitAtPosition( sal_Int32 nPixelX
, sal_Int32 nPixelY
)
1735 throw(uno::RuntimeException
)
1738 ScTabViewShell
* pViewSh
= GetViewShell();
1741 pViewSh
->SplitAtPixel( Point( nPixelX
, nPixelY
), TRUE
, TRUE
);
1742 pViewSh
->FreezeSplitters( FALSE
);
1743 pViewSh
->InvalidateSplit();
1747 void SAL_CALL
ScTabViewObj::freezeAtPosition( sal_Int32 nColumns
, sal_Int32 nRows
)
1748 throw(uno::RuntimeException
)
1751 ScTabViewShell
* pViewSh
= GetViewShell();
1754 // erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae.
1756 pViewSh
->RemoveSplit();
1759 Window
* pWin
= pViewSh
->GetWindowByPos( SC_SPLIT_BOTTOMLEFT
);
1761 aWinStart
= pWin
->GetPosPixel();
1763 ScViewData
* pViewData
= pViewSh
->GetViewData();
1764 Point
aSplit(pViewData
->GetScrPos( (SCCOL
)nColumns
, (SCROW
)nRows
, SC_SPLIT_BOTTOMLEFT
, TRUE
));
1765 aSplit
+= aWinStart
;
1767 pViewSh
->SplitAtPixel( aSplit
, TRUE
, TRUE
);
1768 pViewSh
->FreezeSplitters( TRUE
);
1769 pViewSh
->InvalidateSplit();
1773 void SAL_CALL
ScTabViewObj::addSelectionChangeListener(
1774 const uno::Reference
<view::XSelectionChangeListener
>& xListener
)
1775 throw(uno::RuntimeException
)
1778 uno::Reference
<view::XSelectionChangeListener
>* pObj
=
1779 new uno::Reference
<view::XSelectionChangeListener
>( xListener
);
1780 aSelectionListeners
.Insert( pObj
, aSelectionListeners
.Count() );
1783 void SAL_CALL
ScTabViewObj::removeSelectionChangeListener(
1784 const uno::Reference
< view::XSelectionChangeListener
>& xListener
)
1785 throw(uno::RuntimeException
)
1788 USHORT nCount
= aSelectionListeners
.Count();
1789 for ( USHORT n
=nCount
; n
--; )
1791 uno::Reference
<view::XSelectionChangeListener
> *pObj
= aSelectionListeners
[n
];
1792 if ( *pObj
== xListener
) //! wozu der Mumpitz mit queryInterface?
1794 aSelectionListeners
.DeleteAndDestroy( n
);
1800 void ScTabViewObj::SelectionChanged()
1802 lang::EventObject aEvent
;
1803 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
1804 for ( USHORT n
=0; n
<aSelectionListeners
.Count(); n
++ )
1805 (*aSelectionListeners
[n
])->selectionChanged( aEvent
);
1809 // XPropertySet (View-Optionen)
1810 //! auch an der Applikation anbieten?
1812 uno::Reference
<beans::XPropertySetInfo
> SAL_CALL
ScTabViewObj::getPropertySetInfo()
1813 throw(uno::RuntimeException
)
1816 static uno::Reference
<beans::XPropertySetInfo
> aRef(
1817 new SfxItemPropertySetInfo( aPropSet
.getPropertyMap() ));
1821 void SAL_CALL
ScTabViewObj::setPropertyValue(
1822 const rtl::OUString
& aPropertyName
, const uno::Any
& aValue
)
1823 throw(beans::UnknownPropertyException
, beans::PropertyVetoException
,
1824 lang::IllegalArgumentException
, lang::WrappedTargetException
,
1825 uno::RuntimeException
)
1828 String
aString(aPropertyName
);
1830 if ( aString
.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION
) )
1832 bFilteredRangeSelection
= ScUnoHelpFunctions::GetBoolFromAny(aValue
);
1836 ScTabViewShell
* pViewSh
= GetViewShell();
1839 ScViewData
* pViewData
= pViewSh
->GetViewData();
1840 const ScViewOptions
& rOldOpt
= pViewSh
->GetViewData()->GetOptions();
1841 ScViewOptions
aNewOpt(rOldOpt
);
1843 if ( aString
.EqualsAscii( SC_UNO_COLROWHDR
) || aString
.EqualsAscii( OLD_UNO_COLROWHDR
) )
1844 aNewOpt
.SetOption( VOPT_HEADER
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1845 else if ( aString
.EqualsAscii( SC_UNO_HORSCROLL
) || aString
.EqualsAscii( OLD_UNO_HORSCROLL
) )
1846 aNewOpt
.SetOption( VOPT_HSCROLL
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1847 else if ( aString
.EqualsAscii( SC_UNO_OUTLSYMB
) || aString
.EqualsAscii( OLD_UNO_OUTLSYMB
) )
1848 aNewOpt
.SetOption( VOPT_OUTLINER
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1849 else if ( aString
.EqualsAscii( SC_UNO_SHEETTABS
) || aString
.EqualsAscii( OLD_UNO_SHEETTABS
) )
1850 aNewOpt
.SetOption( VOPT_TABCONTROLS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1851 else if ( aString
.EqualsAscii( SC_UNO_SHOWANCHOR
) )
1852 aNewOpt
.SetOption( VOPT_ANCHOR
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1853 else if ( aString
.EqualsAscii( SC_UNO_SHOWFORM
) )
1854 aNewOpt
.SetOption( VOPT_FORMULAS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1855 else if ( aString
.EqualsAscii( SC_UNO_SHOWGRID
) )
1856 aNewOpt
.SetOption( VOPT_GRID
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1857 else if ( aString
.EqualsAscii( SC_UNO_SHOWHELP
) )
1858 aNewOpt
.SetOption( VOPT_HELPLINES
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1859 else if ( aString
.EqualsAscii( SC_UNO_SHOWNOTES
) )
1860 aNewOpt
.SetOption( VOPT_NOTES
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1861 else if ( aString
.EqualsAscii( SC_UNO_SHOWPAGEBR
) )
1862 aNewOpt
.SetOption( VOPT_PAGEBREAKS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1863 else if ( aString
.EqualsAscii( SC_UNO_SHOWZERO
) )
1864 aNewOpt
.SetOption( VOPT_NULLVALS
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1865 else if ( aString
.EqualsAscii( SC_UNO_SHOWSOLID
) )
1866 aNewOpt
.SetOption( VOPT_SOLIDHANDLES
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1867 else if ( aString
.EqualsAscii( SC_UNO_VALUEHIGH
) || aString
.EqualsAscii( OLD_UNO_VALUEHIGH
) )
1868 aNewOpt
.SetOption( VOPT_SYNTAX
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1869 else if ( aString
.EqualsAscii( SC_UNO_VERTSCROLL
) || aString
.EqualsAscii( OLD_UNO_VERTSCROLL
) )
1870 aNewOpt
.SetOption( VOPT_VSCROLL
, ScUnoHelpFunctions::GetBoolFromAny( aValue
) );
1871 else if ( aString
.EqualsAscii( SC_UNO_SHOWOBJ
) )
1873 sal_Int16 nIntVal
= 0;
1874 if ( aValue
>>= nIntVal
)
1876 //#i80528# adapt to new range eventually
1877 if((sal_Int16
)VOBJ_MODE_HIDE
< nIntVal
) nIntVal
= (sal_Int16
)VOBJ_MODE_SHOW
;
1879 aNewOpt
.SetObjMode( VOBJ_TYPE_OLE
, (ScVObjMode
)nIntVal
);
1882 else if ( aString
.EqualsAscii( SC_UNO_SHOWCHARTS
) )
1884 sal_Int16 nIntVal
= 0;
1885 if ( aValue
>>= nIntVal
)
1887 //#i80528# adapt to new range eventually
1888 if((sal_Int16
)VOBJ_MODE_HIDE
< nIntVal
) nIntVal
= (sal_Int16
)VOBJ_MODE_SHOW
;
1890 aNewOpt
.SetObjMode( VOBJ_TYPE_CHART
, (ScVObjMode
)nIntVal
);
1893 else if ( aString
.EqualsAscii( SC_UNO_SHOWDRAW
) )
1895 sal_Int16 nIntVal
= 0;
1896 if ( aValue
>>= nIntVal
)
1898 //#i80528# adapt to new range eventually
1899 if((sal_Int16
)VOBJ_MODE_HIDE
< nIntVal
) nIntVal
= (sal_Int16
)VOBJ_MODE_SHOW
;
1901 aNewOpt
.SetObjMode( VOBJ_TYPE_DRAW
, (ScVObjMode
)nIntVal
);
1904 else if ( aString
.EqualsAscii( SC_UNO_GRIDCOLOR
) )
1906 sal_Int32 nIntVal
= 0;
1907 if ( aValue
>>= nIntVal
)
1908 aNewOpt
.SetGridColor( nIntVal
, String() );
1910 else if ( aString
.EqualsAscii( SC_UNO_ZOOMTYPE
) )
1912 sal_Int16 nIntVal
= 0;
1913 if ( aValue
>>= nIntVal
)
1914 SetZoomType(nIntVal
);
1916 else if ( aString
.EqualsAscii( SC_UNO_ZOOMVALUE
) )
1918 sal_Int16 nIntVal
= 0;
1919 if ( aValue
>>= nIntVal
)
1923 // Optionen werden an der View und am Dokument (fuer neue Views) gesetzt,
1924 // damit sie beim Speichern erhalten bleiben.
1925 //! An der App (Module) braeuchte man noch eine Extra-Moeglichkeit,
1926 //! das einzustellen (fuer neue Dokumente)
1928 if ( aNewOpt
!= rOldOpt
)
1930 pViewData
->SetOptions( aNewOpt
);
1931 pViewData
->GetDocument()->SetViewOptions( aNewOpt
);
1932 pViewData
->GetDocShell()->SetDocumentModified(); //! wirklich?
1934 pViewSh
->UpdateFixPos();
1935 pViewSh
->PaintGrid();
1936 pViewSh
->PaintTop();
1937 pViewSh
->PaintLeft();
1938 pViewSh
->PaintExtras();
1939 pViewSh
->InvalidateBorder();
1941 SfxBindings
& rBindings
= pViewSh
->GetViewFrame()->GetBindings();
1942 rBindings
.Invalidate( FID_TOGGLEHEADERS
); // -> Checks im Menue
1943 rBindings
.Invalidate( FID_TOGGLESYNTAX
);
1948 uno::Any SAL_CALL
ScTabViewObj::getPropertyValue( const rtl::OUString
& aPropertyName
)
1949 throw(beans::UnknownPropertyException
, lang::WrappedTargetException
,
1950 uno::RuntimeException
)
1953 String
aString(aPropertyName
);
1956 if ( aString
.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION
) )
1958 ScUnoHelpFunctions::SetBoolInAny(aRet
, bFilteredRangeSelection
);
1962 ScTabViewShell
* pViewSh
= GetViewShell();
1965 const ScViewOptions
& rOpt
= pViewSh
->GetViewData()->GetOptions();
1967 if ( aString
.EqualsAscii( SC_UNO_COLROWHDR
) || aString
.EqualsAscii( OLD_UNO_COLROWHDR
) )
1968 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_HEADER
) );
1969 else if ( aString
.EqualsAscii( SC_UNO_HORSCROLL
) || aString
.EqualsAscii( OLD_UNO_HORSCROLL
) )
1970 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_HSCROLL
) );
1971 else if ( aString
.EqualsAscii( SC_UNO_OUTLSYMB
) || aString
.EqualsAscii( OLD_UNO_OUTLSYMB
) )
1972 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_OUTLINER
) );
1973 else if ( aString
.EqualsAscii( SC_UNO_SHEETTABS
) || aString
.EqualsAscii( OLD_UNO_SHEETTABS
) )
1974 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_TABCONTROLS
) );
1975 else if ( aString
.EqualsAscii( SC_UNO_SHOWANCHOR
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_ANCHOR
) );
1976 else if ( aString
.EqualsAscii( SC_UNO_SHOWFORM
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_FORMULAS
) );
1977 else if ( aString
.EqualsAscii( SC_UNO_SHOWGRID
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_GRID
) );
1978 else if ( aString
.EqualsAscii( SC_UNO_SHOWHELP
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_HELPLINES
) );
1979 else if ( aString
.EqualsAscii( SC_UNO_SHOWNOTES
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_NOTES
) );
1980 else if ( aString
.EqualsAscii( SC_UNO_SHOWPAGEBR
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_PAGEBREAKS
) );
1981 else if ( aString
.EqualsAscii( SC_UNO_SHOWZERO
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_NULLVALS
) );
1982 else if ( aString
.EqualsAscii( SC_UNO_SHOWSOLID
) ) ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_SOLIDHANDLES
) );
1983 else if ( aString
.EqualsAscii( SC_UNO_VALUEHIGH
) || aString
.EqualsAscii( OLD_UNO_VALUEHIGH
) )
1984 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_SYNTAX
) );
1985 else if ( aString
.EqualsAscii( SC_UNO_VERTSCROLL
) || aString
.EqualsAscii( OLD_UNO_VERTSCROLL
) )
1986 ScUnoHelpFunctions::SetBoolInAny( aRet
, rOpt
.GetOption( VOPT_VSCROLL
) );
1987 else if ( aString
.EqualsAscii( SC_UNO_SHOWOBJ
) ) aRet
<<= (sal_Int16
)( rOpt
.GetObjMode( VOBJ_TYPE_OLE
) );
1988 else if ( aString
.EqualsAscii( SC_UNO_SHOWCHARTS
) ) aRet
<<= (sal_Int16
)( rOpt
.GetObjMode( VOBJ_TYPE_CHART
) );
1989 else if ( aString
.EqualsAscii( SC_UNO_SHOWDRAW
) ) aRet
<<= (sal_Int16
)( rOpt
.GetObjMode( VOBJ_TYPE_DRAW
) );
1990 else if ( aString
.EqualsAscii( SC_UNO_GRIDCOLOR
) ) aRet
<<= (sal_Int32
)( rOpt
.GetGridColor().GetColor() );
1991 else if ( aString
.EqualsAscii( SC_UNO_VISAREA
) ) aRet
<<= GetVisArea();
1992 else if ( aString
.EqualsAscii( SC_UNO_ZOOMTYPE
) ) aRet
<<= GetZoomType();
1993 else if ( aString
.EqualsAscii( SC_UNO_ZOOMVALUE
) ) aRet
<<= GetZoom();
1999 void SAL_CALL
ScTabViewObj::addPropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
2000 const uno::Reference
<beans::XPropertyChangeListener
>& xListener
)
2001 throw(beans::UnknownPropertyException
,
2002 lang::WrappedTargetException
,
2003 uno::RuntimeException
)
2006 uno::Reference
<beans::XPropertyChangeListener
>* pObj
=
2007 new uno::Reference
<beans::XPropertyChangeListener
>( xListener
);
2008 aPropertyChgListeners
.Insert( pObj
, aPropertyChgListeners
.Count() );
2011 void SAL_CALL
ScTabViewObj::removePropertyChangeListener( const ::rtl::OUString
& /* aPropertyName */,
2012 const uno::Reference
<beans::XPropertyChangeListener
>& xListener
)
2013 throw(beans::UnknownPropertyException
,
2014 lang::WrappedTargetException
,
2015 uno::RuntimeException
)
2018 USHORT nCount
= aPropertyChgListeners
.Count();
2019 for ( USHORT n
=nCount
; n
--; )
2021 uno::Reference
<beans::XPropertyChangeListener
> *pObj
= aPropertyChgListeners
[n
];
2022 if ( *pObj
== xListener
) //! wozu der Mumpitz mit queryInterface?
2024 aPropertyChgListeners
.DeleteAndDestroy( n
);
2030 void SAL_CALL
ScTabViewObj::addVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
2031 const uno::Reference
<beans::XVetoableChangeListener
>& /* aListener */ )
2032 throw(beans::UnknownPropertyException
,
2033 lang::WrappedTargetException
,
2034 uno::RuntimeException
)
2038 void SAL_CALL
ScTabViewObj::removeVetoableChangeListener( const ::rtl::OUString
& /* PropertyName */,
2039 const uno::Reference
<beans::XVetoableChangeListener
>& /* aListener */ )
2040 throw(beans::UnknownPropertyException
,
2041 lang::WrappedTargetException
,
2042 uno::RuntimeException
)
2046 void ScTabViewObj::VisAreaChanged()
2048 beans::PropertyChangeEvent aEvent
;
2049 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
2050 for ( USHORT n
=0; n
<aPropertyChgListeners
.Count(); n
++ )
2051 (*aPropertyChgListeners
[n
])->propertyChange( aEvent
);
2056 void SAL_CALL
ScTabViewObj::startRangeSelection(
2057 const uno::Sequence
<beans::PropertyValue
>& aArguments
)
2058 throw(uno::RuntimeException
)
2061 ScTabViewShell
* pViewSh
= GetViewShell();
2064 String aInitVal
, aTitle
;
2065 BOOL bCloseOnButtonUp
= FALSE
;
2066 BOOL bSingleCell
= FALSE
;
2067 BOOL bMultiSelection
= FALSE
;
2069 rtl::OUString aStrVal
;
2070 const beans::PropertyValue
* pPropArray
= aArguments
.getConstArray();
2071 long nPropCount
= aArguments
.getLength();
2072 for (long i
= 0; i
< nPropCount
; i
++)
2074 const beans::PropertyValue
& rProp
= pPropArray
[i
];
2075 String
aPropName(rProp
.Name
);
2077 if (aPropName
.EqualsAscii( SC_UNONAME_CLOSEONUP
))
2078 bCloseOnButtonUp
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
2079 else if (aPropName
.EqualsAscii( SC_UNONAME_TITLE
))
2081 if ( rProp
.Value
>>= aStrVal
)
2082 aTitle
= String( aStrVal
);
2084 else if (aPropName
.EqualsAscii( SC_UNONAME_INITVAL
))
2086 if ( rProp
.Value
>>= aStrVal
)
2087 aInitVal
= String( aStrVal
);
2089 else if (aPropName
.EqualsAscii( SC_UNONAME_SINGLECELL
))
2090 bSingleCell
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
2091 else if (aPropName
.EqualsAscii( SC_UNONAME_MULTISEL
))
2092 bMultiSelection
= ScUnoHelpFunctions::GetBoolFromAny( rProp
.Value
);
2095 pViewSh
->StartSimpleRefDialog( aTitle
, aInitVal
, bCloseOnButtonUp
, bSingleCell
, bMultiSelection
);
2099 void SAL_CALL
ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException
)
2102 ScTabViewShell
* pViewSh
= GetViewShell();
2104 pViewSh
->StopSimpleRefDialog();
2107 void SAL_CALL
ScTabViewObj::addRangeSelectionListener(
2108 const uno::Reference
<sheet::XRangeSelectionListener
>& xListener
)
2109 throw(uno::RuntimeException
)
2112 uno::Reference
<sheet::XRangeSelectionListener
>* pObj
=
2113 new uno::Reference
<sheet::XRangeSelectionListener
>( xListener
);
2114 aRangeSelListeners
.Insert( pObj
, aRangeSelListeners
.Count() );
2117 void SAL_CALL
ScTabViewObj::removeRangeSelectionListener(
2118 const uno::Reference
<sheet::XRangeSelectionListener
>& xListener
)
2119 throw(uno::RuntimeException
)
2122 USHORT nCount
= aRangeSelListeners
.Count();
2123 for ( USHORT n
=nCount
; n
--; )
2125 uno::Reference
<sheet::XRangeSelectionListener
> *pObj
= aRangeSelListeners
[n
];
2126 if ( *pObj
== xListener
)
2128 aRangeSelListeners
.DeleteAndDestroy( n
);
2134 void SAL_CALL
ScTabViewObj::addRangeSelectionChangeListener(
2135 const uno::Reference
<sheet::XRangeSelectionChangeListener
>& xListener
)
2136 throw(uno::RuntimeException
)
2139 uno::Reference
<sheet::XRangeSelectionChangeListener
>* pObj
=
2140 new uno::Reference
<sheet::XRangeSelectionChangeListener
>( xListener
);
2141 aRangeChgListeners
.Insert( pObj
, aRangeChgListeners
.Count() );
2144 void SAL_CALL
ScTabViewObj::removeRangeSelectionChangeListener(
2145 const uno::Reference
<sheet::XRangeSelectionChangeListener
>& xListener
)
2146 throw(uno::RuntimeException
)
2149 USHORT nCount
= aRangeChgListeners
.Count();
2150 for ( USHORT n
=nCount
; n
--; )
2152 uno::Reference
<sheet::XRangeSelectionChangeListener
> *pObj
= aRangeChgListeners
[n
];
2153 if ( *pObj
== xListener
)
2155 aRangeChgListeners
.DeleteAndDestroy( n
);
2161 void ScTabViewObj::RangeSelDone( const String
& rText
)
2163 sheet::RangeSelectionEvent aEvent
;
2164 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
2165 aEvent
.RangeDescriptor
= rtl::OUString( rText
);
2167 for ( USHORT n
=0; n
<aRangeSelListeners
.Count(); n
++ )
2168 (*aRangeSelListeners
[n
])->done( aEvent
);
2171 void ScTabViewObj::RangeSelAborted( const String
& rText
)
2173 sheet::RangeSelectionEvent aEvent
;
2174 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
2175 aEvent
.RangeDescriptor
= rtl::OUString( rText
);
2177 for ( USHORT n
=0; n
<aRangeSelListeners
.Count(); n
++ )
2178 (*aRangeSelListeners
[n
])->aborted( aEvent
);
2181 void ScTabViewObj::RangeSelChanged( const String
& rText
)
2183 sheet::RangeSelectionEvent aEvent
;
2184 aEvent
.Source
.set(static_cast<cppu::OWeakObject
*>(this));
2185 aEvent
.RangeDescriptor
= rtl::OUString( rText
);
2187 for ( USHORT n
=0; n
<aRangeChgListeners
.Count(); n
++ )
2188 (*aRangeChgListeners
[n
])->descriptorChanged( aEvent
);
2193 rtl::OUString SAL_CALL
ScTabViewObj::getImplementationName() throw(uno::RuntimeException
)
2195 return rtl::OUString::createFromAscii( "ScTabViewObj" );
2198 sal_Bool SAL_CALL
ScTabViewObj::supportsService( const rtl::OUString
& rServiceName
)
2199 throw(uno::RuntimeException
)
2201 String
aServiceStr( rServiceName
);
2202 return aServiceStr
.EqualsAscii( SCTABVIEWOBJ_SERVICE
) ||
2203 aServiceStr
.EqualsAscii( SCVIEWSETTINGS_SERVICE
);
2206 uno::Sequence
<rtl::OUString
> SAL_CALL
ScTabViewObj::getSupportedServiceNames()
2207 throw(uno::RuntimeException
)
2209 uno::Sequence
<rtl::OUString
> aRet(2);
2210 rtl::OUString
* pArray
= aRet
.getArray();
2211 pArray
[0] = rtl::OUString::createFromAscii( SCTABVIEWOBJ_SERVICE
);
2212 pArray
[1] = rtl::OUString::createFromAscii( SCVIEWSETTINGS_SERVICE
);
2218 sal_Int64 SAL_CALL
ScTabViewObj::getSomething(
2219 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
2221 if ( rId
.getLength() == 16 &&
2222 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2223 rId
.getConstArray(), 16 ) )
2225 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
2231 const uno::Sequence
<sal_Int8
>& ScTabViewObj::getUnoTunnelId()
2233 static uno::Sequence
<sal_Int8
> * pSeq
= 0;
2236 osl::Guard
< osl::Mutex
> aGuard( osl::Mutex::getGlobalMutex() );
2239 static uno::Sequence
< sal_Int8
> aSeq( 16 );
2240 rtl_createUuid( (sal_uInt8
*)aSeq
.getArray(), 0, sal_True
);
2248 ScTabViewObj
* ScTabViewObj::getImplementation( const uno::Reference
<uno::XInterface
> xObj
)
2250 ScTabViewObj
* pRet
= NULL
;
2251 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
2253 pRet
= reinterpret_cast<ScTabViewObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething(getUnoTunnelId())));
2257 ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
> SAL_CALL
ScTabViewObj::getTransferable( ) throw (::com::sun::star::uno::RuntimeException
)
2260 ScEditShell
* pShell
= PTR_CAST( ScEditShell
, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2262 return pShell
->GetEditView()->GetTransferable();
2264 ScDrawTextObjectBar
* pTextShell
= PTR_CAST( ScDrawTextObjectBar
, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2267 ScViewData
* pViewData
= GetViewShell()->GetViewData();
2268 ScDrawView
* pView
= pViewData
->GetScDrawView();
2269 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
2271 return pOutView
->GetEditView().GetTransferable();
2274 ScDrawShell
* pDrawShell
= PTR_CAST( ScDrawShell
, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2276 return pDrawShell
->GetDrawView()->CopyToTransferable();
2278 ScTransferObj
* pObj
= GetViewShell()->CopyToTransferable();
2279 uno::Reference
<datatransfer::XTransferable
> xTransferable( pObj
);
2280 return xTransferable
;
2283 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 ScEditShell
* pShell
= PTR_CAST( ScEditShell
, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2288 pShell
->GetEditView()->InsertText( xTrans
, ::rtl::OUString(), FALSE
);
2291 ScDrawTextObjectBar
* pTextShell
= PTR_CAST( ScDrawTextObjectBar
, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2294 ScViewData
* pViewData
= GetViewShell()->GetViewData();
2295 ScDrawView
* pView
= pViewData
->GetScDrawView();
2296 OutlinerView
* pOutView
= pView
->GetTextEditOutlinerView();
2299 pOutView
->GetEditView().InsertText( xTrans
, ::rtl::OUString(), FALSE
);
2304 GetViewShell()->PasteFromTransferable( xTrans
);
2308 //------------------------------------------------------------------------