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