[Libreoffice-commits] core.git: include/tools include/vcl rsc/source vcl/source

Noel Grandin noelgrandin at gmail.com
Mon May 30 08:32:36 UTC 2016


 include/tools/rc.h             |   24 ++++++++++++++----------
 include/vcl/window.hxx         |    7 ++++---
 rsc/source/parser/rscicpx.cxx  |   20 +++++++++-----------
 vcl/source/window/resource.cxx |   31 +++++++++++++------------------
 4 files changed, 40 insertions(+), 42 deletions(-)

New commits:
commit a499d1b980be1eb2bd6ccfa07b1d87c02fcb1343
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sat May 28 14:56:29 2016 +0200

    Convert WINDOW flags to scoped enum
    
    Change-Id: I952fcc940cfe4daca5a810a406a2b8ecd3bd6f47
    Reviewed-on: https://gerrit.libreoffice.org/25582
    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 ff8ea13..eb531bf 100644
--- a/include/tools/rc.h
+++ b/include/tools/rc.h
@@ -38,16 +38,20 @@ namespace o3tl {
     template<> struct typed_flags<RSWND> : is_typed_flags<RSWND, 0x03> {};
 }
 
-#define WINDOW_XYMAPMODE                0x0001
-#define WINDOW_X                        0x0002
-#define WINDOW_Y                        0x0004
-#define WINDOW_WHMAPMODE                0x0008
-#define WINDOW_WIDTH                    0x0010
-#define WINDOW_HEIGHT                   0x0020
-#define WINDOW_TEXT                     0x0040
-#define WINDOW_HELPTEXT                 0x0080
-#define WINDOW_QUICKTEXT                0x0100
-#define WINDOW_HELPID                   0x0200
+enum class RscWindowFlags {
+    XYMapMode                = 0x0001,
+    X                        = 0x0002,
+    Y                        = 0x0004,
+    WHMapMode                = 0x0008,
+    Width                    = 0x0010,
+    Height                   = 0x0020,
+    Text                     = 0x0040,
+    QuickText                = 0x0100,
+    HelpId                   = 0x0200
+};
+namespace o3tl {
+    template<> struct typed_flags<RscWindowFlags> : is_typed_flags<RscWindowFlags, 0x07> {};
+}
 
 // For "FixedImage" resource:
 #define RSC_FIXEDIMAGE_IMAGE            0x0001
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index dea60a9..62e8c64 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -466,12 +466,13 @@ class LifecycleTest;
 
 namespace svt { class PopupWindowControllerImpl; }
 enum class RSWND;
+enum class RscWindowFlags;
 
 struct WindowResHeader
 {
-    sal_uLong nObjMask;
-    OString   aHelpId;
-    RSWND     nRSStyle;
+    RscWindowFlags nObjMask;
+    OString        aHelpId;
+    RSWND          nRSStyle;
 };
 
 enum class WindowHitTest {
diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx
index 73b58ca..a23761d 100644
--- a/rsc/source/parser/rscicpx.cxx
+++ b/rsc/source/parser/rscicpx.cxx
@@ -251,31 +251,29 @@ RscTop * RscTypCont::InitClassWindow( RscTop * pSuper, RscEnum * pMapUnit,
     InsWinBit( pClassWindow, "DialogControl", nTabControlId );
 
     nId = aNmTb.Put( "HelpID", VARNAME );
-    pClassWindow->SetVariable( nId, &aStringLiteral, nullptr, 0, WINDOW_HELPID );
+    pClassWindow->SetVariable( nId, &aStringLiteral, nullptr, 0, (sal_uInt32)RscWindowFlags::HelpId );
 
 
     nRsc_XYMAPMODEId = nId = aNmTb.Put( "_XYMapMode", VARNAME );
-    pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, WINDOW_XYMAPMODE  );
+    pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, (sal_uInt32)RscWindowFlags::XYMapMode  );
     nRsc_X = nId = aNmTb.Put( "_X", VARNAME );
-    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_X  );
+    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::X  );
     nRsc_Y = nId = aNmTb.Put( "_Y", VARNAME );
-    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_Y  );
+    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Y  );
 
     nRsc_WHMAPMODEId = nId = aNmTb.Put( "_WHMapMode", VARNAME );
-    pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, WINDOW_WHMAPMODE  );
+    pClassWindow->SetVariable( nId, pMapUnit, nullptr, 0, (sal_uInt32)RscWindowFlags::WHMapMode  );
     nRsc_WIDTH = nId = aNmTb.Put( "_Width", VARNAME );
-    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_WIDTH  );
+    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Width  );
     nRsc_HEIGHT = nId = aNmTb.Put( "_Height", VARNAME );
-    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, WINDOW_HEIGHT  );
+    pClassWindow->SetVariable( nId, &aLong, nullptr, 0, (sal_uInt32)RscWindowFlags::Height  );
 
     nRsc_DELTALANG = nId = aNmTb.Put( "DeltaLang", VARNAME );
     pClassWindow->SetVariable( nId, pLangGeo, nullptr, VAR_NORC | VAR_NOENUM);
     nId = aNmTb.Put( "Text", VARNAME );
-    pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_TEXT );
-    nId = aNmTb.Put( "HelpText", VARNAME );
-    pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_HELPTEXT );
+    pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscWindowFlags::Text );
     nId = aNmTb.Put( "QuickHelpText", VARNAME );
-    pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, WINDOW_QUICKTEXT );
+    pClassWindow->SetVariable( nId, &aLangString, nullptr, 0, (sal_uInt32)RscWindowFlags::QuickText );
 
     return pClassWindow;
 }
diff --git a/vcl/source/window/resource.cxx b/vcl/source/window/resource.cxx
index 5f627e8..12536be 100644
--- a/vcl/source/window/resource.cxx
+++ b/vcl/source/window/resource.cxx
@@ -50,7 +50,7 @@ WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
 {
     WindowResHeader aHeader;
 
-    aHeader.nObjMask = ReadLongRes();
+    aHeader.nObjMask = (RscWindowFlags)ReadLongRes();
 
     // we need to calculate auto helpids before the resource gets closed
     // if the resource  only contains flags, it will be closed before we try to read a help id
@@ -63,7 +63,7 @@ WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
     // WinBits
     ReadLongRes();
 
-    if( aHeader.nObjMask & WINDOW_HELPID )
+    if( aHeader.nObjMask & RscWindowFlags::HelpId )
         aHeader.aHelpId = ReadByteStringRes();
 
     return aHeader;
@@ -75,40 +75,40 @@ void Window::ImplLoadRes( const ResId& rResId )
 
     SetHelpId( aHeader.aHelpId );
 
-    sal_uLong nObjMask = aHeader.nObjMask;
+    RscWindowFlags nObjMask = aHeader.nObjMask;
 
     bool  bPos  = false;
     bool  bSize = false;
     Point aPos;
     Size  aSize;
 
-    if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
+    if ( nObjMask & (RscWindowFlags::XYMapMode | RscWindowFlags::X | RscWindowFlags::Y) )
     {
         // use size as per resource
         MapUnit ePosMap = MAP_PIXEL;
 
         bPos = true;
 
-        if ( nObjMask & WINDOW_XYMAPMODE )
+        if ( nObjMask & RscWindowFlags::XYMapMode )
             ePosMap = (MapUnit)ReadLongRes();
-        if ( nObjMask & WINDOW_X )
+        if ( nObjMask & RscWindowFlags::X )
             aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
-        if ( nObjMask & WINDOW_Y )
+        if ( nObjMask & RscWindowFlags::Y )
             aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
     }
 
-    if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
+    if ( nObjMask & (RscWindowFlags::WHMapMode | RscWindowFlags::Width | RscWindowFlags::Height) )
     {
         // use size as per resource
         MapUnit eSizeMap = MAP_PIXEL;
 
         bSize = true;
 
-        if ( nObjMask & WINDOW_WHMAPMODE )
+        if ( nObjMask & RscWindowFlags::WHMapMode )
             eSizeMap = (MapUnit)ReadLongRes();
-        if ( nObjMask & WINDOW_WIDTH )
+        if ( nObjMask & RscWindowFlags::Width )
             aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
-        if ( nObjMask & WINDOW_HEIGHT )
+        if ( nObjMask & RscWindowFlags::Height )
             aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
     }
 
@@ -132,14 +132,9 @@ void Window::ImplLoadRes( const ResId& rResId )
     if ( nRSStyle & RSWND::DISABLED )
         Enable( false );
 
-    if ( nObjMask & WINDOW_TEXT )
+    if ( nObjMask & RscWindowFlags::Text )
         SetText( ReadStringRes() );
-    if ( nObjMask & WINDOW_HELPTEXT )
-    {
-        SetHelpText( ReadStringRes() );
-        mpWindowImpl->mbHelpTextDynamic = true;
-    }
-    if ( nObjMask & WINDOW_QUICKTEXT )
+    if ( nObjMask & RscWindowFlags::QuickText )
         SetQuickHelpText( ReadStringRes() );
 }
 


More information about the Libreoffice-commits mailing list