[Libreoffice-commits] core.git: include/tools rsc/inc rsc/source vcl/source
Noel Grandin
noelgrandin at gmail.com
Tue May 31 06:40:25 UTC 2016
include/tools/rc.h | 26 ++++++++++++++------------
rsc/inc/rscdb.hxx | 4 +---
rsc/source/parser/rscicpx.cxx | 34 ++++++++++------------------------
rsc/source/parser/rscinit.cxx | 3 +--
vcl/source/window/toolbox2.cxx | 33 +++++++++++----------------------
5 files changed, 37 insertions(+), 63 deletions(-)
New commits:
commit 59dbfecedb76ecf2ff8d464c144a0adf85eb3766
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Mon May 30 20:15:05 2016 +0200
Convert RSC_TOOLBOXITEM to scoped enum
Change-Id: Ic90b6950016417d5f57963ab69fd20905a943bb7
Reviewed-on: https://gerrit.libreoffice.org/25683
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/include/tools/rc.h b/include/tools/rc.h
index 90e593a..4566203 100644
--- a/include/tools/rc.h
+++ b/include/tools/rc.h
@@ -118,18 +118,20 @@ namespace o3tl {
}
// For "ToolBoxItem" resources:
-#define RSC_TOOLBOXITEM_ID 0x0001
-#define RSC_TOOLBOXITEM_TYPE 0x0002
-#define RSC_TOOLBOXITEM_STATUS 0x0004
-#define RSC_TOOLBOXITEM_HELPID 0x0008
-#define RSC_TOOLBOXITEM_TEXT 0x0010
-#define RSC_TOOLBOXITEM_HELPTEXT 0x0020
-#define RSC_TOOLBOXITEM_BITMAP 0x0040
-#define RSC_TOOLBOXITEM_IMAGE 0x0080
-#define RSC_TOOLBOXITEM_DISABLE 0x0100
-#define RSC_TOOLBOXITEM_STATE 0x0200
-#define RSC_TOOLBOXITEM_HIDE 0x0400
-#define RSC_TOOLBOXITEM_COMMAND 0x0800
+enum class RscToolboxItemFlags {
+ Id = 0x0001,
+ Type = 0x0002,
+ Status = 0x0004,
+ HelpId = 0x0008,
+ Text = 0x0010,
+ Bitmap = 0x0040,
+ Disable = 0x0100,
+ Hide = 0x0400,
+ Command = 0x0800
+};
+namespace o3tl {
+ template<> struct typed_flags<RscToolboxItemFlags> : is_typed_flags<RscToolboxItemFlags, 0xd5f> {};
+}
// For "ToolBox" resources:
enum class RscToolboxFlags {
diff --git a/rsc/inc/rscdb.hxx b/rsc/inc/rscdb.hxx
index 58a1b56..99f7501 100644
--- a/rsc/inc/rscdb.hxx
+++ b/rsc/inc/rscdb.hxx
@@ -206,9 +206,7 @@ class RscTypCont
RscTop * InitClassDockingWindow( RscTop * pSuper,
RscEnum * pMapUnit );
- RscTop * InitClassToolBoxItem( RscTop * pSuper, RscTop * pClassBitmap,
- RscTop * pClassImage,
- RscEnum * pTriState );
+ RscTop * InitClassToolBoxItem( RscTop * pSuper, RscTop * pClassBitmap );
RscTop * InitClassToolBox( RscTop * pSuper, RscTop * pClassToolBoxItem );
RscTop * InitClassSfxStyleFamilyItem( RscTop * pSuper,
RscTop * pClassBitmap,
diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx
index a23761d..7182b34 100644
--- a/rsc/source/parser/rscicpx.cxx
+++ b/rsc/source/parser/rscicpx.cxx
@@ -933,9 +933,7 @@ RscTop * RscTypCont::InitClassDockingWindow( RscTop * pSuper,
}
RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
- RscTop * pClassBitmap,
- RscTop * pClassImage,
- RscEnum * pTriState )
+ RscTop * pClassBitmap )
{
Atom nId;
RscTop * pClassToolBoxItem;
@@ -948,7 +946,7 @@ RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
// initialize variables
nId = aNmTb.Put( "Identifier", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aIdNoZeroUShort, nullptr, 0,
- RSC_TOOLBOXITEM_ID );
+ (sal_uInt32)RscToolboxItemFlags::Id );
{
RscEnum * pEnum;
@@ -961,7 +959,7 @@ RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
// add variable
nId = aNmTb.Put( "Type", VARNAME );
pClassToolBoxItem->SetVariable( nId, pEnum, nullptr, 0,
- RSC_TOOLBOXITEM_TYPE );
+ (sal_uInt32)RscToolboxItemFlags::Type );
}
{
RscFlag * pFlag;
@@ -988,7 +986,7 @@ RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
l_nVarId = aNmTb.Put( "_ToolBoxItemFlags", VARNAME );
pClassToolBoxItem->SetVariable( l_nVarId, pFlag, nullptr,
VAR_HIDDEN | VAR_NOENUM,
- RSC_TOOLBOXITEM_STATUS );
+ (sal_uInt32)RscToolboxItemFlags::Status );
// add client variables
aBaseLst.push_back(
@@ -1029,35 +1027,23 @@ RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper,
}
nId = aNmTb.Put( "HelpID", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aStringLiteral, nullptr, 0,
- RSC_TOOLBOXITEM_HELPID );
+ (sal_uInt32)RscToolboxItemFlags::HelpId );
nId = aNmTb.Put( "Text", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aLangString, nullptr, 0,
- RSC_TOOLBOXITEM_TEXT );
- nId = aNmTb.Put( "HelpText", VARNAME );
- pClassToolBoxItem->SetVariable( nId, &aLangString, nullptr, 0,
- RSC_TOOLBOXITEM_HELPTEXT );
+ (sal_uInt32)RscToolboxItemFlags::Text );
nId = aNmTb.Put( "ItemBitmap", VARNAME );
pClassToolBoxItem->SetVariable( nId, pClassBitmap, nullptr, 0,
- RSC_TOOLBOXITEM_BITMAP );
- nId = aNmTb.Put( "ItemImage", VARNAME );
- pClassToolBoxItem->SetVariable( nId, pClassImage, nullptr, 0,
- RSC_TOOLBOXITEM_IMAGE );
+ (sal_uInt32)RscToolboxItemFlags::Bitmap );
nId = aNmTb.Put( "Disable", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aBool, nullptr, 0,
- RSC_TOOLBOXITEM_DISABLE );
+ (sal_uInt32)RscToolboxItemFlags::Disable );
- nId = aNmTb.Put( "State", VARNAME );
- pClassToolBoxItem->SetVariable( nId, pTriState, nullptr, 0,
- RSC_TOOLBOXITEM_STATE );
- nId = aNmTb.Put( "Hide", VARNAME );
- pClassToolBoxItem->SetVariable( nId, &aBool, nullptr, 0,
- RSC_TOOLBOXITEM_HIDE );
nId = aNmTb.Put( "Hide", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aBool, nullptr, 0,
- RSC_TOOLBOXITEM_HIDE );
+ (sal_uInt32)RscToolboxItemFlags::Hide );
nId = aNmTb.Put( "Command", VARNAME );
pClassToolBoxItem->SetVariable( nId, &aString, nullptr, 0,
- RSC_TOOLBOXITEM_COMMAND );
+ (sal_uInt32)RscToolboxItemFlags::Command );
return pClassToolBoxItem;
}
diff --git a/rsc/source/parser/rscinit.cxx b/rsc/source/parser/rscinit.cxx
index c24e757..9860c4b 100644
--- a/rsc/source/parser/rscinit.cxx
+++ b/rsc/source/parser/rscinit.cxx
@@ -413,8 +413,7 @@ void RscTypCont::Init()
RscTop* pClassDockingWindow = InitClassDockingWindow( pClassWindow, pMapUnit );
pRoot->Insert( pClassDockingWindow );
- RscTop* pClassToolBoxItem = InitClassToolBoxItem( pClassMgr, pClassBitmap,
- pClassImage, pTriState );
+ RscTop* pClassToolBoxItem = InitClassToolBoxItem( pClassMgr, pClassBitmap );
pRoot->Insert( pClassToolBoxItem );
RscTop* pClassToolBox = InitClassToolBox( pClassDockingWindow, pClassToolBoxItem );
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 0bbd7c4..c1de5eb 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -442,38 +442,36 @@ void ToolBox::Select()
void ToolBox::InsertItem( const ResId& rResId )
{
- sal_uLong nObjMask;
+ RscToolboxItemFlags nObjMask;
bool bImage = false; // has image
// create item
ImplToolItem aItem;
GetRes( rResId.SetRT( RSC_TOOLBOXITEM ) );
- nObjMask = ReadLongRes();
+ nObjMask = (RscToolboxItemFlags)ReadLongRes();
- if ( nObjMask & RSC_TOOLBOXITEM_ID )
+ if ( nObjMask & RscToolboxItemFlags::Id )
aItem.mnId = sal::static_int_cast<sal_uInt16>(ReadLongRes());
else
aItem.mnId = 1;
- if ( nObjMask & RSC_TOOLBOXITEM_TYPE )
+ if ( nObjMask & RscToolboxItemFlags::Type )
aItem.meType = (ToolBoxItemType)ReadLongRes();
- if ( nObjMask & RSC_TOOLBOXITEM_STATUS )
+ if ( nObjMask & RscToolboxItemFlags::Status )
aItem.mnBits = (ToolBoxItemBits)ReadLongRes();
- if( nObjMask & RSC_TOOLBOXITEM_HELPID )
+ if( nObjMask & RscToolboxItemFlags::HelpId )
aItem.maHelpId = ReadByteStringRes();
- if ( nObjMask & RSC_TOOLBOXITEM_TEXT )
+ if ( nObjMask & RscToolboxItemFlags::Text )
{
aItem.maText = ReadStringRes();
aItem.maText = MnemonicGenerator::EraseAllMnemonicChars(aItem.maText);
}
- if ( nObjMask & RSC_TOOLBOXITEM_HELPTEXT )
- aItem.maHelpText = ReadStringRes();
- if ( nObjMask & RSC_TOOLBOXITEM_BITMAP )
+ if ( nObjMask & RscToolboxItemFlags::Bitmap )
{
Bitmap aBmp = Bitmap( ResId( static_cast<RSHEADER_TYPE*>(GetClassRes()), *rResId.GetResMgr() ) );
IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE*>(GetClassRes()) ) );
@@ -481,22 +479,13 @@ void ToolBox::InsertItem( const ResId& rResId )
aItem.maImageOriginal = aItem.maImage;
bImage = true;
}
- if ( nObjMask & RSC_TOOLBOXITEM_IMAGE )
- {
- aItem.maImage = Image( ResId( static_cast<RSHEADER_TYPE*>(GetClassRes()), *rResId.GetResMgr() ) );
- IncrementRes( GetObjSizeRes( static_cast<RSHEADER_TYPE*>(GetClassRes()) ) );
- bImage = true;
- }
- if ( nObjMask & RSC_TOOLBOXITEM_DISABLE )
+ if ( nObjMask & RscToolboxItemFlags::Disable )
aItem.mbEnabled = ReadShortRes() == 0;
- if ( nObjMask & RSC_TOOLBOXITEM_STATE )
- aItem.meState = (TriState)ReadLongRes();
-
- if ( nObjMask & RSC_TOOLBOXITEM_HIDE )
+ if ( nObjMask & RscToolboxItemFlags::Hide )
aItem.mbVisible = ReadShortRes() == 0;
- if ( nObjMask & RSC_TOOLBOXITEM_COMMAND )
+ if ( nObjMask & RscToolboxItemFlags::Command )
aItem.maCommandStr = ReadStringRes();
// if no image is loaded, try to load one from the image list
More information about the Libreoffice-commits
mailing list