[Libreoffice-commits] core.git: editeng/source include/editeng

Noel Grandin noel.grandin at collabora.co.uk
Wed Nov 23 07:19:35 UTC 2016


 editeng/source/editeng/editeng.cxx  |    2 +-
 editeng/source/editeng/editundo.cxx |    2 +-
 editeng/source/editeng/editundo.hxx |   10 +++++-----
 editeng/source/editeng/editview.cxx |    2 +-
 editeng/source/editeng/edtspell.cxx |    2 +-
 editeng/source/editeng/impedit.hxx  |    5 +----
 editeng/source/editeng/impedit5.cxx |    6 +++---
 include/editeng/editeng.hxx         |    6 +++++-
 8 files changed, 18 insertions(+), 17 deletions(-)

New commits:
commit aebf05f324661a07f4124a4c48b6fc889d4bfbf6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Nov 23 09:18:23 2016 +0200

    convert ATTRSPECIAL to scoped enum
    
    Change-Id: I8abf09dc5f17343945b909887c580e9016a79ac5

diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index bde286a..c151c67 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -907,7 +907,7 @@ void EditEngine::SetParaAttribsOnly(sal_Int32 nPara, const SfxItemSet& rSet)
     pImpEditEngine->SetParaAttribs(nPara, rSet);
 }
 
-void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial)
+void EditEngine::SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, SetAttribsMode nSpecial)
 {
     pImpEditEngine->SetAttribs(rSel, rSet, nSpecial);
 }
diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx
index 90ea9ba..c96174f 100644
--- a/editeng/source/editeng/editundo.cxx
+++ b/editeng/source/editeng/editundo.cxx
@@ -505,7 +505,7 @@ EditUndoSetAttribs::EditUndoSetAttribs(EditEngine* pEE, const ESelection& rESel,
     bSetIsRemove = false;
     bRemoveParaAttribs = false;
     nRemoveWhich = 0;
-    nSpecial = 0;
+    nSpecial = SetAttribsMode::NONE;
 }
 
 namespace {
diff --git a/editeng/source/editeng/editundo.hxx b/editeng/source/editeng/editundo.hxx
index 1364b0c..f85ee12 100644
--- a/editeng/source/editeng/editundo.hxx
+++ b/editeng/source/editeng/editundo.hxx
@@ -28,7 +28,7 @@
 
 class EditEngine;
 class EditView;
-
+enum class SetAttribsMode;
 
 // EditUndoDelContent
 
@@ -216,10 +216,10 @@ private:
     SfxItemSet          aNewAttribs;
     InfoArrayType       aPrevAttribs;
 
-    sal_uInt8               nSpecial;
+    SetAttribsMode      nSpecial;
     bool                bSetIsRemove;
     bool                bRemoveParaAttribs;
-    sal_uInt16              nRemoveWhich;
+    sal_uInt16          nRemoveWhich;
 
     void                ImpSetSelection( EditView* pView );
 
@@ -230,10 +230,10 @@ public:
 
     SfxItemSet&         GetNewAttribs()     { return aNewAttribs; }
 
-    void                SetSpecial( sal_uInt8 n )           { nSpecial = n; }
+    void                SetSpecial( SetAttribsMode n )  { nSpecial = n; }
     void                SetRemoveAttribs( bool b )      { bSetIsRemove = b; }
     void                SetRemoveParaAttribs( bool b )  { bRemoveParaAttribs = b; }
-    void                SetRemoveWhich( sal_uInt16 n )      { nRemoveWhich = n; }
+    void                SetRemoveWhich( sal_uInt16 n )  { nRemoveWhich = n; }
 
     virtual void        Undo() override;
     virtual void        Redo() override;
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 3245004..2d0ace8 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -481,7 +481,7 @@ void EditView::SetAttribs( const SfxItemSet& rSet )
     DBG_ASSERT( !pImpEditView->aEditSelection.IsInvalid(), "Blind Selection in ...." );
 
     pImpEditView->DrawSelection();
-    pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, ATTRSPECIAL_WHOLEWORD );
+    pImpEditView->pEditEngine->SetAttribs( pImpEditView->GetEditSelection(), rSet, SetAttribsMode::WholeWord );
     pImpEditView->pEditEngine->FormatAndUpdate( this );
 }
 
diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx
index 4077ae5..887e814 100644
--- a/editeng/source/editeng/edtspell.cxx
+++ b/editeng/source/editeng/edtspell.cxx
@@ -624,7 +624,7 @@ void EdtAutoCorrDoc::SetAttr(sal_Int32 nStt, sal_Int32 nEnd,
 
         EditSelection aSel( EditPaM( pCurNode, nStt ), EditPaM( pCurNode, nEnd ) );
         aSel.Max().SetIndex( nEnd );    // ???
-        mpEditEngine->SetAttribs( aSel, aSet, ATTRSPECIAL_EDGE );
+        mpEditEngine->SetAttribs( aSel, aSet, SetAttribsMode::Edge );
         bAllowUndoAction = false;
     }
 }
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index b76fa58..5cb4feb 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -66,9 +66,6 @@
 #define CURSOR_BIDILEVEL_DONTKNOW   0xFFFF
 #define MAXCHARSINPARA      0x3FFF-CHARPOSGROW  // Max 16K, because WYSIWYG array
 
-#define ATTRSPECIAL_WHOLEWORD   1
-#define ATTRSPECIAL_EDGE        2
-
 #define GETCRSR_TXTONLY             0x0001
 #define GETCRSR_STARTOFLINE         0x0002
 #define GETCRSR_ENDOFLINE           0x0004
@@ -821,7 +818,7 @@ public:
 
     SfxItemSet      GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags = GetAttribsFlags::ALL ) const;
     SfxItemSet      GetAttribs( EditSelection aSel, EditEngineAttribs nOnlyHardAttrib = EditEngineAttribs_All  );
-    void            SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_uInt8 nSpecial = 0 );
+    void            SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetAttribsMode nSpecial = SetAttribsMode::NONE );
     void            RemoveCharAttribs( EditSelection aSel, bool bRemoveParaAttribs, sal_uInt16 nWhich );
     void            RemoveCharAttribs( sal_Int32 nPara, sal_uInt16 nWhich = 0, bool bRemoveFeatures = false );
     void            SetFlatMode( bool bFlat );
diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx
index e091a14..1b3c5b3 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -490,13 +490,13 @@ SfxItemSet ImpEditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int
 }
 
 
-void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_uInt8 nSpecial )
+void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, SetAttribsMode nSpecial )
 {
     aSel.Adjust( aEditDoc );
 
     // When no selection => use the Attribute on the word.
     // ( the RTF-parser should actually never call the Method without a Range )
-    if ( ( nSpecial == ATTRSPECIAL_WHOLEWORD ) && !aSel.HasRange() )
+    if ( nSpecial == SetAttribsMode::WholeWord && !aSel.HasRange() )
         aSel = SelectWord( aSel, css::i18n::WordType::ANYWORD_IGNOREWHITESPACES, false );
 
     sal_Int32 nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() );
@@ -547,7 +547,7 @@ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, sal_
                 {
                     aEditDoc.InsertAttrib( pNode, nStartPos, nEndPos, rItem );
                     bCharAttribFound = true;
-                    if ( nSpecial == ATTRSPECIAL_EDGE )
+                    if ( nSpecial == SetAttribsMode::Edge )
                     {
                         CharAttribList::AttribsType& rAttribs = pNode->GetCharAttribs().GetAttribs();
                         for (std::unique_ptr<EditCharAttrib> & rAttrib : rAttribs)
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx
index d8be7c6..2b4f236 100644
--- a/include/editeng/editeng.hxx
+++ b/include/editeng/editeng.hxx
@@ -140,6 +140,10 @@ template<class T> bool checkSvxFieldData(const SvxFieldData* pData)
     return dynamic_cast<const T*>(pData) != nullptr;
 }
 
+enum class SetAttribsMode {
+    NONE, WholeWord, Edge
+};
+
 class SdrObject;
 class EDITENG_DLLPUBLIC EditEngine
 {
@@ -570,7 +574,7 @@ public:
 
     const SfxItemSet& GetBaseParaAttribs(sal_Int32 nPara) const;
     void SetParaAttribsOnly(sal_Int32 nPara, const SfxItemSet& rSet);
-    void SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, sal_uInt8 nSpecial = 0);
+    void SetAttribs(const EditSelection& rSel, const SfxItemSet& rSet, SetAttribsMode nSpecial = SetAttribsMode::NONE);
 
     OUString GetSelected(const EditSelection& rSel) const;
     EditPaM DeleteSelected(const EditSelection& rSel);


More information about the Libreoffice-commits mailing list