diff options
author | Michael E. Bohn <mbn@openoffice.org> | 2010-09-17 01:45:17 +0200 |
---|---|---|
committer | Michael E. Bohn <mbn@openoffice.org> | 2010-09-17 01:45:17 +0200 |
commit | e0f0548d591fff66923fa9e8dee8e331a2cfc8f0 (patch) | |
tree | c277ba9b9292aaf59fb74751564362e01e28a510 /vbahelper/source | |
parent | 8e29a77b5d78f67ce281e0538eea3edaea918faf (diff) |
mib19: #163532# fix for enabling and disabling custom menue entries via vba.
Diffstat (limited to 'vbahelper/source')
-rw-r--r-- | vbahelper/source/vbahelper/vbacommandbarcontrol.cxx | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx index 3f9c7ddeae89..afcb9041b80f 100644 --- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx +++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx @@ -96,6 +96,7 @@ ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException) if( aValue.hasValue() ) aValue >>= bVisible; return bVisible; + } void SAL_CALL ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException) @@ -106,12 +107,16 @@ ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeExc setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) ); ApplyChange(); } + } ::sal_Bool SAL_CALL ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) { sal_Bool bEnabled = sal_True; + rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); + rtl::OUString aCommandURL ; + if( m_xParentMenu.is() ) { // currently only the menu in the MenuBat support Enable/Disable @@ -121,7 +126,14 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) else { // emulated with Visible - bEnabled = getVisible(); + //bEnabled = getVisible(); + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); + if (aValue >>= aCommandURL){ + if (0 == aCommandURL.indexOf(aCommandURLappendix)){ + bEnabled = sal_False; + } + } + } return bEnabled; } @@ -129,6 +141,9 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException) void SAL_CALL ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException) { + rtl::OUString aCommandURL ; + rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___"); + rtl::OUStringBuffer aCommandURLSringBuffer; if( m_xParentMenu.is() ) { // currently only the menu in the MenuBat support Enable/Disable @@ -136,8 +151,20 @@ ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeExcep } else { + uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") ); + if (aValue >>= aCommandURL){ + if (0 == aCommandURL.indexOf(aCommandURLappendix)){ + aCommandURL = aCommandURL.copy(3); + } + if (false == _enabled){ + aCommandURLSringBuffer = aCommandURLappendix; + } + aCommandURLSringBuffer.append(aCommandURL); + setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) ); + ApplyChange(); + } // emulated with Visible - setVisible( _enabled ); + //setVisible( _enabled ); } } |