diff options
author | Daniel Rentz <dr@openoffice.org> | 2010-07-30 17:28:42 +0200 |
---|---|---|
committer | Daniel Rentz <dr@openoffice.org> | 2010-07-30 17:28:42 +0200 |
commit | 77ccf4c8b1828fea6bc0a86b741bfd2d43e2937f (patch) | |
tree | 6fcbbcc4dabc48a2224125a6ab38e7381161f2ca | |
parent | 6d4d2362f1b41c5d64924a7fe43c984cddf14712 (diff) |
mib17: #163146# XLS import: do not skip hidden names, do not rename sheet-local names, add Worksheet.Names VBA symbol -- #i112849# fix crash when closing Calc document
-rw-r--r-- | sc/inc/document.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/bcaslot.cxx | 12 | ||||
-rw-r--r-- | sc/source/filter/excel/xiname.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 27 | ||||
-rwxr-xr-x | sc/source/ui/vba/vbaeventshelper.cxx | 6 | ||||
-rwxr-xr-x | sc/source/ui/vba/vbaeventshelper.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 21 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.hxx | 1 |
8 files changed, 37 insertions, 42 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 83896f76378d..983ceb4ace08 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -337,8 +337,7 @@ private: Timer aTrackTimer; - // mutable for lazy construction - mutable com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents; public: diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 95482b1c624b..540fb577a79b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -136,10 +136,16 @@ ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, ScBroadcastAreaSlot::~ScBroadcastAreaSlot() { for ( ScBroadcastAreas::iterator aIter( aBroadcastAreaTbl.begin()); - aIter != aBroadcastAreaTbl.end(); ++aIter) + aIter != aBroadcastAreaTbl.end(); /* none */) { - if (!(*aIter)->DecRef()) - delete *aIter; + // Prevent hash from accessing dangling pointer in case area is + // deleted. + ScBroadcastArea* pArea = *aIter; + // Erase all so no hash will be accessed upon destruction of the + // hash_set. + aBroadcastAreaTbl.erase( aIter++); + if (!pArea->DecRef()) + delete pArea; } } diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx index 70ff46a0d741..5d21d91c9f53 100644 --- a/sc/source/filter/excel/xiname.cxx +++ b/sc/source/filter/excel/xiname.cxx @@ -132,7 +132,8 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : if( nXclTab != EXC_NAME_GLOBAL ) { sal_uInt16 nUsedTab = (GetBiff() == EXC_BIFF8) ? nXclTab : nExtSheet; - maScName.Append( '_' ).Append( String::CreateFromInt32( nUsedTab ) ); + // #163146# do not rename sheet-local names by default, this breaks VBA scripts +// maScName.Append( '_' ).Append( String::CreateFromInt32( nUsedTab ) ); // TODO: may not work for BIFF5, handle skipped sheets (all BIFF) mnScTab = static_cast< SCTAB >( nUsedTab - 1 ); } @@ -208,7 +209,8 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) : // 4) *** create a defined name in the Calc document *** ------------------ - if( pTokArr && (bBuiltIn || !::get_flag( nFlags, EXC_NAME_HIDDEN )) && !mbVBName ) + // #163146# do not ignore hidden names (may be regular names created by VBA scripts) + if( pTokArr /*&& (bBuiltIn || !::get_flag( nFlags, EXC_NAME_HIDDEN ))*/ && !mbVBName ) { // create the Calc name data ScRangeData* pData = new ScRangeData( GetDocPtr(), maScName, *pTokArr, ScAddress(), nNameType ); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 0d3c8cf639d5..d5d7f6e09292 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -554,17 +554,6 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); } break; - case SFX_EVENT_CLOSEDOC: - { - // explicitly fire WindowDeactivate and Deactivate on closing - uno::Sequence< uno::Any > aArgs; - xVbaEvents->processVbaEvent( WORKBOOK_WINDOWDEACTIVATE, aArgs ); - xVbaEvents->processVbaEvent( WORKBOOK_DEACTIVATE, aArgs ); - // event processor will remove all listeners on destruction - xVbaEvents.clear(); - aDocument.SetVbaEventProcessor( xVbaEvents ); - } - break; } } } @@ -636,24 +625,10 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { uno::Reference< frame::XModel > xModel( GetModel(), uno::UNO_SET_THROW ); - // create VBAGlobals object if not yet done + // create VBAGlobals object if not yet done (this also creates the "ThisExcelDoc" symbol) uno::Reference< lang::XMultiServiceFactory > xFactory( xModel, uno::UNO_QUERY_THROW ); xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); - // Fake ThisComponent being setup by Activate ( which is a view - // related thing ), - // a) if another document is opened then in theory ThisComponent - // will be reset as before, - // b) when this document is 'really' Activated then ThisComponent - // again will be set as before - // The only wrinkle seems if this document is loaded 'InVisible' - // but.. I don't see that this is possible from the vba API - // I could be wrong though - // There may be implications setting the current component - // too early :-/ so I will just manually set the Basic Variables - if( BasicManager* pAppMgr = SFX_APP()->GetBasicManager() ) - pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", uno::Any( xModel ) ); - // create the VBA document event processor uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= xModel; diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 0ef2e0f911bc..45667adf2f2c 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -433,6 +433,12 @@ ScVbaEventsHelper::~ScVbaEventsHelper() { } +void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) throw (uno::RuntimeException) +{ + mxListener.clear(); + VbaEventsHelperBase::disposing( rSource ); +} + // protected ------------------------------------------------------------------ bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx index 4349b83fdb48..a77f5128b3e9 100755 --- a/sc/source/ui/vba/vbaeventshelper.hxx +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -47,6 +47,9 @@ public: const css::uno::Reference< css::uno::XComponentContext >& rxContext ); virtual ~ScVbaEventsHelper(); + // XEventListener + 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); diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx index 5b1963e3d242..4eab79813474 100644 --- a/sc/source/ui/vba/vbaworksheet.cxx +++ b/sc/source/ui/vba/vbaworksheet.cxx @@ -60,6 +60,7 @@ #include <com/sun/star/form/FormComponentType.hpp> #include <com/sun/star/form/XFormsSupplier.hpp> #include <ooo/vba/excel/XlEnableSelection.hpp> +#include <ooo/vba/excel/XWorkbook.hpp> #include <ooo/vba/XControlProvider.hpp> #include <comphelper/processfactory.hxx> @@ -672,24 +673,26 @@ 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 ); +} + +uno::Any SAL_CALL ScVbaWorksheet::OLEObjects( const uno::Any& Index ) throw (uno::RuntimeException) { - ScVbaOLEObjects* aOleObjects; uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW ); uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW ); uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPage, uno::UNO_QUERY_THROW ); - aOleObjects = new ScVbaOLEObjects( this, mxContext, xIndexAccess ); + uno::Reference< excel::XOLEObjects >xOleObjects( new ScVbaOLEObjects( this, mxContext, xIndexAccess ) ); if( Index.hasValue() ) - { - return aOleObjects->Item( Index, uno::Any() ); - } - else - { - return uno::makeAny( uno::Reference< excel::XOLEObjects> ( aOleObjects ) ); - } + return xOleObjects->Item( Index, uno::Any() ); + return uno::Any( xOleObjects ); } + uno::Any SAL_CALL ScVbaWorksheet::Shapes( const uno::Any& aIndex ) throw (uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx index d07cc1a8d55c..196a195258d7 100644 --- a/sc/source/ui/vba/vbaworksheet.hxx +++ b/sc/source/ui/vba/vbaworksheet.hxx @@ -129,6 +129,7 @@ public: virtual css::uno::Any SAL_CALL PivotTables( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Comments( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL OLEObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Shapes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); |