[Libreoffice-commits] core.git: 3 commits - include/store registry/source store/source sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Mon Sep 19 10:48:46 UTC 2016


 include/store/store.h              |    6 +++---
 include/store/types.h              |   14 +++++++-------
 registry/source/keyimpl.cxx        |   32 ++++++++++++++++----------------
 registry/source/regimpl.cxx        |   30 +++++++++++++++---------------
 store/source/lockbyte.cxx          |   12 ++++++------
 store/source/storbios.cxx          |   12 ++++++------
 store/source/stordir.cxx           |    2 +-
 store/source/store.cxx             |    2 +-
 store/source/storlckb.cxx          |   10 +++++-----
 store/source/storpage.cxx          |    6 +++---
 sw/inc/ndhints.hxx                 |    7 ++-----
 sw/source/core/inc/UndoManager.hxx |    4 ++--
 sw/source/core/txtnode/ndtxt.cxx   |    2 +-
 sw/source/core/txtnode/thints.cxx  |    8 ++++----
 sw/source/core/undo/docundo.cxx    |    8 ++++----
 15 files changed, 76 insertions(+), 79 deletions(-)

New commits:
commit e58324aaca6875dbfe7c6c8333d747d2bfd9d089
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Sep 19 10:50:47 2016 +0200

    convert storeAccessMode to scoped enum
    
    Change-Id: I67705cdff0440487019a2992571147d648be1bfc

diff --git a/include/store/store.h b/include/store/store.h
index 61dc1e17..bd6027b 100644
--- a/include/store/store.h
+++ b/include/store/store.h
@@ -74,10 +74,10 @@ STORE_DLLPUBLIC storeError SAL_CALL store_createMemoryFile (
 /** Open a file.
     @param  pFilename [in] the filename as URL or system path.
     @param  eAccessMode [in] the access mode.
-            store_AccessCreate     truncate existing and create,
+            storeAccessMode::Create     truncate existing and create,
             store_AccessReadCreate create not existing,
-            store_AccessReadWrite  write existing,
-            store_AccessReadOnly   never modifies.
+            storeAccessMode::ReadWrite  write existing,
+            storeAccessMode::ReadOnly   never modifies.
     @param  nPageSize [in] the creation page size,
             integer multiple of minimum page size.
     @param  phFile [out] the File Handle.
diff --git a/include/store/types.h b/include/store/types.h
index 1b1724e..fe8c1e0 100644
--- a/include/store/types.h
+++ b/include/store/types.h
@@ -59,14 +59,14 @@ extern "C" {
     @see store_openDirectory()
     @see store_openStream()
  */
-typedef enum
+enum class storeAccessMode
 {
-    store_AccessCreate,
-    store_AccessReadCreate,
-    store_AccessReadWrite,
-    store_AccessReadOnly,
-    store_Access_FORCE_EQUAL_SIZE = SAL_MAX_ENUM
-} storeAccessMode;
+    Create,
+    ReadCreate,
+    ReadWrite,
+    ReadOnly,
+    FORCE_EQUAL_SIZE = SAL_MAX_ENUM
+};
 
 
 /** Error Code enumeration.
diff --git a/registry/source/keyimpl.cxx b/registry/source/keyimpl.cxx
index 9fa3dab..2aeb310 100644
--- a/registry/source/keyimpl.cxx
+++ b/registry/source/keyimpl.cxx
@@ -219,11 +219,11 @@ RegError ORegKey::getValueInfo(const OUString& valueName, RegValueType* pValueTy
 {
     OStoreStream    rValue;
     sal_uInt8*      pBuffer;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     OUString sImplValueName( VALUE_PREFIX );
@@ -301,7 +301,7 @@ RegError ORegKey::setValue(const OUString& valueName, RegValueType vType, RegVal
 
     REG_GUARD(m_pRegistry->m_mutex);
 
-    if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT , sImplValueName, store_AccessCreate) )
+    if ( rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT , sImplValueName, storeAccessMode::Create) )
     {
         return RegError::SET_VALUE_FAILED;
     }
@@ -371,7 +371,7 @@ RegError ORegKey::setLongListValue(const OUString& valueName, sal_Int32* pValueL
 
     REG_GUARD(m_pRegistry->m_mutex);
 
-    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, store_AccessCreate) )
+    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, storeAccessMode::Create) )
     {
         return RegError::SET_VALUE_FAILED;
     }
@@ -430,7 +430,7 @@ RegError ORegKey::setStringListValue(const OUString& valueName, sal_Char** pValu
 
     REG_GUARD(m_pRegistry->m_mutex);
 
-    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, store_AccessCreate) )
+    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, storeAccessMode::Create) )
     {
         return RegError::SET_VALUE_FAILED;
     }
@@ -498,7 +498,7 @@ RegError ORegKey::setUnicodeListValue(const OUString& valueName, sal_Unicode** p
 
     REG_GUARD(m_pRegistry->m_mutex);
 
-    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, store_AccessCreate) )
+    if (rValue.create(getStoreFile(), m_name + m_pRegistry->ROOT, sImplValueName, storeAccessMode::Create) )
     {
         return RegError::SET_VALUE_FAILED;
     }
@@ -557,11 +557,11 @@ RegError ORegKey::getValue(const OUString& valueName, RegValue value) const
     sal_uInt8*      pBuffer;
     RegValueType    valueType;
     sal_uInt32      valueSize;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     OUString sImplValueName( VALUE_PREFIX );
@@ -651,11 +651,11 @@ RegError ORegKey::getLongListValue(const OUString& valueName, sal_Int32** pValue
     sal_uInt8*      pBuffer;
     RegValueType    valueType;
     sal_uInt32      valueSize;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     OUString sImplValueName( VALUE_PREFIX );
@@ -765,11 +765,11 @@ RegError ORegKey::getStringListValue(const OUString& valueName, sal_Char*** pVal
     sal_uInt8*      pBuffer;
     RegValueType    valueType;
     sal_uInt32      valueSize;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     OUString sImplValueName( VALUE_PREFIX );
@@ -871,11 +871,11 @@ RegError ORegKey::getUnicodeListValue(const OUString& valueName, sal_Unicode***
     sal_uInt8*      pBuffer;
     RegValueType    valueType;
     sal_uInt32      valueSize;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     OUString sImplValueName( VALUE_PREFIX );
@@ -1009,7 +1009,7 @@ OStoreDirectory ORegKey::getStoreDir()
     OStoreDirectory rStoreDir;
     OUString        fullPath;
     OUString        relativName;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if ( m_name.equals(m_pRegistry->ROOT) )
     {
@@ -1023,7 +1023,7 @@ OStoreDirectory ORegKey::getStoreDir()
 
     if (m_pRegistry->isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     rStoreDir.create(getStoreFile(), fullPath, relativName, accessMode);
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 75e64bc..0655a46 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -455,21 +455,21 @@ RegError ORegistry::initRegistry(const OUString& regName, RegAccessMode accessMo
 {
     RegError eRet = RegError::INVALID_REGISTRY;
     OStoreFile      rRegFile;
-    storeAccessMode sAccessMode = store_AccessReadWrite;
+    storeAccessMode sAccessMode = storeAccessMode::ReadWrite;
     storeError      errCode;
 
     if (bCreate)
     {
-        sAccessMode = store_AccessCreate;
+        sAccessMode = storeAccessMode::Create;
     }
     else if (accessMode & RegAccessMode::READONLY)
     {
-        sAccessMode = store_AccessReadOnly;
+        sAccessMode = storeAccessMode::ReadOnly;
         m_readOnly = true;
     }
 
     if (regName.isEmpty() &&
-        store_AccessCreate == sAccessMode)
+        storeAccessMode::Create == sAccessMode)
     {
         errCode = rRegFile.createInMemory();
     }
@@ -670,7 +670,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName,
         token = sFullKeyName.getToken( 0, '/', nIndex );
         if (!token.isEmpty())
         {
-            if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), token, store_AccessCreate))
+            if (rStoreDir.create(pKey->getStoreFile(), sFullPath.getStr(), token, storeAccessMode::Create))
             {
                 return RegError::CREATE_KEY_FAILED;
             }
@@ -716,7 +716,7 @@ RegError ORegistry::openKey(RegKeyHandle hKey, const OUString& keyName,
         sal_Int32 n = path.lastIndexOf('/') + 1;
         switch (OStoreDirectory().create(
                     pKey->getStoreFile(), path.copy(0, n), path.copy(n),
-                    isReadOnly() ? store_AccessReadOnly : store_AccessReadWrite))
+                    isReadOnly() ? storeAccessMode::ReadOnly : storeAccessMode::ReadWrite))
         {
         case store_E_NotExists:
             return RegError::KEY_NOT_EXISTS;
@@ -953,13 +953,13 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
     RegValueType    valueType;
     sal_uInt32      valueSize;
     sal_uInt32      nSize;
-    storeAccessMode sourceAccess = store_AccessReadWrite;
+    storeAccessMode sourceAccess = storeAccessMode::ReadWrite;
     OUString        sTargetPath(pTargetKey->getName());
     OUString        sSourcePath(pSourceKey->getName());
 
     if (pSourceKey->isReadOnly())
     {
-        sourceAccess = store_AccessReadOnly;
+        sourceAccess = storeAccessMode::ReadOnly;
     }
 
     if (nCut)
@@ -1019,7 +1019,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
 
     OStoreFile  rTargetFile(pTargetKey->getStoreFile());
 
-    if (!rValue.create(rTargetFile, sTargetPath, valueName, store_AccessReadWrite))
+    if (!rValue.create(rTargetFile, sTargetPath, valueName, storeAccessMode::ReadWrite))
     {
         if (valueType == RegValueType::BINARY)
         {
@@ -1043,7 +1043,7 @@ RegError ORegistry::loadAndSaveValue(ORegKey* pTargetKey,
     }
 
     // write
-    if (rValue.create(rTargetFile, sTargetPath, valueName, store_AccessCreate))
+    if (rValue.create(rTargetFile, sTargetPath, valueName, storeAccessMode::Create))
     {
         rtl_freeMemory(pBuffer);
         return RegError::INVALID_VALUE;
@@ -1292,7 +1292,7 @@ RegError ORegistry::loadAndSaveKeys(ORegKey* pTargetKey,
     sFullKeyName += keyName;
 
     OStoreDirectory rStoreDir;
-    if (rStoreDir.create(pTargetKey->getStoreFile(), sFullPath, keyName, store_AccessCreate))
+    if (rStoreDir.create(pTargetKey->getStoreFile(), sFullPath, keyName, storeAccessMode::Create))
     {
         return RegError::CREATE_KEY_FAILED;
     }
@@ -1396,11 +1396,11 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
     RegValueType    valueType;
     OUString        sFullPath(sPath);
     OString         sIndent;
-    storeAccessMode accessMode = store_AccessReadWrite;
+    storeAccessMode accessMode = storeAccessMode::ReadWrite;
 
     if (isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     for (int i= 0; i < nSpc; i++) sIndent += " ";
@@ -1631,12 +1631,12 @@ RegError ORegistry::dumpKey(const OUString& sPath, const OUString& sName, sal_In
     OStoreDirectory     rStoreDir;
     OUString            sFullPath(sPath);
     OString             sIndent;
-    storeAccessMode     accessMode = store_AccessReadWrite;
+    storeAccessMode     accessMode = storeAccessMode::ReadWrite;
     RegError            _ret = RegError::NO_ERROR;
 
     if (isReadOnly())
     {
-        accessMode = store_AccessReadOnly;
+        accessMode = storeAccessMode::ReadOnly;
     }
 
     for (int i= 0; i < nSpace; i++) sIndent += " ";
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index 1251de2..73ad47f 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -197,14 +197,14 @@ struct FileHandle
         sal_uInt32 nFlags = 0;
         switch (eAccessMode)
         {
-        case store_AccessCreate:
-        case store_AccessReadCreate:
+        case storeAccessMode::Create:
+        case storeAccessMode::ReadCreate:
             nFlags |= osl_File_OpenFlag_Create;
             SAL_FALLTHROUGH;
-        case store_AccessReadWrite:
+        case storeAccessMode::ReadWrite:
             nFlags |= osl_File_OpenFlag_Write;
             SAL_FALLTHROUGH;
-        case store_AccessReadOnly:
+        case storeAccessMode::ReadOnly:
             nFlags |= osl_File_OpenFlag_Read;
             break;
         default:
@@ -243,7 +243,7 @@ struct FileHandle
         {
             // Already existing (O_CREAT | O_EXCL).
             result = osl_openFile (aFileUrl.pData, &m_handle, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
-            if ((result == osl_File_E_None) && (eAccessMode == store_AccessCreate))
+            if ((result == osl_File_E_None) && (eAccessMode == storeAccessMode::Create))
             {
                 // Truncate existing file.
                 result = osl_setFileSize (m_handle, 0);
@@ -853,7 +853,7 @@ FileLockBytes_createInstance (
     if (result != store_E_None)
         return result;
 
-    if (eAccessMode == store_AccessReadOnly)
+    if (eAccessMode == storeAccessMode::ReadOnly)
     {
         ResourceHolder<FileMapping> xMapping;
         if (xMapping.get().initialize (xFile.get().m_handle) == osl_File_E_None)
diff --git a/store/source/storbios.cxx b/store/source/storbios.cxx
index ae6c0ae..00648ce 100644
--- a/store/source/storbios.cxx
+++ b/store/source/storbios.cxx
@@ -584,11 +584,11 @@ storeError OStorePageBIOS::initialize_Impl (
     m_xLockBytes = pLockBytes;
     if (!m_xLockBytes.is())
         return store_E_InvalidParameter;
-    m_bWriteable = (eAccessMode != store_AccessReadOnly);
+    m_bWriteable = (eAccessMode != storeAccessMode::ReadOnly);
 
     // Check access mode.
     storeError eErrCode = store_E_None;
-    if (eAccessMode != store_AccessCreate)
+    if (eAccessMode != storeAccessMode::Create)
     {
         // Load SuperBlock page.
         if ((m_pSuper = new SuperBlockPage()) == nullptr)
@@ -619,9 +619,9 @@ storeError OStorePageBIOS::initialize_Impl (
             return eErrCode;
 
         // Check mode.
-        if (eAccessMode == store_AccessReadOnly)
+        if (eAccessMode == storeAccessMode::ReadOnly)
             return store_E_NotExists;
-        if (eAccessMode == store_AccessReadWrite)
+        if (eAccessMode == storeAccessMode::ReadWrite)
             return store_E_NotExists;
 
         // Check PageSize.
@@ -730,7 +730,7 @@ storeError OStorePageBIOS::acquirePage (
         return store_E_InvalidAccess;
 
     // Check access mode.
-    if (!(m_bWriteable || (eMode == store_AccessReadOnly)))
+    if (!(m_bWriteable || (eMode == storeAccessMode::ReadOnly)))
         return store_E_AccessViolation;
 
     // Find access control list entry.
@@ -738,7 +738,7 @@ storeError OStorePageBIOS::acquirePage (
     if (ace->m_addr == rDescr.m_nAddr)
     {
       // Acquire existing entry (with ShareDenyWrite).
-      if (eMode == store_AccessReadOnly)
+      if (eMode == storeAccessMode::ReadOnly)
         ace->m_used += 1;
       else
         return store_E_AccessViolation;
diff --git a/store/source/stordir.cxx b/store/source/stordir.cxx
index aa34f91..399af1d 100644
--- a/store/source/stordir.cxx
+++ b/store/source/stordir.cxx
@@ -123,7 +123,7 @@ storeError OStoreDirectory_Impl::create (
         return store_E_NotDirectory;
 
     inode_holder_type xNode (aPage.get());
-    eErrCode = xManager->acquirePage (xNode->m_aDescr, store_AccessReadOnly);
+    eErrCode = xManager->acquirePage (xNode->m_aDescr, storeAccessMode::ReadOnly);
     if (eErrCode != store_E_None)
         return eErrCode;
 
diff --git a/store/source/store.cxx b/store/source/store.cxx
index bdb2468..7c06aee 100644
--- a/store/source/store.cxx
+++ b/store/source/store.cxx
@@ -120,7 +120,7 @@ storeError SAL_CALL store_createMemoryFile (
         return store_E_OutOfMemory;
 
     eErrCode = xManager->initialize (
-        &*xLockBytes, store_AccessCreate, nPageSize);
+        &*xLockBytes, storeAccessMode::Create, nPageSize);
     if (eErrCode != store_E_None)
         return eErrCode;
 
diff --git a/store/source/storlckb.cxx b/store/source/storlckb.cxx
index 0e74ab9..eacfc8b 100644
--- a/store/source/storlckb.cxx
+++ b/store/source/storlckb.cxx
@@ -101,19 +101,19 @@ storeError OStoreLockBytes::create (
     }
 
     inode_holder_type xNode (aPage.get());
-    if (eMode != store_AccessReadOnly)
-        eErrCode = xManager->acquirePage (xNode->m_aDescr, store_AccessReadWrite);
+    if (eMode != storeAccessMode::ReadOnly)
+        eErrCode = xManager->acquirePage (xNode->m_aDescr, storeAccessMode::ReadWrite);
     else
-        eErrCode = xManager->acquirePage (xNode->m_aDescr, store_AccessReadOnly);
+        eErrCode = xManager->acquirePage (xNode->m_aDescr, storeAccessMode::ReadOnly);
     if (eErrCode != store_E_None)
         return eErrCode;
 
     m_xManager   = xManager;
     m_xNode      = xNode;
-    m_bWriteable = (eMode != store_AccessReadOnly);
+    m_bWriteable = (eMode != storeAccessMode::ReadOnly);
 
     // Check for truncation.
-    if (eMode == store_AccessCreate)
+    if (eMode == storeAccessMode::Create)
     {
         // Truncate to zero length.
         eErrCode = setSize(0);
diff --git a/store/source/storpage.cxx b/store/source/storpage.cxx
index 0f559b4..3d10ec0 100644
--- a/store/source/storpage.cxx
+++ b/store/source/storpage.cxx
@@ -280,9 +280,9 @@ storeError OStorePageManager::iget (
         if (eErrCode != store_E_NotExists)
             return eErrCode;
 
-        if (eMode == store_AccessReadWrite)
+        if (eMode == storeAccessMode::ReadWrite)
             return store_E_NotExists;
-        if (eMode == store_AccessReadOnly)
+        if (eMode == storeAccessMode::ReadOnly)
             return store_E_NotExists;
 
         if (!base::isWriteable())
@@ -477,7 +477,7 @@ storeError OStorePageManager::remove (const OStorePageKey &rKey)
 
         // Acquire page write access.
         OStorePageDescriptor aDescr (xNode->m_aDescr);
-        eErrCode = base::acquirePage (aDescr, store_AccessReadWrite);
+        eErrCode = base::acquirePage (aDescr, storeAccessMode::ReadWrite);
         if (eErrCode != store_E_None)
             return eErrCode;
 
commit 99e95346ac33f2d04536ab6c268936ab8b822b42
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Sep 19 10:37:35 2016 +0200

    convert CopyOrNewType to scoped enum
    
    Change-Id: I4bc01dfbf3305e7eaa0887444e894d14e9e4d092

diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx
index 5d5c57f..6643a6a 100644
--- a/sw/inc/ndhints.hxx
+++ b/sw/inc/ndhints.hxx
@@ -33,10 +33,7 @@ class SfxPoolItem;
 class SfxItemSet;
 class SwDoc;
 
-typedef enum {
-    COPY = int(true),
-    NEW  = int(false),
-} CopyOrNew_t;
+enum class CopyOrNewType { Copy, New };
 
 /// if COPY then pTextNode must be given!
 SwTextAttr * MakeTextAttr(
@@ -44,7 +41,7 @@ SwTextAttr * MakeTextAttr(
     SfxPoolItem & rNew,
     sal_Int32 const nStt,
     sal_Int32 const nEnd,
-    CopyOrNew_t const bIsCopy = NEW,
+    CopyOrNewType const bIsCopy = CopyOrNewType::New,
     SwTextNode *const pTextNode = nullptr );
 
 SwTextAttr * MakeTextAttr(
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index d01a006..19aec8d 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1839,7 +1839,7 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
         {
             // copy the hint here, but insert it later
             pNewHt = MakeTextAttr( *GetDoc(), pHt->GetAttr(),
-                    nAttrStt, nAttrEnd, COPY, pDest );
+                    nAttrStt, nAttrEnd, CopyOrNewType::Copy, pDest );
 
             lcl_CopyHint(nWhich, pHt, pNewHt, nullptr, pDest);
             aArr.push_back( pNewHt );
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 8afc3ba..d51b84d 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -985,7 +985,7 @@ SwTextAttr* MakeTextAttr(
     SfxPoolItem& rAttr,
     sal_Int32 const nStt,
     sal_Int32 const nEnd,
-    CopyOrNew_t const bIsCopy,
+    CopyOrNewType const bIsCopy,
     SwTextNode *const pTextNode )
 {
     if ( isCHRATR(rAttr.Which()) )
@@ -1042,7 +1042,7 @@ SwTextAttr* MakeTextAttr(
     case RES_TXTATR_ANNOTATION:
         {
             pNew = new SwTextAnnotationField( static_cast<SwFormatField &>(rNew), nStt, rDoc.IsClipBoard() );
-            if (bIsCopy == COPY)
+            if (bIsCopy == CopyOrNewType::Copy)
             {
                 // On copy of the annotation field do not keep the annotated text range by removing
                 // the relation to its annotation mark (relation established via annotation field's name).
@@ -1090,7 +1090,7 @@ SwTextAttr* MakeTextAttr(
     case RES_TXTATR_META:
     case RES_TXTATR_METAFIELD:
         pNew = SwTextMeta::CreateTextMeta( rDoc.GetMetaFieldManager(), pTextNode,
-                static_cast<SwFormatMeta&>(rNew), nStt, nEnd, bIsCopy == COPY );
+                static_cast<SwFormatMeta&>(rNew), nStt, nEnd, bIsCopy == CopyOrNewType::Copy );
         break;
     default:
         assert(RES_TXTATR_AUTOFMT == rNew.Which());
@@ -1223,7 +1223,7 @@ SwTextAttr* SwTextNode::InsertItem(
             rAttr,
             nStart,
             nEnd,
-            (nMode & SetAttrMode::IS_COPY) ? COPY : NEW,
+            (nMode & SetAttrMode::IS_COPY) ? CopyOrNewType::Copy : CopyOrNewType::New,
             this );
 
     if ( pNew )
commit 9049c94b32f00b8239cd2b50e5ac29dabf41cb61
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Sep 19 10:27:37 2016 +0200

    convert UndoOrRedo_t to scoped enum
    
    Change-Id: I8d4dec9a3a861a45e41f8c8699ae5f8d81211369

diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index 74ce2b3..62649df 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -113,8 +113,8 @@ private:
     SwDocShell* m_pDocShell;
     SwView* m_pView;
 
-    typedef enum { UNDO = int(true), REDO = int(false) } UndoOrRedo_t;
-    bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo);
+    enum class UndoOrRedoType { Undo, Redo };
+    bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo);
 
     // UGLY: should not be called
     using SdrUndoManager::Repeat;
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index cc45eb8..7b98290 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -542,7 +542,7 @@ private:
     bool const m_bSaveCursor;
 };
 
-bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo)
+bool UndoManager::impl_DoUndoRedo(UndoOrRedoType undoOrRedo)
 {
     SwDoc & rDoc(*GetUndoNodes().GetDoc());
 
@@ -573,7 +573,7 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo)
     ::sw::UndoRedoContext context(rDoc, *pEditShell);
 
     // N.B. these may throw!
-    if (UNDO == undoOrRedo)
+    if (UndoOrRedoType::Undo == undoOrRedo)
     {
         bRet = SdrUndoManager::UndoWithContext(context);
     }
@@ -608,7 +608,7 @@ bool UndoManager::Undo()
     }
     else
     {
-        return impl_DoUndoRedo(UNDO);
+        return impl_DoUndoRedo(UndoOrRedoType::Undo);
     }
 }
 
@@ -620,7 +620,7 @@ bool UndoManager::Redo()
     }
     else
     {
-        return impl_DoUndoRedo(REDO);
+        return impl_DoUndoRedo(UndoOrRedoType::Redo);
     }
 }
 


More information about the Libreoffice-commits mailing list