[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 11 14:45:05 UTC 2019


 sw/inc/swtypes.hxx                   |   10 +++++-----
 sw/source/core/doc/doclay.cxx        |    8 ++++----
 sw/source/core/frmedt/fews.cxx       |   12 ++++++------
 sw/source/core/inc/UndoInsert.hxx    |    2 +-
 sw/source/core/undo/unins.cxx        |   30 +++++++++++++++---------------
 sw/source/uibase/uiview/viewdlg2.cxx |   10 +++++-----
 6 files changed, 36 insertions(+), 36 deletions(-)

New commits:
commit bd20461c21b09d950edb6b798448d5b04fbeffc6
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Dec 11 08:54:15 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Dec 11 15:43:54 2019 +0100

    convert SwLabelType to scoped enum
    
    Change-Id: I7e842ad3446e0209732f1eb49f2f78da89db18b7
    Reviewed-on: https://gerrit.libreoffice.org/84921
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx
index 03f136e2ea34..1bb96fb329e9 100644
--- a/sw/inc/swtypes.hxx
+++ b/sw/inc/swtypes.hxx
@@ -84,12 +84,12 @@ const SwTwips lMinBorder = 1134;
 // For inserting of captions (what and where to insert).
 // It's here because it is not big enough to justify its own hxx
 // and does not seem to fit somewhere else.
-enum SwLabelType
+enum class SwLabelType
 {
-    LTYPE_TABLE,    // Caption for a table.
-    LTYPE_OBJECT,   // Caption for a graphic or OLE.
-    LTYPE_FLY,      // Caption for a text frame.
-    LTYPE_DRAW      // Caption for a draw object.
+    Table,    // Caption for a table.
+    Object,   // Caption for a graphic or OLE.
+    Fly,      // Caption for a text frame.
+    Draw      // Caption for a draw object.
 };
 
 const sal_uInt8 MAXLEVEL = 10;
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 1b0ac762b6a2..ad864f3ae15c 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -663,10 +663,10 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
 
     switch ( eType )
     {
-        case LTYPE_TABLE:
+        case SwLabelType::Table:
             bTable = true;
             [[fallthrough]];
-        case LTYPE_FLY:
+        case SwLabelType::Fly:
             // At the FlySection's Beginning/End insert the corresponding Node with its Field.
             // The Frame is created automatically.
             {
@@ -695,7 +695,7 @@ lcl_InsertLabel(SwDoc & rDoc, SwTextFormatColls *const pTextFormatCollTable,
             }
             break;
 
-        case LTYPE_OBJECT:
+        case SwLabelType::Object:
             {
                 // Destroy Frame,
                 // insert new Frame,
@@ -1249,7 +1249,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
     {
         GetIDocumentUndoRedo().ClearRedo();
         pUndo.reset(new SwUndoInsertLabel(
-            LTYPE_DRAW, rText, rSeparator, rNumberSeparator, false,
+            SwLabelType::Draw, rText, rSeparator, rNumberSeparator, false,
             nId, rCharacterStyle, false, this ));
     }
 
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 0f0d07082915..286b949e5f34 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -424,8 +424,8 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con
                              const bool bCpyBrd )
 {
     // get node index of cursor position, SwDoc can do everything else itself
-    SwContentFrame *pCnt = LTYPE_DRAW==eType ? nullptr : GetCurrFrame( false );
-    if( LTYPE_DRAW!=eType && !pCnt )
+    SwContentFrame *pCnt = SwLabelType::Draw==eType ? nullptr : GetCurrFrame( false );
+    if( SwLabelType::Draw!=eType && !pCnt )
         return;
 
     StartAllAction();
@@ -437,8 +437,8 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con
     SwFlyFrameFormat* pFlyFormat = nullptr;
     switch( eType )
     {
-    case LTYPE_OBJECT:
-    case LTYPE_FLY:
+    case SwLabelType::Object:
+    case SwLabelType::Fly:
         bInnerCntIsFly = pCnt->IsInFly();
         if (bInnerCntIsFly)
         {
@@ -447,7 +447,7 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con
                         GetFormat()->GetContent().GetContentIdx()->GetIndex();
         }
         break;
-    case LTYPE_TABLE:
+    case SwLabelType::Table:
         if( pCnt->IsInTab() )
         {
             // pass down index to the TableNode for tables
@@ -456,7 +456,7 @@ void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, con
                         ->GetSttNd()->FindTableNode()->GetIndex();
         }
         break;
-    case LTYPE_DRAW:
+    case SwLabelType::Draw:
         if( Imp()->GetDrawView() )
         {
             SwDrawView *pDView = Imp()->GetDrawView();
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index fbfcb2c9a7e0..8d1cf55c78d6 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -211,7 +211,7 @@ public:
     static SwRewriter CreateRewriter(const OUString &rStr);
 
     void SetNodePos( sal_uLong nNd )
-        { if( LTYPE_OBJECT != m_eType ) NODE.nNode = nNd; }
+        { if( SwLabelType::Object != m_eType ) NODE.nNode = nNd; }
 
     void SetUndoKeep()  { m_bUndoKeep = true; }
     void SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet, SwFrameFormat& rNewFly );
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 4de6deab4071..fa6971713755 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -873,7 +873,7 @@ SwUndoInsertLabel::SwUndoInsertLabel( const SwLabelType eTyp,
 
 SwUndoInsertLabel::~SwUndoInsertLabel()
 {
-    if( LTYPE_OBJECT == m_eType || LTYPE_DRAW == m_eType )
+    if( SwLabelType::Object == m_eType || SwLabelType::Draw == m_eType )
     {
         delete OBJECT.pUndoFly;
         delete OBJECT.pUndoAttr;
@@ -886,19 +886,19 @@ void SwUndoInsertLabel::UndoImpl(::sw::UndoRedoContext & rContext)
 {
     SwDoc & rDoc = rContext.GetDoc();
 
-    if( LTYPE_OBJECT == m_eType || LTYPE_DRAW == m_eType )
+    if( SwLabelType::Object == m_eType || SwLabelType::Draw == m_eType )
     {
         OSL_ENSURE( OBJECT.pUndoAttr && OBJECT.pUndoFly, "Pointer not initialized" );
         SwFrameFormat* pFormat;
         SdrObject *pSdrObj = nullptr;
         if( OBJECT.pUndoAttr &&
             nullptr != (pFormat = static_cast<SwFrameFormat*>(OBJECT.pUndoAttr->GetFormat( rDoc ))) &&
-            ( LTYPE_DRAW != m_eType ||
+            ( SwLabelType::Draw != m_eType ||
               nullptr != (pSdrObj = pFormat->FindSdrObject()) ) )
         {
             OBJECT.pUndoAttr->UndoImpl(rContext);
             OBJECT.pUndoFly->UndoImpl(rContext);
-            if( LTYPE_DRAW == m_eType )
+            if( SwLabelType::Draw == m_eType )
             {
                 pSdrObj->SetLayer( m_nLayerId );
             }
@@ -906,7 +906,7 @@ void SwUndoInsertLabel::UndoImpl(::sw::UndoRedoContext & rContext)
     }
     else if( NODE.nNode )
     {
-        if ( m_eType == LTYPE_TABLE && m_bUndoKeep )
+        if ( m_eType == SwLabelType::Table && m_bUndoKeep )
         {
             SwTableNode *pNd = rDoc.GetNodes()[
                         rDoc.GetNodes()[NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
@@ -925,19 +925,19 @@ void SwUndoInsertLabel::RedoImpl(::sw::UndoRedoContext & rContext)
 {
     SwDoc & rDoc = rContext.GetDoc();
 
-    if( LTYPE_OBJECT == m_eType || LTYPE_DRAW == m_eType )
+    if( SwLabelType::Object == m_eType || SwLabelType::Draw == m_eType )
     {
         OSL_ENSURE( OBJECT.pUndoAttr && OBJECT.pUndoFly, "Pointer not initialized" );
         SwFrameFormat* pFormat;
         SdrObject *pSdrObj = nullptr;
         if( OBJECT.pUndoAttr &&
             nullptr != (pFormat = static_cast<SwFrameFormat*>(OBJECT.pUndoAttr->GetFormat( rDoc ))) &&
-            ( LTYPE_DRAW != m_eType ||
+            ( SwLabelType::Draw != m_eType ||
               nullptr != (pSdrObj = pFormat->FindSdrObject()) ) )
         {
             OBJECT.pUndoFly->RedoImpl(rContext);
             OBJECT.pUndoAttr->RedoImpl(rContext);
-            if( LTYPE_DRAW == m_eType )
+            if( SwLabelType::Draw == m_eType )
             {
                 pSdrObj->SetLayer( m_nLayerId );
                 if( pSdrObj->GetLayer() == rDoc.getIDocumentDrawModelAccess().GetHellId() )
@@ -950,7 +950,7 @@ void SwUndoInsertLabel::RedoImpl(::sw::UndoRedoContext & rContext)
     }
     else if( NODE.pUndoInsNd )
     {
-        if ( m_eType == LTYPE_TABLE && m_bUndoKeep )
+        if ( m_eType == SwLabelType::Table && m_bUndoKeep )
         {
             SwTableNode *pNd = rDoc.GetNodes()[
                         rDoc.GetNodes()[NODE.nNode-1]->StartOfSectionIndex()]->GetTableNode();
@@ -974,7 +974,7 @@ void SwUndoInsertLabel::RepeatImpl(::sw::RepeatContext & rContext)
     if( pCNd )
         switch( m_eType )
         {
-        case LTYPE_TABLE:
+        case SwLabelType::Table:
             {
                 const SwTableNode* pTNd = pCNd->FindTableNode();
                 if( pTNd )
@@ -982,8 +982,8 @@ void SwUndoInsertLabel::RepeatImpl(::sw::RepeatContext & rContext)
             }
             break;
 
-        case LTYPE_FLY:
-        case LTYPE_OBJECT:
+        case SwLabelType::Fly:
+        case SwLabelType::Object:
             {
                 SwFlyFrame* pFly;
                 SwContentFrame *pCnt = pCNd->getLayoutFrame( rDoc.getIDocumentLayoutAccess().GetCurrentLayout() );
@@ -991,7 +991,7 @@ void SwUndoInsertLabel::RepeatImpl(::sw::RepeatContext & rContext)
                     nIdx = pFly->GetFormat()->GetContent().GetContentIdx()->GetIndex();
             }
             break;
-        case LTYPE_DRAW:
+        case SwLabelType::Draw:
             break;
         }
 
@@ -1029,7 +1029,7 @@ SwRewriter SwUndoInsertLabel::CreateRewriter(const OUString &rStr)
 void SwUndoInsertLabel::SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChgSet,
                                 SwFrameFormat& rNewFly )
 {
-    if( LTYPE_OBJECT == m_eType || LTYPE_DRAW == m_eType )
+    if( SwLabelType::Object == m_eType || SwLabelType::Draw == m_eType )
     {
         SwUndoFormatAttrHelper aTmp( rOldFly, false );
         rOldFly.SetFormatAttr( rChgSet );
@@ -1043,7 +1043,7 @@ void SwUndoInsertLabel::SetFlys( SwFrameFormat& rOldFly, SfxItemSet const & rChg
 
 void SwUndoInsertLabel::SetDrawObj( SdrLayerID nLId )
 {
-    if( LTYPE_DRAW == m_eType )
+    if( SwLabelType::Draw == m_eType )
     {
         m_nLayerId = nLId;
     }
diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx
index ba691407af19..5644c2fd731f 100644
--- a/sw/source/uibase/uiview/viewdlg2.cxx
+++ b/sw/source/uibase/uiview/viewdlg2.cxx
@@ -204,11 +204,11 @@ void SwView::InsertCaption(const InsCaptionOpt *pOpt)
     if (eType & SelectionType::Ole)
         eType = SelectionType::Graphic;
 
-    const SwLabelType eT = (eType & SelectionType::Table) ? LTYPE_TABLE :
-                      (eType & SelectionType::Frame) ? LTYPE_FLY :
-                      (eType == SelectionType::Text) ? LTYPE_FLY :
-                      (eType & SelectionType::DrawObject) ? LTYPE_DRAW :
-                                                    LTYPE_OBJECT;
+    const SwLabelType eT = (eType & SelectionType::Table) ? SwLabelType::Table :
+                      (eType & SelectionType::Frame) ? SwLabelType::Fly :
+                      (eType == SelectionType::Text) ? SwLabelType::Fly :
+                      (eType & SelectionType::DrawObject) ? SwLabelType::Draw :
+                                                    SwLabelType::Object;
 
     SwFieldMgr aMgr(&rSh);
     SwSetExpFieldType* pFieldType =


More information about the Libreoffice-commits mailing list