xref: /AOO41X/main/sc/source/ui/unoobj/viewuno.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sc.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/awt/MouseButton.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/script/vba/VBAEventId.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/view/DocumentZoomType.hpp>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #include <editeng/outliner.hxx>
37*cdf0e10cSrcweir #include <svx/fmdpage.hxx>
38*cdf0e10cSrcweir #include <svx/svditer.hxx>
39*cdf0e10cSrcweir #include <svx/svdmark.hxx>
40*cdf0e10cSrcweir #include <svx/svdouno.hxx>
41*cdf0e10cSrcweir #include <svx/svdpage.hxx>
42*cdf0e10cSrcweir #include <svx/svdpagv.hxx>
43*cdf0e10cSrcweir #include <svx/svdview.hxx>
44*cdf0e10cSrcweir #include <svx/unoshape.hxx>
45*cdf0e10cSrcweir #include <svx/unoshcol.hxx>
46*cdf0e10cSrcweir #include <svx/fmshell.hxx>
47*cdf0e10cSrcweir #include <sfx2/bindings.hxx>
48*cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
49*cdf0e10cSrcweir #include <sfx2/printer.hxx>
50*cdf0e10cSrcweir #include <sfx2/request.hxx>
51*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
52*cdf0e10cSrcweir #include <rtl/uuid.h>
53*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
54*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #include "drawsh.hxx"
57*cdf0e10cSrcweir #include "drtxtob.hxx"
58*cdf0e10cSrcweir #include "transobj.hxx"
59*cdf0e10cSrcweir #include "editsh.hxx"
60*cdf0e10cSrcweir #include "viewuno.hxx"
61*cdf0e10cSrcweir #include "cellsuno.hxx"
62*cdf0e10cSrcweir #include "miscuno.hxx"
63*cdf0e10cSrcweir #include "tabvwsh.hxx"
64*cdf0e10cSrcweir #include "docsh.hxx"
65*cdf0e10cSrcweir #include "drwlayer.hxx"
66*cdf0e10cSrcweir #include "drawview.hxx"
67*cdf0e10cSrcweir #include "fupoor.hxx"
68*cdf0e10cSrcweir #include "sc.hrc"
69*cdf0e10cSrcweir #include "unoguard.hxx"
70*cdf0e10cSrcweir #include "unonames.hxx"
71*cdf0e10cSrcweir #include "scmod.hxx"
72*cdf0e10cSrcweir #include "appoptio.hxx"
73*cdf0e10cSrcweir #include "gridwin.hxx"
74*cdf0e10cSrcweir #include "sheetevents.hxx"
75*cdf0e10cSrcweir #include "AccessibilityHints.hxx"
76*cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx>
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir using namespace com::sun::star;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir //------------------------------------------------------------------------
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir //!	Clipping-Markierungen
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir //	alles ohne Which-ID, Map nur fuer PropertySetInfo
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap()
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     static SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] =
89*cdf0e10cSrcweir 	{
90*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_COLROWHDR),   0,  &getBooleanCppuType(),          0, 0},
91*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR),    0,  &getCppuType((sal_Int32*)0),    0, 0},
92*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_COLROWHDR),    0,  &getBooleanCppuType(),          0, 0},
93*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_HORSCROLL),    0,  &getBooleanCppuType(),          0, 0},
94*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHEETTABS),    0,  &getBooleanCppuType(),          0, 0},
95*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_VERTSCROLL),   0,  &getBooleanCppuType(),          0, 0},
96*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_HIDESPELL),    0,  &getBooleanCppuType(),          0, 0},  /* deprecated #i91949 */
97*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_HORSCROLL),   0,  &getBooleanCppuType(),          0, 0},
98*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_OUTLSYMB),     0,  &getBooleanCppuType(),          0, 0},
99*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_VALUEHIGH),    0,  &getBooleanCppuType(),          0, 0},
100*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_OUTLSYMB),    0,  &getBooleanCppuType(),          0, 0},
101*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_SHEETTABS),   0,  &getBooleanCppuType(),          0, 0},
102*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWANCHOR),   0,  &getBooleanCppuType(),          0, 0},
103*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWCHARTS),   0,  &getCppuType((sal_Int16*)0),    0, 0},
104*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWDRAW),     0,  &getCppuType((sal_Int16*)0),    0, 0},
105*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWFORM),     0,  &getBooleanCppuType(),          0, 0},
106*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWGRID),     0,  &getBooleanCppuType(),          0, 0},
107*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWHELP),     0,  &getBooleanCppuType(),          0, 0},
108*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWNOTES),    0,  &getBooleanCppuType(),          0, 0},
109*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWOBJ),      0,  &getCppuType((sal_Int16*)0),    0, 0},
110*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR),   0,  &getBooleanCppuType(),          0, 0},
111*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWZERO),     0,  &getBooleanCppuType(),          0, 0},
112*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_SHOWSOLID),    0,  &getBooleanCppuType(),          0, 0},
113*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_VALUEHIGH),   0,  &getBooleanCppuType(),          0, 0},
114*cdf0e10cSrcweir         {MAP_CHAR_LEN(OLD_UNO_VERTSCROLL),  0,  &getBooleanCppuType(),          0, 0},
115*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_VISAREA),      0,  &getCppuType((awt::Rectangle*)0), 0, 0},
116*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE),     0,  &getCppuType((sal_Int16*)0),    0, 0},
117*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE),    0,  &getCppuType((sal_Int16*)0),    0, 0},
118*cdf0e10cSrcweir         {MAP_CHAR_LEN(SC_UNO_VISAREASCREEN),0,  &getCppuType((awt::Rectangle*)0), 0, 0},
119*cdf0e10cSrcweir         {0,0,0,0,0,0}
120*cdf0e10cSrcweir 	};
121*cdf0e10cSrcweir 	return aViewOptPropertyMap_Impl;
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //------------------------------------------------------------------------
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir SV_IMPL_PTRARR( XRangeSelectionListenerArr_Impl, XRangeSelectionListenerPtr );
127*cdf0e10cSrcweir SV_IMPL_PTRARR( XRangeSelectionChangeListenerArr_Impl, XRangeSelectionChangeListenerPtr );
128*cdf0e10cSrcweir SV_IMPL_PTRARR( XSelectionChangeListenerArr_Impl, XSelectionChangeListenerPtr );
129*cdf0e10cSrcweir SV_IMPL_PTRARR( XViewPropertyChangeListenerArr_Impl, XViewPropertyChangeListenerPtr );
130*cdf0e10cSrcweir SV_IMPL_PTRARR( XMouseClickHandlerArr_Impl, XMouseClickHandlerPtr );
131*cdf0e10cSrcweir SV_IMPL_PTRARR( XActivationEventListenerArr_Impl, XActivationEventListenerPtr );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir #define SCTABVIEWOBJ_SERVICE		"com.sun.star.sheet.SpreadsheetView"
134*cdf0e10cSrcweir #define SCVIEWSETTINGS_SERVICE		"com.sun.star.sheet.SpreadsheetViewSettings"
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir //------------------------------------------------------------------------
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, sal_uInt16 nP) :
141*cdf0e10cSrcweir 	pViewShell( pViewSh ),
142*cdf0e10cSrcweir 	nPane( nP )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	if (pViewShell)
145*cdf0e10cSrcweir 		StartListening(*pViewShell);
146*cdf0e10cSrcweir }
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir ScViewPaneBase::~ScViewPaneBase()
149*cdf0e10cSrcweir {
150*cdf0e10cSrcweir 	if (pViewShell)
151*cdf0e10cSrcweir 		EndListening(*pViewShell);
152*cdf0e10cSrcweir }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir void ScViewPaneBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	if ( rHint.ISA( SfxSimpleHint ) &&
157*cdf0e10cSrcweir 			((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
158*cdf0e10cSrcweir 		pViewShell = NULL;
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir uno::Any SAL_CALL ScViewPaneBase::queryInterface( const uno::Type& rType )
162*cdf0e10cSrcweir 												throw(uno::RuntimeException)
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XViewPane )
165*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XCellRangeReferrer )
166*cdf0e10cSrcweir 	SC_QUERYINTERFACE( view::XFormLayerAccess )
167*cdf0e10cSrcweir 	SC_QUERYINTERFACE( view::XControlAccess )
168*cdf0e10cSrcweir 	SC_QUERYINTERFACE( lang::XServiceInfo )
169*cdf0e10cSrcweir 	SC_QUERYINTERFACE( lang::XTypeProvider )
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir 	return uno::Any();			// OWeakObject is in derived objects
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes() throw(uno::RuntimeException)
175*cdf0e10cSrcweir {
176*cdf0e10cSrcweir 	static uno::Sequence<uno::Type> aTypes;
177*cdf0e10cSrcweir 	if ( aTypes.getLength() == 0 )
178*cdf0e10cSrcweir 	{
179*cdf0e10cSrcweir 		aTypes.realloc(5);
180*cdf0e10cSrcweir 		uno::Type* pPtr = aTypes.getArray();
181*cdf0e10cSrcweir 		pPtr[0] = getCppuType((const uno::Reference<sheet::XViewPane>*)0);
182*cdf0e10cSrcweir 		pPtr[1] = getCppuType((const uno::Reference<sheet::XCellRangeReferrer>*)0);
183*cdf0e10cSrcweir 		pPtr[2] = getCppuType((const uno::Reference<view::XFormLayerAccess>*)0);
184*cdf0e10cSrcweir 		pPtr[3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
185*cdf0e10cSrcweir 		pPtr[4] = getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
186*cdf0e10cSrcweir 	}
187*cdf0e10cSrcweir 	return aTypes;
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId()
191*cdf0e10cSrcweir 													throw(uno::RuntimeException)
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 > aId;
194*cdf0e10cSrcweir 	if( aId.getLength() == 0 )
195*cdf0e10cSrcweir 	{
196*cdf0e10cSrcweir 		aId.realloc( 16 );
197*cdf0e10cSrcweir 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
198*cdf0e10cSrcweir 	}
199*cdf0e10cSrcweir 	return aId;
200*cdf0e10cSrcweir }
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir // XViewPane
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException)
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir 	ScUnoGuard aGuard;
207*cdf0e10cSrcweir 	if (pViewShell)
208*cdf0e10cSrcweir 	{
209*cdf0e10cSrcweir 		ScViewData* pViewData = pViewShell->GetViewData();
210*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
211*cdf0e10cSrcweir 								pViewData->GetActivePart() :
212*cdf0e10cSrcweir 								(ScSplitPos) nPane;
213*cdf0e10cSrcweir 		ScHSplitPos eWhichH = WhichH( eWhich );
214*cdf0e10cSrcweir 
215*cdf0e10cSrcweir 		return pViewData->GetPosX( eWhichH );
216*cdf0e10cSrcweir 	}
217*cdf0e10cSrcweir 	DBG_ERROR("keine View ?!?");	//! Exception?
218*cdf0e10cSrcweir 	return 0;
219*cdf0e10cSrcweir }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir void SAL_CALL ScViewPaneBase::setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn )
222*cdf0e10cSrcweir 												throw(uno::RuntimeException)
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir 	ScUnoGuard aGuard;
225*cdf0e10cSrcweir 	if (pViewShell)
226*cdf0e10cSrcweir 	{
227*cdf0e10cSrcweir 		ScViewData* pViewData = pViewShell->GetViewData();
228*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
229*cdf0e10cSrcweir 								pViewData->GetActivePart() :
230*cdf0e10cSrcweir 								(ScSplitPos) nPane;
231*cdf0e10cSrcweir 		ScHSplitPos eWhichH = WhichH( eWhich );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 		long nDeltaX = ((long)nFirstVisibleColumn) - pViewData->GetPosX( eWhichH );
234*cdf0e10cSrcweir 		pViewShell->ScrollX( nDeltaX, eWhichH );
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir }
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException)
239*cdf0e10cSrcweir {
240*cdf0e10cSrcweir 	ScUnoGuard aGuard;
241*cdf0e10cSrcweir 	if (pViewShell)
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir 		ScViewData* pViewData = pViewShell->GetViewData();
244*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
245*cdf0e10cSrcweir 								pViewData->GetActivePart() :
246*cdf0e10cSrcweir 								(ScSplitPos) nPane;
247*cdf0e10cSrcweir 		ScVSplitPos eWhichV = WhichV( eWhich );
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 		return pViewData->GetPosY( eWhichV );
250*cdf0e10cSrcweir 	}
251*cdf0e10cSrcweir 	DBG_ERROR("keine View ?!?");	//! Exception?
252*cdf0e10cSrcweir 	return 0;
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
256*cdf0e10cSrcweir 												throw(uno::RuntimeException)
257*cdf0e10cSrcweir {
258*cdf0e10cSrcweir 	ScUnoGuard aGuard;
259*cdf0e10cSrcweir 	if (pViewShell)
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		ScViewData* pViewData = pViewShell->GetViewData();
262*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
263*cdf0e10cSrcweir 								pViewData->GetActivePart() :
264*cdf0e10cSrcweir 								(ScSplitPos) nPane;
265*cdf0e10cSrcweir 		ScVSplitPos eWhichV = WhichV( eWhich );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 		long nDeltaY = ((long)nFirstVisibleRow) - pViewData->GetPosY( eWhichV );
268*cdf0e10cSrcweir 		pViewShell->ScrollY( nDeltaY, eWhichV );
269*cdf0e10cSrcweir 	}
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange() throw(uno::RuntimeException)
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir 	ScUnoGuard aGuard;
275*cdf0e10cSrcweir 	table::CellRangeAddress aAdr;
276*cdf0e10cSrcweir 	if (pViewShell)
277*cdf0e10cSrcweir 	{
278*cdf0e10cSrcweir 		ScViewData* pViewData = pViewShell->GetViewData();
279*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
280*cdf0e10cSrcweir 								pViewData->GetActivePart() :
281*cdf0e10cSrcweir 								(ScSplitPos) nPane;
282*cdf0e10cSrcweir 		ScHSplitPos eWhichH = WhichH( eWhich );
283*cdf0e10cSrcweir 		ScVSplitPos eWhichV = WhichV( eWhich );
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 		//	VisibleCellsX gibt nur komplett sichtbare Zellen,
286*cdf0e10cSrcweir 		//	VisibleRange in Excel auch teilweise sichtbare.
287*cdf0e10cSrcweir 		//!	anpassen ???
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 		SCCOL nVisX = pViewData->VisibleCellsX( eWhichH );
290*cdf0e10cSrcweir 		SCROW nVisY = pViewData->VisibleCellsY( eWhichV );
291*cdf0e10cSrcweir 		if (!nVisX) nVisX = 1;	// irgendwas muss ja im Range sein
292*cdf0e10cSrcweir 		if (!nVisY) nVisY = 1;
293*cdf0e10cSrcweir 		aAdr.Sheet		 = pViewData->GetTabNo();
294*cdf0e10cSrcweir 		aAdr.StartColumn = pViewData->GetPosX( eWhichH );
295*cdf0e10cSrcweir 		aAdr.StartRow	 = pViewData->GetPosY( eWhichV );
296*cdf0e10cSrcweir 		aAdr.EndColumn	 = aAdr.StartColumn + nVisX - 1;
297*cdf0e10cSrcweir 		aAdr.EndRow		 = aAdr.StartRow    + nVisY - 1;
298*cdf0e10cSrcweir 	}
299*cdf0e10cSrcweir 	return aAdr;
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir // XCellRangeSource
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells()
305*cdf0e10cSrcweir 												throw(uno::RuntimeException)
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir 	ScUnoGuard aGuard;
308*cdf0e10cSrcweir 	if (pViewShell)
309*cdf0e10cSrcweir 	{
310*cdf0e10cSrcweir 		ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 		table::CellRangeAddress aAdr(getVisibleRange());		//! Hilfsfunktion mit ScRange?
313*cdf0e10cSrcweir 		ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet,
314*cdf0e10cSrcweir 						(SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet );
315*cdf0e10cSrcweir 		if ( aRange.aStart == aRange.aEnd )
316*cdf0e10cSrcweir 			return new ScCellObj( pDocSh, aRange.aStart );
317*cdf0e10cSrcweir 		else
318*cdf0e10cSrcweir 			return new ScCellRangeObj( pDocSh, aRange );
319*cdf0e10cSrcweir 	}
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir 	return NULL;
322*cdf0e10cSrcweir }
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir namespace
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir     bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, sal_uInt16 _nPane, FmFormShell*& _rpFormShell, Window*& _rpWindow, SdrView*& _rpSdrView )
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir 	    if ( !_pViewShell )
329*cdf0e10cSrcweir             return false;
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir         ScViewData* pViewData = _pViewShell->GetViewData();
332*cdf0e10cSrcweir 		ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ?
333*cdf0e10cSrcweir 								pViewData->GetActivePart() :
334*cdf0e10cSrcweir 								(ScSplitPos) _nPane;
335*cdf0e10cSrcweir 		_rpWindow = _pViewShell->GetWindowByPos( eWhich );
336*cdf0e10cSrcweir         _rpSdrView = _pViewShell->GetSdrView();
337*cdf0e10cSrcweir         _rpFormShell = _pViewShell->GetFormShell();
338*cdf0e10cSrcweir         return ( _rpFormShell != NULL ) && ( _rpSdrView != NULL )&& ( _rpWindow != NULL );
339*cdf0e10cSrcweir     }
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir // XFormLayerAccess
343*cdf0e10cSrcweir uno::Reference< form::runtime::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& _Form ) throw (uno::RuntimeException)
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir 	ScUnoGuard aGuard;
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir     uno::Reference< form::runtime::XFormController > xController;
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir     Window* pWindow( NULL );
350*cdf0e10cSrcweir     SdrView* pSdrView( NULL );
351*cdf0e10cSrcweir     FmFormShell* pFormShell( NULL );
352*cdf0e10cSrcweir     if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
353*cdf0e10cSrcweir         xController = pFormShell->GetFormController( _Form, *pSdrView, *pWindow );
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     return xController;
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir ::sal_Bool SAL_CALL ScViewPaneBase::isFormDesignMode(  ) throw (uno::RuntimeException)
359*cdf0e10cSrcweir {
360*cdf0e10cSrcweir 	ScUnoGuard aGuard;
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     sal_Bool bIsFormDesignMode( sal_True );
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : NULL );
365*cdf0e10cSrcweir     if ( pFormShell )
366*cdf0e10cSrcweir         bIsFormDesignMode = pFormShell->IsDesignMode();
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir     return bIsFormDesignMode;
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir void SAL_CALL ScViewPaneBase::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir 	ScUnoGuard aGuard;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir     Window* pWindow( NULL );
376*cdf0e10cSrcweir     SdrView* pSdrView( NULL );
377*cdf0e10cSrcweir     FmFormShell* pFormShell( NULL );
378*cdf0e10cSrcweir     if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
379*cdf0e10cSrcweir         pFormShell->SetDesignMode( _DesignMode );
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir // XControlAccess
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl(
385*cdf0e10cSrcweir 							const uno::Reference<awt::XControlModel>& xModel )
386*cdf0e10cSrcweir 				throw(container::NoSuchElementException, uno::RuntimeException)
387*cdf0e10cSrcweir {
388*cdf0e10cSrcweir 	ScUnoGuard aGuard;
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir     uno::Reference<awt::XControl> xRet;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     Window* pWindow( NULL );
393*cdf0e10cSrcweir     SdrView* pSdrView( NULL );
394*cdf0e10cSrcweir     FmFormShell* pFormShell( NULL );
395*cdf0e10cSrcweir     if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
396*cdf0e10cSrcweir         pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xRet );
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     if ( !xRet.is() )
399*cdf0e10cSrcweir 		throw container::NoSuchElementException();		// no control found
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 	return xRet;
402*cdf0e10cSrcweir }
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir awt::Rectangle ScViewPaneBase::GetVisArea() const
405*cdf0e10cSrcweir {
406*cdf0e10cSrcweir 	awt::Rectangle aVisArea;
407*cdf0e10cSrcweir 	if (pViewShell)
408*cdf0e10cSrcweir 	{
409*cdf0e10cSrcweir 		ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
410*cdf0e10cSrcweir 								pViewShell->GetViewData()->GetActivePart() :
411*cdf0e10cSrcweir 								(ScSplitPos) nPane;
412*cdf0e10cSrcweir 		ScGridWindow* pWindow = (ScGridWindow*)pViewShell->GetWindowByPos(eWhich);
413*cdf0e10cSrcweir 		ScDocument* pDoc = pViewShell->GetViewData()->GetDocument();
414*cdf0e10cSrcweir 		if (pWindow && pDoc)
415*cdf0e10cSrcweir 		{
416*cdf0e10cSrcweir 			ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ?
417*cdf0e10cSrcweir 									SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
418*cdf0e10cSrcweir 			ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ?
419*cdf0e10cSrcweir 									SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
420*cdf0e10cSrcweir 			ScAddress aCell(pViewShell->GetViewData()->GetPosX(eWhichH),
421*cdf0e10cSrcweir 				pViewShell->GetViewData()->GetPosY(eWhichV),
422*cdf0e10cSrcweir 				pViewShell->GetViewData()->GetTabNo());
423*cdf0e10cSrcweir             Rectangle aCellRect( pDoc->GetMMRect( aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab() ) );
424*cdf0e10cSrcweir             Size aVisSize( pWindow->PixelToLogic( pWindow->GetSizePixel(), pWindow->GetDrawMapMode( sal_True ) ) );
425*cdf0e10cSrcweir             Point aVisPos( aCellRect.TopLeft() );
426*cdf0e10cSrcweir             if ( pDoc->IsLayoutRTL( aCell.Tab() ) )
427*cdf0e10cSrcweir             {
428*cdf0e10cSrcweir                 aVisPos = aCellRect.TopRight();
429*cdf0e10cSrcweir                 aVisPos.X() -= aVisSize.Width();
430*cdf0e10cSrcweir             }
431*cdf0e10cSrcweir             Rectangle aVisRect( aVisPos, aVisSize );
432*cdf0e10cSrcweir 			aVisArea = AWTRectangle(aVisRect);
433*cdf0e10cSrcweir 		}
434*cdf0e10cSrcweir 	}
435*cdf0e10cSrcweir 	return aVisArea;
436*cdf0e10cSrcweir }
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir //------------------------------------------------------------------------
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir ScViewPaneObj::ScViewPaneObj(ScTabViewShell* pViewSh, sal_uInt16 nP) :
441*cdf0e10cSrcweir 	ScViewPaneBase( pViewSh, nP )
442*cdf0e10cSrcweir {
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir ScViewPaneObj::~ScViewPaneObj()
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir uno::Any SAL_CALL ScViewPaneObj::queryInterface( const uno::Type& rType )
450*cdf0e10cSrcweir 												throw(uno::RuntimeException)
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir 	//	ScViewPaneBase has everything except OWeakObject
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
455*cdf0e10cSrcweir 	if (!aRet.hasValue())
456*cdf0e10cSrcweir 		aRet = OWeakObject::queryInterface( rType );
457*cdf0e10cSrcweir 	return aRet;
458*cdf0e10cSrcweir }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir void SAL_CALL ScViewPaneObj::acquire() throw()
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	OWeakObject::acquire();
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir void SAL_CALL ScViewPaneObj::release() throw()
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir 	OWeakObject::release();
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir //------------------------------------------------------------------------
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir //	Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir //UNUSED2008-05  ScTabViewObj::ScTabViewObj() :
475*cdf0e10cSrcweir //UNUSED2008-05  ScViewPaneBase( NULL, SC_VIEWPANE_ACTIVE ),
476*cdf0e10cSrcweir //UNUSED2008-05  SfxBaseController( NULL ),
477*cdf0e10cSrcweir //UNUSED2008-05  aPropSet( lcl_GetViewOptPropertyMap() ),
478*cdf0e10cSrcweir //UNUSED2008-05  aMouseClickHandlers( 0 ),
479*cdf0e10cSrcweir //UNUSED2008-05  aActivationListeners( 0 ),
480*cdf0e10cSrcweir //UNUSED2008-05  bDrawSelModeSet(sal_False),
481*cdf0e10cSrcweir //UNUSED2008-05  bFilteredRangeSelection(sal_True)
482*cdf0e10cSrcweir //UNUSED2008-05  {
483*cdf0e10cSrcweir //UNUSED2008-05  }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
486*cdf0e10cSrcweir 	ScViewPaneBase( pViewSh, SC_VIEWPANE_ACTIVE ),
487*cdf0e10cSrcweir 	SfxBaseController( pViewSh ),
488*cdf0e10cSrcweir 	aPropSet( lcl_GetViewOptPropertyMap() ),
489*cdf0e10cSrcweir 	aMouseClickHandlers( 0 ),
490*cdf0e10cSrcweir 	aActivationListeners( 0 ),
491*cdf0e10cSrcweir     nPreviousTab( 0 ),
492*cdf0e10cSrcweir 	bDrawSelModeSet(sal_False)
493*cdf0e10cSrcweir {
494*cdf0e10cSrcweir     if (pViewSh)
495*cdf0e10cSrcweir         nPreviousTab = pViewSh->GetViewData()->GetTabNo();
496*cdf0e10cSrcweir }
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir ScTabViewObj::~ScTabViewObj()
499*cdf0e10cSrcweir {
500*cdf0e10cSrcweir 	//!	Listening oder so
501*cdf0e10cSrcweir     if (aMouseClickHandlers.Count())
502*cdf0e10cSrcweir     {
503*cdf0e10cSrcweir         acquire();
504*cdf0e10cSrcweir         EndMouseListening();
505*cdf0e10cSrcweir     }
506*cdf0e10cSrcweir     if (aActivationListeners.Count())
507*cdf0e10cSrcweir     {
508*cdf0e10cSrcweir         acquire();
509*cdf0e10cSrcweir         EndActivationListening();
510*cdf0e10cSrcweir     }
511*cdf0e10cSrcweir }
512*cdf0e10cSrcweir 
513*cdf0e10cSrcweir uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
514*cdf0e10cSrcweir 												throw(uno::RuntimeException)
515*cdf0e10cSrcweir {
516*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XSpreadsheetView )
517*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster )
518*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XActivationBroadcaster )
519*cdf0e10cSrcweir 	SC_QUERYINTERFACE( container::XEnumerationAccess )
520*cdf0e10cSrcweir 	SC_QUERYINTERFACE( container::XIndexAccess )
521*cdf0e10cSrcweir 	SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
522*cdf0e10cSrcweir 	SC_QUERYINTERFACE( view::XSelectionSupplier )
523*cdf0e10cSrcweir 	SC_QUERYINTERFACE( beans::XPropertySet )
524*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XViewSplitable )
525*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XViewFreezable )
526*cdf0e10cSrcweir 	SC_QUERYINTERFACE( sheet::XRangeSelection )
527*cdf0e10cSrcweir 	SC_QUERYINTERFACE( lang::XUnoTunnel )
528*cdf0e10cSrcweir     SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir 	uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
531*cdf0e10cSrcweir 	if (!aRet.hasValue())
532*cdf0e10cSrcweir 		aRet = SfxBaseController::queryInterface( rType );
533*cdf0e10cSrcweir 	return aRet;
534*cdf0e10cSrcweir }
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::acquire() throw()
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir 	SfxBaseController::acquire();
539*cdf0e10cSrcweir }
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::release() throw()
542*cdf0e10cSrcweir {
543*cdf0e10cSrcweir 	SfxBaseController::release();
544*cdf0e10cSrcweir }
545*cdf0e10cSrcweir 
546*cdf0e10cSrcweir void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent )
547*cdf0e10cSrcweir {
548*cdf0e10cSrcweir     ScDocument* pDoc = pDocSh->GetDocument();
549*cdf0e10cSrcweir     // when deleting a sheet, nPreviousTab can be invalid
550*cdf0e10cSrcweir     // (could be handled with reference updates)
551*cdf0e10cSrcweir     if (!pDoc->HasTable(nTab))
552*cdf0e10cSrcweir         return;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir     const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
555*cdf0e10cSrcweir     if (pEvents)
556*cdf0e10cSrcweir     {
557*cdf0e10cSrcweir         const rtl::OUString* pScript = pEvents->GetScript(nEvent);
558*cdf0e10cSrcweir         if (pScript)
559*cdf0e10cSrcweir         {
560*cdf0e10cSrcweir             uno::Any aRet;
561*cdf0e10cSrcweir             uno::Sequence<uno::Any> aParams;
562*cdf0e10cSrcweir             uno::Sequence<sal_Int16> aOutArgsIndex;
563*cdf0e10cSrcweir             uno::Sequence<uno::Any> aOutArgs;
564*cdf0e10cSrcweir             /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
565*cdf0e10cSrcweir         }
566*cdf0e10cSrcweir     }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     // execute VBA event handlers
569*cdf0e10cSrcweir     try
570*cdf0e10cSrcweir     {
571*cdf0e10cSrcweir         uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
572*cdf0e10cSrcweir         // the parameter is the clicked object, as in the mousePressed call above
573*cdf0e10cSrcweir         uno::Sequence< uno::Any > aArgs( 1 );
574*cdf0e10cSrcweir         aArgs[ 0 ] <<= nTab;
575*cdf0e10cSrcweir         xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir     catch( uno::Exception& )
578*cdf0e10cSrcweir     {
579*cdf0e10cSrcweir     }
580*cdf0e10cSrcweir }
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir void ScTabViewObj::SheetChanged( bool bSameTabButMoved )
583*cdf0e10cSrcweir {
584*cdf0e10cSrcweir     if ( !GetViewShell() )
585*cdf0e10cSrcweir         return;
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir     ScViewData* pViewData = GetViewShell()->GetViewData();
588*cdf0e10cSrcweir     ScDocShell* pDocSh = pViewData->GetDocShell();
589*cdf0e10cSrcweir     if (aActivationListeners.Count() > 0)
590*cdf0e10cSrcweir     {
591*cdf0e10cSrcweir         sheet::ActivationEvent aEvent;
592*cdf0e10cSrcweir         uno::Reference< sheet::XSpreadsheetView > xView(this);
593*cdf0e10cSrcweir         uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
594*cdf0e10cSrcweir         aEvent.Source = xSource;
595*cdf0e10cSrcweir         aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, pViewData->GetTabNo());
596*cdf0e10cSrcweir         for ( sal_uInt16 n=0; n<aActivationListeners.Count(); n++ )
597*cdf0e10cSrcweir         {
598*cdf0e10cSrcweir             try
599*cdf0e10cSrcweir             {
600*cdf0e10cSrcweir                 (*aActivationListeners[n])->activeSpreadsheetChanged( aEvent );
601*cdf0e10cSrcweir             }
602*cdf0e10cSrcweir             catch( uno::Exception& )
603*cdf0e10cSrcweir             {
604*cdf0e10cSrcweir                 aActivationListeners.DeleteAndDestroy( n );
605*cdf0e10cSrcweir                 --n; // because it will be increased again in the loop
606*cdf0e10cSrcweir             }
607*cdf0e10cSrcweir         }
608*cdf0e10cSrcweir     }
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir     /*  Handle sheet events, but do not trigger event handlers, if the old
611*cdf0e10cSrcweir         active sheet gets re-activated after inserting/deleting/moving a sheet. */
612*cdf0e10cSrcweir     SCTAB nNewTab = pViewData->GetTabNo();
613*cdf0e10cSrcweir     if ( !bSameTabButMoved && (nNewTab != nPreviousTab) )
614*cdf0e10cSrcweir     {
615*cdf0e10cSrcweir         lcl_CallActivate( pDocSh, nPreviousTab, SC_SHEETEVENT_UNFOCUS );
616*cdf0e10cSrcweir         lcl_CallActivate( pDocSh, nNewTab, SC_SHEETEVENT_FOCUS );
617*cdf0e10cSrcweir     }
618*cdf0e10cSrcweir     nPreviousTab = nNewTab;
619*cdf0e10cSrcweir }
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() throw(uno::RuntimeException)
622*cdf0e10cSrcweir {
623*cdf0e10cSrcweir 	static uno::Sequence<uno::Type> aTypes;
624*cdf0e10cSrcweir 	if ( aTypes.getLength() == 0 )
625*cdf0e10cSrcweir 	{
626*cdf0e10cSrcweir 		uno::Sequence<uno::Type> aViewPaneTypes(ScViewPaneBase::getTypes());
627*cdf0e10cSrcweir 		long nViewPaneLen = aViewPaneTypes.getLength();
628*cdf0e10cSrcweir 		const uno::Type* pViewPanePtr = aViewPaneTypes.getConstArray();
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 		uno::Sequence<uno::Type> aControllerTypes(SfxBaseController::getTypes());
631*cdf0e10cSrcweir 		long nControllerLen = aControllerTypes.getLength();
632*cdf0e10cSrcweir 		const uno::Type* pControllerPtr = aControllerTypes.getConstArray();
633*cdf0e10cSrcweir 
634*cdf0e10cSrcweir 		long nParentLen = nViewPaneLen + nControllerLen;
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir         aTypes.realloc( nParentLen + 12 );
637*cdf0e10cSrcweir 		uno::Type* pPtr = aTypes.getArray();
638*cdf0e10cSrcweir 		pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetView>*)0);
639*cdf0e10cSrcweir 		pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
640*cdf0e10cSrcweir 		pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XIndexAccess>*)0);
641*cdf0e10cSrcweir 		pPtr[nParentLen + 3] = getCppuType((const uno::Reference<view::XSelectionSupplier>*)0);
642*cdf0e10cSrcweir 		pPtr[nParentLen + 4] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
643*cdf0e10cSrcweir 		pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XViewSplitable>*)0);
644*cdf0e10cSrcweir 		pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XViewFreezable>*)0);
645*cdf0e10cSrcweir 		pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XRangeSelection>*)0);
646*cdf0e10cSrcweir 		pPtr[nParentLen + 8] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
647*cdf0e10cSrcweir 		pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XEnhancedMouseClickBroadcaster>*)0);
648*cdf0e10cSrcweir 		pPtr[nParentLen + 10] = getCppuType((const uno::Reference<sheet::XActivationBroadcaster>*)0);
649*cdf0e10cSrcweir         pPtr[nParentLen + 11] = getCppuType((const uno::Reference<datatransfer::XTransferableSupplier>*)0);
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 		long i;
652*cdf0e10cSrcweir 		for (i=0; i<nViewPaneLen; i++)
653*cdf0e10cSrcweir 			pPtr[i] = pViewPanePtr[i];				// parent types first
654*cdf0e10cSrcweir 		for (i=0; i<nControllerLen; i++)
655*cdf0e10cSrcweir 			pPtr[nViewPaneLen+i] = pControllerPtr[i];
656*cdf0e10cSrcweir 	}
657*cdf0e10cSrcweir 	return aTypes;
658*cdf0e10cSrcweir }
659*cdf0e10cSrcweir 
660*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
661*cdf0e10cSrcweir 												throw(uno::RuntimeException)
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 > aId;
664*cdf0e10cSrcweir 	if( aId.getLength() == 0 )
665*cdf0e10cSrcweir 	{
666*cdf0e10cSrcweir 		aId.realloc( 16 );
667*cdf0e10cSrcweir 		rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
668*cdf0e10cSrcweir 	}
669*cdf0e10cSrcweir 	return aId;
670*cdf0e10cSrcweir }
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir // XDocumentView
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir sal_Bool lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
675*cdf0e10cSrcweir {
676*cdf0e10cSrcweir 	sal_uLong nCount = rRanges.Count();
677*cdf0e10cSrcweir 	for (sal_uLong i=0; i<nCount; i++)
678*cdf0e10cSrcweir 	{
679*cdf0e10cSrcweir 		const ScRange* pRange = rRanges.GetObject(i);
680*cdf0e10cSrcweir 		if ( nTab >= pRange->aStart.Tab() && nTab <= pRange->aEnd.Tab() )
681*cdf0e10cSrcweir 			return sal_True;
682*cdf0e10cSrcweir 	}
683*cdf0e10cSrcweir 	return sal_False;
684*cdf0e10cSrcweir }
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir void lcl_ShowObject( ScTabViewShell& rViewSh, ScDrawView& rDrawView, SdrObject* pSelObj )
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
689*cdf0e10cSrcweir 	SCTAB nObjectTab = 0;
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir 	SdrModel* pModel = rDrawView.GetModel();
692*cdf0e10cSrcweir 	sal_uInt16 nPageCount = pModel->GetPageCount();
693*cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<nPageCount && !bFound; i++)
694*cdf0e10cSrcweir 	{
695*cdf0e10cSrcweir 		SdrPage* pPage = pModel->GetPage(i);
696*cdf0e10cSrcweir 		if (pPage)
697*cdf0e10cSrcweir 		{
698*cdf0e10cSrcweir 			SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
699*cdf0e10cSrcweir 			SdrObject* pObject = aIter.Next();
700*cdf0e10cSrcweir 			while (pObject && !bFound)
701*cdf0e10cSrcweir 			{
702*cdf0e10cSrcweir 				if ( pObject == pSelObj )
703*cdf0e10cSrcweir 				{
704*cdf0e10cSrcweir 					bFound = sal_True;
705*cdf0e10cSrcweir 					nObjectTab = static_cast<SCTAB>(i);
706*cdf0e10cSrcweir 				}
707*cdf0e10cSrcweir 				pObject = aIter.Next();
708*cdf0e10cSrcweir 			}
709*cdf0e10cSrcweir 		}
710*cdf0e10cSrcweir 	}
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 	if (bFound)
713*cdf0e10cSrcweir 	{
714*cdf0e10cSrcweir 		rViewSh.SetTabNo( nObjectTab );
715*cdf0e10cSrcweir 		rViewSh.ScrollToObject( pSelObj );
716*cdf0e10cSrcweir 	}
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
720*cdf0e10cSrcweir 						throw(lang::IllegalArgumentException, uno::RuntimeException)
721*cdf0e10cSrcweir {
722*cdf0e10cSrcweir 	ScUnoGuard aGuard;
723*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
724*cdf0e10cSrcweir 
725*cdf0e10cSrcweir 	if ( !pViewSh )
726*cdf0e10cSrcweir 		return sal_False;
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir 	//!	Type of aSelection can be some specific interface instead of XInterface
729*cdf0e10cSrcweir 
730*cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
731*cdf0e10cSrcweir     uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
732*cdf0e10cSrcweir 	if ( !xInterface.is() )  //clear all selections
733*cdf0e10cSrcweir 	{
734*cdf0e10cSrcweir 		ScDrawView* pDrawView = pViewSh->GetScDrawView();
735*cdf0e10cSrcweir 		if (pDrawView)
736*cdf0e10cSrcweir 		{
737*cdf0e10cSrcweir 			pDrawView->ScEndTextEdit();
738*cdf0e10cSrcweir 			pDrawView->UnmarkAll();
739*cdf0e10cSrcweir 		}
740*cdf0e10cSrcweir         else //#102232#; if there is  no DrawView remove range selection
741*cdf0e10cSrcweir             pViewSh->Unmark();
742*cdf0e10cSrcweir         bRet = sal_True;
743*cdf0e10cSrcweir 	}
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 	if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
746*cdf0e10cSrcweir 	{
747*cdf0e10cSrcweir 		pViewSh->SetDrawSelMode(sal_False);
748*cdf0e10cSrcweir 		pViewSh->UpdateLayerLocks();
749*cdf0e10cSrcweir 		bDrawSelModeSet = sal_False;
750*cdf0e10cSrcweir 	}
751*cdf0e10cSrcweir 
752*cdf0e10cSrcweir 	if (bRet)
753*cdf0e10cSrcweir 		return bRet;
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir 	ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
757*cdf0e10cSrcweir 	uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
758*cdf0e10cSrcweir 	uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
759*cdf0e10cSrcweir 	SvxShape* pShapeImp = SvxShape::getImplementation( xShapeSel );
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 	if (pRangesImp)										// Zell-Ranges
762*cdf0e10cSrcweir 	{
763*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
764*cdf0e10cSrcweir 		if ( pViewData->GetDocShell() == pRangesImp->GetDocShell() )
765*cdf0e10cSrcweir 		{
766*cdf0e10cSrcweir 			//	Zuerst evtl. Drawing-Selektion aufheben
767*cdf0e10cSrcweir 			//	(MarkListHasChanged hebt Tabellen-Selektion auf)
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 			ScDrawView* pDrawView = pViewSh->GetScDrawView();
770*cdf0e10cSrcweir 			if (pDrawView)
771*cdf0e10cSrcweir 			{
772*cdf0e10cSrcweir 				pDrawView->ScEndTextEdit();
773*cdf0e10cSrcweir 				pDrawView->UnmarkAll();
774*cdf0e10cSrcweir 			}
775*cdf0e10cSrcweir 			FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
776*cdf0e10cSrcweir 			if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
777*cdf0e10cSrcweir 			{
778*cdf0e10cSrcweir 				//	Slot der Zeichenfunktion nochmal ausfuehren -> abschalten
779*cdf0e10cSrcweir 				SfxDispatcher* pDisp = pViewSh->GetDispatcher();
780*cdf0e10cSrcweir 				if (pDisp)
781*cdf0e10cSrcweir 					pDisp->Execute( pFunc->GetSlotID(), SFX_CALLMODE_SYNCHRON );
782*cdf0e10cSrcweir 			}
783*cdf0e10cSrcweir 			pViewSh->SetDrawShell(sal_False);
784*cdf0e10cSrcweir 			pViewSh->SetDrawSelMode(sal_False);	// nach dem Dispatcher-Execute
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir 			//	Ranges selektieren
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir 			const ScRangeList& rRanges = pRangesImp->GetRangeList();
789*cdf0e10cSrcweir 			sal_uLong nRangeCount = rRanges.Count();
790*cdf0e10cSrcweir 			// for empty range list, remove selection (cursor remains where it was)
791*cdf0e10cSrcweir 			if ( nRangeCount == 0 )
792*cdf0e10cSrcweir 				pViewSh->Unmark();
793*cdf0e10cSrcweir 			else if ( nRangeCount == 1 )
794*cdf0e10cSrcweir 				pViewSh->MarkRange( *rRanges.GetObject(0) );
795*cdf0e10cSrcweir 			else
796*cdf0e10cSrcweir 			{
797*cdf0e10cSrcweir 				//	Mehrfachselektion
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 				const ScRange* pFirst = rRanges.GetObject(0);
800*cdf0e10cSrcweir 				if ( pFirst && !lcl_TabInRanges( pViewData->GetTabNo(), rRanges ) )
801*cdf0e10cSrcweir 					pViewSh->SetTabNo( pFirst->aStart.Tab() );
802*cdf0e10cSrcweir 				pViewSh->DoneBlockMode();
803*cdf0e10cSrcweir 				pViewSh->InitOwnBlockMode();
804*cdf0e10cSrcweir 				pViewData->GetMarkData().MarkFromRangeList( rRanges, sal_True );
805*cdf0e10cSrcweir                 pViewSh->MarkDataChanged();
806*cdf0e10cSrcweir 				pViewData->GetDocShell()->PostPaintGridAll();	// Markierung (alt&neu)
807*cdf0e10cSrcweir 				if ( pFirst )
808*cdf0e10cSrcweir 				{
809*cdf0e10cSrcweir 					pViewSh->AlignToCursor( pFirst->aStart.Col(), pFirst->aStart.Row(),
810*cdf0e10cSrcweir 												SC_FOLLOW_JUMP );
811*cdf0e10cSrcweir 					pViewSh->SetCursor( pFirst->aStart.Col(), pFirst->aStart.Row() );
812*cdf0e10cSrcweir 				}
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir 				//!	Methode an der View, um RangeList zu selektieren
815*cdf0e10cSrcweir 			}
816*cdf0e10cSrcweir 			bRet = sal_True;
817*cdf0e10cSrcweir 		}
818*cdf0e10cSrcweir 	}
819*cdf0e10cSrcweir 	else if ( pShapeImp || xShapeColl.is() )			// Drawing-Layer
820*cdf0e10cSrcweir 	{
821*cdf0e10cSrcweir 		ScDrawView* pDrawView = pViewSh->GetScDrawView();
822*cdf0e10cSrcweir 		if (pDrawView)
823*cdf0e10cSrcweir 		{
824*cdf0e10cSrcweir 			pDrawView->ScEndTextEdit();
825*cdf0e10cSrcweir 			pDrawView->UnmarkAll();
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir 			if (pShapeImp)		// einzelnes Shape
828*cdf0e10cSrcweir 			{
829*cdf0e10cSrcweir 				SdrObject *pObj = pShapeImp->GetSdrObject();
830*cdf0e10cSrcweir 				if (pObj)
831*cdf0e10cSrcweir 				{
832*cdf0e10cSrcweir 					lcl_ShowObject( *pViewSh, *pDrawView, pObj );
833*cdf0e10cSrcweir 					SdrPageView* pPV = pDrawView->GetSdrPageView();
834*cdf0e10cSrcweir 					if ( pPV && pObj->GetPage() == pPV->GetPage() )
835*cdf0e10cSrcweir 					{
836*cdf0e10cSrcweir 						pDrawView->MarkObj( pObj, pPV );
837*cdf0e10cSrcweir 						bRet = sal_True;
838*cdf0e10cSrcweir 					}
839*cdf0e10cSrcweir 				}
840*cdf0e10cSrcweir 			}
841*cdf0e10cSrcweir 			else				// Shape-Collection (xShapeColl ist nicht 0)
842*cdf0e10cSrcweir 			{
843*cdf0e10cSrcweir 				//	Es wird auf die Tabelle des ersten Objekts umgeschaltet,
844*cdf0e10cSrcweir 				//	und alle Objekte selektiert, die auf dieser Tabelle liegen
845*cdf0e10cSrcweir 				//!	Exception, wenn Objekte auf verschiedenen Tabellen?
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 				SdrPageView* pPV = NULL;
848*cdf0e10cSrcweir 				long nCount = xShapeColl->getCount();
849*cdf0e10cSrcweir 				if (nCount)
850*cdf0e10cSrcweir 				{
851*cdf0e10cSrcweir                     sal_Bool bAllMarked(sal_True);
852*cdf0e10cSrcweir 					for ( long i = 0; i < nCount; i++ )
853*cdf0e10cSrcweir 					{
854*cdf0e10cSrcweir                         uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
855*cdf0e10cSrcweir 						if (xShapeInt.is())
856*cdf0e10cSrcweir 						{
857*cdf0e10cSrcweir 							SvxShape* pShape = SvxShape::getImplementation( xShapeInt );
858*cdf0e10cSrcweir 							if (pShape)
859*cdf0e10cSrcweir 							{
860*cdf0e10cSrcweir 								SdrObject *pObj = pShape->GetSdrObject();
861*cdf0e10cSrcweir 								if (pObj)
862*cdf0e10cSrcweir 								{
863*cdf0e10cSrcweir 									if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
864*cdf0e10cSrcweir 									{
865*cdf0e10cSrcweir 										pViewSh->SetDrawSelMode(sal_True);
866*cdf0e10cSrcweir 										pViewSh->UpdateLayerLocks();
867*cdf0e10cSrcweir 										bDrawSelModeSet = sal_True;
868*cdf0e10cSrcweir 									}
869*cdf0e10cSrcweir 									if (!pPV)				// erstes Objekt
870*cdf0e10cSrcweir 									{
871*cdf0e10cSrcweir 										lcl_ShowObject( *pViewSh, *pDrawView, pObj );
872*cdf0e10cSrcweir 										pPV = pDrawView->GetSdrPageView();
873*cdf0e10cSrcweir 									}
874*cdf0e10cSrcweir 									if ( pPV && pObj->GetPage() == pPV->GetPage() )
875*cdf0e10cSrcweir 									{
876*cdf0e10cSrcweir                                         if (pDrawView->IsObjMarkable( pObj, pPV ))
877*cdf0e10cSrcweir 										    pDrawView->MarkObj( pObj, pPV );
878*cdf0e10cSrcweir                                         else
879*cdf0e10cSrcweir                                             bAllMarked = sal_False;
880*cdf0e10cSrcweir 									}
881*cdf0e10cSrcweir 								}
882*cdf0e10cSrcweir 							}
883*cdf0e10cSrcweir 						}
884*cdf0e10cSrcweir 					}
885*cdf0e10cSrcweir                     if (bAllMarked)
886*cdf0e10cSrcweir                         bRet = sal_True;
887*cdf0e10cSrcweir 				}
888*cdf0e10cSrcweir 				else
889*cdf0e10cSrcweir 					bRet = sal_True; // empty XShapes (all shapes are deselected)
890*cdf0e10cSrcweir 			}
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir 			if (bRet)
893*cdf0e10cSrcweir 				pViewSh->SetDrawShell(sal_True);
894*cdf0e10cSrcweir 		}
895*cdf0e10cSrcweir 	}
896*cdf0e10cSrcweir 
897*cdf0e10cSrcweir 	if (!bRet)
898*cdf0e10cSrcweir 		throw lang::IllegalArgumentException();
899*cdf0e10cSrcweir 
900*cdf0e10cSrcweir 	return bRet;
901*cdf0e10cSrcweir }
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir uno::Any SAL_CALL ScTabViewObj::getSelection() throw(uno::RuntimeException)
904*cdf0e10cSrcweir {
905*cdf0e10cSrcweir 	ScUnoGuard aGuard;
906*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
907*cdf0e10cSrcweir 	ScCellRangesBase* pObj = NULL;
908*cdf0e10cSrcweir 	if (pViewSh)
909*cdf0e10cSrcweir 	{
910*cdf0e10cSrcweir 		//	Ist auf dem Drawing-Layer etwas selektiert?
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 		SdrView* pDrawView = pViewSh->GetSdrView();
913*cdf0e10cSrcweir 		if (pDrawView)
914*cdf0e10cSrcweir 		{
915*cdf0e10cSrcweir 			const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
916*cdf0e10cSrcweir 			sal_uLong nMarkCount = rMarkList.GetMarkCount();
917*cdf0e10cSrcweir 			if (nMarkCount)
918*cdf0e10cSrcweir 			{
919*cdf0e10cSrcweir 				//	ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw)
920*cdf0e10cSrcweir 				//	Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein
921*cdf0e10cSrcweir 
922*cdf0e10cSrcweir 				SvxShapeCollection* pShapes = new SvxShapeCollection();
923*cdf0e10cSrcweir 				uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pShapes));
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 				for (sal_uLong i=0; i<nMarkCount; i++)
926*cdf0e10cSrcweir 				{
927*cdf0e10cSrcweir 					SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
928*cdf0e10cSrcweir 					if (pDrawObj)
929*cdf0e10cSrcweir 					{
930*cdf0e10cSrcweir 						uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
931*cdf0e10cSrcweir 						if (xShape.is())
932*cdf0e10cSrcweir 							pShapes->add(xShape);
933*cdf0e10cSrcweir 					}
934*cdf0e10cSrcweir 				}
935*cdf0e10cSrcweir                 return uno::makeAny(xRet);
936*cdf0e10cSrcweir 			}
937*cdf0e10cSrcweir 		}
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 		//	sonst Tabellen-(Zellen-)Selektion
940*cdf0e10cSrcweir 
941*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
942*cdf0e10cSrcweir 		ScDocShell* pDocSh = pViewData->GetDocShell();
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 		const ScMarkData& rMark = pViewData->GetMarkData();
945*cdf0e10cSrcweir 		SCTAB nTabs = rMark.GetSelectCount();
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir 		ScRange aRange;
948*cdf0e10cSrcweir         ScMarkType eMarkType = pViewData->GetSimpleArea(aRange);
949*cdf0e10cSrcweir 		if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
950*cdf0e10cSrcweir 		{
951*cdf0e10cSrcweir 			if (aRange.aStart == aRange.aEnd)
952*cdf0e10cSrcweir 				pObj = new ScCellObj( pDocSh, aRange.aStart );
953*cdf0e10cSrcweir 			else
954*cdf0e10cSrcweir 				pObj = new ScCellRangeObj( pDocSh, aRange );
955*cdf0e10cSrcweir 		}
956*cdf0e10cSrcweir         else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
957*cdf0e10cSrcweir         {
958*cdf0e10cSrcweir             ScMarkData aFilteredMark( rMark );
959*cdf0e10cSrcweir             ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
960*cdf0e10cSrcweir 			ScRangeList aRangeList;
961*cdf0e10cSrcweir             aFilteredMark.FillRangeListWithMarks( &aRangeList, sal_False);
962*cdf0e10cSrcweir             // Theoretically a selection may start and end on a filtered row.
963*cdf0e10cSrcweir             switch (aRangeList.Count())
964*cdf0e10cSrcweir             {
965*cdf0e10cSrcweir                 case 0:
966*cdf0e10cSrcweir                     // No unfiltered row, we have to return some object, so
967*cdf0e10cSrcweir                     // here is one with no ranges.
968*cdf0e10cSrcweir                     pObj = new ScCellRangesObj( pDocSh, aRangeList );
969*cdf0e10cSrcweir                     break;
970*cdf0e10cSrcweir                 case 1:
971*cdf0e10cSrcweir                     {
972*cdf0e10cSrcweir                         const ScRange& rRange = *(aRangeList.GetObject(0));
973*cdf0e10cSrcweir                         if (rRange.aStart == rRange.aEnd)
974*cdf0e10cSrcweir                             pObj = new ScCellObj( pDocSh, rRange.aStart );
975*cdf0e10cSrcweir                         else
976*cdf0e10cSrcweir                             pObj = new ScCellRangeObj( pDocSh, rRange );
977*cdf0e10cSrcweir                     }
978*cdf0e10cSrcweir                     break;
979*cdf0e10cSrcweir                 default:
980*cdf0e10cSrcweir                     pObj = new ScCellRangesObj( pDocSh, aRangeList );
981*cdf0e10cSrcweir             }
982*cdf0e10cSrcweir         }
983*cdf0e10cSrcweir 		else			//	Mehrfachselektion
984*cdf0e10cSrcweir 		{
985*cdf0e10cSrcweir 			ScRangeListRef xRanges;
986*cdf0e10cSrcweir 			pViewData->GetMultiArea( xRanges );
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 			//	bei mehreren Tabellen Ranges kopieren
989*cdf0e10cSrcweir 			//!	sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren?
990*cdf0e10cSrcweir 			if ( nTabs > 1 )
991*cdf0e10cSrcweir 				rMark.ExtendRangeListTables( xRanges );
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir 			pObj = new ScCellRangesObj( pDocSh, *xRanges );
994*cdf0e10cSrcweir 		}
995*cdf0e10cSrcweir 
996*cdf0e10cSrcweir 		if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
997*cdf0e10cSrcweir 		{
998*cdf0e10cSrcweir 			//	remember if the selection was from the cursor position without anything selected
999*cdf0e10cSrcweir 			//	(used when rendering the selection)
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir 			pObj->SetCursorOnly( sal_True );
1002*cdf0e10cSrcweir 		}
1003*cdf0e10cSrcweir 	}
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir     return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
1006*cdf0e10cSrcweir }
1007*cdf0e10cSrcweir 
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir #if 0
1010*cdf0e10cSrcweir // XPrintable
1011*cdf0e10cSrcweir 
1012*cdf0e10cSrcweir rtl::OUString ScTabViewObj::getPrinterName(void) const
1013*cdf0e10cSrcweir {
1014*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1015*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1016*cdf0e10cSrcweir 	if (pViewSh)
1017*cdf0e10cSrcweir 	{
1018*cdf0e10cSrcweir 		SfxPrinter* pPrinter = pViewSh->GetPrinter(sal_True);
1019*cdf0e10cSrcweir 		if (pPrinter)
1020*cdf0e10cSrcweir 			return pPrinter->GetName();
1021*cdf0e10cSrcweir 	}
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir 	DBG_ERROR("getPrinterName: keine View oder kein Printer");
1024*cdf0e10cSrcweir 	return rtl::OUString();
1025*cdf0e10cSrcweir }
1026*cdf0e10cSrcweir 
1027*cdf0e10cSrcweir void ScTabViewObj::setPrinterName(const rtl::OUString& PrinterName)
1028*cdf0e10cSrcweir {
1029*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1030*cdf0e10cSrcweir 	//	Drucker setzen - wie in SfxViewShell::ExecPrint_Impl
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1033*cdf0e10cSrcweir 	if (pViewSh)
1034*cdf0e10cSrcweir 	{
1035*cdf0e10cSrcweir 		SfxPrinter* pPrinter = pViewSh->GetPrinter(sal_True);
1036*cdf0e10cSrcweir 		if (pPrinter)
1037*cdf0e10cSrcweir 		{
1038*cdf0e10cSrcweir 			String aString(PrinterName);
1039*cdf0e10cSrcweir 			SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString );
1040*cdf0e10cSrcweir 			if (pNewPrinter->IsKnown())
1041*cdf0e10cSrcweir 				pViewSh->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
1042*cdf0e10cSrcweir 			else
1043*cdf0e10cSrcweir 				delete pNewPrinter;
1044*cdf0e10cSrcweir 		}
1045*cdf0e10cSrcweir 	}
1046*cdf0e10cSrcweir }
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir XPropertySetRef ScTabViewObj::createPrintOptions(void)
1049*cdf0e10cSrcweir {
1050*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1051*cdf0e10cSrcweir 	return new ScPrintSettingsObj;		//! ScPrintSettingsObj implementieren!
1052*cdf0e10cSrcweir }
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir void ScTabViewObj::print(const XPropertySetRef& xOptions)
1055*cdf0e10cSrcweir {
1056*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1057*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1058*cdf0e10cSrcweir 	if (pViewSh)
1059*cdf0e10cSrcweir 	{
1060*cdf0e10cSrcweir 		//!	xOptions auswerten (wie denn?)
1061*cdf0e10cSrcweir 
1062*cdf0e10cSrcweir 		SfxRequest aReq( SID_PRINTDOCDIRECT, SFX_CALLMODE_SYNCHRON, pViewSh->GetPool() );
1063*cdf0e10cSrcweir 		pViewSh->ExecuteSlot( aReq );
1064*cdf0e10cSrcweir 	}
1065*cdf0e10cSrcweir }
1066*cdf0e10cSrcweir #endif
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir // XEnumerationAccess
1069*cdf0e10cSrcweir 
1070*cdf0e10cSrcweir uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
1071*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1072*cdf0e10cSrcweir {
1073*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1074*cdf0e10cSrcweir     return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetViewPanesEnumeration")));
1075*cdf0e10cSrcweir }
1076*cdf0e10cSrcweir 
1077*cdf0e10cSrcweir // XIndexAccess
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTabViewObj::getCount() throw(uno::RuntimeException)
1080*cdf0e10cSrcweir {
1081*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1082*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1083*cdf0e10cSrcweir 	sal_uInt16 nPanes = 0;
1084*cdf0e10cSrcweir 	if (pViewSh)
1085*cdf0e10cSrcweir 	{
1086*cdf0e10cSrcweir 		nPanes = 1;
1087*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1088*cdf0e10cSrcweir 		if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1089*cdf0e10cSrcweir 			nPanes *= 2;
1090*cdf0e10cSrcweir 		if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1091*cdf0e10cSrcweir 			nPanes *= 2;
1092*cdf0e10cSrcweir 	}
1093*cdf0e10cSrcweir 	return nPanes;
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
1097*cdf0e10cSrcweir 							throw(lang::IndexOutOfBoundsException,
1098*cdf0e10cSrcweir 									lang::WrappedTargetException, uno::RuntimeException)
1099*cdf0e10cSrcweir {
1100*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1101*cdf0e10cSrcweir 	uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((sal_uInt16)nIndex));
1102*cdf0e10cSrcweir 	if (xPane.is())
1103*cdf0e10cSrcweir         return uno::makeAny(xPane);
1104*cdf0e10cSrcweir 	else
1105*cdf0e10cSrcweir 		throw lang::IndexOutOfBoundsException();
1106*cdf0e10cSrcweir //    return uno::Any();
1107*cdf0e10cSrcweir }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir uno::Type SAL_CALL ScTabViewObj::getElementType() throw(uno::RuntimeException)
1110*cdf0e10cSrcweir {
1111*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1112*cdf0e10cSrcweir 	return getCppuType((uno::Reference<sheet::XViewPane>*)0);
1113*cdf0e10cSrcweir }
1114*cdf0e10cSrcweir 
1115*cdf0e10cSrcweir sal_Bool SAL_CALL ScTabViewObj::hasElements() throw(uno::RuntimeException)
1116*cdf0e10cSrcweir {
1117*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1118*cdf0e10cSrcweir 	return ( getCount() != 0 );
1119*cdf0e10cSrcweir }
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir // XSpreadsheetView
1122*cdf0e10cSrcweir 
1123*cdf0e10cSrcweir ScViewPaneObj* ScTabViewObj::GetObjectByIndex_Impl(sal_uInt16 nIndex) const
1124*cdf0e10cSrcweir {
1125*cdf0e10cSrcweir 	static ScSplitPos ePosHV[4] =
1126*cdf0e10cSrcweir 		{ SC_SPLIT_TOPLEFT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMRIGHT };
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1129*cdf0e10cSrcweir 	if (pViewSh)
1130*cdf0e10cSrcweir 	{
1131*cdf0e10cSrcweir 		ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT;	// default Position
1132*cdf0e10cSrcweir 		sal_Bool bError = sal_False;
1133*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1134*cdf0e10cSrcweir 		sal_Bool bHor = ( pViewData->GetHSplitMode() != SC_SPLIT_NONE );
1135*cdf0e10cSrcweir 		sal_Bool bVer = ( pViewData->GetVSplitMode() != SC_SPLIT_NONE );
1136*cdf0e10cSrcweir 		if ( bHor && bVer )
1137*cdf0e10cSrcweir 		{
1138*cdf0e10cSrcweir 			//	links oben, links unten, rechts oben, rechts unten - wie in Excel
1139*cdf0e10cSrcweir 			if ( nIndex < 4 )
1140*cdf0e10cSrcweir 				eWhich = ePosHV[nIndex];
1141*cdf0e10cSrcweir 			else
1142*cdf0e10cSrcweir 				bError = sal_True;
1143*cdf0e10cSrcweir 		}
1144*cdf0e10cSrcweir 		else if ( bHor )
1145*cdf0e10cSrcweir 		{
1146*cdf0e10cSrcweir 			if ( nIndex > 1 )
1147*cdf0e10cSrcweir 				bError = sal_True;
1148*cdf0e10cSrcweir 			else if ( nIndex == 1 )
1149*cdf0e10cSrcweir 				eWhich = SC_SPLIT_BOTTOMRIGHT;
1150*cdf0e10cSrcweir 			// sonst SC_SPLIT_BOTTOMLEFT
1151*cdf0e10cSrcweir 		}
1152*cdf0e10cSrcweir 		else if ( bVer )
1153*cdf0e10cSrcweir 		{
1154*cdf0e10cSrcweir 			if ( nIndex > 1 )
1155*cdf0e10cSrcweir 				bError = sal_True;
1156*cdf0e10cSrcweir 			else if ( nIndex == 0 )
1157*cdf0e10cSrcweir 				eWhich = SC_SPLIT_TOPLEFT;
1158*cdf0e10cSrcweir 			// sonst SC_SPLIT_BOTTOMLEFT
1159*cdf0e10cSrcweir 		}
1160*cdf0e10cSrcweir 		else if ( nIndex > 0 )
1161*cdf0e10cSrcweir 			bError = sal_True;			// nicht geteilt: nur 0 gueltig
1162*cdf0e10cSrcweir 
1163*cdf0e10cSrcweir 		if (!bError)
1164*cdf0e10cSrcweir             return new ScViewPaneObj( pViewSh, sal::static_int_cast<sal_uInt16>(eWhich) );
1165*cdf0e10cSrcweir 	}
1166*cdf0e10cSrcweir 
1167*cdf0e10cSrcweir 	return NULL;
1168*cdf0e10cSrcweir }
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
1171*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1172*cdf0e10cSrcweir {
1173*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1174*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1175*cdf0e10cSrcweir 	if (pViewSh)
1176*cdf0e10cSrcweir 	{
1177*cdf0e10cSrcweir 		ScViewData* pData = pViewSh->GetViewData();
1178*cdf0e10cSrcweir 		SCTAB nTab = pData->GetTabNo();
1179*cdf0e10cSrcweir 		return new ScTableSheetObj( pData->GetDocShell(), nTab );
1180*cdf0e10cSrcweir 	}
1181*cdf0e10cSrcweir 	return NULL;
1182*cdf0e10cSrcweir }
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
1185*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1186*cdf0e10cSrcweir {
1187*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1190*cdf0e10cSrcweir 	if ( pViewSh && xActiveSheet.is() )
1191*cdf0e10cSrcweir 	{
1192*cdf0e10cSrcweir 		//	XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir 		ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xActiveSheet );
1195*cdf0e10cSrcweir 		if ( pRangesImp && pViewSh->GetViewData()->GetDocShell() == pRangesImp->GetDocShell() )
1196*cdf0e10cSrcweir 		{
1197*cdf0e10cSrcweir 			const ScRangeList& rRanges = pRangesImp->GetRangeList();
1198*cdf0e10cSrcweir 			if ( rRanges.Count() == 1 )
1199*cdf0e10cSrcweir 			{
1200*cdf0e10cSrcweir 				SCTAB nNewTab = rRanges.GetObject(0)->aStart.Tab();
1201*cdf0e10cSrcweir 				if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) )
1202*cdf0e10cSrcweir 					pViewSh->SetTabNo( nNewTab );
1203*cdf0e10cSrcweir 			}
1204*cdf0e10cSrcweir 		}
1205*cdf0e10cSrcweir 	}
1206*cdf0e10cSrcweir }
1207*cdf0e10cSrcweir 
1208*cdf0e10cSrcweir uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
1209*cdf0e10cSrcweir {
1210*cdf0e10cSrcweir     uno::Reference< uno::XInterface > xTarget;
1211*cdf0e10cSrcweir     if (GetViewShell())
1212*cdf0e10cSrcweir     {
1213*cdf0e10cSrcweir         SCsCOL nX;
1214*cdf0e10cSrcweir         SCsROW nY;
1215*cdf0e10cSrcweir         ScViewData* pData = GetViewShell()->GetViewData();
1216*cdf0e10cSrcweir         ScSplitPos eSplitMode = pData->GetActivePart();
1217*cdf0e10cSrcweir         SCTAB nTab(pData->GetTabNo());
1218*cdf0e10cSrcweir 		pData->GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir         ScAddress aCellPos (nX, nY, nTab);
1221*cdf0e10cSrcweir         ScCellObj* pCellObj = new ScCellObj(pData->GetDocShell(), aCellPos);
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir         xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir         ScDocument* pDoc = pData->GetDocument();
1226*cdf0e10cSrcweir 		if (pDoc && pDoc->GetDrawLayer())
1227*cdf0e10cSrcweir 		{
1228*cdf0e10cSrcweir         	SdrPage* pDrawPage = NULL;
1229*cdf0e10cSrcweir 			ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
1230*cdf0e10cSrcweir 			if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
1231*cdf0e10cSrcweir 				pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir             SdrView* pDrawView = GetViewShell()->GetSdrView();
1234*cdf0e10cSrcweir 
1235*cdf0e10cSrcweir             if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
1236*cdf0e10cSrcweir             {
1237*cdf0e10cSrcweir                 Window* pActiveWin = pData->GetActiveWin();
1238*cdf0e10cSrcweir                 Point aPos = pActiveWin->PixelToLogic(rPoint);
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir                 sal_uInt16 nHitLog = (sal_uInt16) pActiveWin->PixelToLogic(
1241*cdf0e10cSrcweir                                  Size(pDrawView->GetHitTolerancePixel(),0)).Width();
1242*cdf0e10cSrcweir 
1243*cdf0e10cSrcweir 		        sal_uInt32 nCount(pDrawPage->GetObjCount());
1244*cdf0e10cSrcweir                 sal_Bool bFound(sal_False);
1245*cdf0e10cSrcweir                 sal_uInt32 i(0);
1246*cdf0e10cSrcweir 		        while (i < nCount && !bFound)
1247*cdf0e10cSrcweir 		        {
1248*cdf0e10cSrcweir 			        SdrObject* pObj = pDrawPage->GetObj(i);
1249*cdf0e10cSrcweir                     if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), 0, false))
1250*cdf0e10cSrcweir 			        {
1251*cdf0e10cSrcweir                         xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
1252*cdf0e10cSrcweir                         bFound = sal_True;
1253*cdf0e10cSrcweir                     }
1254*cdf0e10cSrcweir                     ++i;
1255*cdf0e10cSrcweir                 }
1256*cdf0e10cSrcweir             }
1257*cdf0e10cSrcweir         }
1258*cdf0e10cSrcweir     }
1259*cdf0e10cSrcweir     return xTarget;
1260*cdf0e10cSrcweir }
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir bool ScTabViewObj::IsMouseListening() const
1263*cdf0e10cSrcweir {
1264*cdf0e10cSrcweir     if ( aMouseClickHandlers.Count() > 0 )
1265*cdf0e10cSrcweir         return true;
1266*cdf0e10cSrcweir 
1267*cdf0e10cSrcweir     // also include sheet events, because MousePressed must be called for them
1268*cdf0e10cSrcweir     ScViewData* pViewData = GetViewShell()->GetViewData();
1269*cdf0e10cSrcweir     ScDocument* pDoc = pViewData->GetDocument();
1270*cdf0e10cSrcweir     SCTAB nTab = pViewData->GetTabNo();
1271*cdf0e10cSrcweir     return
1272*cdf0e10cSrcweir         pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) ||
1273*cdf0e10cSrcweir         pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true );
1274*cdf0e10cSrcweir }
1275*cdf0e10cSrcweir 
1276*cdf0e10cSrcweir sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
1277*cdf0e10cSrcweir                                     throw (::uno::RuntimeException)
1278*cdf0e10cSrcweir {
1279*cdf0e10cSrcweir     sal_Bool bReturn(sal_False);
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir     uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1282*cdf0e10cSrcweir     if (aMouseClickHandlers.Count() && xTarget.is())
1283*cdf0e10cSrcweir     {
1284*cdf0e10cSrcweir         awt::EnhancedMouseEvent aMouseEvent;
1285*cdf0e10cSrcweir 
1286*cdf0e10cSrcweir         aMouseEvent.Buttons = e.Buttons;
1287*cdf0e10cSrcweir         aMouseEvent.X = e.X;
1288*cdf0e10cSrcweir         aMouseEvent.Y = e.Y;
1289*cdf0e10cSrcweir         aMouseEvent.ClickCount = e.ClickCount;
1290*cdf0e10cSrcweir         aMouseEvent.PopupTrigger = e.PopupTrigger;
1291*cdf0e10cSrcweir         aMouseEvent.Target = xTarget;
1292*cdf0e10cSrcweir 
1293*cdf0e10cSrcweir         for ( sal_uInt16 n=0; n<aMouseClickHandlers.Count(); n++ )
1294*cdf0e10cSrcweir         {
1295*cdf0e10cSrcweir             try
1296*cdf0e10cSrcweir             {
1297*cdf0e10cSrcweir                 if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent ))
1298*cdf0e10cSrcweir                     bReturn = sal_True;
1299*cdf0e10cSrcweir             }
1300*cdf0e10cSrcweir             catch ( uno::Exception& )
1301*cdf0e10cSrcweir             {
1302*cdf0e10cSrcweir                 aMouseClickHandlers.DeleteAndDestroy(n);
1303*cdf0e10cSrcweir                 --n; // because it will be increased again in the loop
1304*cdf0e10cSrcweir             }
1305*cdf0e10cSrcweir         }
1306*cdf0e10cSrcweir     }
1307*cdf0e10cSrcweir 
1308*cdf0e10cSrcweir     // handle sheet events
1309*cdf0e10cSrcweir     bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
1310*cdf0e10cSrcweir     bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
1311*cdf0e10cSrcweir     if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
1312*cdf0e10cSrcweir     {
1313*cdf0e10cSrcweir         sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK;
1314*cdf0e10cSrcweir 
1315*cdf0e10cSrcweir         ScTabViewShell* pViewSh = GetViewShell();
1316*cdf0e10cSrcweir         ScViewData* pViewData = pViewSh->GetViewData();
1317*cdf0e10cSrcweir         ScDocShell* pDocSh = pViewData->GetDocShell();
1318*cdf0e10cSrcweir         ScDocument* pDoc = pDocSh->GetDocument();
1319*cdf0e10cSrcweir         SCTAB nTab = pViewData->GetTabNo();
1320*cdf0e10cSrcweir         const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
1321*cdf0e10cSrcweir         if (pEvents)
1322*cdf0e10cSrcweir         {
1323*cdf0e10cSrcweir             const rtl::OUString* pScript = pEvents->GetScript(nEvent);
1324*cdf0e10cSrcweir             if (pScript)
1325*cdf0e10cSrcweir             {
1326*cdf0e10cSrcweir                 // the macro parameter is the clicked object, as in the mousePressed call above
1327*cdf0e10cSrcweir                 uno::Sequence<uno::Any> aParams(1);
1328*cdf0e10cSrcweir                 aParams[0] <<= xTarget;
1329*cdf0e10cSrcweir 
1330*cdf0e10cSrcweir                 uno::Any aRet;
1331*cdf0e10cSrcweir                 uno::Sequence<sal_Int16> aOutArgsIndex;
1332*cdf0e10cSrcweir                 uno::Sequence<uno::Any> aOutArgs;
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir                 /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1335*cdf0e10cSrcweir 
1336*cdf0e10cSrcweir                 // look for a boolean return value of true
1337*cdf0e10cSrcweir                 sal_Bool bRetValue = sal_False;
1338*cdf0e10cSrcweir                 if (aRet >>= bRetValue)
1339*cdf0e10cSrcweir                 {
1340*cdf0e10cSrcweir                     if (bRetValue)
1341*cdf0e10cSrcweir                         bReturn = sal_True;
1342*cdf0e10cSrcweir                 }
1343*cdf0e10cSrcweir             }
1344*cdf0e10cSrcweir         }
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir         // execute VBA event handler
1347*cdf0e10cSrcweir         if (!bReturn && xTarget.is()) try
1348*cdf0e10cSrcweir         {
1349*cdf0e10cSrcweir             uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
1350*cdf0e10cSrcweir             // the parameter is the clicked object, as in the mousePressed call above
1351*cdf0e10cSrcweir             uno::Sequence< uno::Any > aArgs( 1 );
1352*cdf0e10cSrcweir             aArgs[ 0 ] <<= xTarget;
1353*cdf0e10cSrcweir             xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
1354*cdf0e10cSrcweir         }
1355*cdf0e10cSrcweir         catch( util::VetoException& )
1356*cdf0e10cSrcweir         {
1357*cdf0e10cSrcweir             bReturn = sal_True;
1358*cdf0e10cSrcweir         }
1359*cdf0e10cSrcweir         catch( uno::Exception& )
1360*cdf0e10cSrcweir         {
1361*cdf0e10cSrcweir         }
1362*cdf0e10cSrcweir     }
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir     return bReturn;
1365*cdf0e10cSrcweir }
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
1368*cdf0e10cSrcweir                                     throw (uno::RuntimeException)
1369*cdf0e10cSrcweir {
1370*cdf0e10cSrcweir     sal_Bool bReturn(sal_False);
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir     if (aMouseClickHandlers.Count())
1373*cdf0e10cSrcweir     {
1374*cdf0e10cSrcweir         uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir         if (xTarget.is())
1377*cdf0e10cSrcweir         {
1378*cdf0e10cSrcweir             awt::EnhancedMouseEvent aMouseEvent;
1379*cdf0e10cSrcweir 
1380*cdf0e10cSrcweir             aMouseEvent.Buttons = e.Buttons;
1381*cdf0e10cSrcweir             aMouseEvent.X = e.X;
1382*cdf0e10cSrcweir             aMouseEvent.Y = e.Y;
1383*cdf0e10cSrcweir             aMouseEvent.ClickCount = e.ClickCount;
1384*cdf0e10cSrcweir             aMouseEvent.PopupTrigger = e.PopupTrigger;
1385*cdf0e10cSrcweir             aMouseEvent.Target = xTarget;
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir 	        for ( sal_uInt16 n=0; n<aMouseClickHandlers.Count(); n++ )
1388*cdf0e10cSrcweir             {
1389*cdf0e10cSrcweir                 try
1390*cdf0e10cSrcweir                 {
1391*cdf0e10cSrcweir                     if (!(*aMouseClickHandlers[n])->mouseReleased( aMouseEvent ))
1392*cdf0e10cSrcweir                         bReturn = sal_True;
1393*cdf0e10cSrcweir                 }
1394*cdf0e10cSrcweir                 catch ( uno::Exception& )
1395*cdf0e10cSrcweir                 {
1396*cdf0e10cSrcweir                     aMouseClickHandlers.DeleteAndDestroy(n);
1397*cdf0e10cSrcweir                     --n; // because it will be increased again in the loop
1398*cdf0e10cSrcweir                 }
1399*cdf0e10cSrcweir             }
1400*cdf0e10cSrcweir         }
1401*cdf0e10cSrcweir     }
1402*cdf0e10cSrcweir     return bReturn;
1403*cdf0e10cSrcweir }
1404*cdf0e10cSrcweir 
1405*cdf0e10cSrcweir // XEnhancedMouseClickBroadcaster
1406*cdf0e10cSrcweir 
1407*cdf0e10cSrcweir void ScTabViewObj::StartMouseListening()
1408*cdf0e10cSrcweir {
1409*cdf0e10cSrcweir }
1410*cdf0e10cSrcweir 
1411*cdf0e10cSrcweir void ScTabViewObj::EndMouseListening()
1412*cdf0e10cSrcweir {
1413*cdf0e10cSrcweir     sal_uInt16 nCount(aMouseClickHandlers.Count());
1414*cdf0e10cSrcweir     lang::EventObject aEvent;
1415*cdf0e10cSrcweir     aEvent.Source = (cppu::OWeakObject*)this;
1416*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<nCount; n++ )
1417*cdf0e10cSrcweir     {
1418*cdf0e10cSrcweir         try
1419*cdf0e10cSrcweir         {
1420*cdf0e10cSrcweir             (*aMouseClickHandlers[n])->disposing(aEvent);
1421*cdf0e10cSrcweir         }
1422*cdf0e10cSrcweir         catch ( uno::Exception& )
1423*cdf0e10cSrcweir         {
1424*cdf0e10cSrcweir         }
1425*cdf0e10cSrcweir     }
1426*cdf0e10cSrcweir     aMouseClickHandlers.DeleteAndDestroy(0, nCount);
1427*cdf0e10cSrcweir }
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir void ScTabViewObj::StartActivationListening()
1430*cdf0e10cSrcweir {
1431*cdf0e10cSrcweir }
1432*cdf0e10cSrcweir 
1433*cdf0e10cSrcweir void ScTabViewObj::EndActivationListening()
1434*cdf0e10cSrcweir {
1435*cdf0e10cSrcweir     sal_uInt16 nCount = aActivationListeners.Count();
1436*cdf0e10cSrcweir     lang::EventObject aEvent;
1437*cdf0e10cSrcweir     aEvent.Source = (cppu::OWeakObject*)this;
1438*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<nCount; n++ )
1439*cdf0e10cSrcweir     {
1440*cdf0e10cSrcweir         try
1441*cdf0e10cSrcweir         {
1442*cdf0e10cSrcweir             (*aActivationListeners[n])->disposing(aEvent);
1443*cdf0e10cSrcweir         }
1444*cdf0e10cSrcweir         catch ( uno::Exception& )
1445*cdf0e10cSrcweir         {
1446*cdf0e10cSrcweir         }
1447*cdf0e10cSrcweir     }
1448*cdf0e10cSrcweir     aActivationListeners.DeleteAndDestroy(0, nCount);
1449*cdf0e10cSrcweir }
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1452*cdf0e10cSrcweir                                     throw (uno::RuntimeException)
1453*cdf0e10cSrcweir {
1454*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1455*cdf0e10cSrcweir 
1456*cdf0e10cSrcweir     if (aListener.is())
1457*cdf0e10cSrcweir     {
1458*cdf0e10cSrcweir 	    sal_uInt16 nCount = aMouseClickHandlers.Count();
1459*cdf0e10cSrcweir 	    uno::Reference<awt::XEnhancedMouseClickHandler> *pObj =
1460*cdf0e10cSrcweir 			    new uno::Reference<awt::XEnhancedMouseClickHandler>( aListener );
1461*cdf0e10cSrcweir 	    aMouseClickHandlers.Insert( pObj, nCount );
1462*cdf0e10cSrcweir 
1463*cdf0e10cSrcweir         if (aMouseClickHandlers.Count() == 1 && nCount == 0) // only if a listener added
1464*cdf0e10cSrcweir             StartMouseListening();
1465*cdf0e10cSrcweir     }
1466*cdf0e10cSrcweir }
1467*cdf0e10cSrcweir 
1468*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
1469*cdf0e10cSrcweir                                     throw (uno::RuntimeException)
1470*cdf0e10cSrcweir {
1471*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1472*cdf0e10cSrcweir 	sal_uInt16 nCount = aMouseClickHandlers.Count();
1473*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
1474*cdf0e10cSrcweir 	{
1475*cdf0e10cSrcweir 		uno::Reference<awt::XEnhancedMouseClickHandler> *pObj = aMouseClickHandlers[n];
1476*cdf0e10cSrcweir 		if ( *pObj == aListener )
1477*cdf0e10cSrcweir 			aMouseClickHandlers.DeleteAndDestroy( n );
1478*cdf0e10cSrcweir 	}
1479*cdf0e10cSrcweir     if ((aMouseClickHandlers.Count() == 0) && (nCount > 0)) // only if last listener removed
1480*cdf0e10cSrcweir         EndMouseListening();
1481*cdf0e10cSrcweir }
1482*cdf0e10cSrcweir 
1483*cdf0e10cSrcweir // XActivationBroadcaster
1484*cdf0e10cSrcweir 
1485*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1486*cdf0e10cSrcweir                                     throw (uno::RuntimeException)
1487*cdf0e10cSrcweir {
1488*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1489*cdf0e10cSrcweir 
1490*cdf0e10cSrcweir     if (aListener.is())
1491*cdf0e10cSrcweir     {
1492*cdf0e10cSrcweir 	    sal_uInt16 nCount = aActivationListeners.Count();
1493*cdf0e10cSrcweir 	    uno::Reference<sheet::XActivationEventListener> *pObj =
1494*cdf0e10cSrcweir 			    new uno::Reference<sheet::XActivationEventListener>( aListener );
1495*cdf0e10cSrcweir 	    aActivationListeners.Insert( pObj, nCount );
1496*cdf0e10cSrcweir 
1497*cdf0e10cSrcweir         if (aActivationListeners.Count() == 1 && nCount == 0) // only if a listener added
1498*cdf0e10cSrcweir             StartActivationListening();
1499*cdf0e10cSrcweir     }
1500*cdf0e10cSrcweir }
1501*cdf0e10cSrcweir 
1502*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
1503*cdf0e10cSrcweir                                     throw (uno::RuntimeException)
1504*cdf0e10cSrcweir {
1505*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1506*cdf0e10cSrcweir 	sal_uInt16 nCount = aActivationListeners.Count();
1507*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
1508*cdf0e10cSrcweir 	{
1509*cdf0e10cSrcweir 		uno::Reference<sheet::XActivationEventListener> *pObj = aActivationListeners[n];
1510*cdf0e10cSrcweir 		if ( *pObj == aListener )
1511*cdf0e10cSrcweir 			aActivationListeners.DeleteAndDestroy( n );
1512*cdf0e10cSrcweir 	}
1513*cdf0e10cSrcweir     if ((aActivationListeners.Count() == 0) && (nCount > 0)) // only if last listener removed
1514*cdf0e10cSrcweir         EndActivationListening();
1515*cdf0e10cSrcweir }
1516*cdf0e10cSrcweir 
1517*cdf0e10cSrcweir //	PageBreakMode / Zoom sind Properties
1518*cdf0e10cSrcweir 
1519*cdf0e10cSrcweir #if 0
1520*cdf0e10cSrcweir 
1521*cdf0e10cSrcweir sal_Bool ScTabViewObj::getPagebreakMode(void) const
1522*cdf0e10cSrcweir {
1523*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1524*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1525*cdf0e10cSrcweir 	if (pViewSh)
1526*cdf0e10cSrcweir 		return pViewSh->GetViewData()->IsPagebreakMode();
1527*cdf0e10cSrcweir 	return sal_False;
1528*cdf0e10cSrcweir }
1529*cdf0e10cSrcweir 
1530*cdf0e10cSrcweir void ScTabViewObj::setPagebreakMode(sal_Bool PagebreakMode)
1531*cdf0e10cSrcweir {
1532*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1533*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1534*cdf0e10cSrcweir 	if (pViewSh)
1535*cdf0e10cSrcweir 		pViewSh->SetPagebreakMode(PagebreakMode);
1536*cdf0e10cSrcweir }
1537*cdf0e10cSrcweir 
1538*cdf0e10cSrcweir #endif
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir sal_Int16 ScTabViewObj::GetZoom(void) const
1541*cdf0e10cSrcweir {
1542*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1543*cdf0e10cSrcweir 	if (pViewSh)
1544*cdf0e10cSrcweir 	{
1545*cdf0e10cSrcweir 		const Fraction& rZoomY = pViewSh->GetViewData()->GetZoomY();	// Y wird angezeigt
1546*cdf0e10cSrcweir 		return (sal_Int16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator());
1547*cdf0e10cSrcweir 	}
1548*cdf0e10cSrcweir 	return 0;
1549*cdf0e10cSrcweir }
1550*cdf0e10cSrcweir 
1551*cdf0e10cSrcweir void ScTabViewObj::SetZoom(sal_Int16 nZoom)
1552*cdf0e10cSrcweir {
1553*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1554*cdf0e10cSrcweir 	if (pViewSh)
1555*cdf0e10cSrcweir 	{
1556*cdf0e10cSrcweir 		if ( nZoom != GetZoom() && nZoom != 0 )
1557*cdf0e10cSrcweir 		{
1558*cdf0e10cSrcweir 			if (!pViewSh->GetViewData()->IsPagebreakMode())
1559*cdf0e10cSrcweir 			{
1560*cdf0e10cSrcweir 				ScModule* pScMod = SC_MOD();
1561*cdf0e10cSrcweir 				ScAppOptions aNewOpt(pScMod->GetAppOptions());
1562*cdf0e10cSrcweir 				aNewOpt.SetZoom( nZoom );
1563*cdf0e10cSrcweir 				aNewOpt.SetZoomType( pViewSh->GetViewData()->GetView()->GetZoomType() );
1564*cdf0e10cSrcweir 				pScMod->SetAppOptions( aNewOpt );
1565*cdf0e10cSrcweir 			}
1566*cdf0e10cSrcweir 		}
1567*cdf0e10cSrcweir 		Fraction aFract( nZoom, 100 );
1568*cdf0e10cSrcweir         pViewSh->SetZoom( aFract, aFract, sal_True );
1569*cdf0e10cSrcweir 		pViewSh->PaintGrid();
1570*cdf0e10cSrcweir 		pViewSh->PaintTop();
1571*cdf0e10cSrcweir 		pViewSh->PaintLeft();
1572*cdf0e10cSrcweir 		pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1573*cdf0e10cSrcweir         pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1574*cdf0e10cSrcweir 	}
1575*cdf0e10cSrcweir }
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir sal_Int16 ScTabViewObj::GetZoomType(void) const
1578*cdf0e10cSrcweir {
1579*cdf0e10cSrcweir     sal_Int16 aZoomType = view::DocumentZoomType::OPTIMAL;
1580*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1581*cdf0e10cSrcweir 	if (pViewSh)
1582*cdf0e10cSrcweir 	{
1583*cdf0e10cSrcweir         SvxZoomType eZoomType = pViewSh->GetViewData()->GetView()->GetZoomType();
1584*cdf0e10cSrcweir         switch (eZoomType)
1585*cdf0e10cSrcweir         {
1586*cdf0e10cSrcweir         case SVX_ZOOM_PERCENT:
1587*cdf0e10cSrcweir             aZoomType = view::DocumentZoomType::BY_VALUE;
1588*cdf0e10cSrcweir             break;
1589*cdf0e10cSrcweir         case SVX_ZOOM_OPTIMAL:
1590*cdf0e10cSrcweir             aZoomType = view::DocumentZoomType::OPTIMAL;
1591*cdf0e10cSrcweir             break;
1592*cdf0e10cSrcweir         case SVX_ZOOM_WHOLEPAGE:
1593*cdf0e10cSrcweir             aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
1594*cdf0e10cSrcweir             break;
1595*cdf0e10cSrcweir         case SVX_ZOOM_PAGEWIDTH:
1596*cdf0e10cSrcweir             aZoomType = view::DocumentZoomType::PAGE_WIDTH;
1597*cdf0e10cSrcweir             break;
1598*cdf0e10cSrcweir         case SVX_ZOOM_PAGEWIDTH_NOBORDER:
1599*cdf0e10cSrcweir             aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
1600*cdf0e10cSrcweir             break;
1601*cdf0e10cSrcweir         }
1602*cdf0e10cSrcweir     }
1603*cdf0e10cSrcweir     return aZoomType;
1604*cdf0e10cSrcweir }
1605*cdf0e10cSrcweir 
1606*cdf0e10cSrcweir void ScTabViewObj::SetZoomType(sal_Int16 aZoomType)
1607*cdf0e10cSrcweir {
1608*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1609*cdf0e10cSrcweir 	if (pViewSh)
1610*cdf0e10cSrcweir 	{
1611*cdf0e10cSrcweir         ScDBFunc* pView = pViewSh->GetViewData()->GetView();
1612*cdf0e10cSrcweir         if (pView)
1613*cdf0e10cSrcweir         {
1614*cdf0e10cSrcweir             SvxZoomType eZoomType;
1615*cdf0e10cSrcweir             switch (aZoomType)
1616*cdf0e10cSrcweir             {
1617*cdf0e10cSrcweir             case view::DocumentZoomType::BY_VALUE:
1618*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_PERCENT;
1619*cdf0e10cSrcweir                 break;
1620*cdf0e10cSrcweir             case view::DocumentZoomType::OPTIMAL:
1621*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_OPTIMAL;
1622*cdf0e10cSrcweir                 break;
1623*cdf0e10cSrcweir             case view::DocumentZoomType::ENTIRE_PAGE:
1624*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_WHOLEPAGE;
1625*cdf0e10cSrcweir                 break;
1626*cdf0e10cSrcweir             case view::DocumentZoomType::PAGE_WIDTH:
1627*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_PAGEWIDTH;
1628*cdf0e10cSrcweir                 break;
1629*cdf0e10cSrcweir             case view::DocumentZoomType::PAGE_WIDTH_EXACT:
1630*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_PAGEWIDTH_NOBORDER;
1631*cdf0e10cSrcweir                 break;
1632*cdf0e10cSrcweir             default:
1633*cdf0e10cSrcweir                 eZoomType = SVX_ZOOM_OPTIMAL;
1634*cdf0e10cSrcweir             }
1635*cdf0e10cSrcweir             sal_Int16 nZoom(GetZoom());
1636*cdf0e10cSrcweir             sal_Int16 nOldZoom(nZoom);
1637*cdf0e10cSrcweir 		    if ( eZoomType == SVX_ZOOM_PERCENT )
1638*cdf0e10cSrcweir 		    {
1639*cdf0e10cSrcweir 			    if ( nZoom < MINZOOM )	nZoom = MINZOOM;
1640*cdf0e10cSrcweir 			    if ( nZoom > MAXZOOM )	nZoom = MAXZOOM;
1641*cdf0e10cSrcweir 		    }
1642*cdf0e10cSrcweir 		    else
1643*cdf0e10cSrcweir 			    nZoom = pView->CalcZoom( eZoomType, nOldZoom );
1644*cdf0e10cSrcweir 
1645*cdf0e10cSrcweir 		    switch ( eZoomType )
1646*cdf0e10cSrcweir 		    {
1647*cdf0e10cSrcweir 			    case SVX_ZOOM_WHOLEPAGE:
1648*cdf0e10cSrcweir 			    case SVX_ZOOM_PAGEWIDTH:
1649*cdf0e10cSrcweir                     pView->SetZoomType( eZoomType, sal_True );
1650*cdf0e10cSrcweir 				    break;
1651*cdf0e10cSrcweir 
1652*cdf0e10cSrcweir 			    default:
1653*cdf0e10cSrcweir                     pView->SetZoomType( SVX_ZOOM_PERCENT, sal_True );
1654*cdf0e10cSrcweir 		    }
1655*cdf0e10cSrcweir 			SetZoom( nZoom );
1656*cdf0e10cSrcweir         }
1657*cdf0e10cSrcweir     }
1658*cdf0e10cSrcweir }
1659*cdf0e10cSrcweir 
1660*cdf0e10cSrcweir sal_Bool SAL_CALL ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException)
1661*cdf0e10cSrcweir {
1662*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1663*cdf0e10cSrcweir 	//	wie Menue-Slot SID_WINDOW_SPLIT
1664*cdf0e10cSrcweir 
1665*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1666*cdf0e10cSrcweir 	if (pViewSh)
1667*cdf0e10cSrcweir 	{
1668*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1669*cdf0e10cSrcweir 		return ( pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
1670*cdf0e10cSrcweir 				 pViewData->GetVSplitMode() == SC_SPLIT_NORMAL );
1671*cdf0e10cSrcweir 	}
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir 	return sal_False;
1674*cdf0e10cSrcweir }
1675*cdf0e10cSrcweir 
1676*cdf0e10cSrcweir sal_Bool SAL_CALL ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException)
1677*cdf0e10cSrcweir {
1678*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1679*cdf0e10cSrcweir 	//	wie Menue-Slot SID_WINDOW_FIX
1680*cdf0e10cSrcweir 
1681*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1682*cdf0e10cSrcweir 	if (pViewSh)
1683*cdf0e10cSrcweir 	{
1684*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1685*cdf0e10cSrcweir 		return ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
1686*cdf0e10cSrcweir 				 pViewData->GetVSplitMode() == SC_SPLIT_FIX );
1687*cdf0e10cSrcweir 	}
1688*cdf0e10cSrcweir 
1689*cdf0e10cSrcweir 	return sal_False;
1690*cdf0e10cSrcweir }
1691*cdf0e10cSrcweir 
1692*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException)
1693*cdf0e10cSrcweir {
1694*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1695*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1696*cdf0e10cSrcweir 	if (pViewSh)
1697*cdf0e10cSrcweir 	{
1698*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1699*cdf0e10cSrcweir 		if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1700*cdf0e10cSrcweir 			return pViewData->GetHSplitPos();
1701*cdf0e10cSrcweir 	}
1702*cdf0e10cSrcweir 	return 0;
1703*cdf0e10cSrcweir }
1704*cdf0e10cSrcweir 
1705*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTabViewObj::getSplitVertical() throw(uno::RuntimeException)
1706*cdf0e10cSrcweir {
1707*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1708*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1709*cdf0e10cSrcweir 	if (pViewSh)
1710*cdf0e10cSrcweir 	{
1711*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1712*cdf0e10cSrcweir 		if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1713*cdf0e10cSrcweir 			return pViewData->GetVSplitPos();
1714*cdf0e10cSrcweir 	}
1715*cdf0e10cSrcweir 	return 0;
1716*cdf0e10cSrcweir }
1717*cdf0e10cSrcweir 
1718*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn() throw(uno::RuntimeException)
1719*cdf0e10cSrcweir {
1720*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1721*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1722*cdf0e10cSrcweir 	if (pViewSh)
1723*cdf0e10cSrcweir 	{
1724*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1725*cdf0e10cSrcweir 		if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
1726*cdf0e10cSrcweir 		{
1727*cdf0e10cSrcweir 			long nSplit = pViewData->GetHSplitPos();
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir 			ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
1730*cdf0e10cSrcweir 			if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1731*cdf0e10cSrcweir 				ePos = SC_SPLIT_TOPLEFT;
1732*cdf0e10cSrcweir 
1733*cdf0e10cSrcweir             SCsCOL nCol;
1734*cdf0e10cSrcweir             SCsROW nRow;
1735*cdf0e10cSrcweir             pViewData->GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, sal_False );
1736*cdf0e10cSrcweir 			if ( nCol > 0 )
1737*cdf0e10cSrcweir 				return nCol;
1738*cdf0e10cSrcweir 		}
1739*cdf0e10cSrcweir 	}
1740*cdf0e10cSrcweir 	return 0;
1741*cdf0e10cSrcweir }
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir sal_Int32 SAL_CALL ScTabViewObj::getSplitRow() throw(uno::RuntimeException)
1744*cdf0e10cSrcweir {
1745*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1746*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1747*cdf0e10cSrcweir 	if (pViewSh)
1748*cdf0e10cSrcweir 	{
1749*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1750*cdf0e10cSrcweir 		if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
1751*cdf0e10cSrcweir 		{
1752*cdf0e10cSrcweir 			long nSplit = pViewData->GetVSplitPos();
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir 			ScSplitPos ePos = SC_SPLIT_TOPLEFT;		// es ist vertikal geteilt
1755*cdf0e10cSrcweir             SCsCOL nCol;
1756*cdf0e10cSrcweir             SCsROW nRow;
1757*cdf0e10cSrcweir             pViewData->GetPosFromPixel( 0, nSplit, ePos, nCol, nRow, sal_False );
1758*cdf0e10cSrcweir 			if ( nRow > 0 )
1759*cdf0e10cSrcweir 				return nRow;
1760*cdf0e10cSrcweir 		}
1761*cdf0e10cSrcweir 	}
1762*cdf0e10cSrcweir 	return 0;
1763*cdf0e10cSrcweir }
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
1766*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1767*cdf0e10cSrcweir {
1768*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1769*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1770*cdf0e10cSrcweir 	if (pViewSh)
1771*cdf0e10cSrcweir 	{
1772*cdf0e10cSrcweir 		pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ), sal_True, sal_True );
1773*cdf0e10cSrcweir 		pViewSh->FreezeSplitters( sal_False );
1774*cdf0e10cSrcweir 		pViewSh->InvalidateSplit();
1775*cdf0e10cSrcweir 	}
1776*cdf0e10cSrcweir }
1777*cdf0e10cSrcweir 
1778*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
1779*cdf0e10cSrcweir 												throw(uno::RuntimeException)
1780*cdf0e10cSrcweir {
1781*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1782*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1783*cdf0e10cSrcweir 	if (pViewSh)
1784*cdf0e10cSrcweir 	{
1785*cdf0e10cSrcweir 		//	erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae.
1786*cdf0e10cSrcweir 
1787*cdf0e10cSrcweir 		pViewSh->RemoveSplit();
1788*cdf0e10cSrcweir 
1789*cdf0e10cSrcweir 		Point aWinStart;
1790*cdf0e10cSrcweir 		Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
1791*cdf0e10cSrcweir 		if (pWin)
1792*cdf0e10cSrcweir 			aWinStart = pWin->GetPosPixel();
1793*cdf0e10cSrcweir 
1794*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1795*cdf0e10cSrcweir 		Point aSplit(pViewData->GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, sal_True ));
1796*cdf0e10cSrcweir 		aSplit += aWinStart;
1797*cdf0e10cSrcweir 
1798*cdf0e10cSrcweir 		pViewSh->SplitAtPixel( aSplit, sal_True, sal_True );
1799*cdf0e10cSrcweir 		pViewSh->FreezeSplitters( sal_True );
1800*cdf0e10cSrcweir 		pViewSh->InvalidateSplit();
1801*cdf0e10cSrcweir 	}
1802*cdf0e10cSrcweir }
1803*cdf0e10cSrcweir 
1804*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addSelectionChangeListener(
1805*cdf0e10cSrcweir 				const uno::Reference<view::XSelectionChangeListener>& xListener )
1806*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1807*cdf0e10cSrcweir {
1808*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1809*cdf0e10cSrcweir 	uno::Reference<view::XSelectionChangeListener>* pObj =
1810*cdf0e10cSrcweir 			new uno::Reference<view::XSelectionChangeListener>( xListener );
1811*cdf0e10cSrcweir 	aSelectionListeners.Insert( pObj, aSelectionListeners.Count() );
1812*cdf0e10cSrcweir }
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
1815*cdf0e10cSrcweir 				const uno::Reference< view::XSelectionChangeListener >& xListener )
1816*cdf0e10cSrcweir 													throw(uno::RuntimeException)
1817*cdf0e10cSrcweir {
1818*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1819*cdf0e10cSrcweir 	sal_uInt16 nCount = aSelectionListeners.Count();
1820*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
1821*cdf0e10cSrcweir 	{
1822*cdf0e10cSrcweir 		uno::Reference<view::XSelectionChangeListener> *pObj = aSelectionListeners[n];
1823*cdf0e10cSrcweir 		if ( *pObj == xListener )		//! wozu der Mumpitz mit queryInterface?
1824*cdf0e10cSrcweir 		{
1825*cdf0e10cSrcweir 			aSelectionListeners.DeleteAndDestroy( n );
1826*cdf0e10cSrcweir 			break;
1827*cdf0e10cSrcweir 		}
1828*cdf0e10cSrcweir 	}
1829*cdf0e10cSrcweir }
1830*cdf0e10cSrcweir 
1831*cdf0e10cSrcweir void ScTabViewObj::SelectionChanged()
1832*cdf0e10cSrcweir {
1833*cdf0e10cSrcweir 	lang::EventObject aEvent;
1834*cdf0e10cSrcweir 	aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
1835*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aSelectionListeners.Count(); n++ )
1836*cdf0e10cSrcweir 		(*aSelectionListeners[n])->selectionChanged( aEvent );
1837*cdf0e10cSrcweir 
1838*cdf0e10cSrcweir     // handle sheet events
1839*cdf0e10cSrcweir     ScTabViewShell* pViewSh = GetViewShell();
1840*cdf0e10cSrcweir     ScViewData* pViewData = pViewSh->GetViewData();
1841*cdf0e10cSrcweir     ScDocShell* pDocSh = pViewData->GetDocShell();
1842*cdf0e10cSrcweir     ScDocument* pDoc = pDocSh->GetDocument();
1843*cdf0e10cSrcweir     SCTAB nTab = pViewData->GetTabNo();
1844*cdf0e10cSrcweir     const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
1845*cdf0e10cSrcweir     if (pEvents)
1846*cdf0e10cSrcweir     {
1847*cdf0e10cSrcweir         const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_SELECT);
1848*cdf0e10cSrcweir         if (pScript)
1849*cdf0e10cSrcweir         {
1850*cdf0e10cSrcweir             // the macro parameter is the selection as returned by getSelection
1851*cdf0e10cSrcweir             uno::Sequence<uno::Any> aParams(1);
1852*cdf0e10cSrcweir             aParams[0] = getSelection();
1853*cdf0e10cSrcweir             uno::Any aRet;
1854*cdf0e10cSrcweir             uno::Sequence<sal_Int16> aOutArgsIndex;
1855*cdf0e10cSrcweir             uno::Sequence<uno::Any> aOutArgs;
1856*cdf0e10cSrcweir             /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
1857*cdf0e10cSrcweir         }
1858*cdf0e10cSrcweir     }
1859*cdf0e10cSrcweir 
1860*cdf0e10cSrcweir     // execute VBA event handler
1861*cdf0e10cSrcweir     try
1862*cdf0e10cSrcweir     {
1863*cdf0e10cSrcweir         uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
1864*cdf0e10cSrcweir         // the parameter is the clicked object, as in the mousePressed call above
1865*cdf0e10cSrcweir         uno::Sequence< uno::Any > aArgs( 1 );
1866*cdf0e10cSrcweir         aArgs[ 0 ] <<= getSelection();
1867*cdf0e10cSrcweir         xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs );
1868*cdf0e10cSrcweir     }
1869*cdf0e10cSrcweir     catch( uno::Exception& )
1870*cdf0e10cSrcweir     {
1871*cdf0e10cSrcweir     }
1872*cdf0e10cSrcweir }
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir 
1875*cdf0e10cSrcweir //	XPropertySet (View-Optionen)
1876*cdf0e10cSrcweir //!	auch an der Applikation anbieten?
1877*cdf0e10cSrcweir 
1878*cdf0e10cSrcweir uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
1879*cdf0e10cSrcweir 														throw(uno::RuntimeException)
1880*cdf0e10cSrcweir {
1881*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1882*cdf0e10cSrcweir 	static uno::Reference<beans::XPropertySetInfo> aRef(
1883*cdf0e10cSrcweir 		new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
1884*cdf0e10cSrcweir 	return aRef;
1885*cdf0e10cSrcweir }
1886*cdf0e10cSrcweir 
1887*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::setPropertyValue(
1888*cdf0e10cSrcweir 						const rtl::OUString& aPropertyName, const uno::Any& aValue )
1889*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, beans::PropertyVetoException,
1890*cdf0e10cSrcweir 						lang::IllegalArgumentException, lang::WrappedTargetException,
1891*cdf0e10cSrcweir 						uno::RuntimeException)
1892*cdf0e10cSrcweir {
1893*cdf0e10cSrcweir 	ScUnoGuard aGuard;
1894*cdf0e10cSrcweir 	String aString(aPropertyName);
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
1897*cdf0e10cSrcweir 	if (pViewSh)
1898*cdf0e10cSrcweir 	{
1899*cdf0e10cSrcweir 		ScViewData* pViewData = pViewSh->GetViewData();
1900*cdf0e10cSrcweir 		const ScViewOptions& rOldOpt = pViewSh->GetViewData()->GetOptions();
1901*cdf0e10cSrcweir 		ScViewOptions aNewOpt(rOldOpt);
1902*cdf0e10cSrcweir 
1903*cdf0e10cSrcweir 		if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
1904*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1905*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
1906*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1907*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
1908*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1909*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
1910*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1911*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) )
1912*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1913*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) )
1914*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1915*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) )
1916*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1917*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) )
1918*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1919*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) )
1920*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1921*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) )
1922*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1923*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) )
1924*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1925*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) )
1926*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_SOLIDHANDLES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1927*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
1928*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1929*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
1930*cdf0e10cSrcweir 			aNewOpt.SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
1931*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) )
1932*cdf0e10cSrcweir 		{
1933*cdf0e10cSrcweir 			sal_Int16 nIntVal = 0;
1934*cdf0e10cSrcweir 			if ( aValue >>= nIntVal )
1935*cdf0e10cSrcweir 			{
1936*cdf0e10cSrcweir 				//#i80528# adapt to new range eventually
1937*cdf0e10cSrcweir 				if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir 				aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
1940*cdf0e10cSrcweir 			}
1941*cdf0e10cSrcweir 		}
1942*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) )
1943*cdf0e10cSrcweir 		{
1944*cdf0e10cSrcweir 			sal_Int16 nIntVal = 0;
1945*cdf0e10cSrcweir 			if ( aValue >>= nIntVal )
1946*cdf0e10cSrcweir 			{
1947*cdf0e10cSrcweir 				//#i80528# adapt to new range eventually
1948*cdf0e10cSrcweir 				if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1949*cdf0e10cSrcweir 
1950*cdf0e10cSrcweir 				aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
1951*cdf0e10cSrcweir 			}
1952*cdf0e10cSrcweir 		}
1953*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) )
1954*cdf0e10cSrcweir 		{
1955*cdf0e10cSrcweir 			sal_Int16 nIntVal = 0;
1956*cdf0e10cSrcweir 			if ( aValue >>= nIntVal )
1957*cdf0e10cSrcweir 			{
1958*cdf0e10cSrcweir 				//#i80528# adapt to new range eventually
1959*cdf0e10cSrcweir 				if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
1960*cdf0e10cSrcweir 
1961*cdf0e10cSrcweir 				aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
1962*cdf0e10cSrcweir 			}
1963*cdf0e10cSrcweir 		}
1964*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) )
1965*cdf0e10cSrcweir 		{
1966*cdf0e10cSrcweir 			sal_Int32 nIntVal = 0;
1967*cdf0e10cSrcweir 			if ( aValue >>= nIntVal )
1968*cdf0e10cSrcweir 				aNewOpt.SetGridColor( nIntVal, String() );
1969*cdf0e10cSrcweir 		}
1970*cdf0e10cSrcweir         else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) )
1971*cdf0e10cSrcweir         {
1972*cdf0e10cSrcweir             sal_Int16 nIntVal = 0;
1973*cdf0e10cSrcweir             if ( aValue >>= nIntVal )
1974*cdf0e10cSrcweir                 SetZoomType(nIntVal);
1975*cdf0e10cSrcweir         }
1976*cdf0e10cSrcweir         else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) )
1977*cdf0e10cSrcweir         {
1978*cdf0e10cSrcweir             sal_Int16 nIntVal = 0;
1979*cdf0e10cSrcweir             if ( aValue >>= nIntVal )
1980*cdf0e10cSrcweir                 SetZoom(nIntVal);
1981*cdf0e10cSrcweir         }
1982*cdf0e10cSrcweir 
1983*cdf0e10cSrcweir 		//	Optionen werden an der View und am Dokument (fuer neue Views) gesetzt,
1984*cdf0e10cSrcweir 		//	damit sie beim Speichern erhalten bleiben.
1985*cdf0e10cSrcweir 		//!	An der App (Module) braeuchte man noch eine Extra-Moeglichkeit,
1986*cdf0e10cSrcweir 		//!	das einzustellen (fuer neue Dokumente)
1987*cdf0e10cSrcweir 
1988*cdf0e10cSrcweir 		if ( aNewOpt != rOldOpt )
1989*cdf0e10cSrcweir 		{
1990*cdf0e10cSrcweir 			pViewData->SetOptions( aNewOpt );
1991*cdf0e10cSrcweir 			pViewData->GetDocument()->SetViewOptions( aNewOpt );
1992*cdf0e10cSrcweir 			pViewData->GetDocShell()->SetDocumentModified();	//! wirklich?
1993*cdf0e10cSrcweir 
1994*cdf0e10cSrcweir 			pViewSh->UpdateFixPos();
1995*cdf0e10cSrcweir 			pViewSh->PaintGrid();
1996*cdf0e10cSrcweir 			pViewSh->PaintTop();
1997*cdf0e10cSrcweir 			pViewSh->PaintLeft();
1998*cdf0e10cSrcweir 			pViewSh->PaintExtras();
1999*cdf0e10cSrcweir 			pViewSh->InvalidateBorder();
2000*cdf0e10cSrcweir 
2001*cdf0e10cSrcweir 			SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
2002*cdf0e10cSrcweir 			rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
2003*cdf0e10cSrcweir 			rBindings.Invalidate( FID_TOGGLESYNTAX );
2004*cdf0e10cSrcweir 		}
2005*cdf0e10cSrcweir 	}
2006*cdf0e10cSrcweir }
2007*cdf0e10cSrcweir 
2008*cdf0e10cSrcweir uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aPropertyName )
2009*cdf0e10cSrcweir 				throw(beans::UnknownPropertyException, lang::WrappedTargetException,
2010*cdf0e10cSrcweir 						uno::RuntimeException)
2011*cdf0e10cSrcweir {
2012*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2013*cdf0e10cSrcweir 	String aString(aPropertyName);
2014*cdf0e10cSrcweir 	uno::Any aRet;
2015*cdf0e10cSrcweir 
2016*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
2017*cdf0e10cSrcweir 	if (pViewSh)
2018*cdf0e10cSrcweir 	{
2019*cdf0e10cSrcweir 		const ScViewOptions& rOpt = pViewSh->GetViewData()->GetOptions();
2020*cdf0e10cSrcweir 
2021*cdf0e10cSrcweir 		if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
2022*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HEADER ) );
2023*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
2024*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HSCROLL ) );
2025*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
2026*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_OUTLINER ) );
2027*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
2028*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_TABCONTROLS ) );
2029*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_ANCHOR ) );
2030*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_FORMULAS ) );
2031*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_GRID ) );
2032*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HELPLINES ) );
2033*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NOTES ) );
2034*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_PAGEBREAKS ) );
2035*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NULLVALS ) );
2036*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) )	 ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SOLIDHANDLES ) );
2037*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
2038*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SYNTAX ) );
2039*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
2040*cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_VSCROLL ) );
2041*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) )	 aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
2042*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
2043*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) )	 aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
2044*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) )	 aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() );
2045*cdf0e10cSrcweir 		else if ( aString.EqualsAscii( SC_UNO_VISAREA ) ) aRet <<= GetVisArea();
2046*cdf0e10cSrcweir         else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) aRet <<= GetZoomType();
2047*cdf0e10cSrcweir         else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) aRet <<= GetZoom();
2048*cdf0e10cSrcweir         else if ( aString.EqualsAscii( SC_UNO_VISAREASCREEN ) )
2049*cdf0e10cSrcweir         {
2050*cdf0e10cSrcweir             ScViewData* pViewData = pViewSh->GetViewData();
2051*cdf0e10cSrcweir             Window* pActiveWin = ( pViewData ? pViewData->GetActiveWin() : NULL );
2052*cdf0e10cSrcweir             if ( pActiveWin )
2053*cdf0e10cSrcweir             {
2054*cdf0e10cSrcweir                 Rectangle aRect = pActiveWin->GetWindowExtentsRelative( NULL );
2055*cdf0e10cSrcweir                 aRet <<= AWTRectangle( aRect );
2056*cdf0e10cSrcweir             }
2057*cdf0e10cSrcweir         }
2058*cdf0e10cSrcweir 	}
2059*cdf0e10cSrcweir 
2060*cdf0e10cSrcweir 	return aRet;
2061*cdf0e10cSrcweir }
2062*cdf0e10cSrcweir 
2063*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addPropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
2064*cdf0e10cSrcweir 									const uno::Reference<beans::XPropertyChangeListener >& xListener )
2065*cdf0e10cSrcweir 								throw(beans::UnknownPropertyException,
2066*cdf0e10cSrcweir 									lang::WrappedTargetException,
2067*cdf0e10cSrcweir 									uno::RuntimeException)
2068*cdf0e10cSrcweir {
2069*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2070*cdf0e10cSrcweir 	uno::Reference<beans::XPropertyChangeListener>* pObj =
2071*cdf0e10cSrcweir 			new uno::Reference<beans::XPropertyChangeListener>( xListener );
2072*cdf0e10cSrcweir 	aPropertyChgListeners.Insert( pObj, aPropertyChgListeners.Count() );
2073*cdf0e10cSrcweir }
2074*cdf0e10cSrcweir 
2075*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removePropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
2076*cdf0e10cSrcweir 									const uno::Reference<beans::XPropertyChangeListener >& xListener )
2077*cdf0e10cSrcweir 								throw(beans::UnknownPropertyException,
2078*cdf0e10cSrcweir 									lang::WrappedTargetException,
2079*cdf0e10cSrcweir 									uno::RuntimeException)
2080*cdf0e10cSrcweir {
2081*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2082*cdf0e10cSrcweir 	sal_uInt16 nCount = aPropertyChgListeners.Count();
2083*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
2084*cdf0e10cSrcweir 	{
2085*cdf0e10cSrcweir 		uno::Reference<beans::XPropertyChangeListener> *pObj = aPropertyChgListeners[n];
2086*cdf0e10cSrcweir 		if ( *pObj == xListener )		//! wozu der Mumpitz mit queryInterface?
2087*cdf0e10cSrcweir 		{
2088*cdf0e10cSrcweir 			aPropertyChgListeners.DeleteAndDestroy( n );
2089*cdf0e10cSrcweir 			break;
2090*cdf0e10cSrcweir 		}
2091*cdf0e10cSrcweir 	}
2092*cdf0e10cSrcweir }
2093*cdf0e10cSrcweir 
2094*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
2095*cdf0e10cSrcweir                                     const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2096*cdf0e10cSrcweir 								throw(beans::UnknownPropertyException,
2097*cdf0e10cSrcweir 									lang::WrappedTargetException,
2098*cdf0e10cSrcweir 									uno::RuntimeException)
2099*cdf0e10cSrcweir {
2100*cdf0e10cSrcweir }
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
2103*cdf0e10cSrcweir                                     const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
2104*cdf0e10cSrcweir 								throw(beans::UnknownPropertyException,
2105*cdf0e10cSrcweir 									lang::WrappedTargetException,
2106*cdf0e10cSrcweir 									uno::RuntimeException)
2107*cdf0e10cSrcweir {
2108*cdf0e10cSrcweir }
2109*cdf0e10cSrcweir 
2110*cdf0e10cSrcweir void ScTabViewObj::VisAreaChanged()
2111*cdf0e10cSrcweir {
2112*cdf0e10cSrcweir 	beans::PropertyChangeEvent aEvent;
2113*cdf0e10cSrcweir 	aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2114*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aPropertyChgListeners.Count(); n++ )
2115*cdf0e10cSrcweir 		(*aPropertyChgListeners[n])->propertyChange( aEvent );
2116*cdf0e10cSrcweir }
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir // XRangeSelection
2119*cdf0e10cSrcweir 
2120*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::startRangeSelection(
2121*cdf0e10cSrcweir 								const uno::Sequence<beans::PropertyValue>& aArguments )
2122*cdf0e10cSrcweir 									throw(uno::RuntimeException)
2123*cdf0e10cSrcweir {
2124*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2125*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
2126*cdf0e10cSrcweir 	if (pViewSh)
2127*cdf0e10cSrcweir 	{
2128*cdf0e10cSrcweir 		String aInitVal, aTitle;
2129*cdf0e10cSrcweir 		sal_Bool bCloseOnButtonUp = sal_False;
2130*cdf0e10cSrcweir 		sal_Bool bSingleCell = sal_False;
2131*cdf0e10cSrcweir         sal_Bool bMultiSelection = sal_False;
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir 		rtl::OUString aStrVal;
2134*cdf0e10cSrcweir 		const beans::PropertyValue* pPropArray = aArguments.getConstArray();
2135*cdf0e10cSrcweir 		long nPropCount = aArguments.getLength();
2136*cdf0e10cSrcweir 		for (long i = 0; i < nPropCount; i++)
2137*cdf0e10cSrcweir 		{
2138*cdf0e10cSrcweir 			const beans::PropertyValue& rProp = pPropArray[i];
2139*cdf0e10cSrcweir 			String aPropName(rProp.Name);
2140*cdf0e10cSrcweir 
2141*cdf0e10cSrcweir 			if (aPropName.EqualsAscii( SC_UNONAME_CLOSEONUP ))
2142*cdf0e10cSrcweir 				bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2143*cdf0e10cSrcweir 			else if (aPropName.EqualsAscii( SC_UNONAME_TITLE ))
2144*cdf0e10cSrcweir 			{
2145*cdf0e10cSrcweir 				if ( rProp.Value >>= aStrVal )
2146*cdf0e10cSrcweir 					aTitle = String( aStrVal );
2147*cdf0e10cSrcweir 			}
2148*cdf0e10cSrcweir 			else if (aPropName.EqualsAscii( SC_UNONAME_INITVAL ))
2149*cdf0e10cSrcweir 			{
2150*cdf0e10cSrcweir 				if ( rProp.Value >>= aStrVal )
2151*cdf0e10cSrcweir 					aInitVal = String( aStrVal );
2152*cdf0e10cSrcweir 			}
2153*cdf0e10cSrcweir 			else if (aPropName.EqualsAscii( SC_UNONAME_SINGLECELL ))
2154*cdf0e10cSrcweir 				bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2155*cdf0e10cSrcweir             else if (aPropName.EqualsAscii( SC_UNONAME_MULTISEL ))
2156*cdf0e10cSrcweir                 bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
2157*cdf0e10cSrcweir 		}
2158*cdf0e10cSrcweir 
2159*cdf0e10cSrcweir 		pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
2160*cdf0e10cSrcweir 	}
2161*cdf0e10cSrcweir }
2162*cdf0e10cSrcweir 
2163*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException)
2164*cdf0e10cSrcweir {
2165*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2166*cdf0e10cSrcweir 	ScTabViewShell* pViewSh = GetViewShell();
2167*cdf0e10cSrcweir 	if (pViewSh)
2168*cdf0e10cSrcweir 		pViewSh->StopSimpleRefDialog();
2169*cdf0e10cSrcweir }
2170*cdf0e10cSrcweir 
2171*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addRangeSelectionListener(
2172*cdf0e10cSrcweir 								const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2173*cdf0e10cSrcweir 									throw(uno::RuntimeException)
2174*cdf0e10cSrcweir {
2175*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2176*cdf0e10cSrcweir 	uno::Reference<sheet::XRangeSelectionListener>* pObj =
2177*cdf0e10cSrcweir 			new uno::Reference<sheet::XRangeSelectionListener>( xListener );
2178*cdf0e10cSrcweir 	aRangeSelListeners.Insert( pObj, aRangeSelListeners.Count() );
2179*cdf0e10cSrcweir }
2180*cdf0e10cSrcweir 
2181*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeRangeSelectionListener(
2182*cdf0e10cSrcweir 								const uno::Reference<sheet::XRangeSelectionListener>& xListener )
2183*cdf0e10cSrcweir 									throw(uno::RuntimeException)
2184*cdf0e10cSrcweir {
2185*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2186*cdf0e10cSrcweir 	sal_uInt16 nCount = aRangeSelListeners.Count();
2187*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
2188*cdf0e10cSrcweir 	{
2189*cdf0e10cSrcweir 		uno::Reference<sheet::XRangeSelectionListener> *pObj = aRangeSelListeners[n];
2190*cdf0e10cSrcweir 		if ( *pObj == xListener )
2191*cdf0e10cSrcweir 		{
2192*cdf0e10cSrcweir 			aRangeSelListeners.DeleteAndDestroy( n );
2193*cdf0e10cSrcweir 			break;
2194*cdf0e10cSrcweir 		}
2195*cdf0e10cSrcweir 	}
2196*cdf0e10cSrcweir }
2197*cdf0e10cSrcweir 
2198*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener(
2199*cdf0e10cSrcweir 								const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2200*cdf0e10cSrcweir 									throw(uno::RuntimeException)
2201*cdf0e10cSrcweir {
2202*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2203*cdf0e10cSrcweir 	uno::Reference<sheet::XRangeSelectionChangeListener>* pObj =
2204*cdf0e10cSrcweir 			new uno::Reference<sheet::XRangeSelectionChangeListener>( xListener );
2205*cdf0e10cSrcweir 	aRangeChgListeners.Insert( pObj, aRangeChgListeners.Count() );
2206*cdf0e10cSrcweir }
2207*cdf0e10cSrcweir 
2208*cdf0e10cSrcweir void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener(
2209*cdf0e10cSrcweir 								const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
2210*cdf0e10cSrcweir 									throw(uno::RuntimeException)
2211*cdf0e10cSrcweir {
2212*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2213*cdf0e10cSrcweir 	sal_uInt16 nCount = aRangeChgListeners.Count();
2214*cdf0e10cSrcweir 	for ( sal_uInt16 n=nCount; n--; )
2215*cdf0e10cSrcweir 	{
2216*cdf0e10cSrcweir 		uno::Reference<sheet::XRangeSelectionChangeListener> *pObj = aRangeChgListeners[n];
2217*cdf0e10cSrcweir 		if ( *pObj == xListener )
2218*cdf0e10cSrcweir 		{
2219*cdf0e10cSrcweir 			aRangeChgListeners.DeleteAndDestroy( n );
2220*cdf0e10cSrcweir 			break;
2221*cdf0e10cSrcweir 		}
2222*cdf0e10cSrcweir 	}
2223*cdf0e10cSrcweir }
2224*cdf0e10cSrcweir 
2225*cdf0e10cSrcweir void ScTabViewObj::RangeSelDone( const String& rText )
2226*cdf0e10cSrcweir {
2227*cdf0e10cSrcweir 	sheet::RangeSelectionEvent aEvent;
2228*cdf0e10cSrcweir 	aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2229*cdf0e10cSrcweir 	aEvent.RangeDescriptor = rtl::OUString( rText );
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aRangeSelListeners.Count(); n++ )
2232*cdf0e10cSrcweir 		(*aRangeSelListeners[n])->done( aEvent );
2233*cdf0e10cSrcweir }
2234*cdf0e10cSrcweir 
2235*cdf0e10cSrcweir void ScTabViewObj::RangeSelAborted( const String& rText )
2236*cdf0e10cSrcweir {
2237*cdf0e10cSrcweir 	sheet::RangeSelectionEvent aEvent;
2238*cdf0e10cSrcweir 	aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2239*cdf0e10cSrcweir 	aEvent.RangeDescriptor = rtl::OUString( rText );
2240*cdf0e10cSrcweir 
2241*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aRangeSelListeners.Count(); n++ )
2242*cdf0e10cSrcweir 		(*aRangeSelListeners[n])->aborted( aEvent );
2243*cdf0e10cSrcweir }
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir void ScTabViewObj::RangeSelChanged( const String& rText )
2246*cdf0e10cSrcweir {
2247*cdf0e10cSrcweir 	sheet::RangeSelectionEvent aEvent;
2248*cdf0e10cSrcweir 	aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
2249*cdf0e10cSrcweir 	aEvent.RangeDescriptor = rtl::OUString( rText );
2250*cdf0e10cSrcweir 
2251*cdf0e10cSrcweir 	for ( sal_uInt16 n=0; n<aRangeChgListeners.Count(); n++ )
2252*cdf0e10cSrcweir 		(*aRangeChgListeners[n])->descriptorChanged( aEvent );
2253*cdf0e10cSrcweir }
2254*cdf0e10cSrcweir 
2255*cdf0e10cSrcweir // XServiceInfo
2256*cdf0e10cSrcweir 
2257*cdf0e10cSrcweir rtl::OUString SAL_CALL ScTabViewObj::getImplementationName() throw(uno::RuntimeException)
2258*cdf0e10cSrcweir {
2259*cdf0e10cSrcweir 	return rtl::OUString::createFromAscii( "ScTabViewObj" );
2260*cdf0e10cSrcweir }
2261*cdf0e10cSrcweir 
2262*cdf0e10cSrcweir sal_Bool SAL_CALL ScTabViewObj::supportsService( const rtl::OUString& rServiceName )
2263*cdf0e10cSrcweir 													throw(uno::RuntimeException)
2264*cdf0e10cSrcweir {
2265*cdf0e10cSrcweir 	String aServiceStr( rServiceName );
2266*cdf0e10cSrcweir 	return aServiceStr.EqualsAscii( SCTABVIEWOBJ_SERVICE ) ||
2267*cdf0e10cSrcweir 		   aServiceStr.EqualsAscii( SCVIEWSETTINGS_SERVICE );
2268*cdf0e10cSrcweir }
2269*cdf0e10cSrcweir 
2270*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
2271*cdf0e10cSrcweir 													throw(uno::RuntimeException)
2272*cdf0e10cSrcweir {
2273*cdf0e10cSrcweir 	uno::Sequence<rtl::OUString> aRet(2);
2274*cdf0e10cSrcweir 	rtl::OUString* pArray = aRet.getArray();
2275*cdf0e10cSrcweir 	pArray[0] = rtl::OUString::createFromAscii( SCTABVIEWOBJ_SERVICE );
2276*cdf0e10cSrcweir 	pArray[1] = rtl::OUString::createFromAscii( SCVIEWSETTINGS_SERVICE );
2277*cdf0e10cSrcweir 	return aRet;
2278*cdf0e10cSrcweir }
2279*cdf0e10cSrcweir 
2280*cdf0e10cSrcweir // XUnoTunnel
2281*cdf0e10cSrcweir 
2282*cdf0e10cSrcweir sal_Int64 SAL_CALL ScTabViewObj::getSomething(
2283*cdf0e10cSrcweir 				const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
2284*cdf0e10cSrcweir {
2285*cdf0e10cSrcweir 	if ( rId.getLength() == 16 &&
2286*cdf0e10cSrcweir           0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
2287*cdf0e10cSrcweir 									rId.getConstArray(), 16 ) )
2288*cdf0e10cSrcweir 	{
2289*cdf0e10cSrcweir         return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
2290*cdf0e10cSrcweir 	}
2291*cdf0e10cSrcweir 	return 0;
2292*cdf0e10cSrcweir }
2293*cdf0e10cSrcweir 
2294*cdf0e10cSrcweir // static
2295*cdf0e10cSrcweir const uno::Sequence<sal_Int8>& ScTabViewObj::getUnoTunnelId()
2296*cdf0e10cSrcweir {
2297*cdf0e10cSrcweir 	static uno::Sequence<sal_Int8> * pSeq = 0;
2298*cdf0e10cSrcweir 	if( !pSeq )
2299*cdf0e10cSrcweir 	{
2300*cdf0e10cSrcweir 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
2301*cdf0e10cSrcweir 		if( !pSeq )
2302*cdf0e10cSrcweir 		{
2303*cdf0e10cSrcweir 			static uno::Sequence< sal_Int8 > aSeq( 16 );
2304*cdf0e10cSrcweir 			rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
2305*cdf0e10cSrcweir 			pSeq = &aSeq;
2306*cdf0e10cSrcweir 		}
2307*cdf0e10cSrcweir 	}
2308*cdf0e10cSrcweir 	return *pSeq;
2309*cdf0e10cSrcweir }
2310*cdf0e10cSrcweir 
2311*cdf0e10cSrcweir // static
2312*cdf0e10cSrcweir ScTabViewObj* ScTabViewObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
2313*cdf0e10cSrcweir {
2314*cdf0e10cSrcweir 	ScTabViewObj* pRet = NULL;
2315*cdf0e10cSrcweir 	uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
2316*cdf0e10cSrcweir 	if (xUT.is())
2317*cdf0e10cSrcweir         pRet = reinterpret_cast<ScTabViewObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
2318*cdf0e10cSrcweir 	return pRet;
2319*cdf0e10cSrcweir }
2320*cdf0e10cSrcweir 
2321*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable(  ) throw (::com::sun::star::uno::RuntimeException)
2322*cdf0e10cSrcweir {
2323*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2324*cdf0e10cSrcweir 	ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2325*cdf0e10cSrcweir 	if (pShell)
2326*cdf0e10cSrcweir 		return pShell->GetEditView()->GetTransferable();
2327*cdf0e10cSrcweir 
2328*cdf0e10cSrcweir     ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2329*cdf0e10cSrcweir     if (pTextShell)
2330*cdf0e10cSrcweir     {
2331*cdf0e10cSrcweir         ScViewData* pViewData = GetViewShell()->GetViewData();
2332*cdf0e10cSrcweir         ScDrawView* pView = pViewData->GetScDrawView();
2333*cdf0e10cSrcweir         OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2334*cdf0e10cSrcweir         if (pOutView)
2335*cdf0e10cSrcweir 			return pOutView->GetEditView().GetTransferable();
2336*cdf0e10cSrcweir     }
2337*cdf0e10cSrcweir 
2338*cdf0e10cSrcweir     ScDrawShell* pDrawShell = PTR_CAST( ScDrawShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2339*cdf0e10cSrcweir     if (pDrawShell)
2340*cdf0e10cSrcweir         return pDrawShell->GetDrawView()->CopyToTransferable();
2341*cdf0e10cSrcweir 
2342*cdf0e10cSrcweir     ScTransferObj* pObj = GetViewShell()->CopyToTransferable();
2343*cdf0e10cSrcweir 	uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
2344*cdf0e10cSrcweir 	return xTransferable;
2345*cdf0e10cSrcweir }
2346*cdf0e10cSrcweir 
2347*cdf0e10cSrcweir 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)
2348*cdf0e10cSrcweir {
2349*cdf0e10cSrcweir 	ScUnoGuard aGuard;
2350*cdf0e10cSrcweir 	ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2351*cdf0e10cSrcweir 	if (pShell)
2352*cdf0e10cSrcweir         pShell->GetEditView()->InsertText( xTrans, ::rtl::OUString(), sal_False );
2353*cdf0e10cSrcweir     else
2354*cdf0e10cSrcweir     {
2355*cdf0e10cSrcweir         ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
2356*cdf0e10cSrcweir         if (pTextShell)
2357*cdf0e10cSrcweir         {
2358*cdf0e10cSrcweir             ScViewData* pViewData = GetViewShell()->GetViewData();
2359*cdf0e10cSrcweir             ScDrawView* pView = pViewData->GetScDrawView();
2360*cdf0e10cSrcweir             OutlinerView* pOutView = pView->GetTextEditOutlinerView();
2361*cdf0e10cSrcweir             if ( pOutView )
2362*cdf0e10cSrcweir             {
2363*cdf0e10cSrcweir                 pOutView->GetEditView().InsertText( xTrans, ::rtl::OUString(), sal_False );
2364*cdf0e10cSrcweir                 return;
2365*cdf0e10cSrcweir             }
2366*cdf0e10cSrcweir         }
2367*cdf0e10cSrcweir 
2368*cdf0e10cSrcweir         GetViewShell()->PasteFromTransferable( xTrans );
2369*cdf0e10cSrcweir     }
2370*cdf0e10cSrcweir }
2371*cdf0e10cSrcweir 
2372*cdf0e10cSrcweir //------------------------------------------------------------------------
2373*cdf0e10cSrcweir 
2374*cdf0e10cSrcweir 
2375*cdf0e10cSrcweir 
2376*cdf0e10cSrcweir 
2377