[Libreoffice-commits] core.git: svx/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 13 13:18:20 UTC 2017


 svx/source/dialog/docrecovery.cxx |   14 +++++++-------
 svx/source/inc/docrecovery.hxx    |   32 ++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 21 deletions(-)

New commits:
commit ec7cc3e529740384735f7c396461cc16d419f874
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Feb 13 10:45:55 2017 +0200

    convert EDocStates to o3tl::typed_flags
    
    Change-Id: I56564932a96560f2113cdc98f389b6a7ede79cf5
    Reviewed-on: https://gerrit.libreoffice.org/34203
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index d03e228..b335863 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -338,7 +338,7 @@ void RecoveryCore::doRecovery()
 }
 
 
-ERecoveryState RecoveryCore::mapDocState2RecoverState(sal_Int32 eDocState)
+ERecoveryState RecoveryCore::mapDocState2RecoverState(EDocStates eDocState)
 {
     // ???
     ERecoveryState eRecState = E_NOT_RECOVERED_YET;
@@ -352,18 +352,18 @@ ERecoveryState RecoveryCore::mapDocState2RecoverState(sal_Int32 eDocState)
 
     // running ...
     if (
-        ((eDocState & E_TRY_LOAD_BACKUP  ) == E_TRY_LOAD_BACKUP  ) ||
-        ((eDocState & E_TRY_LOAD_ORIGINAL) == E_TRY_LOAD_ORIGINAL)
+        (eDocState & EDocStates::TryLoadBackup  ) ||
+        (eDocState & EDocStates::TryLoadOriginal)
        )
         eRecState = E_RECOVERY_IS_IN_PROGRESS;
     // red
-    else if ((eDocState & E_DAMAGED) == E_DAMAGED)
+    else if (eDocState & EDocStates::Damaged)
         eRecState = E_RECOVERY_FAILED;
     // yellow
-    else if ((eDocState & E_INCOMPLETE) == E_INCOMPLETE)
+    else if (eDocState & EDocStates::Incomplete)
         eRecState = E_ORIGINAL_DOCUMENT_RECOVERED;
     // green
-    else if ((eDocState & E_SUCCEDED) == E_SUCCEDED)
+    else if (eDocState & EDocStates::Succeeded)
         eRecState = E_SUCCESSFULLY_RECOVERED;
 
     return eRecState;
@@ -398,7 +398,7 @@ void SAL_CALL RecoveryCore::statusChanged(const css::frame::FeatureStateEvent& a
     TURLInfo                        aNew;
 
     aNew.ID          = lInfo.getUnpackedValueOrDefault(STATEPROP_ID         , (sal_Int32)0     );
-    aNew.DocState    = lInfo.getUnpackedValueOrDefault(STATEPROP_STATE      , (sal_Int32)0     );
+    aNew.DocState    = (EDocStates)lInfo.getUnpackedValueOrDefault(STATEPROP_STATE      , (sal_Int32)0     );
     aNew.OrgURL      = lInfo.getUnpackedValueOrDefault(STATEPROP_ORGURL     , OUString());
     aNew.TempURL     = lInfo.getUnpackedValueOrDefault(STATEPROP_TEMPURL    , OUString());
     aNew.FactoryURL  = lInfo.getUnpackedValueOrDefault(STATEPROP_FACTORYURL , OUString());
diff --git a/svx/source/inc/docrecovery.hxx b/svx/source/inc/docrecovery.hxx
index 50b76bc..1f3b3fa 100644
--- a/svx/source/inc/docrecovery.hxx
+++ b/svx/source/inc/docrecovery.hxx
@@ -30,6 +30,7 @@
 #include <svtools/svlbitm.hxx>
 #include <svtools/svmedit2.hxx>
 #include <svtools/treelistbox.hxx>
+#include <o3tl/typed_flags_set.hxx>
 
 #include <cppuhelper/implbase.hxx>
 #include <com/sun/star/task/StatusIndicatorFactory.hpp>
@@ -73,29 +74,32 @@
 #define DLG_RET_OK_AUTOLUNCH                            101
 
 
-namespace svx{
-    namespace DocRecovery{
-
-
-enum EDocStates
+enum class EDocStates
 {
     /* TEMP STATES */
 
     /// default state, if a document was new created or loaded
-    E_UNKNOWN = 0,
+    Unknown           = 0x000,
     /** an action was started (saving/loading) ... Can be interesting later if the process may be was interrupted by an exception. */
-    E_TRY_LOAD_BACKUP = 16,
-    E_TRY_LOAD_ORIGINAL = 32,
+    TryLoadBackup     = 0x010,
+    TryLoadOriginal   = 0x020,
 
     /* FINAL STATES */
 
     /// the Auto/Emergency saved document isn't useable any longer
-    E_DAMAGED = 64,
+    Damaged           = 0x040,
     /// the Auto/Emergency saved document is not really up-to-date (some changes can be missing)
-    E_INCOMPLETE = 128,
+    Incomplete        = 0x080,
     /// the Auto/Emergency saved document was processed successfully
-    E_SUCCEDED = 512
+    Succeeded         = 0x200
 };
+namespace o3tl {
+    template<> struct typed_flags<EDocStates> : is_typed_flags<EDocStates, 0x2f0> {};
+}
+
+
+namespace svx{
+    namespace DocRecovery{
 
 
 enum ERecoveryState
@@ -134,7 +138,7 @@ struct TURLInfo
     OUString Module;
 
     /// state info as e.g. VALID, CORRUPTED, NON EXISTING ...
-    sal_Int32 DocState;
+    EDocStates DocState;
 
     /// ui representation for DocState!
     ERecoveryState RecoveryState;
@@ -146,7 +150,7 @@ struct TURLInfo
 
     TURLInfo()
         : ID           (-1                 )
-        , DocState     (E_UNKNOWN          )
+        , DocState     (EDocStates::Unknown)
         , RecoveryState(E_NOT_RECOVERED_YET)
     {}
 };
@@ -256,7 +260,7 @@ class RecoveryCore : public ::cppu::WeakImplHelper< css::frame::XStatusListener
 
 
         /** @short  TODO */
-        static ERecoveryState mapDocState2RecoverState(sal_Int32 eDocState);
+        static ERecoveryState mapDocState2RecoverState(EDocStates eDocState);
 
 
     // uno interface


More information about the Libreoffice-commits mailing list