summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mst@openoffice.org>2010-11-25 14:31:11 +0100
committerMichael Stahl <mst@openoffice.org>2010-11-25 14:31:11 +0100
commitd2ab337e8fd277143ac7e811f9f12ea15c592f6e (patch)
tree529613350e6ee7c7cc1050907e3630bd48986497
parent0cf92721c0f308a4644763b3bea0e0d6804ff268 (diff)
unodapi: #i115383#: clean up UndoActionCount:
remove static {Get,Set}UndoActionCount() from SwDoc, UndoManager, SwEditShell. use the already existing UndoOptions in SwModule instead. refactor the ugly hack with undo in SwInputWindow a little.
-rw-r--r--sw/inc/doc.hxx4
-rw-r--r--sw/inc/editsh.hxx4
-rw-r--r--sw/source/core/edit/edundo.cxx15
-rw-r--r--sw/source/core/inc/UndoManager.hxx5
-rw-r--r--sw/source/core/undo/docundo.cxx36
-rw-r--r--sw/source/ui/app/apphdl.cxx24
-rw-r--r--sw/source/ui/inc/inputwin.hxx21
-rwxr-xr-xsw/source/ui/ribbar/inputwin.cxx94
-rw-r--r--sw/source/ui/uiview/view.cxx4
9 files changed, 67 insertions, 140 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 08c56eb19d6f..ae99e62f80a9 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -798,10 +798,6 @@ public:
IDocumentUndoRedo & GetIDocumentUndoRedo();
IDocumentUndoRedo const& GetIDocumentUndoRedo() const;
- /** abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions */
- static sal_uInt16 GetUndoActionCount();
- static void SetUndoActionCount(sal_uInt16 nNew);
-
/** IDocumentLinksAdministration
*/
virtual bool IsVisibleLinks() const;
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 544c68ed0327..8780ea9eb7b7 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -535,10 +535,6 @@ public:
SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 );
SwUndoId GetUndoIds( String* pUndoStr = 0, SwUndoIds *pUndoIds = 0) const;
- // abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions
- static USHORT GetUndoActionCount();
- static void SetUndoActionCount( USHORT nNew );
-
// Redo
SwUndoId GetRedoIds( String* pRedoStr = 0, SwUndoIds *pRedoIds = 0) const;
diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx
index 832cc2dbaa19..c3614fca091a 100644
--- a/sw/source/core/edit/edundo.cxx
+++ b/sw/source/core/edit/edundo.cxx
@@ -240,21 +240,6 @@ USHORT SwEditShell::Repeat( USHORT nCount )
return bRet;
}
- // abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions
-
-USHORT SwEditShell::GetUndoActionCount()
-{
- return SwDoc::GetUndoActionCount();
-}
-
-
-void SwEditShell::SetUndoActionCount( USHORT nNew )
-{
- SwDoc::SetUndoActionCount( nNew );
-}
-
-
-
void lcl_SelectSdrMarkList( SwEditShell* pShell,
const SdrMarkList* pSdrMarkList )
diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx
index 7c6155d35c24..ef12215629aa 100644
--- a/sw/source/core/inc/UndoManager.hxx
+++ b/sw/source/core/inc/UndoManager.hxx
@@ -43,9 +43,6 @@ class UndoManager
: public IDocumentUndoRedo
{
public:
- /// max number of undo actions
- static sal_uInt16 GetUndoActionCount();
- static void SetUndoActionCount(sal_uInt16 nNew);
UndoManager(SwDoc & rDoc);
@@ -110,8 +107,6 @@ private:
with the given Id as UserId?
*/
bool HasUndoId(SwUndoId const eId) const;
- /// max number of Undo actions
-// static sal_uInt16 nUndoActions;
};
} // namespace sw
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 0b13baa8050e..553db79b6990 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -30,10 +30,13 @@
#include <UndoManager.hxx>
+#include <unotools/undoopt.hxx>
+
#include <vcl/wrkwin.hxx>
#include <svx/svdmodel.hxx>
+#include <swmodule.hxx>
#include <doc.hxx>
#include <ndarr.hxx>
#include <pam.hxx>
@@ -48,9 +51,6 @@
using namespace ::com::sun::star;
-/// max number of Undo actions
-static USHORT g_nUndoActions = UNDO_ACTION_COUNT;
-
// the undo array should never grow beyond this limit:
#define UNDO_ACTION_LIMIT (USHRT_MAX - 1000)
@@ -102,16 +102,6 @@ void UndoArrStatus::Paint( const Rectangle& )
// SwDoc methods /////////////////////////////////////////////////////////
-sal_uInt16 SwDoc::GetUndoActionCount()
-{
- return ::sw::UndoManager::GetUndoActionCount();
-}
-
-void SwDoc::SetUndoActionCount( sal_uInt16 nNew )
-{
- ::sw::UndoManager::SetUndoActionCount(nNew);
-}
-
sal_Bool SwDoc::RestoreInvisibleContent()
{
return GetUndoManager().RestoreInvisibleContent();
@@ -121,16 +111,6 @@ sal_Bool SwDoc::RestoreInvisibleContent()
namespace sw {
-sal_uInt16 UndoManager::GetUndoActionCount()
-{
- return g_nUndoActions;
-}
-
-void UndoManager::SetUndoActionCount( sal_uInt16 nNew )
-{
- g_nUndoActions = nNew;
-}
-
UndoManager::UndoManager(SwDoc & rDoc)
: m_rDoc(rDoc)
, m_pUndoNodes( new SwNodes(&rDoc) )
@@ -310,12 +290,13 @@ void UndoManager::AppendUndo(SwUndo *const pUndo)
}
#endif
- if (GetUndoActionCount() < nUndoCnt)
+ sal_Int32 const nActions(SW_MOD()->GetUndoOptions().GetUndoCount());
+ if (nActions < nUndoCnt)
{
// immer 1/10 loeschen
//JP 23.09.95: oder wenn neu eingestellt wurde um die Differenz
//JP 29.5.2001: Task #83891#: remove only the overlapping actions
- DelUndoObj( nUndoCnt - GetUndoActionCount() );
+ DelUndoObj( nUndoCnt - nActions );
}
else
{
@@ -611,12 +592,13 @@ UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter)
if( !--nUndoSttEnd )
{
++nUndoCnt;
- if (GetUndoActionCount() < nUndoCnt)
+ sal_Int32 const nActions(SW_MOD()->GetUndoOptions().GetUndoCount());
+ if (nActions < nUndoCnt)
{
// immer 1/10 loeschen
//JP 23.09.95: oder wenn neu eingestellt wurde um die Differenz
//JP 29.5.2001: Task #83891#: remove only the overlapping actions
- DelUndoObj( nUndoCnt - GetUndoActionCount() );
+ DelUndoObj( nUndoCnt - nActions );
}
else
{
diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx
index 84fe6705212a..1badfbe6dda1 100644
--- a/sw/source/ui/app/apphdl.cxx
+++ b/sw/source/ui/app/apphdl.cxx
@@ -800,22 +800,18 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, sal
}
else if( pBrdCst == pUndoOptions )
{
- const int nNew = GetUndoOptions().GetUndoCount();
- const int nOld = SwEditShell::GetUndoActionCount();
- if(!nNew || !nOld)
+ sal_Int32 const nNew = GetUndoOptions().GetUndoCount();
+ bool const bUndo = (nNew != 0);
+ // switch Undo for all DocShells
+ TypeId aType(TYPE(SwDocShell));
+ SwDocShell * pDocShell =
+ static_cast<SwDocShell *>(SfxObjectShell::GetFirst(&aType));
+ while (pDocShell)
{
- sal_Bool bUndo = nNew != 0;
- //ueber DocShells iterieren und Undo umschalten
-
- TypeId aType(TYPE(SwDocShell));
- SwDocShell* pDocShell = (SwDocShell*)SfxObjectShell::GetFirst(&aType);
- while( pDocShell )
- {
- pDocShell->GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
- pDocShell = (SwDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
- }
+ pDocShell->GetDoc()->GetIDocumentUndoRedo().DoUndo(bUndo);
+ pDocShell = static_cast<SwDocShell *>(
+ SfxObjectShell::GetNext(*pDocShell, &aType));
}
- SwEditShell::SetUndoActionCount( static_cast< USHORT >(nNew));
}
else if ( pBrdCst == pColorConfig || pBrdCst == pAccessibilityOptions )
{
diff --git a/sw/source/ui/inc/inputwin.hxx b/sw/source/ui/inc/inputwin.hxx
index 8693572d167f..c752b723937f 100644
--- a/sw/source/ui/inc/inputwin.hxx
+++ b/sw/source/ui/inc/inputwin.hxx
@@ -27,17 +27,11 @@
#ifndef SW_INPUTWIN_HXX
#define SW_INPUTWIN_HXX
-
-#ifndef _MENU_HXX //autogen
+#include <vcl/edit.hxx>
#include <vcl/menu.hxx>
-#endif
-#include <sfx2/childwin.hxx>
-#ifndef _TOOLBOX_HXX //autogen
#include <vcl/toolbox.hxx>
-#endif
-#ifndef _EDIT_HXX //autogen
-#include <vcl/edit.hxx>
-#endif
+
+#include <sfx2/childwin.hxx>
class SwFldMgr;
class SwWrtShell;
@@ -72,16 +66,17 @@ friend class InputEdit;
SwView* pView;
SfxBindings* pBindings;
String aAktTableName, sOldFml;
- USHORT nActionCnt;
+ sal_Int32 m_nActionCount;
BOOL bFirst : 1; //Initialisierungen beim ersten Aufruf
BOOL bActive : 1; //fuer Hide/Show beim Dokumentwechsel
BOOL bIsTable : 1;
BOOL bDelSel : 1;
- BOOL bDoesUndo : 1;
- BOOL bResetUndo : 1;
- BOOL bCallUndo : 1;
+ bool m_bDoesUndo : 1;
+ bool m_bResetUndo : 1;
+ bool m_bCallUndo : 1;
+ void CleanupUglyHackWithUndo();
void DelBoxCntnt();
DECL_LINK( ModifyHdl, InputEdit* );
diff --git a/sw/source/ui/ribbar/inputwin.cxx b/sw/source/ui/ribbar/inputwin.cxx
index e6d7bf26db80..ec85bc2a3bf6 100755
--- a/sw/source/ui/ribbar/inputwin.cxx
+++ b/sw/source/ui/ribbar/inputwin.cxx
@@ -36,6 +36,7 @@
#include <svx/ruler.hxx>
#include <svl/zforlist.hxx>
#include <svl/stritem.hxx>
+#include <unotools/undoopt.hxx>
#include "swtypes.hxx"
#include "cmdid.h"
@@ -74,9 +75,13 @@ SwInputWindow::SwInputWindow( Window* pParent, SfxBindings* pBind )
pView(0),
pBindings(pBind),
aAktTableName(aEmptyStr)
+ , m_nActionCount(0)
+ , m_bDoesUndo(true)
+ , m_bResetUndo(false)
+ , m_bCallUndo(false)
{
- bFirst = bDoesUndo = TRUE;
- bActive = bIsTable = bDelSel = bResetUndo = bCallUndo = FALSE;
+ bFirst = TRUE;
+ bActive = bIsTable = bDelSel = FALSE;
FreeResource();
@@ -143,16 +148,27 @@ __EXPORT SwInputWindow::~SwInputWindow()
if(pWrtShell)
pWrtShell->EndSelTblCells();
- if( bResetUndo )
+ CleanupUglyHackWithUndo();
+}
+
+void SwInputWindow::CleanupUglyHackWithUndo()
+{
+ if (m_bResetUndo)
{
DelBoxCntnt();
- pWrtShell->DoUndo( bDoesUndo );
- if(bCallUndo)
+ pWrtShell->DoUndo(m_bDoesUndo);
+ if (m_bCallUndo)
+ {
pWrtShell->Undo();
- SwEditShell::SetUndoActionCount( nActionCnt );
+ }
+ if (0 == m_nActionCount)
+ {
+ SW_MOD()->GetUndoOptions().SetUndoCount(0);
+ }
}
}
+
//==================================================================
void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
@@ -233,13 +249,17 @@ void SwInputWindow::ShowWin()
{
if( bIsTable )
{
- bResetUndo = TRUE;
- nActionCnt = SwEditShell::GetUndoActionCount();
- SwEditShell::SetUndoActionCount( nActionCnt + 1 );
+ m_bResetUndo = true;
+ m_nActionCount = SW_MOD()->GetUndoOptions().GetUndoCount();
+ if (0 == m_nActionCount) { // deactivated? turn it on...
+ SW_MOD()->GetUndoOptions().SetUndoCount(1);
+ }
- bDoesUndo = pWrtShell->DoesUndo();
- if( !bDoesUndo )
- pWrtShell->DoUndo( TRUE );
+ m_bDoesUndo = pWrtShell->DoesUndo();
+ if (!m_bDoesUndo)
+ {
+ pWrtShell->DoUndo(true);
+ }
if( !pWrtShell->SwCrsrShell::HasSelection() )
{
@@ -252,9 +272,11 @@ void SwInputWindow::ShowWin()
pWrtShell->StartUndo( UNDO_DELETE );
pWrtShell->Delete();
if( 0 != pWrtShell->EndUndo( UNDO_DELETE ))
- bCallUndo = TRUE;
+ {
+ m_bCallUndo = true;
+ }
}
- pWrtShell->DoUndo( FALSE );
+ pWrtShell->DoUndo(false);
SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
if( pWrtShell->GetTblBoxFormulaAttrs( aSet ))
@@ -376,15 +398,7 @@ void SwInputWindow::ApplyFormula()
{
pView->GetViewFrame()->GetDispatcher()->Lock(FALSE);
pView->GetEditWin().LockKeyInput(FALSE);
- if( bResetUndo )
- {
- DelBoxCntnt();
- pWrtShell->DoUndo( bDoesUndo );
- SwEditShell::SetUndoActionCount( nActionCnt );
- if( bCallUndo )
- pWrtShell->Undo();
- bResetUndo = FALSE;
- }
+ CleanupUglyHackWithUndo();
pWrtShell->Pop( FALSE );
// JP 13.01.97: Formel soll immer mit einem "=" beginnen, hier
@@ -411,15 +425,7 @@ void SwInputWindow::CancelFormula()
{
pView->GetViewFrame()->GetDispatcher()->Lock( FALSE );
pView->GetEditWin().LockKeyInput(FALSE);
- if( bResetUndo )
- {
- DelBoxCntnt();
- pWrtShell->DoUndo( bDoesUndo );
- SwEditShell::SetUndoActionCount( nActionCnt );
- if( bCallUndo )
- pWrtShell->Undo();
- bResetUndo = FALSE;
- }
+ CleanupUglyHackWithUndo();
pWrtShell->Pop( FALSE );
if( bDelSel )
@@ -496,7 +502,7 @@ void SwInputWindow::SetFormula( const String& rFormula, BOOL bDelFlag )
IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG )
{
- if( bIsTable && bResetUndo )
+ if (bIsTable && m_bResetUndo)
{
pWrtShell->StartAllAction();
DelBoxCntnt();
@@ -670,25 +676,3 @@ SfxChildWinInfo __EXPORT SwInputChild::GetInfo() const
return aInfo;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx
index 1b3858fbda2d..2444cdd847d2 100644
--- a/sw/source/ui/uiview/view.cxx
+++ b/sw/source/ui/uiview/view.cxx
@@ -974,9 +974,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh )
!pDocSh->GetVisArea(ASPECT_CONTENT).IsEmpty() )
SetVisArea( pDocSh->GetVisArea(ASPECT_CONTENT),sal_False);
- SwEditShell::SetUndoActionCount(
- static_cast< USHORT >( SW_MOD()->GetUndoOptions().GetUndoCount() ) );
- pWrtShell->DoUndo( 0 != SwEditShell::GetUndoActionCount() );
+ pWrtShell->DoUndo( 0 != SW_MOD()->GetUndoOptions().GetUndoCount() );
const BOOL bBrowse = pWrtShell->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
SetNewWindowAllowed(!bBrowse);