From 2302d3fff5bbd5a695a6988ee435c2f4b51f2d31 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 16 Apr 2010 23:05:45 +0200 Subject: CWS gnumake2: move header generation for oovbaapi to offuh --- sc/source/ui/vba/makefile.mk | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 253d0f52ab96..e27bf970cc7b 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -109,15 +109,3 @@ SLOFILES= \ .INCLUDE : target.mk -.IF "$(L10N_framework)"=="" - -ALLTAR : \ - $(MISC)$/$(TARGET).don \ - -$(SLOFILES) : $(MISC)$/$(TARGET).don - -$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb - +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ - echo $@ - -.ENDIF -- cgit From 4eed799a79cffa08a9cae7e8980a0f4673441289 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 18 Aug 2010 17:20:31 +0200 Subject: mib19: #163305# do not fire sheet activation events, when a sheet gets inserted/deleted etc. and the active sheet just changes its index --- sc/source/ui/vba/vbaeventshelper.cxx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 45667adf2f2c..f19a2e57e549 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -470,14 +470,12 @@ bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) { - // check preconditions for some events, add more events if needed - bool bExecuteEvent = true; + // framework and Calc fire a few events before 'opened', ignore them + bool bExecuteEvent = mbOpened; + + // special handling for some events switch( rInfo.mnEventId ) { - case WORKBOOK_ACTIVATE: - // while loading, framework fires this before 'opened' event, delay it - bExecuteEvent = mbOpened; - break; case WORKBOOK_OPEN: bExecuteEvent = !mbOpened; if( bExecuteEvent ) @@ -490,15 +488,17 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, break; case WORKSHEET_SELECTIONCHANGE: // if selection is not changed, then do not fire the event - bExecuteEvent = mbOpened && isSelectionChanged( rArgs, 0 ); + bExecuteEvent = bExecuteEvent && isSelectionChanged( rArgs, 0 ); break; } // add workbook event associated to a sheet event - bool bSheetEvent = false; - rInfo.maUserData >>= bSheetEvent; - if( bSheetEvent && bExecuteEvent ) - rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + if( bExecuteEvent ) + { + bool bSheetEvent = false; + if( (rInfo.maUserData >>= bSheetEvent) && bSheetEvent ) + rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + } return bExecuteEvent; } -- cgit From f43dbd543d60efafd66bb50c5e4e2d0bf6ee0d53 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 23 Aug 2010 12:08:40 +0200 Subject: #163288# treat Excel number format 'General' as standard format --- sc/source/ui/vba/vbarange.cxx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 455af075306c..d34c0421805f 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -539,19 +539,22 @@ public: { uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps(); sal_Int16 nType = ::comphelper::getINT16( - xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) ); + xNumberProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) ); return nType; } - bool setNumberFormat( const rtl::OUString& rFormat ) + bool setNumberFormat( const rtl::OUString& rFormat ) { - lang::Locale aLocale; - uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); - xNumProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale; - sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false ); - if ( nNewIndex == -1 ) // format not defined + // #163288# treat "General" as "Standard" format + sal_Int32 nNewIndex = 0; + if( !rFormat.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "General" ) ) ) { - nNewIndex = mxFormats->addNew( rFormat, aLocale ); + lang::Locale aLocale; + uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); + xNumProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) ) ) >>= aLocale; + nNewIndex = mxFormats->queryKey( rFormat, aLocale, false ); + if ( nNewIndex == -1 ) // format not defined + nNewIndex = mxFormats->addNew( rFormat, aLocale ); } mxRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat") ), uno::makeAny( nNewIndex ) ); return true; @@ -561,7 +564,7 @@ public: { uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps(); lang::Locale aLocale; - xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale; + xNumberProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Locale" ) ) ) >>= aLocale; uno::Reference xTypes( mxFormats, uno::UNO_QUERY ); if ( xTypes.is() ) { -- cgit From c99b24c76c886ddaa93e290412c7674807c23405 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 23 Aug 2010 13:53:47 +0200 Subject: mib19: improved event handling: do not supreppress global events, when Application.EnableEvents symbol set to false --- sc/source/ui/vba/vbaeventshelper.cxx | 50 +++++++++++++++++------------------- sc/source/ui/vba/vbaeventshelper.hxx | 1 - 2 files changed, 24 insertions(+), 27 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index f19a2e57e549..99ccbeaaa822 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -441,35 +441,13 @@ void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) t // protected ------------------------------------------------------------------ -bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) { // document and document shell are needed during event processing - if( !mpDocShell || !mpDoc ) + if( !mpShell || !mpDoc ) throw uno::RuntimeException(); - // get Application object and check if events are enabled (this is an Excel-only attribute) - uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); - if( !xApplication.is() && mpShell ) - { - uno::Any aVBAGlobals; - mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); - uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY ); - if( xHelperInterface.is() ) - { - xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY ); - mxApplication = xApplication; - } - } - if( !xApplication.is() ) - throw uno::RuntimeException(); - - // return whether event processing is enabled - return xApplication->getEnableEvents(); -} - -bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, - const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) -{ // framework and Calc fire a few events before 'opened', ignore them bool bExecuteEvent = mbOpened; @@ -492,12 +470,32 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, break; } - // add workbook event associated to a sheet event if( bExecuteEvent ) { + // add workbook event associated to a sheet event bool bSheetEvent = false; if( (rInfo.maUserData >>= bSheetEvent) && bSheetEvent ) rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + + /* For document events: get Application object and check if events are + enabled via EnableEvents symbol (this is an Excel-only attribute). + Check this again for every event, as the event handler may change + the state of the EnableEvents symbol. Global events such as + AUTO_OPEN and AUTO_CLOSE are always enabled. */ + if( rInfo.meType == EVENTHANDLER_DOCUMENT ) + { + // reference to application is held weakly, get application on first try + uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); + if( !xApplication.is() ) + { + uno::Any aVBAGlobals; + mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); + uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY_THROW ); + xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY_THROW ); + mxApplication = xApplication; + } + bExecuteEvent = xApplication->getEnableEvents(); + } } return bExecuteEvent; diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index a77f5128b3e9..eaac96117d32 100755 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -51,7 +51,6 @@ public: virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) throw (css::uno::RuntimeException); protected: - virtual bool implEventsEnabled() throw (css::uno::RuntimeException); virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException); -- cgit From 997221829f958e2ca08e9b8d57292f380317e808 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 25 Aug 2010 13:43:42 +0200 Subject: mib19: #163419# do not throw exceptions into Application core --- sc/source/ui/vba/vbaeventshelper.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 99ccbeaaa822..7b0400c59b76 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -90,7 +90,6 @@ private: uno::Reference< awt::XWindow > getContainerWindow(); bool isMouseReleased(); DECL_LINK( fireResizeMacro, void* ); - void processWindowResizeMacro(); private: ::osl::Mutex maMutex; @@ -271,6 +270,8 @@ void SAL_CALL ScVbaEventsListener::borderWidthsChanged( const uno::Reference< un void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException) { + if( !mrVbaEvents.hasVbaEventHandler( WORKSHEET_CHANGE, aArgs ) ) + sal_Int32 nCount = aEvent.Changes.getLength(); if( nCount == 0 ) return; @@ -362,19 +363,18 @@ bool ScVbaEventsListener::isMouseReleased() IMPL_LINK( ScVbaEventsListener, fireResizeMacro, void*, EMPTYARG ) { - if( !mbDisposed && isMouseReleased() ) - processWindowResizeMacro(); + if( !mbDisposed && isMouseReleased() ) try + { + mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); + } + catch( uno::Exception& ) + { + // #163419# do not throw exceptions into application core + } release(); return 0; } -void ScVbaEventsListener::processWindowResizeMacro() -{ - OSL_TRACE( "**** Attempt to FIRE MACRO **** " ); - if( !mbDisposed ) - mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); -} - // ============================================================================ ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& xContext ) : -- cgit From cec16f1b7a3c5e7327b41c8b4a5386628b339f0d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 25 Aug 2010 13:48:27 +0200 Subject: mib19: #163419# corrected wrong commit --- sc/source/ui/vba/vbaeventshelper.cxx | 2 -- 1 file changed, 2 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 7b0400c59b76..996bf52e0794 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -270,8 +270,6 @@ void SAL_CALL ScVbaEventsListener::borderWidthsChanged( const uno::Reference< un void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException) { - if( !mrVbaEvents.hasVbaEventHandler( WORKSHEET_CHANGE, aArgs ) ) - sal_Int32 nCount = aEvent.Changes.getLength(); if( nCount == 0 ) return; -- cgit From 7e8aec45e5b2313a682fcec37e47e2f6ee8a2a47 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 26 Aug 2010 14:15:19 +0200 Subject: mib19: #163428# VBA symbol Worksheet.Visible supports xlSheetVeryHidden now --- sc/source/ui/vba/vbaworksheet.cxx | 43 +++++++++++++++++++++++++++------------ sc/source/ui/vba/vbaworksheet.hxx | 5 +++-- 2 files changed, 33 insertions(+), 15 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 6ee6fa1f6b19..b2421727f109 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -179,18 +180,18 @@ openNewDoc(rtl::OUString aSheetName ) return xModel; } -ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ) +ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext ), mbVeryHidden( false ) { } ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheet >& xSheet, - const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel) + const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel), mbVeryHidden( false ) { } ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args, - uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ) + uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ), mbVeryHidden( false ) { if ( args.getLength() < 2 ) throw lang::IllegalArgumentException(); @@ -221,24 +222,40 @@ ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeExcept xNamed->setName( rName ); } -sal_Bool +sal_Int32 ScVbaWorksheet::getVisible() throw (uno::RuntimeException) { uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - uno::Any aValue = xProps->getPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) ); - sal_Bool bRet = false; - aValue >>= bRet; - return bRet; + bool bVisible = false; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) ) >>= bVisible; + using namespace ::ooo::vba::excel::XlSheetVisibility; + return bVisible ? xlSheetVisible : (mbVeryHidden ? xlSheetVeryHidden : xlSheetHidden); } void -ScVbaWorksheet::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException) +ScVbaWorksheet::setVisible( sal_Int32 nVisible ) throw (uno::RuntimeException) { + using namespace ::ooo::vba::excel::XlSheetVisibility; + bool bVisible = true; + switch( nVisible ) + { + case xlSheetVisible: case 1: // Excel accepts -1 and 1 for visible sheets + bVisible = true; + mbVeryHidden = false; + break; + case xlSheetHidden: + bVisible = false; + mbVeryHidden = false; + break; + case xlSheetVeryHidden: + bVisible = false; + mbVeryHidden = true; + break; + default: + throw uno::RuntimeException(); + } uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - uno::Any aValue( bVisible ); - xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue); + xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), uno::Any( bVisible ) ); } sal_Int16 diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index 78bcc2503a49..ff5850b7c445 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -62,6 +62,7 @@ class ScVbaWorksheet : public WorksheetImpl_BASE css::uno::Reference< ov::excel::XChartObjects > mxCharts; css::uno::Reference< ov::excel::XHyperlinks > mxHlinks; ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons; + bool mbVeryHidden; css::uno::Reference< ov::excel::XWorksheet > getSheetAtOffset(SCTAB offset) throw (css::uno::RuntimeException); css::uno::Reference< ov::excel::XRange > getSheetRange() throw (css::uno::RuntimeException); @@ -91,8 +92,8 @@ public: // Attributes virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); virtual void SAL_CALL setName( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); - virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual void SAL_CALL setVisible( sal_Int32 nVisible ) throw (css::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getStandardWidth() throw (css::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getStandardHeight() throw (css::uno::RuntimeException); virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException); -- cgit From 9840b5ce988888a7c85560e2b1e0c1b99bfa96b4 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 26 Aug 2010 18:37:44 +0200 Subject: dr77: #i114128# import legacy drawing controls --- sc/source/ui/vba/vbasheetobject.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 sc/source/ui/vba/vbasheetobject.cxx (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx old mode 100755 new mode 100644 index 4bd0f1d60547..f92cafa0da0d --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -350,14 +350,14 @@ void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) // if a macro name has been passed, try to attach it to the event if( rMacroName.getLength() > 0 ) { - VBAMacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); - if( !aResolvedMacro.IsResolved() ) + MacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName ); + if( !aResolvedMacro.mbFound ) throw uno::RuntimeException(); script::ScriptEventDescriptor aDescriptor; aDescriptor.ListenerType = maListenerType; aDescriptor.EventMethod = maEventMethod; aDescriptor.ScriptType = CREATE_OUSTRING( "Script" ); - aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.ResolvedMacro() ); + aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.msResolvedMacro ); xEventMgr->registerScriptEvent( nIndex, aDescriptor ); } } -- cgit From 02ced0d8f545a00a610ae461d925e7851e9baef0 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Wed, 1 Sep 2010 10:26:59 +0200 Subject: mib19: #163498# correct parent for sheet-local defined names --- sc/source/ui/vba/vbanames.cxx | 5 +++-- sc/source/ui/vba/vbaworkbook.cxx | 14 ++++++-------- sc/source/ui/vba/vbaworksheet.cxx | 13 +++++++++++-- 3 files changed, 20 insertions(+), 12 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index 9fd22bf89f7a..1386bec7fa70 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -100,7 +100,6 @@ ScVbaNames::Add( const css::uno::Any& Name , const css::uno::Any& RefersToR1C1, const css::uno::Any& RefersToR1C1Local ) throw (css::uno::RuntimeException) { - rtl::OUString sName; uno::Reference< excel::XRange > xRange; if ( Name.hasValue() ) @@ -158,6 +157,8 @@ ScVbaNames::Add( const css::uno::Any& Name , if ( mxNames->hasByName( sName ) ) mxNames->removeByName(sName); mxNames->addNewByName( sName , rtl::OUString(sTmp) , aCellAddr , (sal_Int32)nType); + uno::Reference< sheet::XNamedRange > xName( mxNames->getByName( sName ), uno::UNO_QUERY_THROW ); + return uno::Any( uno::Reference< excel::XName >( new ScVbaName( getParent(), mxContext, xName, mxNames, mxModel ) ) ); } } return css::uno::Any(); @@ -174,7 +175,7 @@ uno::Reference< container::XEnumeration > ScVbaNames::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW ); - return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); + return new NamesEnumeration( getParent(), mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames ); } uno::Any diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx index 28469c4685a2..1e2acd6252b8 100644 --- a/sc/source/ui/vba/vbaworkbook.cxx +++ b/sc/source/ui/vba/vbaworkbook.cxx @@ -300,7 +300,7 @@ ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::Runtime } css::uno::Any SAL_CALL -ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) +ScVbaWorkbook::Styles( const uno::Any& Item ) throw (uno::RuntimeException) { // quick look and Styles object doesn't seem to have a valid parent // or a least the object browser just shows an object that has no @@ -313,18 +313,16 @@ ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException) // Amelia Wang uno::Any SAL_CALL -ScVbaWorkbook::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) +ScVbaWorkbook::Names( const uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel( getModel() ); + uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW ); uno::Reference< beans::XPropertySet > xProps( xModel, uno::UNO_QUERY_THROW ); uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xNames( new ScVbaNames( this , mxContext , xNamedRanges , xModel )); - if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - { + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, xModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); return uno::Any( xNames ); } - return uno::Any( xNames->Item( aIndex, uno::Any() ) ); -} rtl::OUString& ScVbaWorkbook::getServiceImplName() diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index b2421727f109..1f31cb7e19ce 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ #include "vbaworksheets.hxx" #include "vbahyperlinks.hxx" #include "vbasheetobjects.hxx" +#include "vbanames.hxx" #define STANDARDWIDTH 2267 #define STANDARDHEIGHT 427 @@ -733,8 +735,15 @@ ScVbaWorksheet::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeExceptio uno::Any SAL_CALL ScVbaWorksheet::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException) { - uno::Reference< excel::XWorkbook > xWorkbook( getParent(), uno::UNO_QUERY_THROW ); - return xWorkbook->Names( aIndex ); + // fake sheet-local names by returning all global names + // #163498# initialize Names object with correct parent (this worksheet) + // TODO: real sheet-local names... + uno::Reference< beans::XPropertySet > xProps( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW ); + uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, mxModel ) ); + if ( aIndex.hasValue() ) + return uno::Any( xNames->Item( aIndex, uno::Any() ) ); + return uno::Any( xNames ); } uno::Any SAL_CALL -- cgit From e0e1dac321cd029d51f211979b43c039b1a2ddfa Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Tue, 7 Sep 2010 15:52:13 +0200 Subject: mib19: #163561# use mode SC_SIZE_DIRECT for SetWidthOrHeight --- sc/source/ui/vba/vbarange.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index d34c0421805f..230af4f5d5e3 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -3740,7 +3740,8 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx SCCOLROW nColArr[2]; nColArr[0] = thisAddress.StartColumn; nColArr[1] = thisAddress.EndColumn; - aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, + // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values + aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_DIRECT, nTwips, TRUE, TRUE ); } @@ -3904,7 +3905,8 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti SCCOLROW nRowArr[2]; nRowArr[0] = thisAddress.StartRow; nRowArr[1] = thisAddress.EndRow; - aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, + // #163561# use mode SC_SIZE_DIRECT: hide for height 0, show for other values + aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_DIRECT, nTwips, TRUE, TRUE ); } -- cgit From 9f7c8470ae5b47b3a36e6f447228e8ec6f95d0c3 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 8 Sep 2010 14:20:41 +0200 Subject: mib19: #163497# implement VBA Placement property --- sc/source/ui/vba/vbasheetobject.cxx | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) mode change 100755 => 100644 sc/source/ui/vba/vbasheetobject.cxx (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx old mode 100755 new mode 100644 index 4bd0f1d60547..28e54de859ad --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -38,7 +38,9 @@ #include #include #include +#include #include "vbafont.hxx" +#include "drwlayer.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -237,13 +239,38 @@ void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno: sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException) { - // TODO - return excel::XlPlacement::xlMoveAndSize; + sal_Int32 nRet = excel::XlPlacement::xlMoveAndSize; + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = ScDrawLayer::GetAnchor(pObj); + if (eType == SCA_PAGE) + nRet = excel::XlPlacement::xlFreeFloating; + } + } + return nRet; } -void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException) +void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 nPlacement ) throw (uno::RuntimeException) { - // TODO + SvxShape* pShape = SvxShape::getImplementation( mxShape ); + if(pShape) + { + SdrObject* pObj = pShape->GetSdrObject(); + if (pObj) + { + ScAnchorType eType = SCA_CELL; + if ( nPlacement == excel::XlPlacement::xlFreeFloating ) + eType = SCA_PAGE; + + // xlMove is not supported, treated as SCA_CELL (xlMoveAndSize) + + ScDrawLayer::SetAnchor(pObj, eType); + } + } } sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException) -- cgit From 369f4c3d1fca0b4d3b96a9085169545abc641736 Mon Sep 17 00:00:00 2001 From: Thomas Benisch Date: Wed, 8 Sep 2010 19:23:58 +0200 Subject: mib19: #163530# Filter box shows only entry of first row --- sc/source/ui/vba/vbarange.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 230af4f5d5e3..25d19fb76687 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -4355,6 +4355,20 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const { RangeHelper multiCellRange( mxRange ); autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress(); + // #163530# Filter box shows only entry of first row + ScDocument* pDocument = ( pShell ? pShell->GetDocument() : NULL ); + if ( pDocument ) + { + SCCOL nStartCol = autoFiltAddress.StartColumn; + SCROW nStartRow = autoFiltAddress.StartRow; + SCCOL nEndCol = autoFiltAddress.EndColumn; + SCROW nEndRow = autoFiltAddress.EndRow; + pDocument->GetDataArea( autoFiltAddress.Sheet, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, true ); + autoFiltAddress.StartColumn = nStartCol; + autoFiltAddress.StartRow = nStartRow; + autoFiltAddress.EndColumn = nEndCol; + autoFiltAddress.EndRow = nEndRow; + } } uno::Reference< sheet::XDatabaseRanges > xDBRanges = lcl_GetDataBaseRanges( pShell ); @@ -4374,13 +4388,9 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const uno::Reference< beans::XPropertySet > xDBRangeProps( xDataBaseRange, uno::UNO_QUERY_THROW ); // set autofilt xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(sal_True) ); - // set header + // set header (autofilter always need column headers) uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW ); - sal_Bool bHasColHeader = sal_False; - ScDocument* pDoc = pShell ? pShell->GetDocument() : NULL; - - bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ) ? sal_True : sal_False; - xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( bHasColHeader ) ); + xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( sal_True ) ); } -- cgit From d75e8a885ff260f25ec71abb0c4c772453f504fb Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 9 Sep 2010 13:55:29 +0200 Subject: mib19: #163560# use default cell font and RefDevice for column width --- sc/source/ui/vba/vbarange.cxx | 61 ++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 25d19fb76687..d32ad0a4b41e 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -172,6 +172,9 @@ using namespace ::ooo::vba; using namespace ::com::sun::star; using ::std::vector; +// difference between VBA and file format width, in character units +const double fExtraWidth = 182.0 / 256.0; + // * 1 point = 1/72 inch = 20 twips // * 1 inch = 72 points = 1440 twips // * 1 cm = 567 twips @@ -3614,15 +3617,6 @@ ScVbaRange::getDefaultMethodName( ) throw (uno::RuntimeException) } -uno::Reference< awt::XDevice > -getDeviceFromDoc( const uno::Reference< frame::XModel >& xModel ) throw( uno::RuntimeException ) -{ - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XFrame> xFrame( xController->getFrame(), uno::UNO_QUERY_THROW ); - uno::Reference< awt::XDevice > xDevice( xFrame->getComponentWindow(), uno::UNO_QUERY_THROW ); - return xDevice; -} - // returns calc internal col. width ( in points ) double ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno::RuntimeException) @@ -3645,29 +3639,16 @@ ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (u } // return Char Width in points -double getDefaultCharWidth( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) -{ - const static rtl::OUString sDflt( RTL_CONSTASCII_USTRINGPARAM("Default")); - const static rtl::OUString sCharFontName( RTL_CONSTASCII_USTRINGPARAM("CharFontName")); - const static rtl::OUString sPageStyles( RTL_CONSTASCII_USTRINGPARAM("PageStyles")); - // get the font from the default style - uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xNameAccess( xStyleSupplier->getStyleFamilies(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xNameAccess2( xNameAccess->getByName( sPageStyles ), uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xNameAccess2->getByName( sDflt ), uno::UNO_QUERY_THROW ); - rtl::OUString sFontName; - xProps->getPropertyValue( sCharFontName ) >>= sFontName; - - uno::Reference< awt::XDevice > xDevice = getDeviceFromDoc( xModel ); - awt::FontDescriptor aDesc; - aDesc.Name = sFontName; - uno::Reference< awt::XFont > xFont( xDevice->getFont( aDesc ), uno::UNO_QUERY_THROW ); - double nCharPixelWidth = xFont->getCharWidth( (sal_Int8)'0' ); - - double nPixelsPerMeter = xDevice->getInfo().PixelPerMeterX; - double nCharWidth = nCharPixelWidth / nPixelsPerMeter; - nCharWidth = nCharWidth * (double)56700;// in twips - return lcl_TwipsToPoints( (USHORT)nCharWidth ); +double getDefaultCharWidth( ScDocShell* pDocShell ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + OutputDevice* pRefDevice = pDoc->GetRefDevice(); + ScPatternAttr* pAttr = pDoc->GetDefPattern(); + ::Font aDefFont; + pAttr->GetFont( aDefFont, SC_AUTOCOL_BLACK, pRefDevice ); + pRefDevice->SetFont( aDefFont ); + long nCharWidth = pRefDevice->GetTextWidth( String( '0' ) ); // 1/100th mm + return lcl_hmmToPoints( nCharWidth ); } uno::Any SAL_CALL @@ -3685,7 +3666,7 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) if ( pShell ) { uno::Reference< frame::XModel > xModel = pShell->GetModel(); - double defaultCharWidth = getDefaultCharWidth( xModel ); + double defaultCharWidth = getDefaultCharWidth( pShell ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int32 nStartCol = thisAddress.StartColumn; @@ -3700,9 +3681,9 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) if ( nColTwips != nCurTwips ) return aNULL(); } - nColWidth = lcl_Round2DecPlaces( lcl_TwipsToPoints( nColTwips ) ); - if ( xModel.is() ) - nColWidth = nColWidth / defaultCharWidth; + nColWidth = lcl_TwipsToPoints( nColTwips ); + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth / defaultCharWidth ) - fExtraWidth; } nColWidth = lcl_Round2DecPlaces( nColWidth ); return uno::makeAny( nColWidth ); @@ -3727,11 +3708,8 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx ScDocShell* pDocShell = getScDocShell(); if ( pDocShell ) { - uno::Reference< frame::XModel > xModel = pDocShell->GetModel(); - if ( xModel.is() ) - { - - nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) ); + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth + fExtraWidth ) * getDefaultCharWidth( pDocShell ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); USHORT nTwips = lcl_pointsToTwips( nColWidth ); @@ -3745,7 +3723,6 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx nTwips, TRUE, TRUE ); } - } } uno::Any SAL_CALL -- cgit From a43f7851c7d3424e845eedffe8ef25c6e9e8fe99 Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 10 Sep 2010 13:10:07 +0200 Subject: sb129: #i113189# change UNO components to use passive registration --- sc/source/ui/vba/service.cxx | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 2b1f14cf154a..7e986338e7d1 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -84,41 +84,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - OSL_TRACE("In component_writeInfo"); -#if 0 - // Component registration - if ( component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) ) - { - // Singleton registration - try - { - registry::XRegistryKey * pKey = - reinterpret_cast< registry::XRegistryKey * >(pRegistryKey); - - Reference< registry::XRegistryKey >xKey = pKey->createKey( - rtl::OUString::createFromAscii( ("ooo.vba.Globals/UNO/SINGLETONS/ooo.vba.theGlobals") ) ); - xKey->setStringValue( ::rtl::OUString::createFromAscii( - ("ooo.vba.Globals") ) ); - return sal_True; - } - catch( uno::Exception& /*e*/ ) - { - //recomp & friends will detect false returned and fail - } - } - return sal_False; -#else - // Component registration - return component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); -#endif - - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) -- cgit From a7f5a052a807e8e26cfb6012135adbb43348781a Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 13 Sep 2010 17:41:51 +0200 Subject: mib19: #163557# make VBA Application settings globally available for all open workbooks --- sc/source/ui/vba/vbaapplication.cxx | 38 ++++++++++++++++++++++++++++++------- sc/source/ui/vba/vbaapplication.hxx | 7 ++++--- 2 files changed, 35 insertions(+), 10 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index f3965393e919..a53ca5cabe72 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -60,6 +60,7 @@ #include "sc.hrc" #include +#include #include #include @@ -108,11 +109,32 @@ public: ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){} }; +// ============================================================================ + +/** Global application settings shared by all open workbooks. */ +struct ScVbaAppSettings +{ + sal_Int32 mnCalculation; + sal_Bool mbDisplayAlerts; + sal_Bool mbEnableEvents; + + explicit ScVbaAppSettings(); +}; + +ScVbaAppSettings::ScVbaAppSettings() : + mnCalculation( excel::XlCalculation::xlCalculationAutomatic ), + mbDisplayAlerts( sal_True ), + mbEnableEvents( sal_True ) +{ +} + +struct ScVbaStaticAppSettings : public ::rtl::Static< ScVbaAppSettings, ScVbaStaticAppSettings > {}; + +// ============================================================================ + ScVbaApplication::ScVbaApplication( const uno::Reference& xContext ) : ScVbaApplication_BASE( xContext ), - m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ), - m_bDisplayAlerts( sal_True ), - m_bEnableEvents( sal_True ) + mrAppSettings( ScVbaStaticAppSettings::get() ) { } @@ -415,6 +437,7 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::Runtime ::sal_Int32 SAL_CALL ScVbaApplication::getCalculation() throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); if(xCalc->isAutomaticCalculationEnabled()) return excel::XlCalculation::xlCalculationAutomatic; @@ -425,6 +448,7 @@ ScVbaApplication::getCalculation() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException) { + // TODO: in Excel, this is an application-wide setting uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW); switch(_calculation) { @@ -704,25 +728,25 @@ ScVbaApplication::getName() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException) { - m_bDisplayAlerts = displayAlerts; + mrAppSettings.mbDisplayAlerts = displayAlerts; } sal_Bool SAL_CALL ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) { - return m_bDisplayAlerts; + return mrAppSettings.mbDisplayAlerts; } void SAL_CALL ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) { - m_bEnableEvents = bEnable; + mrAppSettings.mbEnableEvents = bEnable; } sal_Bool SAL_CALL ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) { - return m_bEnableEvents; + return mrAppSettings.mbEnableEvents; } void SAL_CALL diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index a7be5feb1d27..91d09d006c5b 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -39,12 +39,13 @@ //typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE; typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE; +struct ScVbaAppSettings; + class ScVbaApplication : public ScVbaApplication_BASE { private: - sal_Int32 m_xCalculation; - sal_Bool m_bDisplayAlerts; - sal_Bool m_bEnableEvents; + // note: member variables moved to struct "ScVbaAppSettings", see cxx file, to be shared by all application instances + ScVbaAppSettings& mrAppSettings; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); -- cgit From 676af9dc74cd77e16e82b716ad3bb8410cabf61f Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 13 Sep 2010 17:47:04 +0200 Subject: mib19: #163557# cleanup VBA XDocuments implementation, trigger Workbook_Open event when creating a new Excel workbook via Workbooks.Add --- sc/source/ui/vba/vbaworkbooks.cxx | 66 +++++++++++++++++++++++++++++++-------- sc/source/ui/vba/vbaworkbooks.hxx | 5 +-- 2 files changed, 54 insertions(+), 17 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 7efee1505dcb..194d3d1b9656 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -46,7 +46,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -81,7 +83,7 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& if( xLibContainer.is() ) { - if( !xLibContainer->hasByName( aPrjName ) ) + if( !xLibContainer->hasByName( aPrjName ) ) xLibContainer->createLibrary( aPrjName ); uno::Any aLibAny = xLibContainer->getByName( aPrjName ); uno::Reference< container::XNameContainer > xLib; @@ -130,6 +132,18 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& } } } + + /* Trigger the Workbook_Open event, event processor will register + itself as listener for specific events. */ + try + { + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pShell->GetDocument()->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_OPEN, aArgs ); + } + catch( uno::Exception& ) + { + } } } @@ -200,9 +214,41 @@ ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) uno::Any SAL_CALL -ScVbaWorkbooks::Add() throw (uno::RuntimeException) +ScVbaWorkbooks::Add( const uno::Any& Template ) throw (uno::RuntimeException) { - uno::Reference xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheetDocument > xSpreadDoc; + sal_Int32 nWorkbookType = 0; + ::rtl::OUString aTemplateFileName; + if( Template >>= nWorkbookType ) + { + // nWorkbookType is a constant from XlWBATemplate (added in Excel 2007) + // TODO: create chart-sheet if supported by Calc + + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + // create a document with one sheet only + uno::Reference< sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_SET_THROW ); + uno::Reference< container::XIndexAccess > xSheetsIA( xSheets, uno::UNO_QUERY_THROW ); + while( xSheetsIA->getCount() > 1 ) + { + uno::Reference< container::XNamed > xSheetName( xSheetsIA->getByIndex( xSheetsIA->getCount() - 1 ), uno::UNO_QUERY_THROW ); + xSheets->removeByName( xSheetName->getName() ); + } + } + else if( Template >>= aTemplateFileName ) + { + // TODO: create document from template + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else if( !Template.hasValue() ) + { + // regular spreadsheet document with configured number of sheets + xSpreadDoc.set( createDocument(), uno::UNO_QUERY_THROW ); + } + else + { + // illegal argument + throw uno::RuntimeException(); + } // need to set up the document modules ( and vba mode ) here setUpDocumentModules( xSpreadDoc ); @@ -211,10 +257,10 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException) return uno::Any(); } -void +void SAL_CALL ScVbaWorkbooks::Close() throw (uno::RuntimeException) { - VbaDocumentsBase::Close(); + closeDocuments(); } bool @@ -254,7 +300,7 @@ ScVbaWorkbooks::getFileFilterType( const rtl::OUString& rFileName ) } // #TODO# #FIXME# can any of the unused params below be used? -uno::Any +uno::Any SAL_CALL ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLinks*/, const uno::Any& ReadOnly, const uno::Any& Format, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*IgnoreReadOnlyRecommended*/, const uno::Any& /*Origin*/, const uno::Any& Delimiter, const uno::Any& /*Editable*/, const uno::Any& /*Notify*/, const uno::Any& /*Converter*/, const uno::Any& /*AddToMru*/ ) throw (uno::RuntimeException) { // we need to detect if this is a URL, if not then assume its a file path @@ -333,7 +379,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi else if ( !isSpreadSheetFile( sType ) ) throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() ); - uno::Reference xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); + uno::Reference xSpreadDoc( openDocument( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) @@ -341,12 +387,6 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi return aRet; } -uno::Any -ScVbaWorkbooks::Open( const rtl::OUString& Filename, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException) -{ - return VbaDocumentsBase::Open( Filename, ReadOnly, rProps ); -} - rtl::OUString& ScVbaWorkbooks::getServiceImplName() { diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx index 5d6210244d80..3392829f1a05 100644 --- a/sc/source/ui/vba/vbaworkbooks.hxx +++ b/sc/source/ui/vba/vbaworkbooks.hxx @@ -60,12 +60,9 @@ public: virtual css::uno::Sequence getServiceNames(); // XWorkbooks - virtual css::uno::Any SAL_CALL Add() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Template ) throw (css::uno::RuntimeException); virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& UpdateLinks, const css::uno::Any& ReadOnly, const css::uno::Any& Format, const css::uno::Any& Password, const css::uno::Any& WriteResPassword, const css::uno::Any& IgnoreReadOnlyRecommended, const css::uno::Any& Origin, const css::uno::Any& Delimiter, const css::uno::Any& Editable, const css::uno::Any& Notify, const css::uno::Any& Converter, const css::uno::Any& AddToMru ) throw (css::uno::RuntimeException); - - // VbaDocumentsBase / XDocumentsBase (to avoid warning C4266 for hiding function on wntmsci) - virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException); }; #endif /* SC_VBA_WORKBOOKS_HXX */ -- cgit From f84ff82a7fd78ca8584e4b56d98d83170b60e86c Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Tue, 14 Sep 2010 16:39:22 +0200 Subject: mib19: #163625# for empty status bar text, call XStatusIndicator::end --- sc/source/ui/vba/vbaapplication.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index a53ca5cabe72..5bb44c126fdf 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -418,8 +418,10 @@ ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::Runtime if( _statusbar >>= sText ) { setDisplayStatusBar( sal_True ); - xStatusIndicator->start( sText, 100 ); - //xStatusIndicator->setText( sText ); + if ( sText.getLength() ) + xStatusIndicator->start( sText, 100 ); + else + xStatusIndicator->end(); // restore normal state for empty text } else if( _statusbar >>= bDefault ) { -- cgit From 7e98422fec2e9132dee0bacba19f323a4b192509 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Tue, 14 Sep 2010 23:23:30 +0200 Subject: mib19: #163566# use common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells --- sc/source/ui/vba/vbarange.cxx | 24 ++++++++++++++++++------ sc/source/ui/vba/vbarange.hxx | 6 ++++++ sc/source/ui/vba/vbaworksheet.cxx | 5 ++++- 3 files changed, 28 insertions(+), 7 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index d32ad0a4b41e..95b54cc1f9d2 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -2060,6 +2060,18 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr return xRange->Cells( nRowIndex, nColumnIndex ); } + // Performance: Use a common helper method for ScVbaRange::Cells and ScVbaWorksheet::Cells, + // instead of creating a new ScVbaRange object in often-called ScVbaWorksheet::Cells + return CellsHelper( mxParent, mxContext, mxRange, nRowIndex, nColumnIndex ); +} + +// static +uno::Reference< excel::XRange > +ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, + const uno::Reference< uno::XComponentContext >& xContext, + const uno::Reference< css::table::XCellRange >& xRange, + const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException) +{ sal_Int32 nRow = 0, nColumn = 0; sal_Bool bIsIndex = nRowIndex.hasValue(); @@ -2071,7 +2083,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr // convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) ) if ( nRowIndex.hasValue() && !( nRowIndex >>= nRow ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2082,7 +2094,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr } if ( bIsColumnIndex && !( nColumnIndex >>= nColumn ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2092,17 +2104,17 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr catch( uno::Exception& ) {} // silence any errors } - RangeHelper thisRange( mxRange ); + RangeHelper thisRange( xRange ); table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells // #FIXE needs proper parent ( Worksheet ) - return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) ); + return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange ) ); sal_Int32 nIndex = --nRow; if( bIsIndex && !bIsColumnIndex ) // .Cells(n) { - uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW); + uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, ::uno::UNO_QUERY_THROW); sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount(); if ( !nIndex || nIndex < 0 ) @@ -2115,7 +2127,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( xParent, xContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index e7488e434f30..a8aada649575 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -149,6 +149,12 @@ public: const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); + static css::uno::Reference< ov::excel::XRange > CellsHelper( + const css::uno::Reference< ov::XHelperInterface >& xParent, + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::table::XCellRange >& xRange, + const css::uno::Any &nRowIndex, const css::uno::Any &nColumnIndex ) throw(css::uno::RuntimeException); + // Attributes virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException); virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 1f31cb7e19ce..c57048d5b148 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -658,7 +658,10 @@ uno::Reference< excel::XRange > ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol ) throw (uno::RuntimeException) { - return getSheetRange()->Cells( nRow, nCol ); + // Performance optimization for often-called Cells method: + // Use a common helper method instead of creating a new ScVbaRange object + uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW ); + return ScVbaRange::CellsHelper( mxParent, mxContext, xRange, nRow, nCol ); } uno::Reference< excel::XRange > -- cgit From bbf445b0244ec56dd37c9230b3c734f2ec843933 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Wed, 15 Sep 2010 14:11:13 +0200 Subject: mib19: #163640# do not fire selection change events when changing/insertintg/deleting sheets --- sc/source/ui/vba/vbaapplication.cxx | 5 ++ sc/source/ui/vba/vbaapplication.hxx | 3 + sc/source/ui/vba/vbaeventshelper.cxx | 109 ++++++++++++++++++++--------------- sc/source/ui/vba/vbaeventshelper.hxx | 8 +-- 4 files changed, 72 insertions(+), 53 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 5bb44c126fdf..30d4bd4d39a0 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -142,6 +142,11 @@ ScVbaApplication::~ScVbaApplication() { } +/*static*/ bool ScVbaApplication::getDocumentEventsEnabled() +{ + return ScVbaStaticAppSettings::get().mbEnableEvents; +} + SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) ); diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index 91d09d006c5b..bb696c967a37 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -56,6 +56,9 @@ public: ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext ); virtual ~ScVbaApplication(); + /** Returns true, if VBA document events are enabled. */ + static bool getDocumentEventsEnabled(); + virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); // XExactName diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 996bf52e0794..86d5f643a8b2 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -48,6 +48,7 @@ #include "cellsuno.hxx" #include "convuno.hxx" +#include "vbaapplication.hxx" using namespace ::com::sun::star; using namespace ::com::sun::star::script::vba::VBAEventId; @@ -55,6 +56,40 @@ using namespace ::ooo::vba; // ============================================================================ +namespace { + +/** Extracts a sheet index from the specified element of the passed sequence. + The element may be an integer, or a Calc range or ranges object. */ +SCTAB lclGetTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) +{ + VbaEventsHelperBase::checkArgument( rArgs, nIndex ); + + // first try to extract a sheet index + SCTAB nTab = -1; + if( rArgs[ nIndex ] >>= nTab ) + return nTab; + + // next, try single range object + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); + if( xCellRangeAddressable.is() ) + return xCellRangeAddressable->getRangeAddress().Sheet; + + // at last, try range list + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + if( xRanges.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); + if( aRangeAddresses.getLength() > 0 ) + return aRangeAddresses[ 0 ].Sheet; + } + + throw lang::IllegalArgumentException(); +} + +} // namespace + +// ============================================================================ + typedef ::cppu::WeakImplHelper4< awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener, util::XChangesListener > ScVbaEventsListener_BASE; @@ -475,25 +510,13 @@ bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, if( (rInfo.maUserData >>= bSheetEvent) && bSheetEvent ) rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); - /* For document events: get Application object and check if events are - enabled via EnableEvents symbol (this is an Excel-only attribute). + /* For document events: check if events are enabled via the + Application.EnableEvents symbol (this is an Excel-only attribute). Check this again for every event, as the event handler may change the state of the EnableEvents symbol. Global events such as AUTO_OPEN and AUTO_CLOSE are always enabled. */ if( rInfo.meType == EVENTHANDLER_DOCUMENT ) - { - // reference to application is held weakly, get application on first try - uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); - if( !xApplication.is() ) - { - uno::Any aVBAGlobals; - mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); - uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY_THROW ); - xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY_THROW ); - mxApplication = xApplication; - } - bExecuteEvent = xApplication->getEnableEvents(); - } + bExecuteEvent = ScVbaApplication::getDocumentEventsEnabled(); } return bExecuteEvent; @@ -618,7 +641,7 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, { bool bSheetEvent = false; rInfo.maUserData >>= bSheetEvent; - SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1; + SCTAB nTab = bSheetEvent ? lclGetTabFromArgs( rArgs, 0 ) : -1; if( bSheetEvent && (nTab < 0) ) throw lang::IllegalArgumentException(); @@ -632,43 +655,37 @@ void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, // private -------------------------------------------------------------------- -SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) -{ - checkArgument( rArgs, nIndex ); - - // first try to extract a sheet index - SCTAB nTab = -1; - if( rArgs[ nIndex ] >>= nTab ) - return nTab; +namespace { - // next, try single range object - uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); - if( xCellRangeAddressable.is() ) - return xCellRangeAddressable->getRangeAddress().Sheet; +/** Compares the passed range lists representing sheet selections. Ignores + selections that refer to different sheets (returns false in this case). */ +bool lclSelectionChanged( const ScRangeList& rLeft, const ScRangeList& rRight ) +{ + // one of the range lists empty? -> return false, if both lists empty + bool bLeftEmpty = rLeft.Count() == 0; + bool bRightEmpty = rRight.Count() == 0; + if( bLeftEmpty || bRightEmpty ) + return !(bLeftEmpty && bRightEmpty); - // at last, try range list - uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); - if( xRanges.is() ) - { - uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); - if( aRangeAddresses.getLength() > 0 ) - return aRangeAddresses[ 0 ].Sheet; - } + // check sheet indexes of the range lists (assuming that all ranges in a list are on the same sheet) + if( rLeft.GetObject( 0 )->aStart.Tab() != rRight.GetObject( 0 )->aStart.Tab() ) + return false; - throw lang::IllegalArgumentException(); + // compare all ranges + return rLeft != rRight; } +} // namespace + bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) { + uno::Reference< uno::XInterface > xOldSelection( maOldSelection, uno::UNO_QUERY ); uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false ); - if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) ) - { - bool bChanged = maOldSelection != pNewCellRanges->GetRangeList(); - maOldSelection = pNewCellRanges->GetRangeList(); - return bChanged; - } - maOldSelection.Clear(); - return true; + ScCellRangesBase* pOldCellRanges = ScCellRangesBase::getImplementation( xOldSelection ); + ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ); + bool bChanged = !pOldCellRanges || !pNewCellRanges || lclSelectionChanged( pOldCellRanges->GetRangeList(), pNewCellRanges->GetRangeList() ); + maOldSelection <<= xNewSelection; + return bChanged; } uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const @@ -678,7 +695,7 @@ uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rA // directly from basic and register them as listeners // extract sheet index, will throw, if parameter is invalid - SCTAB nTab = getTabFromArgs( rArgs, nIndex ); + SCTAB nTab = lclGetTabFromArgs( rArgs, nIndex ); // create Workbook uno::Sequence< uno::Any > aArgs( 2 ); diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index eaac96117d32..f1e8a4fb712d 100755 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -33,8 +33,6 @@ #include "excelvbahelper.hxx" #include "rangelst.hxx" -namespace ooo { namespace vba { namespace excel { class XApplication; } } } - class ScVbaEventsListener; // ============================================================================ @@ -57,9 +55,6 @@ protected: virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); private: - /** Extracts a sheet index from the first element of the passed sequence. The - element may be an integer, or a Calc range or ranges object. */ - static SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException); /** Checks if selection has been changed compared to selection of last call. @return true, if the selection has been changed. */ bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); @@ -74,11 +69,10 @@ private: css::uno::Any createWindow() const throw (css::uno::RuntimeException); private: - mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication; ::rtl::Reference< ScVbaEventsListener > mxListener; + css::uno::Any maOldSelection; ScDocShell* mpDocShell; ScDocument* mpDoc; - ScRangeList maOldSelection; bool mbOpened; }; -- cgit From afea0155c26d0864a9a629b2453afff3490e9bed Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 15 Sep 2010 18:01:02 +0200 Subject: mib19: #163641# use clipboard content in ScVbaRange::Insert only if it was copied by implnCut/implnCopy --- sc/source/ui/vba/excelvbahelper.cxx | 17 +++++++++++++++++ sc/source/ui/vba/vbarange.cxx | 11 +++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 2c39d7154b4b..2813d928eba8 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -150,7 +150,14 @@ implnCopy( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) + { pViewShell->CopyToClip(NULL,false,false,true); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } void @@ -158,7 +165,14 @@ implnCut( const uno::Reference< frame::XModel>& xModel ) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) + { pViewShell->CutToClip( NULL, TRUE ); + + // mark the copied transfer object so it is used in ScVbaRange::Insert + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if (pClipObj) + pClipObj->SetUseInApi( true ); + } } void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) @@ -181,7 +195,10 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFl ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin ); ScDocument* pDoc = NULL; if ( pOwnClip ) + { pDoc = pOwnClip->GetDocument(); + pOwnClip->SetUseInApi( false ); // don't use in Insert after it was pasted once + } pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, eMoveMode, IDF_NONE, TRUE ); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 95b54cc1f9d2..891a5a36ecfd 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -123,6 +123,7 @@ #include #include #include "docfunc.hxx" +#include "transobj.hxx" #include #include @@ -4547,10 +4548,8 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const } void SAL_CALL -ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException) +ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /* CopyOrigin */ ) throw (uno::RuntimeException) { - sal_Bool bCopyOrigin = sal_True; - CopyOrigin >>= bCopyOrigin; // It appears ( from the web ) that the undocumented CopyOrigin // param should contain member of enum XlInsertFormatOrigin // which can have values xlFormatFromLeftOrAbove or xlFormatFromRightOrBelow @@ -4585,7 +4584,11 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW ); xCellRangeMove->insertCells( thisAddress, mode ); - if ( bCopyOrigin ) + + // Paste from clipboard only if the clipboard content was copied via VBA, and not already pasted via VBA again. + // "Insert" behavior should not depend on random clipboard content previously copied by the user. + ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); + if ( pClipObj && pClipObj->GetUseInApi() ) { // After the insert ( this range ) actually has moved ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); -- cgit From 5469a815aebac1f954c674c730d27163aff1a457 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Fri, 17 Sep 2010 13:52:02 +0200 Subject: mib19: #163566# do not throw assertion if container is not available --- sc/source/ui/vba/vbaworksheet.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index c57048d5b148..aa7ee3932b08 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -917,7 +917,8 @@ ScVbaWorksheet::getFormControls() // get the www-standard container ( maybe we should access the // 'www-standard' by name rather than index, this seems an // implementation detail - xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); + if( xIndexAccess->hasElements() ) + xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY ); } catch( uno::Exception& ) -- cgit From 1fd5a79a0b542ae5a97d45d14106fbcc1645cd22 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 17 Sep 2010 15:28:21 +0200 Subject: mib19: #163556# preserve VBA compatibility in ODF roundtrip --- sc/source/ui/vba/vbaworkbooks.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 194d3d1b9656..a9f1970be34e 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -75,11 +75,15 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& ScDocShell* pShell = excel::getDocShell( xModel ); if ( pShell ) { + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + /* Set library container to VBA compatibility mode. This will create + the VBA Globals object and store it in the Basic manager of the + document. */ uno::Reference xLibContainer = pShell->GetBasicContainer(); uno::Reference xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); xVBACompat->setVBACompatibilityMode( sal_True ); - String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) ); - pShell->GetBasicManager()->SetName( aPrjName ); if( xLibContainer.is() ) { @@ -92,8 +96,6 @@ void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& { uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW); - // bootstrap vbaglobals - xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals"))); uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW ); // set up the module info for the workbook and sheets in the nealy created // spreadsheet -- cgit From 01c39c4385fb9a3668ba308d58136925eb232230 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 17 Sep 2010 18:42:00 +0200 Subject: mib19: set correct Parent for objects (ranges, sheets) passed to VBA event handlers --- sc/source/ui/vba/excelvbahelper.cxx | 62 ++++++++++++++++++++---------- sc/source/ui/vba/excelvbahelper.hxx | 73 +++++++++++++++++++++--------------- sc/source/ui/vba/vbaeventshelper.cxx | 32 +++++----------- 3 files changed, 96 insertions(+), 71 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 2813d928eba8..42a415d68e32 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -24,24 +24,25 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include + #include "excelvbahelper.hxx" + +#include +#include +#include "docuno.hxx" #include "tabvwsh.hxx" #include "transobj.hxx" #include "scmod.hxx" #include "cellsuno.hxx" -#include -#include + +namespace ooo { +namespace vba { +namespace excel { using namespace ::com::sun::star; using namespace ::ooo::vba; -namespace ooo -{ -namespace vba -{ -namespace excel -{ +// ============================================================================ ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) { @@ -246,11 +247,10 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) return NULL; } -uno::Reference< XHelperInterface > -getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +uno::Reference< vba::XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet ) throw ( uno::RuntimeException ) { - uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW ); rtl::OUString sCodeName; xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName; // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible @@ -258,28 +258,52 @@ getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at // the document in the future could fix this, especially IF the switching of the vba mode takes care to // create the special document module objects if they don't exist. - uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xRange ) ), uno::UNO_QUERY ); - + uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xSheet ) ), uno::UNO_QUERY ); return xParent; } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + uno::Reference< XHelperInterface > getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException ) { uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW ); uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW ); - return getUnoSheetModuleObj( xRange ); } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCell >& xCell ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xCell, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< frame::XModel >& xModel, SCTAB nTab ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSpreadsheetDocument > xDoc( xModel, uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheets->getByIndex( nTab ), uno::UNO_QUERY_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } +// ============================================================================ -} //excel -} //vba -} //ooo +} // namespace excel +} // namespace vba +} // namespace ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index da0474e6ceb0..be04fefa1639 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -27,41 +27,54 @@ #ifndef SC_EXCEL_VBA_HELPER_HXX #define SC_EXCEL_VBA_HELPER_HXX -#include -#include +#include +#include "docsh.hxx" #include #include +#include #include class ScCellRangesBase; -namespace ooo +namespace ooo { +namespace vba { +namespace excel { + +// ============================================================================ + +// nTabs empty means apply zoom to all sheets +void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); +void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); +void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); +ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; +ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; +ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); +SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); + +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCell >& xCell ) throw ( css::uno::RuntimeException ); +css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) throw ( css::uno::RuntimeException ); + +ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + +// ============================================================================ + +class ScVbaCellRangeAccess { - namespace vba - { - namespace excel - { - // nTabs empty means apply zoom to all sheets - void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); - void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); - ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); - SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); - ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - class ScVbaCellRangeAccess - { - public: - static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); - }; -} -} -} +public: + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); +}; + +// ============================================================================ + +} // namespace excel +} // namespace vba +} // namespace ooo + #endif diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 86d5f643a8b2..b7438e87160e 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -691,27 +691,9 @@ bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rAr uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { - // Eventually we will be able to pull the Workbook/Worksheet objects - // directly from basic and register them as listeners - // extract sheet index, will throw, if parameter is invalid SCTAB nTab = lclGetTabFromArgs( rArgs, nIndex ); - - // create Workbook - uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); - aArgs[ 1 ] <<= mxModel; - uno::Reference< uno::XInterface > xWorkbook( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_SET_THROW ); - - // create WorkSheet - String aSheetName; - mpDoc->GetName( nTab, aSheetName ); - aArgs = uno::Sequence< uno::Any >( 3 ); - aArgs[ 0 ] <<= xWorkbook; - aArgs[ 1 ] <<= mxModel; - aArgs[ 2 ] <<= ::rtl::OUString( aSheetName ); - uno::Reference< uno::XInterface > xWorksheet( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Worksheet", aArgs ), uno::UNO_SET_THROW ); - return uno::Any( xWorksheet ); + return uno::Any( excel::getUnoSheetModuleObj( mxModel, nTab ) ); } uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const @@ -723,11 +705,16 @@ uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, throw lang::IllegalArgumentException(); uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent if ( xRanges.is() ) + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRanges ); aArgs[ 1 ] <<= xRanges; + } else + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRange ); aArgs[ 1 ] <<= xRange; + } uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW ); return uno::Any( xVbaRange ); } @@ -735,9 +722,10 @@ uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, uno::Any ScVbaEventsHelper::createHyperlink( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { + uno::Reference< table::XCell > xCell = getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); uno::Sequence< uno::Any > aArgs( 2 ); - aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent - aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xCell ); + aArgs[ 1 ] <<= xCell; uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW ); return uno::Any( xHyperlink ); } -- cgit From 3024512c90d8660d35d4824471c436d68aa62241 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 17 Sep 2010 19:32:15 +0200 Subject: mib19: #163664# text values for VBA range Value property must be parsed (always English) --- sc/source/ui/vba/vbarange.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 891a5a36ecfd..5f97aaac506a 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -740,8 +740,26 @@ CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< tab rtl::OUString aString; if ( aValue >>= aString ) { - uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); - xTextRange->setString( aString ); + // The required behavior for a string value is: + // 1. If the first character is a single quote, use the rest as a string cell, regardless of the cell's number format. + // 2. Otherwise, if the cell's number format is "text", use the string value as a string cell. + // 3. Otherwise, parse the string value in English locale, and apply a corresponding number format with the cell's locale + // if the cell's number format was "General". + // Case 1 is handled here, the rest in ScCellObj::InputEnglishString + + if ( aString.toChar() == '\'' ) // case 1 - handle with XTextRange + { + rtl::OUString aRemainder( aString.copy(1) ); // strip the quote + uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW ); + xTextRange->setString( aRemainder ); + } + else + { + // call implementation method InputEnglishString + ScCellObj* pCellObj = dynamic_cast< ScCellObj* >( xCell.get() ); + if ( pCellObj ) + pCellObj->InputEnglishString( aString ); + } } else isExtracted = false; -- cgit From eda40b701292c8bf568ea3359b2c4c0efaaa8333 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 20 Sep 2010 13:52:55 +0200 Subject: mib19: wrong parent in VBA Worksheet.Cells symbol --- sc/source/ui/vba/vbaworksheet.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index aa7ee3932b08..7e033716a872 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -661,7 +661,7 @@ ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol ) // Performance optimization for often-called Cells method: // Use a common helper method instead of creating a new ScVbaRange object uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW ); - return ScVbaRange::CellsHelper( mxParent, mxContext, xRange, nRow, nCol ); + return ScVbaRange::CellsHelper( this, mxContext, xRange, nRow, nCol ); } uno::Reference< excel::XRange > -- cgit From 0f707f2b957e79db22d0ec138b8e58c9766d4da5 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 20 Sep 2010 13:53:57 +0200 Subject: mib19: #163666# fire Worksheet_Change event when using the Range.Value, Range.Formula, Range.Clear[Contents] symbols --- sc/source/ui/vba/vbaeventshelper.cxx | 54 ++++++++++++++++--------- sc/source/ui/vba/vbarange.cxx | 78 +++++++++++++++++++++++++----------- sc/source/ui/vba/vbarange.hxx | 18 ++++++--- 3 files changed, 102 insertions(+), 48 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index b7438e87160e..6ea807a16eae 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -59,7 +59,7 @@ using namespace ::ooo::vba; namespace { /** Extracts a sheet index from the specified element of the passed sequence. - The element may be an integer, or a Calc range or ranges object. */ + The element may be an integer, a Calc range or ranges object, or a VBA Range object. */ SCTAB lclGetTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) { VbaEventsHelperBase::checkArgument( rArgs, nIndex ); @@ -69,12 +69,23 @@ SCTAB lclGetTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nInde if( rArgs[ nIndex ] >>= nTab ) return nTab; - // next, try single range object + // try VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( xVbaRange.is() ) + { + uno::Reference< XHelperInterface > xVbaHelper( xVbaRange, uno::UNO_QUERY_THROW ); + // TODO: in the future, the parent may be an excel::XChart (chart sheet) -> will there be a common base interface? + uno::Reference< excel::XWorksheet > xVbaSheet( xVbaHelper->getParent(), uno::UNO_QUERY_THROW ); + // VBA sheet index is 1-based + return static_cast< SCTAB >( xVbaSheet->getIndex() - 1 ); + } + + // try single UNO range object uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); if( xCellRangeAddressable.is() ) return xCellRangeAddressable->getRangeAddress().Sheet; - // at last, try range list + // at last, try UNO range list uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); if( xRanges.is() ) { @@ -321,7 +332,7 @@ void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aE aChange.ReplacedElement >>= xRangeObj; if( xRangeObj.is() ) { - uno::Sequence< uno::Any > aArgs(1); + uno::Sequence< uno::Any > aArgs( 1 ); aArgs[0] <<= xRangeObj; mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs ); } @@ -699,23 +710,28 @@ uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rA uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const throw (lang::IllegalArgumentException, uno::RuntimeException) { - uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); - uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); - if ( !xRanges.is() && !xRange.is() ) - throw lang::IllegalArgumentException(); - - uno::Sequence< uno::Any > aArgs( 2 ); - if ( xRanges.is() ) + // it is possible to pass an existing VBA Range object + uno::Reference< excel::XRange > xVbaRange = getXSomethingFromArgs< excel::XRange >( rArgs, nIndex ); + if( !xVbaRange.is() ) { - aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRanges ); - aArgs[ 1 ] <<= xRanges; - } - else - { - aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRange ); - aArgs[ 1 ] <<= xRange; + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); + if ( !xRanges.is() && !xRange.is() ) + throw lang::IllegalArgumentException(); + + uno::Sequence< uno::Any > aArgs( 2 ); + if ( xRanges.is() ) + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRanges ); + aArgs[ 1 ] <<= xRanges; + } + else + { + aArgs[ 0 ] <<= excel::getUnoSheetModuleObj( xRange ); + aArgs[ 1 ] <<= xRange; + } + xVbaRange.set( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_QUERY_THROW ); } - uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW ); return uno::Any( xVbaRange ); } diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 5f97aaac506a..6cd129a6ae2d 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -24,6 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + +#include "vbarange.hxx" + #include #include @@ -31,6 +34,8 @@ #include #include +#include +#include #include #include #include @@ -135,7 +140,7 @@ #include #include -#include "vbarange.hxx" +#include "vbaapplication.hxx" #include "vbafont.hxx" #include "vbacomment.hxx" #include "vbainterior.hxx" @@ -268,6 +273,26 @@ SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) return pDataSet; } +void ScVbaRange::fireChangeEvent() +{ + if( ScVbaApplication::getDocumentEventsEnabled() ) + { + if( ScDocument* pDoc = getScDocument() ) + { + uno::Reference< script::vba::XVBAEventProcessor > xVBAEvents = pDoc->GetVbaEventProcessor(); + if( xVBAEvents.is() ) try + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= uno::Reference< excel::XRange >( this ); + xVBAEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_CHANGE, aArgs ); + } + catch( uno::Exception& ) + { + } + } + } +} + class SingleRangeEnumeration : public EnumerationHelper_BASE { uno::Reference< XHelperInterface > m_xParent; @@ -1498,7 +1523,7 @@ ScVbaRange::getValue() throw (uno::RuntimeException) void -ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) throw (uno::RuntimeException) +ScVbaRange::setValue( const uno::Any& aValue, ValueSetter& valueSetter, bool bFireEvent ) throw (uno::RuntimeException) { uno::TypeClass aClass = aValue.getValueTypeClass(); if ( aClass == uno::TypeClass_SEQUENCE ) @@ -1533,6 +1558,7 @@ ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) thro { visitArray( valueSetter ); } + if( bFireEvent ) fireChangeEvent(); } void SAL_CALL @@ -1547,20 +1573,20 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) return; } CellValueSetter valueSetter( aValue ); - setValue( aValue, valueSetter ); + setValue( aValue, valueSetter, true ); } -void +void SAL_CALL ScVbaRange::Clear() throw (uno::RuntimeException) { using namespace ::com::sun::star::sheet::CellFlags; sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; - ClearContents( nFlags ); + ClearContents( nFlags, true ); } //helper ClearContent void -ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) +ScVbaRange::ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (uno::RuntimeException) { // #TODO code within the test below "if ( m_Areas.... " can be removed // Test is performed only because m_xRange is NOT set to be @@ -1574,40 +1600,44 @@ ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException) uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW ); ScVbaRange* pRange = getImplementation( xRange ); if ( pRange ) - pRange->ClearContents( nFlags ); + pRange->ClearContents( nFlags, false ); // do not fire for single ranges } + // fire change event for the entire range list + if( bFireEvent ) fireChangeEvent(); return; } uno::Reference< sheet::XSheetOperation > xSheetOperation(mxRange, uno::UNO_QUERY_THROW); xSheetOperation->clearContents( nFlags ); + if( bFireEvent ) fireChangeEvent(); } -void + +void SAL_CALL ScVbaRange::ClearComments() throw (uno::RuntimeException) { - ClearContents( sheet::CellFlags::ANNOTATION ); + ClearContents( sheet::CellFlags::ANNOTATION, false ); } -void +void SAL_CALL ScVbaRange::ClearContents() throw (uno::RuntimeException) { - sal_Int32 nClearFlags = ( sheet::CellFlags::VALUE | - sheet::CellFlags::STRING | sheet::CellFlags::DATETIME | - sheet::CellFlags::FORMULA ); - ClearContents( nClearFlags ); + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = VALUE | STRING | DATETIME | FORMULA; + ClearContents( nFlags, true ); } -void +void SAL_CALL ScVbaRange::ClearFormats() throw (uno::RuntimeException) { - //FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED - sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR; - ClearContents( nClearFlags ); + //FIXME: need to check if we need to combine FORMATTED + using namespace ::com::sun::star::sheet::CellFlags; + sal_Int32 nFlags = HARDATTR | FORMATTED | EDITATTR; + ClearContents( nFlags, false ); } void -ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException) +ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram, bool bFireEvent ) throw (uno::RuntimeException) { // If this is a multiple selection apply setFormula over all areas if ( m_Areas->getCount() > 1 ) @@ -1618,7 +1648,7 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar:: return; } CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram ); - setValue( rFormula, formulaValueSetter ); + setValue( rFormula, formulaValueSetter, bFireEvent ); } uno::Any @@ -1642,7 +1672,7 @@ void ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException) { // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true ); } uno::Any @@ -1654,7 +1684,7 @@ ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException) void ScVbaRange::setFormulaR1C1(const uno::Any& rFormula ) throw (uno::RuntimeException) { - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 ); + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1, true ); } uno::Any @@ -3273,7 +3303,7 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() ); sal_Int16 nDataOption1 = excel::XlSortDataOption::xlSortNormal; - sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal;; + sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal; sal_Int16 nDataOption3 = excel::XlSortDataOption::xlSortNormal; ScDocument* pDoc = getScDocument(); @@ -4428,7 +4458,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const // Use the normal uno api, sometimes e.g. when you want to use ALL as the filter // we can't use refresh as the uno interface doesn't have a concept of ALL // in this case we just call the core calc functionality - - bool bAll = false;; + bool bAll = false; if ( ( Field >>= nField ) ) { uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc( diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index a8aada649575..e8079a855544 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -99,6 +99,7 @@ class ScVbaRange : public ScVbaRange_BASE sal_Bool mbIsRows; sal_Bool mbIsColumns; css::uno::Reference< ov::excel::XValidation > m_xValidation; + double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException); void visitArray( ArrayVisitor& vistor ); @@ -107,11 +108,14 @@ class ScVbaRange : public ScVbaRange_BASE void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException ); - void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException); - virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException); - virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); - virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); - virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException); + void ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (css::uno::RuntimeException); + + css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException); + void setValue( const css::uno::Any& aValue, ValueSetter& setter, bool bFireEvent ) throw ( css::uno::RuntimeException); + + css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException); + void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar, bool bFireEvent ) throw ( css::uno::RuntimeException); + css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException ); ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException ); ScCellRangesObj* getCellRangesObj() throw ( css::uno::RuntimeException ); @@ -120,6 +124,10 @@ class ScVbaRange : public ScVbaRange_BASE css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious ); css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException ); css::awt::Point getPosition() throw ( css::uno::RuntimeException ); + + /** Fires a Worksheet_Change event for this range or range list. */ + void fireChangeEvent(); + protected: virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException ); virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException ); -- cgit From 011d4319b1bf4082cec40482df7251d5e550aae2 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Mon, 20 Sep 2010 15:32:20 +0200 Subject: mib19: #163691# remember VBA object provider instance --- sc/source/ui/vba/vbaworksheet.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 7e033716a872..6491024071b2 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -195,7 +195,7 @@ ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args, uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ), mbVeryHidden( false ) { - if ( args.getLength() < 2 ) + if ( args.getLength() < 3 ) throw lang::IllegalArgumentException(); rtl::OUString sSheetName; -- cgit From 3da958037834a99e595acd7f19b6122ddd56433f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 1 Nov 2010 15:32:50 +0100 Subject: undoapi: Enter/LeaveBasicCall are no-ops nowadays - removed --- sc/source/ui/vba/vbaapplication.cxx | 5 ----- 1 file changed, 5 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index f3965393e919..cb86ac074a32 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -450,7 +450,6 @@ 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 ); @@ -464,8 +463,6 @@ ScVbaApplication::wait( double time ) throw (uno::RuntimeException) // forces a broadcast SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth)); } - SFX_APP()->LeaveBasicCall(); - } uno::Any SAL_CALL @@ -1133,7 +1130,6 @@ uno::Any SAL_CALL ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeException ) { StarBASIC* pBasic = SFX_APP()->GetBasic(); - SFX_APP()->EnterBasicCall(); SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FuncCaller") ), SbxCLASS_METHOD ); uno::Any aRet; if ( pMeth ) @@ -1144,7 +1140,6 @@ ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeExcep OSL_TRACE("pNew has type %d and string value %s", pNew->GetType(), rtl::OUStringToOString( pNew->GetString(), RTL_TEXTENCODING_UTF8 ).getStr() ); aRet = sbxToUnoValue( pNew ); } - SFX_APP()->LeaveBasicCall(); return aRet; } -- cgit From cd42389ad67b403a07a0dda8e2a6e213def49251 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 17 Jan 2011 13:20:22 +0100 Subject: removetooltypes01: #i112600# remove tooltypes from sc --- sc/source/ui/vba/excelvbahelper.cxx | 6 +- sc/source/ui/vba/vbafont.cxx | 18 +++--- sc/source/ui/vba/vbaformat.cxx | 8 +-- sc/source/ui/vba/vbahelper.cxx | 10 ++-- sc/source/ui/vba/vbahyperlinks.cxx | 2 +- sc/source/ui/vba/vbapagesetup.cxx | 12 ++-- sc/source/ui/vba/vbarange.cxx | 106 ++++++++++++++++++------------------ sc/source/ui/vba/vbawindow.cxx | 2 +- sc/source/ui/vba/vbaworksheets.cxx | 2 +- 9 files changed, 83 insertions(+), 83 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 42a415d68e32..04d88935acfc 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -167,7 +167,7 @@ implnCut( const uno::Reference< frame::XModel>& xModel ) ScTabViewShell* pViewShell = getBestViewShell( xModel ); if ( pViewShell ) { - pViewShell->CutToClip( NULL, TRUE ); + pViewShell->CutToClip( NULL, sal_True ); // mark the copied transfer object so it is used in ScVbaRange::Insert ScTransferObj* pClipObj = ScTransferObj::GetOwnClipboard( NULL ); @@ -176,7 +176,7 @@ implnCut( const uno::Reference< frame::XModel>& xModel ) } } -void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) +void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) { PasteCellsWarningReseter resetWarningBox; sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); @@ -202,7 +202,7 @@ void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFl } pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, - eMoveMode, IDF_NONE, TRUE ); + eMoveMode, IDF_NONE, sal_True ); pTabViewShell->CellContentChanged(); } } diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx index 5894d3ea8c71..20e9d93fff03 100644 --- a/sc/source/ui/vba/vbafont.cxx +++ b/sc/source/ui/vba/vbafont.cxx @@ -229,7 +229,7 @@ uno::Any SAL_CALL ScVbaFont::getSize() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getSize(); } @@ -256,7 +256,7 @@ uno::Any SAL_CALL ScVbaFont::getColorIndex() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getColorIndex(); } @@ -355,7 +355,7 @@ uno::Any SAL_CALL ScVbaFont::getBold() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getBold(); } @@ -398,7 +398,7 @@ uno::Any SAL_CALL ScVbaFont::getUnderline() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); sal_Int32 nValue = awt::FontUnderline::NONE; @@ -425,7 +425,7 @@ uno::Any SAL_CALL ScVbaFont::getStrikethrough() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getStrikethrough(); } @@ -434,7 +434,7 @@ uno::Any SAL_CALL ScVbaFont::getShadow() throw (uno::RuntimeException) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getShadow(); } @@ -443,7 +443,7 @@ uno::Any SAL_CALL ScVbaFont::getItalic() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getItalic(); @@ -453,7 +453,7 @@ uno::Any SAL_CALL ScVbaFont::getName() throw ( uno::RuntimeException ) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return ScVbaFont_BASE::getName(); } @@ -476,7 +476,7 @@ uno::Any SAL_CALL ScVbaFont::getOutlineFont() throw (uno::RuntimeException) { if ( GetDataSet() ) - if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, TRUE, NULL) == SFX_ITEM_DONTCARE ) + if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, sal_True, NULL) == SFX_ITEM_DONTCARE ) return aNULL(); return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ) ); } diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index d08451af63f4..3b0ba2367c1a 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -582,8 +582,8 @@ ScVbaFormat::getLocked( ) throw (script::BasicErrorException, uno::Runtim SfxItemSet* pDataSet = getCurrentDataSet(); if ( pDataSet ) { - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, sal_True); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, sal_True, NULL); if(eState != SFX_ITEM_DONTCARE) aCellProtection = uno::makeAny(rProtAttr.GetProtection()); } @@ -615,8 +615,8 @@ ScVbaFormat::getFormulaHidden( ) throw (script::BasicErrorException, uno: SfxItemSet* pDataSet = getCurrentDataSet(); if ( pDataSet ) { - const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE); - SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL); + const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, sal_True); + SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, sal_True, NULL); if(eState != SFX_ITEM_DONTCARE) aBoolRet = uno::makeAny(rProtAttr.GetHideFormula()); } diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx index cc76b1e60125..ff6e78249650 100644 --- a/sc/source/ui/vba/vbahelper.cxx +++ b/sc/source/ui/vba/vbahelper.cxx @@ -160,7 +160,7 @@ public: } }; -void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, USHORT nSlot, SfxCallMode nCall) +void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nSlot, SfxCallMode nCall) { ScTabViewShell* pViewShell = getBestViewShell( xModel ); SfxViewFrame* pViewFrame = NULL; @@ -202,10 +202,10 @@ implnCut() { ScTabViewShell* pViewShell = getCurrentBestViewShell(); if ( pViewShell ) - pViewShell->CutToClip( NULL, TRUE ); + pViewShell->CutToClip( NULL, sal_True ); } -void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) +void implnPasteSpecial(sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose) { PasteCellsWarningReseter resetWarningBox; sal_Bool bAsLink(sal_False), bOtherDoc(sal_False); @@ -231,7 +231,7 @@ void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_B pDoc = pOwnClip->GetDocument(); pTabViewShell->PasteFromClip( nFlags, pDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, - eMoveMode, IDF_NONE, TRUE ); + eMoveMode, IDF_NONE, sal_True ); pTabViewShell->CellContentChanged(); } } @@ -460,7 +460,7 @@ void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& C } } else - pDispatcher->Execute( (USHORT)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); + pDispatcher->Execute( (sal_uInt16)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs ); } } diff --git a/sc/source/ui/vba/vbahyperlinks.cxx b/sc/source/ui/vba/vbahyperlinks.cxx index 89a8109e6aa2..943b51cb7b8c 100644 --- a/sc/source/ui/vba/vbahyperlinks.cxx +++ b/sc/source/ui/vba/vbahyperlinks.cxx @@ -48,7 +48,7 @@ bool lclContains( const ScRangeList& rScOuter, const uno::Reference< excel::XRan if( (rScInner.Count() == 0) || (rScOuter.Count() == 0) ) throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Empty range objects" ) ), uno::Reference< uno::XInterface >() ); - for( ULONG nIndex = 0, nCount = rScInner.Count(); nIndex < nCount; ++nIndex ) + for( sal_uLong nIndex = 0, nCount = rScInner.Count(); nIndex < nCount; ++nIndex ) if( !rScOuter.In( *rScInner.GetObject( nIndex ) ) ) return false; return true; diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx index d660ddbbfd77..3ad50b07fa3e 100644 --- a/sc/source/ui/vba/vbapagesetup.cxx +++ b/sc/source/ui/vba/vbapagesetup.cxx @@ -76,7 +76,7 @@ rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeEx if( nCount ) { ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); - USHORT nFlags = SCA_VALID; + sal_uInt16 nFlags = SCA_VALID; nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE ); ScRangeList aRangeList; for( sal_Int32 i=0; i aSeq( aCellRanges.Count() ); - USHORT i=0; + sal_uInt16 i=0; for( ScRange* pRange = aCellRanges.First(); pRange; pRange = aCellRanges.Next() ) { table::CellRangeAddress aRangeAddress; @@ -148,7 +148,7 @@ uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeEx void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException) { - USHORT scaleToPageY = 0; + sal_uInt16 scaleToPageY = 0; try { sal_Bool aValue; @@ -171,7 +171,7 @@ uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeEx void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException) { - USHORT scaleToPageX = 0; + sal_uInt16 scaleToPageX = 0; try { sal_Bool aValue = sal_False; @@ -194,7 +194,7 @@ uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException) void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException) { - USHORT pageScale = 0; + sal_uInt16 pageScale = 0; try { if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN ) @@ -216,7 +216,7 @@ void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::Ru } // these only exist in S08 - USHORT nScale = 0; + sal_uInt16 nScale = 0; mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPages")), uno::makeAny( nScale )); mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( nScale )); mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( nScale )); diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index 6cd129a6ae2d..5cb6d44fc902 100755 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -188,13 +188,13 @@ double lcl_hmmToPoints( double nVal ) { return ( (double)((nVal /1000 ) * 567 ) static const sal_Int16 supportedIndexTable[] = { excel::XlBordersIndex::xlEdgeLeft, excel::XlBordersIndex::xlEdgeTop, excel::XlBordersIndex::xlEdgeBottom, excel::XlBordersIndex::xlEdgeRight, excel::XlBordersIndex::xlDiagonalDown, excel::XlBordersIndex::xlDiagonalUp, excel::XlBordersIndex::xlInsideVertical, excel::XlBordersIndex::xlInsideHorizontal }; -USHORT lcl_pointsToTwips( double nVal ) +sal_uInt16 lcl_pointsToTwips( double nVal ) { nVal = nVal * static_cast(20); short nTwips = static_cast(nVal); return nTwips; } -double lcl_TwipsToPoints( USHORT nVal ) +double lcl_TwipsToPoints( sal_uInt16 nVal ) { double nPoints = nVal; return nPoints / 20; @@ -549,7 +549,7 @@ public: { SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange ); - SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, TRUE, NULL); + SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, sal_True, NULL); // one of the cells in the range is not like the other ;-) // so return a zero length format to indicate that if ( eState == SFX_ITEM_DONTCARE ) @@ -1151,7 +1151,7 @@ public: }; bool -getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv ) +getCellRangesForAddress( sal_uInt16& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv ) { ScDocument* pDoc = NULL; @@ -1159,8 +1159,8 @@ getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDoc { pDoc = pDocSh->GetDocument(); String aString(sAddress); - USHORT nMask = SCA_VALID; - //USHORT nParse = rCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_A1 ); + sal_uInt16 nMask = SCA_VALID; + //sal_uInt16 nParse = rCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_A1 ); rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0 ); if ( rResFlags & SCA_VALID ) { @@ -1205,7 +1205,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S eConv = pDocSh->GetDocument()->GetAddressConvention(); } - USHORT nFlags = 0; + sal_uInt16 nFlags = 0; if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv ) ) return false; @@ -2028,7 +2028,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut if ( refStyle == excel::XlReferenceStyle::xlR1C1 ) dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, 0, 0 ); } - USHORT nFlags = SCA_VALID; + sal_uInt16 nFlags = SCA_VALID; ScDocShell* pDocShell = getScDocShell(); ScDocument* pDoc = pDocShell->GetDocument(); @@ -2036,8 +2036,8 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); String sRange; - USHORT ROW_ABSOLUTE = ( SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE ); - USHORT COL_ABSOLUTE = ( SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE ); + sal_uInt16 ROW_ABSOLUTE = ( SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE ); + sal_uInt16 COL_ABSOLUTE = ( SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE ); // default nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE ); if ( RowAbsolute.hasValue() ) @@ -2225,7 +2225,7 @@ void setCursor( const SCCOL& nCol, const SCROW& nRow, const uno::Reference< fra if ( bInSel ) pShell->SetCursor( nCol, nRow ); else - pShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_NONE, FALSE, FALSE, TRUE, FALSE ); + pShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_NONE, sal_False, sal_False, sal_True, sal_False ); } } @@ -2607,7 +2607,7 @@ ScVbaRange::getWrapText() throw (script::BasicErrorException, uno::RuntimeExcept SfxItemSet* pDataSet = getCurrentDataSet(); - SfxItemState eState = pDataSet->GetItemState( ATTR_LINEBREAK, TRUE, NULL); + SfxItemState eState = pDataSet->GetItemState( ATTR_LINEBREAK, sal_True, NULL); if ( eState == SFX_ITEM_DONTCARE ) return aNULL(); @@ -2747,10 +2747,10 @@ uno::Any SAL_CALL ScVbaRange::getCellRange( ) throw (uno::RuntimeException) throw uno::RuntimeException(); } -static USHORT +static sal_uInt16 getPasteFlags (sal_Int32 Paste) { - USHORT nFlags = IDF_NONE; + sal_uInt16 nFlags = IDF_NONE; switch (Paste) { case excel::XlPasteType::xlPasteComments: nFlags = IDF_NOTE;break; @@ -2778,10 +2778,10 @@ getPasteFlags (sal_Int32 Paste) return nFlags; } -static USHORT +static sal_uInt16 getPasteFormulaBits( sal_Int32 Operation) { - USHORT nFormulaBits = PASTE_NOFUNC ; + sal_uInt16 nFormulaBits = PASTE_NOFUNC ; switch (Operation) { case excel::XlPasteSpecialOperation::xlPasteSpecialOperationAdd: @@ -2828,8 +2828,8 @@ ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, cons if ( Transpose.hasValue() ) Transpose >>= bTranspose; - USHORT nFlags = getPasteFlags(nPaste); - USHORT nFormulaBits = getPasteFormulaBits(nOperation); + sal_uInt16 nFlags = getPasteFlags(nPaste); + sal_uInt16 nFormulaBits = getPasteFormulaBits(nOperation); excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose); // restore selection xSelection->select( uno::makeAny( xSel ) ); @@ -3357,9 +3357,9 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& nOrientation = ::comphelper::getINT16( Orientation ); // persist new option to be next calls default if ( nOrientation == excel::XlSortOrientation::xlSortRows ) - aSortParam.bByRow = FALSE; + aSortParam.bByRow = sal_False; else - aSortParam.bByRow = TRUE; + aSortParam.bByRow = sal_True; } @@ -3419,26 +3419,26 @@ ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& { nOrder1 = ::comphelper::getINT16(Order1); if ( nOrder1 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[0] = TRUE; + aSortParam.bAscending[0] = sal_True; else - aSortParam.bAscending[0] = FALSE; + aSortParam.bAscending[0] = sal_False; } if ( Order2.hasValue() ) { nOrder2 = ::comphelper::getINT16(Order2); if ( nOrder2 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[1] = TRUE; + aSortParam.bAscending[1] = sal_True; else - aSortParam.bAscending[1] = FALSE; + aSortParam.bAscending[1] = sal_False; } if ( Order3.hasValue() ) { nOrder3 = ::comphelper::getINT16(Order3); if ( nOrder3 == excel::XlSortOrder::xlAscending ) - aSortParam.bAscending[2] = TRUE; + aSortParam.bAscending[2] = sal_True; else - aSortParam.bAscending[2] = FALSE; + aSortParam.bAscending[2] = sal_False; } uno::Reference< table::XCellRange > xKey1; @@ -3526,7 +3526,7 @@ ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException) aArgs.Put( sfxAsync, sfxAsync.Which() ); SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher(); - USHORT nSID = 0; + sal_uInt16 nSID = 0; switch( Direction ) { @@ -3683,7 +3683,7 @@ double ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno::RuntimeException) { ScDocument* pDoc = getScDocument(); - USHORT nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); + sal_uInt16 nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3693,7 +3693,7 @@ double ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (uno::RuntimeException) { ScDocument* pDoc = getDocumentFromRange( mxRange ); - USHORT nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); + sal_uInt16 nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet ); double nPoints = lcl_TwipsToPoints( nWidth ); nPoints = lcl_Round2DecPlaces( nPoints ); return nPoints; @@ -3732,11 +3732,11 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int32 nStartCol = thisAddress.StartColumn; sal_Int32 nEndCol = thisAddress.EndColumn; - USHORT nColTwips = 0; + sal_uInt16 nColTwips = 0; for( sal_Int32 nCol = nStartCol ; nCol <= nEndCol; ++nCol ) { thisAddress.StartColumn = nCol; - USHORT nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); + sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) ); if ( nCol == nStartCol ) nColTwips = nCurTwips; if ( nColTwips != nCurTwips ) @@ -3773,15 +3773,15 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx nColWidth = ( nColWidth + fExtraWidth ) * getDefaultCharWidth( pDocShell ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - USHORT nTwips = lcl_pointsToTwips( nColWidth ); + sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth ); ScDocFunc aFunc(*pDocShell); SCCOLROW nColArr[2]; nColArr[0] = thisAddress.StartColumn; nColArr[1] = thisAddress.EndColumn; // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values - aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_DIRECT, - nTwips, TRUE, TRUE ); + aFunc.SetWidthOrHeight( sal_True, 1, nColArr, thisAddress.Sheet, SC_SIZE_DIRECT, + nTwips, sal_True, sal_True ); } } @@ -3896,7 +3896,7 @@ ScVbaRange::getRowHeight() throw (uno::RuntimeException) sal_Int32 nStartRow = thisAddress.StartRow; sal_Int32 nEndRow = thisAddress.EndRow; - USHORT nRowTwips = 0; + sal_uInt16 nRowTwips = 0; // #TODO probably possible to use the SfxItemSet ( and see if // SFX_ITEM_DONTCARE is set ) to improve performance // #CHECKME looks like this is general behaviour not just row Range specific @@ -3907,7 +3907,7 @@ ScVbaRange::getRowHeight() throw (uno::RuntimeException) for ( sal_Int32 nRow = nStartRow ; nRow <= nEndRow; ++nRow ) { thisAddress.StartRow = nRow; - USHORT nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); + sal_uInt16 nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet ); if ( nRow == nStartRow ) nRowTwips = nCurTwips; if ( nRowTwips != nCurTwips ) @@ -3936,7 +3936,7 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti nHeight = lcl_Round2DecPlaces( nHeight ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - USHORT nTwips = lcl_pointsToTwips( nHeight ); + sal_uInt16 nTwips = lcl_pointsToTwips( nHeight ); ScDocShell* pDocShell = getDocShellFromRange( mxRange ); ScDocFunc aFunc(*pDocShell); @@ -3944,8 +3944,8 @@ ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeExcepti nRowArr[0] = thisAddress.StartRow; nRowArr[1] = thisAddress.EndRow; // #163561# use mode SC_SIZE_DIRECT: hide for height 0, show for other values - aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_DIRECT, - nTwips, TRUE, TRUE ); + aFunc.SetWidthOrHeight( sal_False, 1, nRowArr, thisAddress.Sheet, SC_SIZE_DIRECT, + nTwips, sal_True, sal_True ); } uno::Any SAL_CALL @@ -3957,10 +3957,10 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException) { RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - BOOL bColumn = FALSE; + sal_Bool bColumn = sal_False; if (thisAddress.StartRow==0) - bColumn = TRUE; + bColumn = sal_True; uno::Reference< frame::XModel > xModel = pShell->GetModel(); if ( xModel.is() ) @@ -3997,10 +3997,10 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); if ((thisAddress.StartColumn==0) && (thisAddress.StartRow==0)) return; - BOOL bColumn = FALSE; + sal_Bool bColumn = sal_False; if (thisAddress.StartRow==0) - bColumn = TRUE; + bColumn = sal_True; ScAddress aAddr( static_cast(thisAddress.StartColumn), thisAddress.StartRow, thisAddress.Sheet ); uno::Reference< frame::XModel > xModel = pShell->GetModel(); @@ -4008,9 +4008,9 @@ ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeExcepti { ScTabViewShell* pViewShell = excel::getBestViewShell( xModel ); if ( nPageBreak == excel::XlPageBreak::xlPageBreakManual ) - pViewShell->InsertPageBreak( bColumn, TRUE, &aAddr); + pViewShell->InsertPageBreak( bColumn, sal_True, &aAddr); else if ( nPageBreak == excel::XlPageBreak::xlPageBreakNone ) - pViewShell->DeletePageBreak( bColumn, TRUE, &aAddr); + pViewShell->DeletePageBreak( bColumn, sal_True, &aAddr); } } } @@ -4204,7 +4204,7 @@ ScDBData* lcl_GetDBData_Impl( ScDocShell* pDocShell, sal_Int16 nSheet ) ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection(); if (pNames) { - USHORT nPos = 0; + sal_uInt16 nPos = 0; if (pNames->SearchName( sName , nPos )) pRet = (*pNames)[nPos]; } @@ -4220,7 +4220,7 @@ void lcl_SelectAll( ScDocShell* pDocShell, ScQueryParam& aParam ) if ( pViewData ) { OSL_TRACE("Pushing out SelectAll query"); - pViewData->GetView()->Query( aParam, NULL, TRUE ); + pViewData->GetView()->Query( aParam, NULL, sal_True ); } } } @@ -4401,7 +4401,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const SCROW nStartRow = autoFiltAddress.StartRow; SCCOL nEndCol = autoFiltAddress.EndColumn; SCROW nEndRow = autoFiltAddress.EndRow; - pDocument->GetDataArea( autoFiltAddress.Sheet, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, true ); + pDocument->GetDataArea( autoFiltAddress.Sheet, nStartCol, nStartRow, nEndCol, nEndRow, sal_True, true ); autoFiltAddress.StartColumn = nStartCol; autoFiltAddress.StartRow = nStartRow; autoFiltAddress.EndColumn = nEndCol; @@ -4674,15 +4674,15 @@ ScVbaRange::Autofit() throw (uno::RuntimeException) SCCOLROW nColArr[2]; nColArr[0] = thisAddress.StartColumn; nColArr[1] = thisAddress.EndColumn; - BOOL bDirection = TRUE; + sal_Bool bDirection = sal_True; if ( mbIsRows ) { - bDirection = FALSE; + bDirection = sal_False; nColArr[0] = thisAddress.StartRow; nColArr[1] = thisAddress.EndRow; } aFunc.SetWidthOrHeight( bDirection, 1, nColArr, thisAddress.Sheet, SC_SIZE_OPTIMAL, - 0, TRUE, TRUE ); + 0, sal_True, sal_True ); } } @@ -5196,7 +5196,7 @@ ScVbaRange::AutoFill( const uno::Reference< excel::XRange >& Destination, const } ScDocFunc aFunc(*pDocSh); #ifdef VBA_OOBUILD_HACK - aFunc.FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd, nCount, fStep, fEndValue, TRUE, TRUE ); + aFunc.FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd, nCount, fStep, fEndValue, sal_True, sal_True ); #endif } sal_Bool SAL_CALL @@ -5420,7 +5420,7 @@ ScVbaRange::PreviousNext( bool bIsPrevious ) SCTAB nTab = refRange.aStart.Tab(); ScDocument* pDoc = getScDocument(); - pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, TRUE,TRUE, markedRange ); + pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, sal_True,sal_True, markedRange ); refRange.aStart.SetCol( nNewX ); refRange.aStart.SetRow( nNewY ); refRange.aStart.SetTab( nTab ); diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx index 10dad39341b7..5964fe98317c 100644 --- a/sc/source/ui/vba/vbawindow.cxx +++ b/sc/source/ui/vba/vbawindow.cxx @@ -773,7 +773,7 @@ ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException) { sal_Int32 nWindowView = excel::XlWindowView::xlNormalView; _view >>= nWindowView; - USHORT nSlot = FID_NORMALVIEWMODE; + sal_uInt16 nSlot = FID_NORMALVIEWMODE; switch ( nWindowView ) { case excel::XlWindowView::xlNormalView: diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 7fa5196a6b04..bd21cb396c66 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -415,7 +415,7 @@ ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException) bSelectSingle = false; } else - rMarkData.SelectTable( static_cast< SCTAB >( pSheet->getSheetID() ), TRUE ); + rMarkData.SelectTable( static_cast< SCTAB >( pSheet->getSheetID() ), sal_True ); } } -- cgit From 894985ff00c217013cc360a77108fc68cd8647e7 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 28 Jan 2011 13:59:35 +0100 Subject: CWS gnumake3: kill ENABLE_VBA --- sc/source/ui/vba/makefile.mk | 4 ---- sc/source/ui/vba/testvba/makefile.mk | 5 ----- 2 files changed, 9 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 5842b90237ff..dd489830b1c6 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -37,10 +37,6 @@ VISIBILITY_HIDDEN=TRUE .INCLUDE : settings.mk DLLPRE = -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF .IF "$(L10N_framework)"=="" INCPRE=$(INCCOM)$/$(TARGET) diff --git a/sc/source/ui/vba/testvba/makefile.mk b/sc/source/ui/vba/testvba/makefile.mk index fb131f314ed3..534085e326e1 100644 --- a/sc/source/ui/vba/testvba/makefile.mk +++ b/sc/source/ui/vba/testvba/makefile.mk @@ -36,11 +36,6 @@ ENABLE_EXCEPTIONS=TRUE .INCLUDE : settings.mk DLLPRE = -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - INCPRE=$(INCCOM)$/$(TARGET) CDEFS+=-DVBA_OOBUILD_HACK # ------------------------------------------------------------------ -- cgit From 1a5aaf0b88db4a7479eeb1893f2b8bb5ae72111f Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 15 Mar 2011 01:58:39 -0400 Subject: Some attempts to get the VBA code to build. --- sc/source/ui/vba/excelvbahelper.cxx | 16 +++--- sc/source/ui/vba/excelvbahelper.hxx | 56 +++++++-------------- sc/source/ui/vba/makefile.mk | 7 --- sc/source/ui/vba/service.cxx | 10 ---- sc/source/ui/vba/vbaaxis.cxx | 2 +- sc/source/ui/vba/vbachart.cxx | 14 +++--- sc/source/ui/vba/vbaeventshelper.cxx | 8 +-- sc/source/ui/vba/vbaeventshelper.hxx | 2 +- sc/source/ui/vba/vbaformat.cxx | 2 +- sc/source/ui/vba/vbapagebreak.cxx | 4 +- sc/source/ui/vba/vbarange.cxx | 97 +++++++++++++++++++++--------------- sc/source/ui/vba/vbasheetobject.cxx | 6 ++- 12 files changed, 107 insertions(+), 117 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 5ec8fd16c80d..989ca4678707 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -44,6 +44,10 @@ using namespace ::com::sun::star; using namespace ::ooo::vba; +namespace ooo { +namespace vba { +namespace excel { + // ============================================================================ uno::Reference< sheet::XDatabaseRanges > @@ -331,8 +335,8 @@ sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const rtl::OUString& sRangeStr ) return false; } -uno::Reference< XHelperInterface > -getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +uno::Reference< vba::XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSpreadsheet >& xSheet ) throw ( uno::RuntimeException ) { uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW ); rtl::OUString sCodeName; @@ -458,8 +462,6 @@ ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) // ============================================================================ -} //excel -} //vba -} //ooo - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +} // namespace excel +} // namespace vba +} // namespace ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 13e7bf985d32..4534cb1dd918 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -28,8 +28,8 @@ #ifndef SC_EXCEL_VBA_HELPER_HXX #define SC_EXCEL_VBA_HELPER_HXX -#include -#include +#include +#include "docsh.hxx" #include #include #include @@ -52,11 +52,19 @@ void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); +void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange ); ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); +sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr ); +formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula ); +void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula ); +void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar ); +css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException ); + +css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException ); css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet ) throw ( css::uno::RuntimeException ); css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); @@ -64,6 +72,7 @@ css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const cs css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::frame::XModel >& xModel, SCTAB nTab ) throw ( css::uno::RuntimeException ); ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); @@ -71,43 +80,16 @@ css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Ref class ScVbaCellRangeAccess { - namespace vba - { - namespace excel - { - // nTabs empty means apply zoom to all sheets - void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ); - void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnCut( const css::uno::Reference< css::frame::XModel>& xModel ); - void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose); - void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange ); - ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; - ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); - SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); - sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr ); - formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula ); - void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula ); - void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar ); - css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException ); +public: + static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); +}; + +// ============================================================================ - css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); - css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); - ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); - ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); - css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); +} // namespace excel +} // namespace vba +} // namespace ooo - class ScVbaCellRangeAccess - { - public: - static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj ); - }; - } - } -} #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 67d600116b0c..bd355b184668 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -37,13 +37,6 @@ VISIBILITY_HIDDEN=TRUE .INCLUDE : settings.mk DLLPRE = -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - -CDEFS+=-DVBA_OOBUILD_HACK - .IF "$(L10N_framework)"=="" INCPRE=$(INCCOM)$/$(TARGET) diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 05dc4ab91820..56ed8a38fc6f 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -85,16 +85,6 @@ extern "C" *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( - lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) - { - OSL_TRACE("In component_writeInfo"); - - // Component registration - return component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); - } - SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) diff --git a/sc/source/ui/vba/vbaaxis.cxx b/sc/source/ui/vba/vbaaxis.cxx index 3d599b25a599..843b278fcbfc 100644 --- a/sc/source/ui/vba/vbaaxis.cxx +++ b/sc/source/ui/vba/vbaaxis.cxx @@ -572,7 +572,7 @@ ScVbaAxis::setScaleType( ::sal_Int32 _nScaleType ) throw (script::BasicErrorExce switch (_nScaleType) { case xlScaleLinear: - mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( false ) ); + mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_False ) ); break; case xlScaleLogarithmic: mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_True ) ); diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx index 16893723a19a..1377291fcb24 100644 --- a/sc/source/ui/vba/vbachart.cxx +++ b/sc/source/ui/vba/vbachart.cxx @@ -331,7 +331,7 @@ try case xlXYScatter: case xlBubble: // not possible case xlBubble3DEffect: // not possible - mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( false )); + mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False )); break; case xlXYScatterLines: case xlXYScatterLinesNoMarkers: @@ -385,7 +385,7 @@ try default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP)) { - mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( false)); + mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False)); } break; } @@ -455,7 +455,7 @@ try default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL)) { - mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(false)); + mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False)); } break; } @@ -476,7 +476,7 @@ try case xlConeBarStacked: case xlPyramidColStacked: case xlPyramidBarStacked: - mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( false )); + mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False )); mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True )); break; case xlPyramidColStacked100: @@ -497,8 +497,8 @@ try mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True )); break; default: - mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( false)); - mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( false)); + mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False)); + mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False)); break; } switch (_nChartType) @@ -542,7 +542,7 @@ try default: if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D)) { - mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( false)); + mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False)); } break; } diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index f1c706a7a091..e22632529617 100644 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -137,6 +137,7 @@ private: uno::Reference< awt::XWindow > getContainerWindow(); bool isMouseReleased(); DECL_LINK( fireResizeMacro, void* ); + void processWindowResizeMacro(); private: ::osl::Mutex maMutex; @@ -689,13 +690,13 @@ namespace { bool lclSelectionChanged( const ScRangeList& rLeft, const ScRangeList& rRight ) { // one of the range lists empty? -> return false, if both lists empty - bool bLeftEmpty = rLeft.Count() == 0; - bool bRightEmpty = rRight.Count() == 0; + bool bLeftEmpty = rLeft.empty(); + bool bRightEmpty = rRight.empty(); if( bLeftEmpty || bRightEmpty ) return !(bLeftEmpty && bRightEmpty); // check sheet indexes of the range lists (assuming that all ranges in a list are on the same sheet) - if( rLeft.GetObject( 0 )->aStart.Tab() != rRight.GetObject( 0 )->aStart.Tab() ) + if( rLeft.front()->aStart.Tab() != rRight.front()->aStart.Tab() ) return false; // compare all ranges @@ -706,7 +707,6 @@ bool lclSelectionChanged( const ScRangeList& rLeft, const ScRangeList& rRight ) bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) { - uno::Reference< uno::XInterface > xOldSelection( maOldSelection, uno::UNO_QUERY ); uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false ); if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) ) { diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index f299afd7ac6c..fccbe2873f84 100644 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -71,9 +71,9 @@ private: private: ::rtl::Reference< ScVbaEventsListener > mxListener; - css::uno::Any maOldSelection; ScDocShell* mpDocShell; ScDocument* mpDoc; + ScRangeList maOldSelection; bool mbOpened; }; diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx index 853ddaff2484..83563e05ea02 100644 --- a/sc/source/ui/vba/vbaformat.cxx +++ b/sc/source/ui/vba/vbaformat.cxx @@ -59,7 +59,7 @@ using namespace ::com::sun::star; #define LOCALE "Locale" template< typename Ifc1 > -ScVbaFormat< Ifc1 >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( script::BasicErrorException ) : ScVbaFormat_BASE( xParent, xContext ), m_aDefaultLocale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US") ), rtl::OUString() ), mxPropertySet( _xPropertySet ), mxModel( xModel ), mbCheckAmbiguoity( bCheckAmbiguoity ), mbAddIndent( false ) +ScVbaFormat< Ifc1 >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( script::BasicErrorException ) : ScVbaFormat_BASE( xParent, xContext ), m_aDefaultLocale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US") ), rtl::OUString() ), mxPropertySet( _xPropertySet ), mxModel( xModel ), mbCheckAmbiguoity( bCheckAmbiguoity ), mbAddIndent( sal_False ) { try { diff --git a/sc/source/ui/vba/vbapagebreak.cxx b/sc/source/ui/vba/vbapagebreak.cxx index fa75e96f6954..3939c33128cc 100644 --- a/sc/source/ui/vba/vbapagebreak.cxx +++ b/sc/source/ui/vba/vbapagebreak.cxx @@ -70,7 +70,7 @@ void ScVbaPageBreak::setType(sal_Int32 type) throw (uno::RuntimeException) if( type == excel::XlPageBreak::xlPageBreakNone ) { - mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(false)); + mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False)); return; } @@ -84,7 +84,7 @@ void ScVbaPageBreak::setType(sal_Int32 type) throw (uno::RuntimeException) template< typename Ifc1 > void ScVbaPageBreak::Delete() throw ( script::BasicErrorException, uno::RuntimeException) { - mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(false)); + mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False)); } template< typename Ifc1 > diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx index af6336eb39ea..7a57e33be889 100644 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -176,6 +176,7 @@ #include "dbdocfun.hxx" #include "patattr.hxx" #include "olinetab.hxx" +#include "transobj.hxx" #include #include @@ -539,11 +540,9 @@ public: bool setNumberFormat( const rtl::OUString& rFormat ) { - lang::Locale aLocale; - uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); - xNumProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Locale" )) ) >>= aLocale; - sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false ); - if ( nNewIndex == -1 ) // format not defined + // #163288# treat "General" as "Standard" format + sal_Int32 nNewIndex = 0; + if( !rFormat.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "General" ) ) ) { lang::Locale aLocale; uno::Reference< beans::XPropertySet > xNumProps = getNumberProps(); @@ -1607,7 +1606,7 @@ ScVbaRange::getValue() throw (uno::RuntimeException) void -ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) throw (uno::RuntimeException) +ScVbaRange::setValue( const uno::Any& aValue, ValueSetter& valueSetter, bool bFireEvent ) throw (uno::RuntimeException) { uno::TypeClass aClass = aValue.getValueTypeClass(); if ( aClass == uno::TypeClass_SEQUENCE ) @@ -1657,10 +1656,12 @@ ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException) return; } CellValueSetter valueSetter( aValue ); - setValue( aValue, valueSetter ); + setValue( aValue, valueSetter, true ); +#if 0 // TODO: Noel, do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } void SAL_CALL @@ -1668,10 +1669,12 @@ ScVbaRange::Clear() throw (uno::RuntimeException) { using namespace ::com::sun::star::sheet::CellFlags; sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED; - ClearContents( nFlags ); + ClearContents( nFlags, true ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } //helper ClearContent @@ -1690,7 +1693,7 @@ ScVbaRange::ClearContents( sal_Int32 nFlags, bool bFireEvent ) throw (uno::Runti uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW ); ScVbaRange* pRange = getImplementation( xRange ); if ( pRange ) - pRange->ClearContents( nFlags ); + pRange->ClearContents( nFlags, false ); // do not fire for single ranges } // fire change event for the entire range list if( bFireEvent ) fireChangeEvent(); @@ -1715,10 +1718,12 @@ ScVbaRange::ClearContents() throw (uno::RuntimeException) sal_Int32 nClearFlags = ( sheet::CellFlags::VALUE | sheet::CellFlags::STRING | sheet::CellFlags::DATETIME | sheet::CellFlags::FORMULA ); - ClearContents( nClearFlags ); + ClearContents( nClearFlags, true ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } void SAL_CALL @@ -1726,10 +1731,12 @@ ScVbaRange::ClearFormats() throw (uno::RuntimeException) { //FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR; - ClearContents( nClearFlags ); + ClearContents( nClearFlags, false ); +#if 0 // TODO: do we still need this? // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } void @@ -1744,10 +1751,12 @@ ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar:: return; } CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram ); - setValue( rFormula, formulaValueSetter ); + setValue( rFormula, formulaValueSetter, bFireEvent ); +#if 0 // TODO: ditto // Fires the range change event. lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() ); +#endif } uno::Any @@ -1771,7 +1780,7 @@ void ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException) { // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion - setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );; + setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1, true ); } uno::Any @@ -1877,7 +1886,7 @@ ScVbaRange::HasFormula() throw (uno::RuntimeException) ScCellRangesBase* pFormulaRanges = dynamic_cast< ScCellRangesBase * > ( xRanges.get() ); // check if there are no formula cell, return false if ( pFormulaRanges->GetRangeList().empty() ) - return uno::makeAny(false); + return uno::makeAny(sal_False); // chech if there are holes (where some cells are not formulas) // or returned range is not equal to this range @@ -2125,7 +2134,7 @@ ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolut // force external to be false // only first address should have the // document and sheet specifications - aExternalCopy = uno::makeAny(false); + aExternalCopy = uno::makeAny(sal_False); } sAddress += xRange->Address( RowAbsolute, ColumnAbsolute, ReferenceStyle, aExternalCopy, RelativeTo ); } @@ -2273,7 +2282,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, { ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 ); ScRange tmpRange; - sal_uInt16 flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( mxRange ), dDetails ); + sal_uInt16 flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( xRange ), dDetails ); if ( ( flags & 0x200 ) != 0x200 ) throw uno::RuntimeException(); nColumn = tmpRange.aStart.Col() + 1; @@ -2290,7 +2299,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, } if ( !( aColumnAny >>= nColumn ) ) { - uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext ); + uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext ); uno::Any aConverted; try { @@ -2301,7 +2310,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, } } } - RangeHelper thisRange( mxRange ); + RangeHelper thisRange( xRange ); table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells @@ -2324,7 +2333,7 @@ ScVbaRange::CellsHelper( const uno::Reference< ov::XHelperInterface >& xParent, --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( xParent, xContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void @@ -3850,6 +3859,18 @@ double getDefaultCharWidth( const uno::Reference< frame::XModel >& xModel ) thro return lcl_TwipsToPoints( (sal_uInt16)nCharWidth ); } +double getDefaultCharWidth( ScDocShell* pDocShell ) +{ + ScDocument* pDoc = pDocShell->GetDocument(); + OutputDevice* pRefDevice = pDoc->GetRefDevice(); + ScPatternAttr* pAttr = pDoc->GetDefPattern(); + ::Font aDefFont; + pAttr->GetFont( aDefFont, SC_AUTOCOL_BLACK, pRefDevice ); + pRefDevice->SetFont( aDefFont ); + long nCharWidth = pRefDevice->GetTextWidth( String( '0' ) ); // 1/100th mm + return lcl_hmmToPoints( nCharWidth ); +} + uno::Any SAL_CALL ScVbaRange::getColumnWidth() throw (uno::RuntimeException) { @@ -3865,7 +3886,7 @@ ScVbaRange::getColumnWidth() throw (uno::RuntimeException) if ( pShell ) { uno::Reference< frame::XModel > xModel = pShell->GetModel(); - double defaultCharWidth = getDefaultCharWidth( pShell ); + double defaultCharWidth = getDefaultCharWidth( xModel ); RangeHelper thisRange( mxRange ); table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); sal_Int32 nStartCol = thisAddress.StartColumn; @@ -3904,26 +3925,24 @@ ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeEx double nColWidth = 0; _columnwidth >>= nColWidth; nColWidth = lcl_Round2DecPlaces( nColWidth ); - ScDocShell* pDocShell = getScDocShell(); - if ( pDocShell ) - { - uno::Reference< frame::XModel > xModel = pDocShell->GetModel(); - if ( xModel.is() ) - { - - nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) ); - RangeHelper thisRange( mxRange ); - table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); - sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth ); + ScDocShell* pDocShell = getScDocShell(); + if ( pDocShell ) + { + if ( nColWidth != 0.0 ) + nColWidth = ( nColWidth + fExtraWidth ) * getDefaultCharWidth( pDocShell ); + RangeHelper thisRange( mxRange ); + table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress(); + sal_uInt16 nTwips = lcl_pointsToTwips( nColWidth ); - ScDocFunc aFunc(*pDocShell); - SCCOLROW nColArr[2]; - nColArr[0] = thisAddress.StartColumn; - nColArr[1] = thisAddress.EndColumn; - aFunc.SetWidthOrHeight( true, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL, - nTwips, true, true ); + ScDocFunc aFunc(*pDocShell); + SCCOLROW nColArr[2]; + nColArr[0] = thisAddress.StartColumn; + nColArr[1] = thisAddress.EndColumn; + // #163561# use mode SC_SIZE_DIRECT: hide for width 0, show for other values + aFunc.SetWidthOrHeight( true, 1, nColArr, thisAddress.Sheet, + SC_SIZE_DIRECT, nTwips, true, true ); - } + } } uno::Any SAL_CALL @@ -4740,7 +4759,7 @@ ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const } void SAL_CALL -ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException) +ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& /*CopyOrigin*/ ) throw (uno::RuntimeException) { // It appears ( from the web ) that the undocumented CopyOrigin // param should contain member of enum XlInsertFormatOrigin diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx index f7582d9a25a2..9c8b5e2e501b 100644 --- a/sc/source/ui/vba/vbasheetobject.cxx +++ b/sc/source/ui/vba/vbasheetobject.cxx @@ -241,6 +241,7 @@ void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno: sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException) { sal_Int32 nRet = excel::XlPlacement::xlMoveAndSize; +#if 0 // TODO: not working at the moment. SvxShape* pShape = SvxShape::getImplementation( mxShape ); if(pShape) { @@ -252,11 +253,13 @@ sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeExcep nRet = excel::XlPlacement::xlFreeFloating; } } +#endif return nRet; } -void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 nPlacement ) throw (uno::RuntimeException) +void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException) { +#if 0 // TODO: not working at the moment. SvxShape* pShape = SvxShape::getImplementation( mxShape ); if(pShape) { @@ -272,6 +275,7 @@ void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 nPlacement ) throw ( ScDrawLayer::SetAnchor(pObj, eType); } } +#endif } sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException) -- cgit From 970dfb78ae6e80e0463adfa462a9d942bd7ed2a7 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Tue, 15 Mar 2011 09:56:18 +0000 Subject: more merge fixes, compiles and links now --- sc/source/ui/vba/excelvbahelper.cxx | 10 ++++++++-- sc/source/ui/vba/vbaapplication.cxx | 5 +++++ sc/source/ui/vba/vbaworksheet.cxx | 19 ++++--------------- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'sc/source/ui/vba') diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 989ca4678707..4f49aab539c4 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -38,8 +38,6 @@ #include "compiler.hxx" #include "token.hxx" #include "tokenarray.hxx" -#include -#include using namespace ::com::sun::star; using namespace ::ooo::vba; @@ -106,6 +104,14 @@ ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRang return pScCellRangesBase->GetDocShell(); } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); + uno::Reference< sheet::XSpreadsheet > xSheet( xSheetRange->getSpreadsheet(), uno::UNO_SET_THROW ); + return getUnoSheetModuleObj( xSheet ); +} + ScDocShell* GetDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException ) { // need the ScCellRangesBase to get docshell diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 59bf41d21cd1..817ec1ecbf4a 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -183,6 +183,11 @@ ScVbaApplication::~ScVbaApplication() { } +/*static*/ bool ScVbaApplication::getDocumentEventsEnabled() +{ + return ScVbaStaticAppSettings::get().mbEnableEvents; +} + SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) ); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 7b889b4603c7..94f197d32de5 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -30,6 +30,7 @@ #include #include "vbaworksheet.hxx" +#include "vbanames.hxx" #include #include @@ -245,7 +246,7 @@ ScVbaWorksheet::getVisible() throw (uno::RuntimeException) } void -ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException) +ScVbaWorksheet::setVisible( ::sal_Int32 nVisible ) throw (uno::RuntimeException) { using namespace ::ooo::vba::excel::XlSheetVisibility; bool bVisible = true; @@ -267,21 +268,9 @@ ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException) throw uno::RuntimeException(); } uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW ); - - sal_Bool bVisible = true; - switch( _Visible ) - { - case excel::XlSheetVisibility::xlSheetHidden: - case excel::XlSheetVisibility::xlSheetVeryHidden: - bVisible = false; - break; - case excel::XlSheetVisibility::xlSheetVisible: - bVisible = true; - break; - } - uno::Any aValue( bVisible ); xProps->setPropertyValue - (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue); + ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), + uno::Any( bVisible ) ); } sal_Int16 -- cgit