include/tools/rc.h | 24 +++++++++++++++++++----- include/vcl/window.hxx | 5 +++-- rsc/inc/rscdb.hxx | 2 ++ rsc/source/parser/rscicpx.cxx | 10 +++++----- vcl/source/window/menu.cxx | 8 ++++---- vcl/source/window/resource.cxx | 8 ++++---- 6 files changed, 37 insertions(+), 20 deletions(-)
New commits: commit 743cdf36d128bc1d0ea3315675b0bb5f85388099 Author: Noel Grandin <[email protected]> Date: Sat May 14 19:52:29 2016 +0200 convert RSC_MENU to scoped enum Change-Id: Ice3784b4168738550d2c0f5ee6da1bd49d15becf Reviewed-on: https://gerrit.libreoffice.org/24997 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/tools/rc.h b/include/tools/rc.h index 211eb25..6b5c900 100644 --- a/include/tools/rc.h +++ b/include/tools/rc.h @@ -53,6 +53,7 @@ namespace o3tl { #define WINDOW_HELPID 0x4000 // For "WorkWindow" resources: + #define WORKWIN_SHOWNORMAL 0 #define WORKWIN_SHOWMINIMIZED 1 #define WORKWIN_SHOWMAXIMIZED 2 @@ -61,9 +62,14 @@ namespace o3tl { #define RSC_FIXEDIMAGE_IMAGE 0x0001 // For all menu resources: -#define RSC_MENU_ITEMS 0x01 -#define RSC_MENU_TEXT 0x02 -#define RSC_MENU_DEFAULTITEMID 0x04 +enum class RscMenu { + Items = 0x01, + Text = 0x02, + DefaultItemId = 0x04 +}; +namespace o3tl { + template<> struct typed_flags<RscMenu> : is_typed_flags<RscMenu, 0x07> {}; +} // "MenuItem" resource options: #define RSC_MENUITEM_SEPARATOR 0x001 diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx index 4b48624..1bbd9fd 100644 --- a/rsc/source/parser/rscicpx.cxx +++ b/rsc/source/parser/rscicpx.cxx @@ -899,13 +899,13 @@ RscTop * RscTypCont::InitClassMenu( RscTop * pSuper, aBaseLst.push_back( pCont = new RscCont( pHS->getID( "ContMenuItem" ), RSC_NOTYPE ) ); pCont->SetTypeClass( pClassMenuItem ); nId = aNmTb.Put( "ItemList", VARNAME ); - pClassMenu->SetVariable( nId, pCont, nullptr, 0, RSC_MENU_ITEMS ); + pClassMenu->SetVariable( nId, pCont, nullptr, 0, (sal_uInt32)RscMenu::Items ); } nId = aNmTb.Put( "Text", VARNAME ); - pClassMenu->SetVariable( nId, &aLangString, nullptr, 0, RSC_MENU_TEXT ); + pClassMenu->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscMenu::Text ); nId = aNmTb.Put( "DefaultItemId", VARNAME ); pClassMenu->SetVariable( nId, &aIdUShort, nullptr, 0, - RSC_MENU_DEFAULTITEMID ); + (sal_uInt32)RscMenu::DefaultItemId ); return pClassMenu; } diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 096faee..075c53b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2805,9 +2805,9 @@ PopupMenu::PopupMenu( const ResId& rResId ) rResId.SetRT( RSC_MENU ); GetRes( rResId ); - sal_uLong nObjMask = ReadLongRes(); + RscMenu nObjMask = (RscMenu)ReadLongRes(); - if( nObjMask & RSC_MENU_ITEMS ) + if( nObjMask & RscMenu::Items ) { sal_uLong nObjFollows = ReadLongRes(); // insert menu items @@ -2818,11 +2818,11 @@ PopupMenu::PopupMenu( const ResId& rResId ) } } - if( nObjMask & RSC_MENU_TEXT ) + if( nObjMask & RscMenu::Text ) { aTitleText = ReadStringRes(); } - if( nObjMask & RSC_MENU_DEFAULTITEMID ) + if( nObjMask & RscMenu::DefaultItemId ) SetDefaultItem( sal::static_int_cast<sal_uInt16>(ReadLongRes()) ); } commit 1938fd869b8226af00925caa7ac991618d35ee0c Author: Noel Grandin <[email protected]> Date: Sat May 14 16:17:25 2016 +0200 Convert RSWND to scoped enum Change-Id: If6e5753ade8b096a4ba1c10b47c2360ff26d181f Reviewed-on: https://gerrit.libreoffice.org/24993 Tested-by: Jenkins <[email protected]> Reviewed-by: Noel Grandin <[email protected]> diff --git a/include/tools/rc.h b/include/tools/rc.h index 49f6ebd..211eb25 100644 --- a/include/tools/rc.h +++ b/include/tools/rc.h @@ -21,14 +21,22 @@ #define INCLUDED_TOOLS_RC_H #include <tools/rcid.h> +#include <o3tl/typed_flags_set.hxx> // Defines for all "Window" resources. // (Here are all window styles that are not in WinBits) #define RSC_EXTRAMAPUNIT 0xFFFF // do not change that value! -#define RSWND_DISABLED 0x01 -#define RSWND_CLIENTSIZE 0x02 +// Attributes in *.src files +enum class RSWND { + NONE = 0x00, + DISABLED = 0x01, // "Disable" attribute + CLIENTSIZE = 0x02 // "OutputSize" attribute +}; +namespace o3tl { + template<> struct typed_flags<RSWND> : is_typed_flags<RSWND, 0x03> {}; +} #define WINDOW_XYMAPMODE 0x0001 #define WINDOW_X 0x0002 diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 9f4a8dc..d9f9d91 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -465,12 +465,13 @@ class MenuFloatingWindow; class LifecycleTest; namespace svt { class PopupWindowControllerImpl; } +enum class RSWND; struct WindowResHeader { sal_uLong nObjMask; - OString aHelpId; - sal_uLong nRSStyle; + OString aHelpId; + RSWND nRSStyle; }; namespace vcl { diff --git a/rsc/inc/rscdb.hxx b/rsc/inc/rscdb.hxx index ea4cdd0..07db859 100644 --- a/rsc/inc/rscdb.hxx +++ b/rsc/inc/rscdb.hxx @@ -45,6 +45,7 @@ enum class ToolBoxItemType; enum class ButtonType; enum class WindowAlign; enum class SfxStyleFamily; +enum class RSWND; struct WriteRcContext { @@ -146,6 +147,7 @@ class RscTypCont void SETCONST( RscConst *, Atom, sal_uInt32 ); inline void SETCONST( RscConst *p1, const char * p2, SymbolType p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } inline void SETCONST( RscConst *p1, Atom p2, ToolBoxItemBits p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } + inline void SETCONST( RscConst *p1, Atom p2, RSWND p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } inline void SETCONST( RscConst *p1, Atom p2, WindowBorderStyle p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } inline void SETCONST( RscConst *p1, const char * p2, KeyFuncType p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } inline void SETCONST( RscConst *p1, Atom p2, MenuItemBits p3 ) { SETCONST(p1, p2, static_cast<sal_uInt32>(p3)); } diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx index 2060798..4b48624 100644 --- a/rsc/source/parser/rscicpx.cxx +++ b/rsc/source/parser/rscicpx.cxx @@ -219,9 +219,9 @@ RscTop * RscTypCont::InitClassWindow( RscTop * pSuper, RscEnum * pMapUnit, // set the constants in table nDisableId = pHS->getID( "RSWND_DISABLE" ); - SETCONST( pFlag, nDisableId, RSWND_DISABLED ); + SETCONST( pFlag, nDisableId, RSWND::DISABLED ); nOutputSizeId = pHS->getID( "RSWND_OUTPUTSIZE" ); - SETCONST( pFlag, nOutputSizeId, RSWND_CLIENTSIZE ); + SETCONST( pFlag, nOutputSizeId, RSWND::CLIENTSIZE ); // add variable nVarId = aNmTb.Put( "_RscExtraFlags", VARNAME ); diff --git a/vcl/source/window/resource.cxx b/vcl/source/window/resource.cxx index 4550162..332d163 100644 --- a/vcl/source/window/resource.cxx +++ b/vcl/source/window/resource.cxx @@ -59,7 +59,7 @@ WindowResHeader Window::ImplLoadResHeader( const ResId& rResId ) aHeader.aHelpId = ImplAutoHelpID( rResId.GetResMgr() ); // ResourceStyle - aHeader.nRSStyle = ReadLongRes(); + aHeader.nRSStyle = (RSWND)ReadLongRes(); // WinBits ReadLongRes(); @@ -112,10 +112,10 @@ void Window::ImplLoadRes( const ResId& rResId ) aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap ); } - sal_uLong nRSStyle = aHeader.nRSStyle; + RSWND nRSStyle = aHeader.nRSStyle; // looks bad due to optimization - if ( nRSStyle & RSWND_CLIENTSIZE ) + if ( nRSStyle & RSWND::CLIENTSIZE ) { if ( bPos ) SetPosPixel( aPos ); @@ -129,7 +129,7 @@ void Window::ImplLoadRes( const ResId& rResId ) else if ( bSize ) SetSizePixel( aSize ); - if ( nRSStyle & RSWND_DISABLED ) + if ( nRSStyle & RSWND::DISABLED ) Enable( false ); if ( nObjMask & WINDOW_TEXT ) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
