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