tdf#169155 use o3tl::enumarray for AutoRecovery and LayoutManager

using modern C++ enum classes instead of traditional #define macros

Change-Id: I2e2e32e26ac14dcde77de1c0853a2a03eb284e3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200143
Tested-by: Jenkins
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
Mo Amr
2026-02-28 12:07:10 +01:00
committed by Ilmari Lauhakangas
parent e4e601b1eb
commit 56343500ee
4 changed files with 60 additions and 51 deletions
+34 -28
View File
@@ -49,24 +49,28 @@ inline constexpr o3tl::enumarray<FramePropHandle, OUString> FramePropNames =
};
/** properties for "LayoutManager" class */
enum class LayoutManagerPropHandle
{
MenuBarCloser,
AutomaticToolbars,
RefreshVisibility,
HideCurrentUI,
LockCount,
PreserveContentSize,
RefreshToolTip,
LAST = RefreshToolTip
};
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER = u"MenuBarCloser"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS = u"AutomaticToolbars"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY = u"RefreshContextToolbarVisibility"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI = u"HideCurrentUI"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT = u"LockCount"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE = u"PreserveContentSize"_ustr;
inline constexpr OUString LAYOUTMANAGER_PROPNAME_ASCII_REFRESHTOOLTIP = u"RefreshContextToolbarToolTip"_ustr;
#define LAYOUTMANAGER_PROPNAME_MENUBARCLOSER LAYOUTMANAGER_PROPNAME_ASCII_MENUBARCLOSER
#define LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER 0
#define LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS 1
#define LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY 2
#define LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI 3
#define LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT 4
#define LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE 5
#define LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP 6
inline constexpr o3tl::enumarray<LayoutManagerPropHandle, OUString> LayoutManagerPropNames =
{
u"MenuBarCloser"_ustr,
u"AutomaticToolbars"_ustr,
u"RefreshContextToolbarVisibility"_ustr,
u"HideCurrentUI"_ustr,
u"LockCount"_ustr,
u"PreserveContentSize"_ustr,
u"RefreshContextToolbarToolTip"_ustr
};
/** properties for "UICommandDescription" class */
inline constexpr OUString UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDIMAGELIST = u"private:resource/image/commandimagelist"_ustr;
@@ -77,18 +81,20 @@ inline constexpr OUString UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST
#define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
/** properties for "AutoRecovery" class */
enum class AutoRecoveryPropHandle
{
ExistsRecoveryData,
ExistsSessionData,
Crashed,
LAST = Crashed
};
inline constexpr OUString AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA = u"ExistsRecoveryData"_ustr;
inline constexpr OUString AUTORECOVERY_PROPNAME_ASCII_EXISTS_SESSIONDATA = u"ExistsSessionData"_ustr;
inline constexpr OUString AUTORECOVERY_PROPNAME_ASCII_CRASHED = u"Crashed"_ustr;
#define AUTORECOVERY_PROPNAME_EXISTS_RECOVERYDATA AUTORECOVERY_PROPNAME_ASCII_EXISTS_RECOVERYDATA
#define AUTORECOVERY_PROPNAME_EXISTS_SESSIONDATA AUTORECOVERY_PROPNAME_ASCII_EXISTS_SESSIONDATA
#define AUTORECOVERY_PROPNAME_CRASHED AUTORECOVERY_PROPNAME_ASCII_CRASHED
#define AUTORECOVERY_PROPHANDLE_EXISTS_RECOVERYDATA 0
#define AUTORECOVERY_PROPHANDLE_EXISTS_SESSIONDATA 1
#define AUTORECOVERY_PROPHANDLE_CRASHED 2
inline constexpr o3tl::enumarray<AutoRecoveryPropHandle, OUString> AutoRecoveryPropNames =
{
u"ExistsRecoveryData"_ustr,
u"ExistsSessionData"_ustr,
u"Crashed"_ustr
};
/** properties for Filter config */
@@ -126,13 +126,13 @@ LayoutManager::LayoutManager( const Reference< XComponentContext >& xContext ) :
m_aAsyncLayoutTimer.SetTimeout( 50 );
m_aAsyncLayoutTimer.SetInvokeHandler( LINK( this, LayoutManager, AsyncLayoutHdl ) );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_AUTOMATICTOOLBARS, LAYOUTMANAGER_PROPHANDLE_AUTOMATICTOOLBARS, css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, cppu::UnoType<decltype(m_bAutomaticToolbars)>::get() );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_HIDECURRENTUI, LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI, beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, cppu::UnoType<decltype(m_bHideCurrentUI)>::get() );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_LOCKCOUNT, LAYOUTMANAGER_PROPHANDLE_LOCKCOUNT, beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::READONLY, &m_nLockCount, cppu::UnoType<decltype(m_nLockCount)>::get() );
registerProperty( LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER, beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloseButton, cppu::UnoType<decltype(m_bMenuBarCloseButton)>::get() );
registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHVISIBILITY, LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY, beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
registerProperty( LAYOUTMANAGER_PROPNAME_ASCII_PRESERVE_CONTENT_SIZE, LAYOUTMANAGER_PROPHANDLE_PRESERVE_CONTENT_SIZE, beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, cppu::UnoType<decltype(m_bPreserveContentSize)>::get() );
registerPropertyNoMember( LAYOUTMANAGER_PROPNAME_ASCII_REFRESHTOOLTIP, LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP, beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
registerProperty( LayoutManagerPropNames[LayoutManagerPropHandle::AutomaticToolbars], static_cast<sal_Int32>(LayoutManagerPropHandle::AutomaticToolbars), css::beans::PropertyAttribute::TRANSIENT, &m_bAutomaticToolbars, cppu::UnoType<decltype(m_bAutomaticToolbars)>::get() );
registerProperty( LayoutManagerPropNames[LayoutManagerPropHandle::HideCurrentUI], static_cast<sal_Int32>(LayoutManagerPropHandle::HideCurrentUI), beans::PropertyAttribute::TRANSIENT, &m_bHideCurrentUI, cppu::UnoType<decltype(m_bHideCurrentUI)>::get() );
registerProperty( LayoutManagerPropNames[LayoutManagerPropHandle::LockCount], static_cast<sal_Int32>(LayoutManagerPropHandle::LockCount), beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::READONLY, &m_nLockCount, cppu::UnoType<decltype(m_nLockCount)>::get() );
registerProperty( LayoutManagerPropNames[LayoutManagerPropHandle::MenuBarCloser], static_cast<sal_Int32>(LayoutManagerPropHandle::MenuBarCloser), beans::PropertyAttribute::TRANSIENT, &m_bMenuBarCloseButton, cppu::UnoType<decltype(m_bMenuBarCloseButton)>::get() );
registerPropertyNoMember( LayoutManagerPropNames[LayoutManagerPropHandle::RefreshVisibility], static_cast<sal_Int32>(LayoutManagerPropHandle::RefreshVisibility), beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
registerProperty( LayoutManagerPropNames[LayoutManagerPropHandle::PreserveContentSize], static_cast<sal_Int32>(LayoutManagerPropHandle::PreserveContentSize), beans::PropertyAttribute::TRANSIENT, &m_bPreserveContentSize, cppu::UnoType<decltype(m_bPreserveContentSize)>::get() );
registerPropertyNoMember( LayoutManagerPropNames[LayoutManagerPropHandle::RefreshToolTip], static_cast<sal_Int32>(LayoutManagerPropHandle::RefreshToolTip), beans::PropertyAttribute::TRANSIENT, cppu::UnoType<bool>::get(), css::uno::Any(false) );
}
LayoutManager::~LayoutManager()
@@ -3035,16 +3035,19 @@ void SAL_CALL LayoutManager::elementReplaced( const ui::ConfigurationEvent& Even
void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
const uno::Any& aValue )
{
if ( (nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY) && (nHandle != LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP) )
LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue );
switch( nHandle )
if ( (nHandle != static_cast<sal_Int32>(LayoutManagerPropHandle::RefreshVisibility)) &&
(nHandle != static_cast<sal_Int32>(LayoutManagerPropHandle::RefreshToolTip)) )
{
case LAYOUTMANAGER_PROPHANDLE_MENUBARCLOSER:
LayoutManager_PBase::setFastPropertyValue_NoBroadcast( nHandle, aValue );
}
switch( static_cast<LayoutManagerPropHandle>(nHandle) )
{
case LayoutManagerPropHandle::MenuBarCloser:
implts_updateMenuBarClose();
break;
case LAYOUTMANAGER_PROPHANDLE_REFRESHVISIBILITY:
case LayoutManagerPropHandle::RefreshVisibility:
{
bool bValue(false);
if (( aValue >>= bValue ) && bValue )
@@ -3060,11 +3063,11 @@ void SAL_CALL LayoutManager::setFastPropertyValue_NoBroadcast( sal_Int32 n
break;
}
case LAYOUTMANAGER_PROPHANDLE_HIDECURRENTUI:
case LayoutManagerPropHandle::HideCurrentUI:
implts_setCurrentUIVisibility( !m_bHideCurrentUI );
break;
case LAYOUTMANAGER_PROPHANDLE_REFRESHTOOLTIP:
case LayoutManagerPropHandle::RefreshToolTip:
if (m_xToolbarManager.is())
m_xToolbarManager->updateToolbarsTips();
break;
+7 -7
View File
@@ -4012,9 +4012,9 @@ void SAL_CALL AutoRecovery::setFastPropertyValue_NoBroadcast( sal_Int32
void SAL_CALL AutoRecovery::getFastPropertyValue(css::uno::Any& aValue ,
sal_Int32 nHandle) const
{
switch(nHandle)
switch(static_cast<AutoRecoveryPropHandle>(nHandle))
{
case AUTORECOVERY_PROPHANDLE_EXISTS_RECOVERYDATA :
case AutoRecoveryPropHandle::ExistsRecoveryData :
{
bool bSessionData = officecfg::Office::Recovery::RecoveryInfo::SessionData::get();
bool bRecoveryData = !m_lDocCache.empty();
@@ -4028,11 +4028,11 @@ void SAL_CALL AutoRecovery::getFastPropertyValue(css::uno::Any& aValue ,
}
break;
case AUTORECOVERY_PROPHANDLE_CRASHED :
case AutoRecoveryPropHandle::Crashed :
aValue <<= officecfg::Office::Recovery::RecoveryInfo::Crashed::get();
break;
case AUTORECOVERY_PROPHANDLE_EXISTS_SESSIONDATA :
case AutoRecoveryPropHandle::ExistsSessionData :
aValue <<= officecfg::Office::Recovery::RecoveryInfo::SessionData::get();
break;
}
@@ -4042,9 +4042,9 @@ css::uno::Sequence< css::beans::Property > impl_getStaticPropertyDescriptor()
{
return
{
css::beans::Property( AUTORECOVERY_PROPNAME_CRASHED , AUTORECOVERY_PROPHANDLE_CRASHED , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
css::beans::Property( AUTORECOVERY_PROPNAME_EXISTS_RECOVERYDATA, AUTORECOVERY_PROPHANDLE_EXISTS_RECOVERYDATA, cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
css::beans::Property( AUTORECOVERY_PROPNAME_EXISTS_SESSIONDATA , AUTORECOVERY_PROPHANDLE_EXISTS_SESSIONDATA , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
css::beans::Property( AutoRecoveryPropNames[AutoRecoveryPropHandle::Crashed] , static_cast<sal_Int32>(AutoRecoveryPropHandle::Crashed) , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
css::beans::Property( AutoRecoveryPropNames[AutoRecoveryPropHandle::ExistsRecoveryData] , static_cast<sal_Int32>(AutoRecoveryPropHandle::ExistsRecoveryData) , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
css::beans::Property( AutoRecoveryPropNames[AutoRecoveryPropHandle::ExistsSessionData] , static_cast<sal_Int32>(AutoRecoveryPropHandle::ExistsSessionData) , cppu::UnoType<bool>::get() , css::beans::PropertyAttribute::TRANSIENT | css::beans::PropertyAttribute::READONLY ),
};
}
+1 -1
View File
@@ -3222,7 +3222,7 @@ void XFrameImpl::impl_setCloser( /*IN*/ const css::uno::Reference< css::frame::X
css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
xFrameProps->getPropertyValue(FramePropNames[FramePropHandle::LayoutManager]) >>= xLayoutManager;
css::uno::Reference< css::beans::XPropertySet > xLayoutProps(xLayoutManager, css::uno::UNO_QUERY_THROW);
xLayoutProps->setPropertyValue(LAYOUTMANAGER_PROPNAME_MENUBARCLOSER, css::uno::Any(bState));
xLayoutProps->setPropertyValue(LayoutManagerPropNames[LayoutManagerPropHandle::MenuBarCloser], css::uno::Any(bState));
}
catch(const css::uno::RuntimeException&)
{ throw; }