Add vba support for assigning names to cell ranges

This commit is contained in:
August Sodora 2011-10-26 15:32:55 -04:00 committed by Noel Power
parent ea95d600de
commit f323d36f29
3 changed files with 25 additions and 1 deletions

View file

@ -64,7 +64,7 @@ interface XRange
interface ::ooo::vba::excel::XFormat;
//interface ::ooo::vba::XHelperInterface;
[attribute, readonly] any Name;
[attribute] any Name;
[attribute] any Value;
[attribute] any Formula;
[attribute] any FormulaArray;

View file

@ -1569,6 +1569,29 @@ uno::Any SAL_CALL ScVbaRange::getName() throw (uno::RuntimeException)
return uno::makeAny( xName );
}
void
ScVbaRange::setName( const uno::Any& aName ) throw (uno::RuntimeException)
{
uno::Reference< excel::XName > xName;
ScDocShell* pDocShell = getScDocShell();
uno::Reference< frame::XModel > xModel = pDocShell ? pDocShell->GetModel() : NULL;
if ( !xModel.is() )
{
throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid document" )), uno::Reference< uno::XInterface >() );
}
uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
uno::Reference< sheet::XNamedRanges > xNamedRanges( xPropertySet->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NamedRanges"))) , uno::UNO_QUERY_THROW );
uno::Reference< excel::XNames > xNames( new ScVbaNames( uno::Reference< XHelperInterface >(), mxContext , xNamedRanges , xModel ) );
uno::Any aDummy;
//uno::Any aRefersTo;
// aRefersTo <<= uno::Reference< excel::XRange >(this, uno::UNO_QUERY);
xNames->Add(aName, getCellRange(), aDummy, aDummy, aDummy, aDummy,
aDummy, aDummy, aDummy, aDummy, aDummy);
}
uno::Any
ScVbaRange::getValue( ValueGetter& valueGetter) throw (uno::RuntimeException)
{

View file

@ -167,6 +167,7 @@ public:
// Attributes
virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException);
virtual void SAL_CALL setName( const css::uno::Any& aName ) throw (css::uno::RuntimeException);
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);
virtual css::uno::Any SAL_CALL getFormula() throw (css::uno::RuntimeException);