Files
libreoffice/sc/source/ui/vba/vbaapplication.cxx
Jens-Heiner Rechtien 87307aba9e CWS-TOOLING: integrate CWS frmdlg
2008-12-18 09:13:09 +0100 oj  r265667 : merge from odff05
2008-12-18 07:58:16 +0100 oj  r265658 : #i94555# patch from <regina>, ODFF:
Add GAMMA, CHISQDIST, CHISQINV.
Make the 'cumulative' parameter of GAMMADIST optional.
Adapt the domain of CHIDIST to allow negative x.
Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV.
Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and
ODFF if omitted, for backwards compatibility.
2008-12-15 14:06:11 +0100 oj  r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37)
2008-12-15 13:55:28 +0100 oj  r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:55:07 +0100 oj  r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:48 +0100 oj  r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:36 +0100 oj  r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:54:24 +0100 oj  r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:48:11 +0100 oj  r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:31:12 +0100 oj  r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:13:58 +0100 oj  r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:10:09 +0100 oj  r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 13:05:11 +0100 oj  r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:47:17 +0100 oj  r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:46:19 +0100 oj  r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 10:45:47 +0100 oj  r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C'
CWS: frmdlg
New MWS: DEV300
New milestone: m37
2008-12-15 07:35:07 +0100 oj  r265458 : add dependency to formula
2008-12-15 07:34:24 +0100 oj  r265457 : add dependency to formula
2008-12-12 13:22:00 +0100 msc  r265413 : #i97089#
2008-12-12 13:20:25 +0100 msc  r265412 : #i97089#
2008-12-12 12:35:12 +0100 msc  r265406 : #i97089#
2008-12-12 12:34:16 +0100 msc  r265405 : #i97089#
2008-12-12 12:33:05 +0100 msc  r265404 : #i97089#
2008-12-12 12:31:11 +0100 msc  r265403 : #i97089#
2008-12-08 11:59:10 +0100 oj  r264981 : insert RTL_LOG
2008-12-08 11:50:17 +0100 oj  r264980 : some small changes
2008-12-05 12:57:57 +0100 oj  r264902 : eof changed
2008-12-05 12:56:46 +0100 oj  r264901 : eof changed
2008-12-05 12:28:47 +0100 oj  r264899 : wrong var used
2008-12-05 10:08:57 +0100 oj  r264890 : token order reversed
2008-12-04 13:49:22 +0100 oc  r264843 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:45:27 +0100 oc  r264842 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:42:54 +0100 oc  r264841 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:37:41 +0100 oc  r264840 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 13:34:11 +0100 oc  r264839 : #i96688: Adapt autotests because of outsourced functionwizard
2008-12-04 12:35:31 +0100 oj  r264835 : new help ids for struct and function tabpage
2008-12-04 12:00:35 +0100 oj  r264828 : set explicit help id
2008-12-03 14:53:27 +0100 oj  r264786 : #i96845# change ref button
2008-12-03 14:51:49 +0100 oj  r264785 : #i96845# change ref button
2008-12-03 08:51:57 +0100 oj  r264746 : convert dos to unix lineends
2008-12-03 08:50:45 +0100 oj  r264745 : convert dos to unix lineends
2008-12-03 08:50:05 +0100 oj  r264744 : convert dos to unix lineends
2008-12-02 12:28:33 +0100 oj  r264686 : clear help text when new helpid is set
2008-12-02 12:28:02 +0100 oj  r264685 : set help id for listbox category
2008-12-02 07:15:56 +0100 oj  r264655 : remove define to auto generate help ids
2008-12-01 14:36:43 +0100 oj  r264604 : use temp var
2008-12-01 14:18:31 +0100 oj  r264601 : moved ScJumpToken to formula
2008-12-01 14:18:11 +0100 oj  r264600 : moved ScJumpToken to formula
2008-12-01 14:14:35 +0100 oj  r264599 : moved ScJumpToken from sc
2008-12-01 10:48:51 +0100 oj  r264589 : change quickhelptext from Shrink to Select
2008-12-01 10:28:41 +0100 oj  r264588 : fix opcode data, has to be Any.Void
2008-11-28 11:16:48 +0100 oj  r264532 : add help ids
2008-11-28 10:16:56 +0100 oj  r264529 : set help id
2008-11-28 10:16:43 +0100 oj  r264528 : set help id
2008-11-26 13:55:04 +0100 oj  r264381 : #94535# use of optional instead of deleting a string myself and some small changes
2008-11-26 09:53:20 +0100 oj  r264346 : compile error with debug/without debug
2008-11-25 07:41:28 +0100 oj  r264271 : put static into the method which make use of them
2008-11-24 08:16:07 +0100 oj  r264196 : removed not needed classes for op code
2008-11-24 08:13:44 +0100 oj  r264195 : removed not needed classes for op code
2008-11-21 14:05:53 +0100 oj  r264135 : make GetOpCode inline
2008-11-21 12:35:27 +0100 oj  r264124 : hold symbols
2008-11-20 09:27:27 +0100 oj  r264028 : merged code from DEV300_m35 which got lost
2008-11-19 20:42:12 +0100 oj  r264022 : more changes for formula dialog remove
2008-11-19 20:37:41 +0100 oj  r264021 : removed unused var
2008-11-19 20:35:35 +0100 oj  r264020 : some more changes at token
2008-11-19 10:59:47 +0100 oj  r263967 : deleted
2008-11-19 10:58:24 +0100 oj  r263966 : add forui and for res files
2008-11-18 15:27:36 +0100 oj  r263777 : unused para removed
2008-11-18 15:23:23 +0100 oj  r263775 : add insert button to add field dlg
2008-11-18 13:39:53 +0100 oj  r263764 : enable the formula dialog as well for conditional print as for conditional formatting
2008-11-18 12:03:25 +0100 oj  r263760 : rename isRef in IsRef
2008-11-17 11:46:16 +0100 oj  r263711 : patches for function handling
2008-11-17 11:36:22 +0100 oj  r263710 : add new for forui and res file
2008-11-17 09:21:12 +0100 oj  r263704 : patches for some resource for libformula
2008-11-15 12:45:30 +0100 oj  r263701 : changes for formula editor extraction
2008-11-07 08:23:27 +0100 oj  r263416 : merge from DEV300:m35
2008-11-07 08:22:35 +0100 oj  r263415 : merge from DEV300:m35
2008-11-07 08:22:16 +0100 oj  r263414 : merge from DEV300:m35
2008-11-07 08:21:41 +0100 oj  r263413 : merge from DEV300:m35
2008-11-07 08:21:31 +0100 oj  r263412 : merge from DEV300:m35
2008-11-07 08:20:38 +0100 oj  r263411 : merge from DEV300:m35
2008-11-07 08:20:00 +0100 oj  r263410 : merge from DEV300:m35
2008-11-07 08:18:50 +0100 oj  r263409 : merge from DEV300:m35
2008-11-07 08:18:19 +0100 oj  r263408 : merge from DEV300:m35
2008-11-07 08:10:27 +0100 oj  r263407 : merge from DEV300:m35
2008-10-21 07:43:46 +0200 oj  r262560 : some compile errors resolved
2008-10-17 16:40:01 +0200 oj  r262291 : dep for 1st target
2008-10-07 10:08:39 +0200 oj  r262077 : copy
2008-10-07 09:45:31 +0200 oj  r262076 : #i94535# 
2008-10-07 09:44:26 +0200 oj  r262075 : #i94535# new base class
2008-10-07 09:43:21 +0200 oj  r262074 : moved to formula
2008-10-07 09:41:51 +0200 oj  r262073 : new images
2008-10-07 09:03:01 +0200 oj  r262072 : new ids for formula
2008-10-02 08:46:27 +0200 oj  r262024 : #i94535# move the formula compiler to formula
2008-10-02 08:08:54 +0200 oj  r262023 : #i94535#
2008-10-02 08:06:28 +0200 oj  r262022 : #i94535#
2008-10-02 08:05:52 +0200 oj  r262021 : #i94535#
2008-10-01 17:15:29 +0200 oj  r262014 : #i94535#
2008-10-01 17:12:40 +0200 oj  r262013 : new module formula
2008-10-01 17:04:55 +0200 oj  r262012 : #i94535#
2008-10-01 16:49:03 +0200 oj  r262010 : #i94535#
2008-10-01 16:46:59 +0200 oj  r262009 : #i94535#
2009-01-08 10:47:13 +00:00

960 lines
39 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: vbaapplication.cxx,v $
* $Revision: 1.7 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <stdio.h>
#include<com/sun/star/sheet/XSpreadsheetView.hpp>
#include <com/sun/star/sheet/XSpreadsheets.hpp>
#include<com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include<org/openoffice/excel/XlCalculation.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XCalculatable.hpp>
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
#include <com/sun/star/task/XStatusIndicator.hpp>
#include <org/openoffice/excel/XlMousePointer.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include "vbaapplication.hxx"
#include "vbaworkbooks.hxx"
#include "vbaworkbook.hxx"
#include "vbaworksheets.hxx"
#include "vbarange.hxx"
#include "vbawsfunction.hxx"
#include "vbadialogs.hxx"
#include "vbawindow.hxx"
#include "vbawindows.hxx"
#include "vbaglobals.hxx"
#include "tabvwsh.hxx"
#include "gridwin.hxx"
#include "vbanames.hxx"
#include "vbashape.hxx"
#include "sc.hrc"
#include <osl/file.hxx>
#include <sfx2/request.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/app.hxx>
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
#include <docuno.hxx>
#include <basic/sbx.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbuno.hxx>
#include <basic/sbmeth.hxx>
using namespace ::org::openoffice;
using namespace ::com::sun::star;
// #TODO is this defined somewhere else?
#if ( defined UNX ) || ( defined OS2 ) //unix
#define FILE_PATH_SEPERATOR "/"
#else // windows
#define FILE_PATH_SEPERATOR "\\"
#endif
#define EXCELVERSION "11.0"
class ActiveWorkbook : public ScVbaWorkbook
{
protected:
virtual uno::Reference< frame::XModel > getModel()
{
return getCurrentDocument();
}
public:
ActiveWorkbook( const uno::Reference< vba::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){}
};
ScVbaApplication::ScVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): ScVbaApplication_BASE( uno::Reference< vba::XHelperInterface >(), xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic )
{
}
ScVbaApplication::~ScVbaApplication()
{
}
uno::Reference< excel::XWorkbook >
ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException)
{
return new ActiveWorkbook( this, mxContext );
}
uno::Reference< excel::XWorkbook > SAL_CALL
ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException)
{
return getActiveWorkbook();
}
uno::Any SAL_CALL
ScVbaApplication::getSelection() throw (uno::RuntimeException)
{
uno::Reference< lang::XServiceInfo > xServiceInfo( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW );
rtl::OUString sImpementaionName = xServiceInfo->getImplementationName();
if( sImpementaionName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") )
{
uno::Reference< drawing::XShapes > xShapes( getCurrentDocument()->getCurrentSelection(), uno::UNO_QUERY_THROW );
uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, ScVbaShape::getType( xShape ) ) ) );
}
else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) ||
xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges")))
{
uno::Reference< table::XCellRange > xRange( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
if ( !xRange.is() )
{
uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY);
if ( xRanges.is() )
return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRanges ) ) );
}
return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( this, mxContext, xRange ) ) );
}
else
{
throw uno::RuntimeException( sImpementaionName + rtl::OUString::createFromAscii(" donot be surpported"), uno::Reference< uno::XInterface >() );
}
}
uno::Reference< excel::XRange >
ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
{
uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW );
uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW);
ScTabViewShell* pViewShell = getCurrentBestViewShell();
if ( !pViewShell )
throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
ScViewData* pTabView = pViewShell->GetViewData();
if ( !pTabView )
throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewData available"), uno::Reference< uno::XInterface >() );
sal_Int32 nCursorX = pTabView->GetCurX();
sal_Int32 nCursorY = pTabView->GetCurY();
return new ScVbaRange( this, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
}
sal_Bool
ScVbaApplication::getScreenUpdating() throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
return !xModel->hasControllersLocked();
}
void
ScVbaApplication::setScreenUpdating(sal_Bool bUpdate) throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
if (bUpdate)
xModel->unlockControllers();
else
xModel->lockControllers();
}
sal_Bool
ScVbaApplication::getDisplayStatusBar() throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
if( xProps.is() ){
uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
if( xLayoutManager.is() && xLayoutManager->isElementVisible( url ) ){
return sal_True;
}
}
return sal_False;
}
void
ScVbaApplication::setDisplayStatusBar(sal_Bool bDisplayStatusBar) throw (uno::RuntimeException)
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< frame::XFrame > xFrame( xModel->getCurrentController()->getFrame(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
if( xProps.is() ){
uno::Reference< frame::XLayoutManager > xLayoutManager( xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LayoutManager")) ), uno::UNO_QUERY_THROW );
rtl::OUString url(RTL_CONSTASCII_USTRINGPARAM( "private:resource/statusbar/statusbar" ));
if( xLayoutManager.is() ){
if( bDisplayStatusBar && !xLayoutManager->isElementVisible( url ) ){
if( !xLayoutManager->showElement( url ) )
xLayoutManager->createElement( url );
return;
}
else if( !bDisplayStatusBar && xLayoutManager->isElementVisible( url ) ){
xLayoutManager->hideElement( url );
return;
}
}
}
return;
}
uno::Any SAL_CALL
ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
uno::Reference< vba::XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) );
if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
{
// void then somebody did Workbooks.something in vba
return uno::Any( xWorkBooks );
}
return uno::Any ( xWorkBooks->Item( aIndex, uno::Any() ) );
}
uno::Any SAL_CALL
ScVbaApplication::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
uno::Any result;
if ( xWorkbook.is() )
result = xWorkbook->Worksheets( aIndex );
else
// Fixme - check if this is reasonable/desired behavior
throw uno::RuntimeException( rtl::OUString::createFromAscii(
"No ActiveWorkBook available" ), uno::Reference< uno::XInterface >() );
return result;
}
uno::Any SAL_CALL
ScVbaApplication::WorksheetFunction( ) throw (::com::sun::star::uno::RuntimeException)
{
return uno::makeAny( uno::Reference< script::XInvocation >( new ScVbaWSFunction( this, mxContext) ) );
}
uno::Any SAL_CALL
ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
{
// #TODO Evaluate allows other things to be evaluated, e.g. functions
// I think ( like SIN(3) etc. ) need to investigate that
// named Ranges also? e.g. [MyRange] if so need a list of named ranges
uno::Any aVoid;
return uno::Any( getActiveWorkbook()->getActiveSheet()->Range( uno::Any( Name ), aVoid ) );
}
uno::Any
ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException)
{
uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< vba::XHelperInterface >( ScVbaGlobals::getGlobalsImpl( mxContext )->getApplication(), uno::UNO_QUERY_THROW ), mxContext ) );
if( !aIndex.hasValue() )
return uno::Any( xDialogs );
return uno::Any( xDialogs->Item( aIndex ) );
}
uno::Reference< excel::XWindow > SAL_CALL
ScVbaApplication::getActiveWindow() throw (uno::RuntimeException)
{
// #FIXME sofar can't determine Parent
return new ScVbaWindow( uno::Reference< vba::XHelperInterface >(), mxContext, getCurrentDocument() );
}
uno::Any SAL_CALL
ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
{
//# FIXME TODO, implementation
uno::Any result;
result <<= sal_False;
return result;
}
::rtl::OUString
ScVbaApplication::getVersion() throw (uno::RuntimeException)
{
return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(EXCELVERSION));
}
void SAL_CALL
ScVbaApplication::setCutCopyMode( const uno::Any& /*_cutcopymode*/ ) throw (uno::RuntimeException)
{
//# FIXME TODO, implementation
}
uno::Any SAL_CALL
ScVbaApplication::getStatusBar() throw (uno::RuntimeException)
{
return uno::makeAny( !getDisplayStatusBar() );
}
void SAL_CALL
ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::RuntimeException)
{
rtl::OUString sText;
sal_Bool bDefault = sal_False;
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY_THROW );
if( _statusbar >>= sText )
{
setDisplayStatusBar( sal_True );
xStatusIndicator->start( sText, 100 );
//xStatusIndicator->setText( sText );
}
else if( _statusbar >>= bDefault )
{
if( bDefault == sal_False )
{
xStatusIndicator->end();
setDisplayStatusBar( sal_True );
}
}
else
throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid prarameter. It should be a string or False" ),
uno::Reference< uno::XInterface >() );
}
double SAL_CALL
ScVbaApplication::CountA( const uno::Any& arg1 ) throw (uno::RuntimeException)
{
double result = 0;
uno::Reference< script::XInvocation > xInvoc( WorksheetFunction(), uno::UNO_QUERY_THROW );
if ( xInvoc.is() )
{
static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("CountA" ) );
uno::Sequence< uno::Any > Params(1);
Params[0] = arg1;
uno::Sequence< sal_Int16 > OutParamIndex;
uno::Sequence< uno::Any > OutParam;
xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= result;
}
return result;
}
::sal_Int32 SAL_CALL
ScVbaApplication::getCalculation() throw (uno::RuntimeException)
{
uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
if(xCalc->isAutomaticCalculationEnabled())
return excel::XlCalculation::xlCalculationAutomatic;
else
return excel::XlCalculation::xlCalculationManual;
}
void SAL_CALL
ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException)
{
uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
switch(_calculation)
{
case excel::XlCalculation::xlCalculationManual:
xCalc->enableAutomaticCalculation(sal_False);
break;
case excel::XlCalculation::xlCalculationAutomatic:
case excel::XlCalculation::xlCalculationSemiautomatic:
xCalc->enableAutomaticCalculation(sal_True);
break;
}
}
uno::Any SAL_CALL
ScVbaApplication::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
uno::Reference< vba::XCollection > xWindows = ScVbaWindows::Windows( mxContext );
if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
return uno::Any( xWindows );
return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
}
void SAL_CALL
ScVbaApplication::wait( double time ) throw (uno::RuntimeException)
{
StarBASIC* pBasic = SFX_APP()->GetBasic();
SFX_APP()->EnterBasicCall();
SbxArrayRef aArgs = new SbxArray;
SbxVariableRef aRef = new SbxVariable;
aRef->PutDouble( time );
aArgs->Put( aRef, 1 );
SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WaitUntil") ), SbxCLASS_METHOD );
if ( pMeth )
{
pMeth->SetParameters( aArgs );
SbxVariableRef refTemp = pMeth;
// forces a broadcast
SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth));
}
SFX_APP()->LeaveBasicCall();
}
uno::Any SAL_CALL
ScVbaApplication::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
{
uno::Reference< excel::XRange > xVbRange = ScVbaRange::ApplicationRange( mxContext, Cell1, Cell2 );
return uno::makeAny( xVbRange );
}
uno::Any SAL_CALL
ScVbaApplication::Names( ) throw ( uno::RuntimeException )
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< sheet::XNamedRanges > xNamedRanges( getActiveSheet() , uno::UNO_QUERY_THROW );
css::uno::Reference< excel::XNames > xNames ( new ScVbaNames( this , mxContext , xNamedRanges , xModel ) );
return uno::makeAny( xNames );
}
uno::Reference< excel::XWorksheet > SAL_CALL
ScVbaApplication::getActiveSheet() throw (uno::RuntimeException)
{
uno::Reference< excel::XWorksheet > result;
uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
if ( xWorkbook.is() )
{
uno::Reference< excel::XWorksheet > xWorksheet(
xWorkbook->getActiveSheet(), uno::UNO_QUERY );
if ( xWorksheet.is() )
{
result = xWorksheet;
}
}
if ( !result.is() )
{
// Fixme - check if this is reasonable/desired behavior
throw uno::RuntimeException( rtl::OUString::createFromAscii(
"No activeSheet available" ), uno::Reference< uno::XInterface >() );
}
return result;
}
/*******************************************************************************
* In msdn:
* Reference Optional Variant. The destination. Can be a Range
* object, a string that contains a cell reference in R1C1-style notation,
* or a string that contains a Visual Basic procedure name.
* Scroll Optional Variant. True to scrol, False to not scroll through
* the window. The default is False.
* Parser is split to three parts, Range, R1C1 string and procedure name.
* by test excel, it seems Scroll no effect. ???
*******************************************************************************/
void SAL_CALL
ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) throw (uno::RuntimeException)
{
//test Scroll is a boolean
sal_Bool bScroll = sal_False;
//R1C1-style string or a string of procedure name.
if( Scroll.hasValue() )
{
sal_Bool aScroll = sal_False;
if( Scroll >>= aScroll )
{
bScroll = aScroll;
}
else
throw uno::RuntimeException( rtl::OUString::createFromAscii( "sencond parameter should be boolean" ),
uno::Reference< uno::XInterface >() );
}
rtl::OUString sRangeName;
if( Reference >>= sRangeName )
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
xModel->getCurrentController(), uno::UNO_QUERY_THROW );
uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet();
ScTabViewShell* pShell = getCurrentBestViewShell();
ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
try
{
uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( mxContext, sRangeName, getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
;
if( bScroll )
{
xVbaSheetRange->Select();
uno::Reference< excel::XWindow > xWindow = getActiveWindow();
ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ),
uno::makeAny( (sal_Int16)nValueY ),
uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ),
uno::makeAny( (sal_Int16)nValueX ) );
gridWindow->GrabFocus();
}
else
{
xVbaSheetRange->Select();
gridWindow->GrabFocus();
}
}
catch( uno::RuntimeException )
{
//maybe this should be a procedure name
//TODO for procedure name
//browse::XBrowseNodeFactory is a singlton. OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory")
//and the createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) to get a root browse::XBrowseNode.
//for query XInvocation interface.
//but how to directly get the XInvocation?
throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference for range name, it should be procedure name" ),
uno::Reference< uno::XInterface >() );
}
return;
}
uno::Reference< excel::XRange > xRange;
if( Reference >>= xRange )
{
uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY );
ScTabViewShell* pShell = getCurrentBestViewShell();
ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
if ( xVbaRange.is() )
{
//TODO bScroll should be using, In this time, it doesenot have effection
if( bScroll )
{
xVbaRange->Select();
uno::Reference< excel::XWindow > xWindow = getActiveWindow();
ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ),
uno::makeAny( (sal_Int16)nValueY ),
uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ),
uno::makeAny( (sal_Int16)nValueX ) );
gridWindow->GrabFocus();
}
else
{
xVbaRange->Select();
gridWindow->GrabFocus();
}
}
return;
}
throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference or name" ),
uno::Reference< uno::XInterface >() );
}
namespace
{
static uno::Reference< frame::XController > lcl_getCurrentController()
{
const uno::Reference< frame::XModel > xWorkingDoc( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
uno::Reference< frame::XController > xController;
if ( xWorkingDoc.is() )
xController.set( xWorkingDoc->getCurrentController(), uno::UNO_SET_THROW );
else
xController.set( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
return xController;
}
}
sal_Int32 SAL_CALL
ScVbaApplication::getCursor() throw (uno::RuntimeException)
{
sal_Int32 nPointerStyle( POINTER_ARROW );
try
{
const uno::Reference< frame::XController > xController( lcl_getCurrentController(), uno::UNO_SET_THROW );
const uno::Reference< frame::XFrame > xFrame ( xController->getFrame(), uno::UNO_SET_THROW );
const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
// why the heck isn't there an XWindowPeer::getPointer, but a setPointer only?
const Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
if ( pWindow )
nPointerStyle = pWindow->GetSystemWindow()->GetPointer().GetStyle();
}
catch( const uno::Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
switch( nPointerStyle )
{
case POINTER_ARROW:
return excel::XlMousePointer::xlNorthwestArrow;
case POINTER_NULL:
return excel::XlMousePointer::xlDefault;
case POINTER_WAIT:
return excel::XlMousePointer::xlWait;
case POINTER_TEXT:
return excel::XlMousePointer::xlIBeam;
default:
return excel::XlMousePointer::xlDefault;
}
}
void SAL_CALL
ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
{
try
{
::std::vector< uno::Reference< frame::XController > > aControllers;
const uno::Reference< frame::XModel2 > xModel2( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
if ( xModel2.is() )
{
const uno::Reference< container::XEnumeration > xEnumControllers( xModel2->getControllers(), uno::UNO_SET_THROW );
while ( xEnumControllers->hasMoreElements() )
{
const uno::Reference< frame::XController > xController( xEnumControllers->nextElement(), uno::UNO_QUERY_THROW );
aControllers.push_back( xController );
}
}
else
{
const uno::Reference< frame::XModel > xModel( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY );
if ( xModel.is() )
{
const uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW );
aControllers.push_back( xController );
}
else
{
const uno::Reference< frame::XController > xController( SfxObjectShell::GetCurrentComponent(), uno::UNO_QUERY_THROW );
aControllers.push_back( xController );
}
}
for ( ::std::vector< uno::Reference< frame::XController > >::const_iterator controller = aControllers.begin();
controller != aControllers.end();
++controller
)
{
const uno::Reference< frame::XFrame > xFrame ( (*controller)->getFrame(), uno::UNO_SET_THROW );
const uno::Reference< awt::XWindow > xWindow ( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
OSL_ENSURE( pWindow, "ScVbaApplication::setCursor: no window!" );
if ( !pWindow )
continue;
switch( _cursor )
{
case excel::XlMousePointer::xlNorthwestArrow:
{
const Pointer& rPointer( POINTER_ARROW );
pWindow->GetSystemWindow()->SetPointer( rPointer );
pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
break;
}
case excel::XlMousePointer::xlWait:
case excel::XlMousePointer::xlIBeam:
{
const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) );
//It will set the edit window, toobar and statusbar's mouse pointer.
pWindow->GetSystemWindow()->SetPointer( rPointer );
pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_True );
//It only set the edit window's mouse pointer
//pWindow->.SetPointer( rPointer );
//pWindow->.EnableChildPointerOverwrite( sal_True );
//printf("\nset Cursor...%d\n", pWindow->.GetType());
break;
}
case excel::XlMousePointer::xlDefault:
{
const Pointer& rPointer( POINTER_NULL );
pWindow->GetSystemWindow()->SetPointer( rPointer );
pWindow->GetSystemWindow()->EnableChildPointerOverwrite( sal_False );
break;
}
default:
throw uno::RuntimeException( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
// TODO: isn't this a flaw in the API? It should be allowed to throw an
// IllegalArgumentException, or so
}
}
}
catch( const uno::Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
// #TODO perhaps we should switch the return type depending of the filter
// type, e.g. return Calc for Calc and Excel if its an imported doc
rtl::OUString SAL_CALL
ScVbaApplication::getName() throw (uno::RuntimeException)
{
static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Excel" ) );
return appName;
}
// #TODO #FIXME get/setDisplayAlerts are just stub impl
void SAL_CALL
ScVbaApplication::setDisplayAlerts(sal_Bool /*displayAlerts*/) throw (uno::RuntimeException)
{
}
sal_Bool SAL_CALL
ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException)
{
return sal_True;
}
void SAL_CALL
ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException )
{
uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
uno::Reference< sheet::XCalculatable > xCalculatable( getCurrentDocument(), uno::UNO_QUERY_THROW );
xCalculatable->calculateAll();
}
uno::Reference< beans::XPropertySet > lcl_getPathSettingsService( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException )
{
static uno::Reference< beans::XPropertySet > xPathSettings;
if ( !xPathSettings.is() )
{
uno::Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager(), uno::UNO_QUERY_THROW );
xPathSettings.set( xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.util.PathSettings"), xContext), uno::UNO_QUERY_THROW );
}
return xPathSettings;
}
rtl::OUString ScVbaApplication::getOfficePath( const rtl::OUString& _sPathType ) throw ( uno::RuntimeException )
{
rtl::OUString sRetPath;
uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
try
{
rtl::OUString sUrl;
xProps->getPropertyValue( _sPathType ) >>= sUrl;
// if its a list of paths then use the last one
sal_Int32 nIndex = sUrl.lastIndexOf( ';' ) ;
if ( nIndex > 0 )
sUrl = sUrl.copy( nIndex + 1 );
::osl::File::getSystemPathFromFileURL( sUrl, sRetPath );
}
catch (uno::Exception&)
{
DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
}
return sRetPath;
}
void SAL_CALL
ScVbaApplication::setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (script::BasicErrorException, uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
rtl::OUString aURL;
osl::FileBase::getFileURLFromSystemPath( DefaultFilePath, aURL );
xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")), uno::makeAny( aURL ) );
}
::rtl::OUString SAL_CALL
ScVbaApplication::getDefaultFilePath( ) throw (script::BasicErrorException, uno::RuntimeException)
{
return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")));
}
::rtl::OUString SAL_CALL
ScVbaApplication::LibraryPath( ) throw (script::BasicErrorException, uno::RuntimeException)
{
return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Basic")));
}
::rtl::OUString SAL_CALL
ScVbaApplication::TemplatesPath( ) throw (script::BasicErrorException, uno::RuntimeException)
{
return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template")));
}
::rtl::OUString SAL_CALL
ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::RuntimeException)
{
static rtl::OUString sPathSep( RTL_CONSTASCII_USTRINGPARAM( FILE_PATH_SEPERATOR ) );
return sPathSep;
}
uno::Reference< excel::XRange > SAL_CALL
ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const uno::Reference< excel::XRange >& Arg2, const uno::Any& Arg3, const uno::Any& Arg4, const uno::Any& Arg5, const uno::Any& Arg6, const uno::Any& Arg7, const uno::Any& Arg8, const uno::Any& Arg9, const uno::Any& Arg10, const uno::Any& Arg11, const uno::Any& Arg12, const uno::Any& Arg13, const uno::Any& Arg14, const uno::Any& Arg15, const uno::Any& Arg16, const uno::Any& Arg17, const uno::Any& Arg18, const uno::Any& Arg19, const uno::Any& Arg20, const uno::Any& Arg21, const uno::Any& Arg22, const uno::Any& Arg23, const uno::Any& Arg24, const uno::Any& Arg25, const uno::Any& Arg26, const uno::Any& Arg27, const uno::Any& Arg28, const uno::Any& Arg29, const uno::Any& Arg30 ) throw (script::BasicErrorException, uno::RuntimeException)
{
std::vector< uno::Reference< excel::XRange > > vRanges;
if ( !Arg1.is() || !Arg2.is() )
DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
vRanges.push_back( Arg1 );
vRanges.push_back( Arg2 );
if ( Arg3.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg3, uno::UNO_QUERY_THROW ) );
if ( Arg4.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg4, uno::UNO_QUERY_THROW ) );
if ( Arg5.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg5, uno::UNO_QUERY_THROW ) );
if ( Arg6.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg6, uno::UNO_QUERY_THROW ) );
if ( Arg7.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg7, uno::UNO_QUERY_THROW ) );
if ( Arg8.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg8, uno::UNO_QUERY_THROW ) );
if ( Arg9.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg9, uno::UNO_QUERY_THROW ) );
if ( Arg10.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg10, uno::UNO_QUERY_THROW ) );
if ( Arg11.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg11, uno::UNO_QUERY_THROW ) );
if ( Arg12.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg12, uno::UNO_QUERY_THROW ) );
if ( Arg13.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg13, uno::UNO_QUERY_THROW ) );
if ( Arg14.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg14, uno::UNO_QUERY_THROW ) );
if ( Arg15.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg15, uno::UNO_QUERY_THROW ) );
if ( Arg16.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg16, uno::UNO_QUERY_THROW ) );
if ( Arg17.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg17, uno::UNO_QUERY_THROW ) );
if ( Arg18.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg18, uno::UNO_QUERY_THROW ) );
if ( Arg19.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg19, uno::UNO_QUERY_THROW ) );
if ( Arg20.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg20, uno::UNO_QUERY_THROW ) );
if ( Arg21.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg21, uno::UNO_QUERY_THROW ) );
if ( Arg22.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg22, uno::UNO_QUERY_THROW ) );
if ( Arg23.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg23, uno::UNO_QUERY_THROW ) );
if ( Arg24.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg24, uno::UNO_QUERY_THROW ) );
if ( Arg25.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg25, uno::UNO_QUERY_THROW ) );
if ( Arg26.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg26, uno::UNO_QUERY_THROW ) );
if ( Arg27.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg27, uno::UNO_QUERY_THROW ) );
if ( Arg28.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg28, uno::UNO_QUERY_THROW ) );
if ( Arg29.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg29, uno::UNO_QUERY_THROW ) );
if ( Arg30.hasValue() )
vRanges.push_back( uno::Reference< excel::XRange >( Arg30, uno::UNO_QUERY_THROW ) );
std::vector< uno::Reference< excel::XRange > >::iterator it = vRanges.begin();
std::vector< uno::Reference< excel::XRange > >::iterator it_end = vRanges.end();
uno::Reference< excel::XRange > xRefRange( *it );
++it;
for ( ; it != it_end; ++it )
{
ScVbaRange* pRange = dynamic_cast< ScVbaRange * >( xRefRange.get());
if ( pRange )
xRefRange = pRange->intersect( *it );
if ( !xRefRange.is() )
return uno::Reference< excel::XRange >();
}
return xRefRange;
}
void
ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeException )
{
sal_Bool bVolatile = sal_True;
aVolatile >>= bVolatile;
return;
/*
if ( bVolatile )
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Volatile - not supported" ) ), uno::Reference< uno::XInterface >() );
// bVoloatile is false - currently this only would make sense if
// the autocalculate mode is set to be true.
// so really this is crap, #TODO try and understand how ( or if )
// the calculation mode and volatile interoperate
if ( ! getCalculation() == excel::XlCalculation::xlCalculationAutomatic )
setCalculation( excel::XlCalculation::xlCalculationAutomatic );
*/
}
void SAL_CALL
ScVbaApplication::DoEvents() throw ( uno::RuntimeException )
{
}
::sal_Bool SAL_CALL
ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
{
sal_Bool bRes = sal_False;
ScTabViewShell* pViewShell = getCurrentBestViewShell();
if ( pViewShell )
{
SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE);
SfxAllItemSet reqList( SFX_APP()->GetPool() );
reqList.Put( sfxFormBar );
pViewShell->GetState( reqList );
const SfxPoolItem *pItem=0;
if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, sal_False, &pItem ) == SFX_ITEM_SET )
bRes = ((SfxBoolItem*)pItem)->GetValue();
}
return bRes;
}
void SAL_CALL
ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException )
{
ScTabViewShell* pViewShell = getCurrentBestViewShell();
if ( pViewShell && ( _displayformulabar != getDisplayFormulaBar() ) )
{
SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar);
SfxAllItemSet reqList( SFX_APP()->GetPool() );
SfxRequest aReq( FID_TOGGLEINPUTLINE, 0, reqList );
pViewShell->Execute( aReq );
}
}
rtl::OUString&
ScVbaApplication::getServiceImplName()
{
static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaApplication") );
return sImplName;
}
uno::Sequence< rtl::OUString >
ScVbaApplication::getServiceNames()
{
static uno::Sequence< rtl::OUString > aServiceNames;
if ( aServiceNames.getLength() == 0 )
{
aServiceNames.realloc( 1 );
aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.excel.Application" ) );
}
return aServiceNames;
}