diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-09-01 10:26:59 +0200 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-09-01 10:26:59 +0200 |
commit | 02ced0d8f545a00a610ae461d925e7851e9baef0 (patch) | |
tree | e8af21fb7fa65de6464bb520d95bfff2f7c39549 /sc/source/ui | |
parent | mib19: rebase to OOO330m6 (diff) | |
download | core-02ced0d8f545a00a610ae461d925e7851e9baef0.tar.gz core-02ced0d8f545a00a610ae461d925e7851e9baef0.zip |
mib19: #163498# correct parent for sheet-local defined names
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/vba/vbanames.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworkbook.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/vba/vbaworksheet.cxx | 13 |
3 files changed, 20 insertions, 12 deletions
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 <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XSheetPageBreak.hpp> #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp> +#include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> @@ -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 |