[Libreoffice-commits] core.git: cui/source include/editeng include/svl sc/source svl/source sw/inc sw/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Mar 16 06:10:22 UTC 2017


 cui/source/dialogs/SpellDialog.cxx |   10 +++++-----
 include/editeng/editund2.hxx       |    2 +-
 include/svl/undo.hxx               |    5 +----
 sc/source/ui/inc/undobase.hxx      |    1 -
 sc/source/ui/inc/undoblk.hxx       |    1 -
 sc/source/ui/inc/undodraw.hxx      |    1 -
 sc/source/ui/undo/undobase.cxx     |    8 --------
 sc/source/ui/undo/undoblk.cxx      |    5 -----
 sc/source/ui/undo/undodraw.cxx     |    8 --------
 sc/source/ui/view/gridwin.cxx      |    3 ++-
 svl/source/undo/undo.cxx           |   16 ----------------
 sw/inc/undobj.hxx                  |    5 ++---
 sw/source/core/doc/dbgoutsw.cxx    |   12 ++----------
 sw/source/core/undo/docundo.cxx    |    8 +++-----
 14 files changed, 16 insertions(+), 69 deletions(-)

New commits:
commit 64ea8306b0ceb001132ac9cbc945a12afc01b8cd
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Mar 15 15:50:43 2017 +0200

    drop GetId() from SfxUndoAction
    
    mostly so that the subclasses can use proper enum types for their own
    IDs.
    It turns out that nothing at the svl/sfx2 level needs an ID anyhow.
    
    Change-Id: I3c020aeafb812fa30d896216d4e3bc1a82cbfeab
    Reviewed-on: https://gerrit.libreoffice.org/35222
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/dialogs/SpellDialog.cxx b/cui/source/dialogs/SpellDialog.cxx
index 16e57d0..dabd9a0 100644
--- a/cui/source/dialogs/SpellDialog.cxx
+++ b/cui/source/dialogs/SpellDialog.cxx
@@ -119,7 +119,7 @@ public:
         {}
 
     virtual void            Undo() override;
-    virtual sal_uInt16          GetId() const override;
+    sal_uInt16              GetId() const;
 
     void                    SetEnableChangePB(){m_bEnableChangePB = true;}
     bool                    IsEnableChangePB(){return m_bEnableChangePB;}
@@ -1931,15 +1931,15 @@ void SentenceEditWindow_Impl::Undo()
     if(!GetUndoActionCount())
         return;
     bool bSaveUndoEdit = IsUndoEditMode();
-    sal_uInt16 nId;
+    SpellUndoAction_Impl* pUndoAction;
     //if the undo edit mode is active then undo all changes until the UNDO_EDIT_MODE action has been found
     do
     {
-        nId = rUndoMgr.GetUndoActionId();
+        pUndoAction = static_cast<SpellUndoAction_Impl*>(rUndoMgr.GetUndoAction());
         rUndoMgr.Undo();
-    }while(bSaveUndoEdit && SPELLUNDO_UNDO_EDIT_MODE != nId && GetUndoActionCount());
+    }while(bSaveUndoEdit && SPELLUNDO_UNDO_EDIT_MODE != pUndoAction->GetId() && GetUndoActionCount());
 
-    if(bSaveUndoEdit || SPELLUNDO_CHANGE_GROUP == nId)
+    if(bSaveUndoEdit || SPELLUNDO_CHANGE_GROUP == pUndoAction->GetId())
         GetSpellDialog()->UpdateBoxes_Impl();
 }
 
diff --git a/include/editeng/editund2.hxx b/include/editeng/editund2.hxx
index 72f671c..0a86fe7 100644
--- a/include/editeng/editund2.hxx
+++ b/include/editeng/editund2.hxx
@@ -63,7 +63,7 @@ public:
     virtual OUString GetComment() const override;
     /// See SfxUndoAction::GetViewShellId().
     sal_Int32 GetViewShellId() const override;
-    virtual sal_uInt16  GetId() const override;
+    sal_uInt16  GetId() const;
 };
 
 #endif // INCLUDED_EDITENG_EDITUND2_HXX
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx
index 52a2918..3fdfb8b 100644
--- a/include/svl/undo.hxx
+++ b/include/svl/undo.hxx
@@ -59,7 +59,6 @@ public:
 
     virtual OUString    GetComment() const;
     virtual OUString    GetRepeatComment(SfxRepeatTarget&) const;
-    virtual sal_uInt16  GetId() const;
     /// ID of the view shell that created this undo action.
     virtual sal_Int32 GetViewShellId() const;
     /// Timestamp when this undo item was created.
@@ -151,7 +150,7 @@ public:
     /// See SfxUndoAction::GetViewShellId().
     sal_Int32 GetViewShellId() const override;
     virtual OUString        GetRepeatComment(SfxRepeatTarget&) const override;
-    virtual sal_uInt16      GetId() const override;
+    virtual sal_uInt16      GetId() const;
 
     void SetComment(const OUString& rComment);
     void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
@@ -194,7 +193,6 @@ namespace svl
         virtual void            AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false ) = 0;
 
         virtual size_t          GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const = 0;
-        virtual sal_uInt16      GetUndoActionId() const = 0;
         virtual OUString        GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const = 0;
         virtual SfxUndoAction*  GetUndoAction( size_t nNo=0 ) const = 0;
         /// Get info about all undo actions (comment, view shell id, etc.)
@@ -314,7 +312,6 @@ public:
     virtual void            SetMaxUndoActionCount( size_t nMaxUndoActionCount ) override;
     virtual void            AddUndoAction( SfxUndoAction *pAction, bool bTryMerg=false ) override;
     virtual size_t          GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const override;
-    virtual sal_uInt16      GetUndoActionId() const override;
     virtual OUString        GetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const override;
     virtual SfxUndoAction*  GetUndoAction( size_t nNo=0 ) const override;
     OUString                GetUndoActionsInfo() const override;
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
index 571690f..24ef2ee 100644
--- a/sc/source/ui/inc/undobase.hxx
+++ b/sc/source/ui/inc/undobase.hxx
@@ -183,7 +183,6 @@ public:
     virtual bool            Merge( SfxUndoAction *pNextAction ) override;
     virtual OUString        GetComment() const override;
     virtual OUString        GetRepeatComment(SfxRepeatTarget&) const override;
-    virtual sal_uInt16      GetId() const override;
     /// See SfxUndoAction::GetViewShellId().
     sal_Int32 GetViewShellId() const override;
 };
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 76e4433..c558b44 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -671,7 +671,6 @@ public:
     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
 
     virtual OUString GetComment() const override;
-    virtual sal_uInt16  GetId() const override;
 
 private:
     ScMarkData      aMarkData;
diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx
index 763fa4f..43cb776 100644
--- a/sc/source/ui/inc/undodraw.hxx
+++ b/sc/source/ui/inc/undodraw.hxx
@@ -45,7 +45,6 @@ public:
     virtual bool            Merge( SfxUndoAction *pNextAction ) override;
     virtual OUString        GetComment() const override;
     virtual OUString        GetRepeatComment(SfxRepeatTarget&) const override;
-    virtual sal_uInt16      GetId() const override;
     /// See SfxUndoAction::GetViewShellId().
     sal_Int32 GetViewShellId() const override;
 };
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
index 036cdd9..b8b0aca 100644
--- a/sc/source/ui/undo/undobase.cxx
+++ b/sc/source/ui/undo/undobase.cxx
@@ -642,14 +642,6 @@ OUString ScUndoWrapper::GetRepeatComment(SfxRepeatTarget& rTarget) const
     return OUString();
 }
 
-sal_uInt16 ScUndoWrapper::GetId() const
-{
-    if (pWrappedUndo)
-        return pWrappedUndo->GetId();
-    else
-        return 0;
-}
-
 bool ScUndoWrapper::Merge( SfxUndoAction* pNextAction )
 {
     if (pWrappedUndo)
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 8ab8095..c9f626c 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -1758,11 +1758,6 @@ bool ScUndoSelectionStyle::CanRepeat(SfxRepeatTarget& rTarget) const
     return dynamic_cast<const ScTabViewTarget*>( &rTarget) !=  nullptr;
 }
 
-sal_uInt16 ScUndoSelectionStyle::GetId() const
-{
-    return STR_UNDO_APPLYCELLSTYLE;
-}
-
 ScUndoEnterMatrix::ScUndoEnterMatrix( ScDocShell* pNewDocShell, const ScRange& rArea,
                                       ScDocument* pNewUndoDoc, const OUString& rForm ) :
     ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ),
diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx
index 484dd76..e779733 100644
--- a/sc/source/ui/undo/undodraw.cxx
+++ b/sc/source/ui/undo/undodraw.cxx
@@ -56,14 +56,6 @@ OUString ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
     return OUString();
 }
 
-sal_uInt16 ScUndoDraw::GetId() const
-{
-    if (pDrawUndo)
-        return pDrawUndo->GetId();
-    else
-        return 0;
-}
-
 bool  ScUndoDraw::Merge( SfxUndoAction* pNextAction )
 {
     if (pDrawUndo)
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index 3640f0b..bfbae12 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -129,6 +129,7 @@
 #include "spellcheckcontext.hxx"
 #include "uiobject.hxx"
 #include "scabstdlg.hxx"
+#include "undoblk.hxx"
 
 #include <svx/sdrpagewindow.hxx>
 #include <svx/sdr/overlay/overlaymanager.hxx>
@@ -1860,7 +1861,7 @@ void ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
     if (nMouseStatus == SC_GM_WATERUNDO)    // Undo in format paintbrush mode
     {
         ::svl::IUndoManager* pMgr = pViewData->GetDocShell()->GetUndoManager();
-        if ( pMgr->GetUndoActionCount() && pMgr->GetUndoActionId() == STR_UNDO_APPLYCELLSTYLE )
+        if ( pMgr->GetUndoActionCount() && dynamic_cast<ScUndoSelectionStyle*>(pMgr->GetUndoAction()) )
             pMgr->Undo();
         return;
     }
diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx
index 4636021..71dd56d 100644
--- a/svl/source/undo/undo.cxx
+++ b/svl/source/undo/undo.cxx
@@ -70,11 +70,6 @@ OUString SfxUndoAction::GetComment() const
 }
 
 
-sal_uInt16 SfxUndoAction::GetId() const
-{
-    return 0;
-}
-
 sal_Int32 SfxUndoAction::GetViewShellId() const
 {
     return -1;
@@ -698,17 +693,6 @@ OUString SfxUndoManager::GetUndoActionComment( size_t nNo, bool const i_currentL
 }
 
 
-sal_uInt16 SfxUndoManager::GetUndoActionId() const
-{
-    UndoManagerGuard aGuard( *m_xData );
-
-    assert(m_xData->pActUndoArray->nCurUndoAction > 0);
-    if ( m_xData->pActUndoArray->nCurUndoAction == 0 )
-        return 0;
-    return m_xData->pActUndoArray->aUndoActions[m_xData->pActUndoArray->nCurUndoAction-1].pAction->GetId();
-}
-
-
 SfxUndoAction* SfxUndoManager::GetUndoAction( size_t nNo ) const
 {
     UndoManagerGuard aGuard( *m_xData );
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 2662573..3f0e521 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -72,9 +72,6 @@ protected:
     */
     virtual SwRewriter GetRewriter() const;
 
-    // return type is sal_uInt16 because this overrides SfxUndoAction::GetId()
-    virtual sal_uInt16 GetId() const override { return static_cast<sal_uInt16>(m_nId); }
-
     // the 4 methods that derived classes have to override
     // base implementation does nothing
     virtual void RepeatImpl( ::sw::RepeatContext & );
@@ -97,6 +94,8 @@ public:
     SwUndo(SwUndoId const nId, const SwDoc* pDoc);
     virtual ~SwUndo() override;
 
+    SwUndoId GetId() const { return m_nId; }
+
     /**
        Returns textual comment for this undo object.
 
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 79c0b97..d4c95ac 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -768,16 +768,8 @@ const char * dbg_out(SwNodes & rNodes)
 
 static OUString lcl_dbg_out(const SwUndo & rUndo)
 {
-    OUString aStr("[ ");
-
-    aStr += OUString::number(
-                static_cast<SfxUndoAction const&>(rUndo).GetId());
-    aStr += ": ";
-
-    aStr += rUndo.GetComment();
-    aStr += " ]";
-
-    return aStr;
+    return "[ " + OUString::number(rUndo.GetId())
+                + ": " + rUndo.GetComment() + " ]";
 }
 
 const char * dbg_out(const SwUndo & rUndo)
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 4d117da..e1ca524 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -387,8 +387,7 @@ UndoManager::GetLastUndoInfo(
     }
     if (o_pId)
     {
-        sal_uInt16 const nId(pAction->GetId());
-        *o_pId = static_cast<SwUndoId>(nId);
+        *o_pId = static_cast<const SwUndo*>(pAction)->GetId();
     }
 
     return true;
@@ -446,8 +445,7 @@ bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
     }
     if (o_pId)
     {
-        sal_uInt16 const nId(pAction->GetId());
-        *o_pId = static_cast<SwUndoId>(nId);
+        *o_pId = static_cast<const SwUndo*>(pAction)->GetId();
     }
 
     return true;
@@ -655,7 +653,7 @@ bool UndoManager::Repeat(::sw::RepeatContext & rContext,
 
     OUString const comment(pRepeatAction->GetComment());
     OUString const rcomment(pRepeatAction->GetRepeatComment(rContext));
-    sal_uInt16 const nId(pRepeatAction->GetId());
+    SwUndoId const nId(static_cast<const SwUndo*>(pRepeatAction)->GetId());
     if (DoesUndo())
     {
         int nViewShellId = -1;


More information about the Libreoffice-commits mailing list