diff options
author | Michael Stahl <mst@openoffice.org> | 2010-12-15 09:14:08 +0100 |
---|---|---|
committer | Michael Stahl <mst@openoffice.org> | 2010-12-15 09:14:08 +0100 |
commit | 8e7d7f0e1418945ccc41ea65de273cfd7e2bf652 (patch) | |
tree | 5616c2220911317c90a113ec0cb8ffea02084ec4 | |
parent | 58a64dfc06da10c1f0ce97cb8a68817941d7a36e (diff) |
undoapi: #i115383#: change return type of GetLastUndoInfo() to bool:
unfortunately several places need the ID, so add the ID as an out parameter.
a bool return is necessary in case the Undo action is not a writer action,
but created via the undo API.
-rw-r--r-- | sw/inc/IDocumentUndoRedo.hxx | 6 | ||||
-rw-r--r-- | sw/inc/editsh.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/doc/doc.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/docnode/ndtbl.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/edit/edundo.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/edit/edws.cxx | 5 | ||||
-rw-r--r-- | sw/source/core/frmedt/fefly1.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/inc/UndoManager.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/undo/docundo.cxx | 15 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbmgr.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/docvw/edtwin.cxx | 9 | ||||
-rwxr-xr-x | sw/source/ui/shells/annotsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/shells/basesh.cxx | 4 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewstat.cxx | 3 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtsh2.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/wrtsh/wrtundo.cxx | 2 |
16 files changed, 61 insertions, 33 deletions
diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx index 030ef9e3aa0d..9980d1c8d2a4 100644 --- a/sw/inc/IDocumentUndoRedo.hxx +++ b/sw/inc/IDocumentUndoRedo.hxx @@ -146,9 +146,11 @@ public: /** Get Id and comment of last Undo action. @param o_pStr if not 0, receives comment of last Undo action. - @return Id of last Undo action, or UNDO_EMPTY if there is none. + @param o_pId if not 0, receives Id of last Undo action. + @return true if there is a Undo action, false if none */ - virtual SwUndoId GetLastUndoInfo(::rtl::OUString *const o_pStr) const = 0; + virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const = 0; /** Get comments of Undo actions. @return comments of all top-level Undo actions. diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 86791b62fcc6..c5f82d2ceebf 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -533,7 +533,8 @@ public: // schliesst Klammerung der nUndoId, nicht vom UI benutzt SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 ); - SwUndoId GetLastUndoInfo(::rtl::OUString *const o_pStr) const; + bool GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const; bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const; SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 6a51fc0ffd1c..fe1f8be5c44d 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -2439,8 +2439,9 @@ bool SwDoc::HasInvisibleContent() const bool SwDoc::RestoreInvisibleContent() { bool bRet = false; - if (UNDO_UI_DELETE_INVISIBLECNTNT == - GetIDocumentUndoRedo().GetLastUndoInfo(0)) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId) + && (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId)) { SwPaM aPam( GetNodes().GetEndOfPostIts() ); SwUndoIter aUndoIter( &aPam ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 97e197b97fdc..96fa4f4c3fb0 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2380,7 +2380,9 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) if( pUndo ) { delete pUndo; - if (UNDO_REDLINE == GetIDocumentUndoRedo().GetLastUndoInfo(0)) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId) + && (UNDO_REDLINE == nLastUndoId)) { SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>( GetIDocumentUndoRedo().RemoveLastUndo(UNDO_REDLINE)); diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx index 9849b4c152c8..1ba494a88b79 100644 --- a/sw/source/core/edit/edundo.cxx +++ b/sw/source/core/edit/edundo.cxx @@ -69,8 +69,8 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt ) // JP 02.04.98: Cursor merken - beim Auto-Format/-Korrektur // soll dieser wieder an die Position - SwUndoId const nLastUndoId = - GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0); + SwUndoId nLastUndoId(UNDO_EMPTY); + GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId); BOOL bRestoreCrsr = 1 == nCnt && ( UNDO_AUTOFORMAT == nLastUndoId || UNDO_AUTOCORRECT == nLastUndoId ); Push(); diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx index 8b2d35a25e35..1a681ad2cf29 100644 --- a/sw/source/core/edit/edws.cxx +++ b/sw/source/core/edit/edws.cxx @@ -298,8 +298,9 @@ SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId, { return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); } -SwUndoId SwEditShell::GetLastUndoInfo(::rtl::OUString *const o_pStr) const -{ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr); } +bool SwEditShell::GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const +{ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); } bool SwEditShell::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const { return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index 1a80a96e44b2..231fb022dcb5 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -768,11 +768,15 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali // aufgezeichnet werden. bool const bDoesUndo = GetDoc()->GetIDocumentUndoRedo().DoesUndo(); + SwUndoId nLastUndoId(UNDO_EMPTY); if (bDoesUndo && - (UNDO_INSLAYFMT == - GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0))) + GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0, + & nLastUndoId)) { - GetDoc()->GetIDocumentUndoRedo().DoUndo(false); + if (UNDO_INSLAYFMT == nLastUndoId) + { + GetDoc()->GetIDocumentUndoRedo().DoUndo(false); + } } ((SfxItemSet&)rSet).Put( *pOldAnchor ); diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx index 28e1139b5af4..7c2ed51782a0 100644 --- a/sw/source/core/inc/UndoManager.hxx +++ b/sw/source/core/inc/UndoManager.hxx @@ -69,7 +69,8 @@ public: virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const*const pRewriter); virtual void DelAllUndoObj(); - virtual SwUndoId GetLastUndoInfo(::rtl::OUString *const o_pStr) const; + virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const; virtual SwUndoComments_t GetUndoComments() const; virtual SwUndo* RemoveLastUndo(SwUndoId const eUndoId); virtual bool HasTooManyUndos() const; diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index 0a25c7d217bc..6a922dba6a04 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -850,11 +850,13 @@ IdAndName_t lcl_GetUndoIdAndName(const SwUndos & rUndos, sal_uInt16 nPos) } -SwUndoId UndoManager::GetLastUndoInfo(::rtl::OUString *const o_pStr) const +bool +UndoManager::GetLastUndoInfo( + ::rtl::OUString *const o_pStr, SwUndoId *const o_pId) const { if (!m_nUndoPos) { - return UNDO_EMPTY; + return false; } IdAndName_t const idAndName(lcl_GetUndoIdAndName(*m_pUndos, m_nUndoPos-1)); @@ -863,8 +865,12 @@ SwUndoId UndoManager::GetLastUndoInfo(::rtl::OUString *const o_pStr) const { *o_pStr = idAndName.second; } + if (o_pId) + { + *o_pId = idAndName.first; + } - return idAndName.first; + return true; } @@ -1069,7 +1075,8 @@ bool UndoManager::Repeat(SwUndoIter & rUndoIter, sal_uInt16 const nRepeatCnt) SwUndoId UndoManager::GetRepeatInfo(::rtl::OUString *const o_pStr) const { - SwUndoId const nRepeatId = GetLastUndoInfo(o_pStr); + SwUndoId nRepeatId(UNDO_EMPTY); + GetLastUndoInfo(o_pStr, & nRepeatId); if( REPEAT_START <= nRepeatId && REPEAT_END > nRepeatId ) { return nRepeatId; diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index e5444d286230..e8633e3e3806 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -2938,10 +2938,13 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); pWorkDoc->EmbedAllLinks(); - if (UNDO_UI_DELETE_INVISIBLECNTNT == - rWorkShell.GetLastUndoInfo(0)) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId)) { - rWorkShell.Undo(); + if (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId) + { + rWorkShell.Undo(); + } } // #i69485# lock fields to prevent access to the result set while calculating layout rWorkShell.LockExpFlds(); diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 792c022a4995..e3991352b0b3 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -4320,10 +4320,13 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) !GetConnectMetaFile() && rSh.VisArea().IsInside( aDocPt )) { - if (UNDO_INS_FROM_SHADOWCRSR == - rSh.GetLastUndoInfo(0)) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (rSh.GetLastUndoInfo(0, & nLastUndoId)) { - rSh.Undo(); + if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId) + { + rSh.Undo(); + } } SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode(); rSh.SetShadowCrsrPos( aDocPt, eMode ); diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 646cdd3aab2a..a2ffdfc31eea 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -1448,7 +1448,7 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); if ( nCount ) pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); - else if (UNDO_EMPTY != rSh.GetLastUndoInfo(0)) + else if (rSh.GetLastUndoInfo(0, 0)) { rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) ); } @@ -1498,7 +1498,7 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) SfxStringListItem aItem( nWhich ); if ((nWhich == SID_GETUNDOSTRINGS) && - (UNDO_EMPTY != rSh.GetLastUndoInfo(0))) + rSh.GetLastUndoInfo(0, 0)) { rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); } diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 1bde15f42aed..9b760ed1b596 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -543,7 +543,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet) { case SID_UNDO: { - if (UNDO_EMPTY != rSh.GetLastUndoInfo(0)) + if (rSh.GetLastUndoInfo(0, 0)) { rSet.Put( SfxStringItem(nWhich, rSh.GetDoString(SwWrtShell::UNDO))); @@ -577,7 +577,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet) } case SID_GETUNDOSTRINGS: - if (UNDO_EMPTY != rSh.GetLastUndoInfo(0)) + if (rSh.GetLastUndoInfo(0, 0)) { SfxStringListItem aStrLst( nWhich ); rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst ); diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index 0f449ebabe5e..d0b9d2a06827 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -156,8 +156,7 @@ void SwView::GetState(SfxItemSet &rSet) break; case SID_CLEARHISTORY: { - rSet.Put(SfxBoolItem(nWhich, - pWrtShell->GetLastUndoInfo(0) != UNDO_EMPTY)); + rSet.Put(SfxBoolItem(nWhich, pWrtShell->GetLastUndoInfo(0, 0))); } break; case SID_UNDO: diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 89993926feb5..daf2fabe17fc 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -481,9 +481,13 @@ void SwWrtShell::NavigatorPaste( const NaviContentBookmark& rBkmk, // the undostack. Then the change of the section dont create // any undoobject. - BUG 69145 BOOL bDoesUndo = DoesUndo(); - if (UNDO_INSSECTION != GetLastUndoInfo(0)) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetLastUndoInfo(0, & nLastUndoId)) { - DoUndo(false); + if (UNDO_INSSECTION != nLastUndoId) + { + DoUndo(false); + } } UpdateSection( GetSectionFmtPos( *pIns->GetFmt() ), aSection ); DoUndo( bDoesUndo ); diff --git a/sw/source/ui/wrtsh/wrtundo.cxx b/sw/source/ui/wrtsh/wrtundo.cxx index 1e38985e0ec5..3e9349c409ba 100644 --- a/sw/source/ui/wrtsh/wrtundo.cxx +++ b/sw/source/ui/wrtsh/wrtundo.cxx @@ -118,7 +118,7 @@ String SwWrtShell::GetDoString( DoType eDoType ) const { case UNDO: nResStr = STR_UNDO; - GetLastUndoInfo(& aUndoStr); + GetLastUndoInfo(& aUndoStr, 0); break; case REDO: nResStr = STR_REDO; |