diff options
289 files changed, 7625 insertions, 8104 deletions
diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index a421cc8a164e..818fec8009c9 100644..100755 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -71,6 +71,7 @@ class SmPrintOptionsTabPage : public SfxTabPage MetricField aZoom; FixedLine aFixedLine3; CheckBox aNoRightSpaces; + CheckBox aSaveOnlyUsedSymbols; DECL_LINK(SizeButtonClickHdl, Button *); diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index f03cd43fc965..f8ffef16dfcd 100644..100755 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -29,19 +29,21 @@ #define SMDLL 1 -#include <sot/storage.hxx> -#include <sot/sotref.hxx> +#include <rtl/ustring.hxx> +#include <sfx2/docfac.hxx> #include <sfx2/objsh.hxx> +#include <sot/sotref.hxx> +#include <sot/storage.hxx> #include <svl/lstner.hxx> -#include <sfx2/docfac.hxx> +#include <vcl/jobset.hxx> #include <vcl/virdev.hxx> +#include <set> + #include "format.hxx" #include "parse.hxx" #include "smmod.hxx" -#include <vcl/jobset.hxx> - class SmNode; class SfxMenuBarManager; class SfxPrinter; @@ -124,6 +126,8 @@ class SmDocShell : public SfxObjectShell, public SfxListener USHORT nModifyCount; BOOL bIsFormulaArranged; + std::set< rtl::OUString > aUsedSymbols; // to export used symbols only when saving + virtual void SFX_NOTIFY(SfxBroadcaster& rBC, const TypeId& rBCType, @@ -200,6 +204,8 @@ public: const SmNode * GetFormulaTree() const { return pTree; } void SetFormulaTree(SmNode *&rTree) { pTree = rTree; } + const std::set< rtl::OUString > & GetUsedSymbols() const { return aUsedSymbols; } + String GetAccessibleText(); EditEngine & GetEditEngine(); @@ -210,7 +216,7 @@ public: void Repaint(); - virtual SfxUndoManager *GetUndoManager (); + virtual ::svl::IUndoManager *GetUndoManager (); virtual SfxItemPool& GetPool() const; diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx index facf17d561e2..e30193490539 100644..100755 --- a/starmath/inc/parse.hxx +++ b/starmath/inc/parse.hxx @@ -33,11 +33,16 @@ #include <tools/list.hxx> #include <tools/string.hxx> +#include <set> +#include <stack> +#include <list> + #include "types.hxx" class SmNode; class SmDocShell; +////////////////////////////////////////////////////////////////////// // TokenGroups #define TGOPER 0x00000001 @@ -113,17 +118,18 @@ enum SmTokenType struct SmToken { - // token text - String aText; - // token info - SmTokenType eType; + + String aText; // token text + SmTokenType eType; // token info sal_Unicode cMathChar; + // parse-help info - ULONG nGroup; - USHORT nLevel; + ULONG nGroup; + USHORT nLevel; + // token position - USHORT nRow; - xub_StrLen nCol; + USHORT nRow; + xub_StrLen nCol; SmToken(); }; @@ -152,6 +158,7 @@ struct SmErrorDesc String Text; }; + DECLARE_STACK(SmNodeStack, SmNode *) DECLARE_LIST(SmErrDescList, SmErrorDesc *) @@ -170,19 +177,22 @@ enum SmConvert class SmParser { - String BufferString; - SmToken CurToken; - SmNodeStack NodeStack; - SmErrDescList ErrDescList; - int CurError; - LanguageType nLang; - xub_StrLen BufferIndex, - nTokenIndex; - USHORT Row, - ColOff; - SmConvert eConversion; - BOOL bImportSymNames, - bExportSymNames; + String m_aBufferString; + SmToken m_aCurToken; + SmNodeStack m_aNodeStack; + SmErrDescList m_aErrDescList; + int m_nCurError; + LanguageType m_nLang; + xub_StrLen m_nBufferIndex, + m_nTokenIndex; + USHORT m_Row, + m_nColOff; + SmConvert m_eConversion; + BOOL m_bImportSymNames, + m_bExportSymNames; + + // map of used symbols (used to reduce file size by exporting only actually used symbols) + std::set< rtl::OUString > m_aUsedSymbols; // declare copy-constructor and assignment-operator private SmParser(const SmParser &); @@ -193,7 +203,7 @@ protected: BOOL IsDelimiter( const String &rTxt, xub_StrLen nPos ); #endif void NextToken(); - xub_StrLen GetTokenIndex() const { return nTokenIndex; } + xub_StrLen GetTokenIndex() const { return m_nTokenIndex; } void Insert(const String &rText, USHORT nPos); void Replace( USHORT nPos, USHORT nLen, const String &rText ); @@ -231,37 +241,43 @@ protected: void GlyphSpecial(); // end of grammar - LanguageType GetLanguage() const { return nLang; } - void SetLanguage( LanguageType nNewLang ) { nLang = nNewLang; } + LanguageType GetLanguage() const { return m_nLang; } + void SetLanguage( LanguageType nNewLang ) { m_nLang = nNewLang; } void Error(SmParseError Error); + void ClearUsedSymbols() { m_aUsedSymbols.clear(); } + void AddToUsedSymbols( const String &rSymbolName ) { m_aUsedSymbols.insert( rSymbolName ); } + public: SmParser(); SmNode *Parse(const String &rBuffer); - const String & GetText() const { return BufferString; }; + const String & GetText() const { return m_aBufferString; }; - SmConvert GetConversion() const { return eConversion; } - void SetConversion(SmConvert eConv) { eConversion = eConv; } + SmConvert GetConversion() const { return m_eConversion; } + void SetConversion(SmConvert eConv) { m_eConversion = eConv; } - BOOL IsImportSymbolNames() const { return bImportSymNames; } - void SetImportSymbolNames(BOOL bVal) { bImportSymNames = bVal; } - BOOL IsExportSymbolNames() const { return bExportSymNames; } - void SetExportSymbolNames(BOOL bVal) { bExportSymNames = bVal; } + BOOL IsImportSymbolNames() const { return m_bImportSymNames; } + void SetImportSymbolNames(BOOL bVal) { m_bImportSymNames = bVal; } + BOOL IsExportSymbolNames() const { return m_bExportSymNames; } + void SetExportSymbolNames(BOOL bVal) { m_bExportSymNames = bVal; } USHORT AddError(SmParseError Type, SmNode *pNode); const SmErrorDesc * NextError(); const SmErrorDesc * PrevError(); const SmErrorDesc * GetError(USHORT i = 0xFFFF); + + bool IsUsedSymbol( const String &rSymbolName ) const { return m_aUsedSymbols.find( rSymbolName ) != m_aUsedSymbols.end(); } + std::set< rtl::OUString > GetUsedSymbols() const { return m_aUsedSymbols; } }; inline BOOL SmParser::TokenInGroup(ULONG nGroup) { - return (CurToken.nGroup & nGroup) ? TRUE : FALSE; + return (m_aCurToken.nGroup & nGroup) ? TRUE : FALSE; } diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index 1b919471115c..7acefec94808 100644..100755 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -82,10 +82,9 @@ #define SID_CMDBOXWINDOW (SID_SMA_START + 122) #define SID_TOOLBOXWINDOW (SID_SMA_START + 123) #define SID_NO_RIGHT_SPACES (SID_SMA_START + 124) +#define SID_SAVE_ONLY_USED_SYMBOLS (SID_SMA_START + 125) #define SID_DUMMY (SID_SMA_START + 254) -//#define GID_FORMEL (RID_GROUPS_OFFSET + 1) -//#define GID_ERROR (RID_GROUPS_OFFSET + 2) //#define RID_OPTIONSDIALOG (RID_APP_START + 1) #define RID_FONTDIALOG (RID_APP_START + 2) @@ -100,8 +99,6 @@ #define RID_PRINTUIOPTIONS (RID_APP_START + 11) #define RID_MATH_TOOLBOX (RID_APP_START + 50) -// wegen #58705# entfernt -//#define RID_DRAW_OBJECTBAR (RID_APP_START + 51) #define RID_DEFAULTSAVEQUERY (RID_APP_START + 102) #define RID_WRITESYMBOLERROR (RID_APP_START + 202) diff --git a/starmath/inc/toolbox.hxx b/starmath/inc/toolbox.hxx index fcc1b046f2dd..fcc1b046f2dd 100755..100644 --- a/starmath/inc/toolbox.hxx +++ b/starmath/inc/toolbox.hxx diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index d414d1e72309..0eae96d02328 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -244,7 +244,7 @@ protected: const String& rText, USHORT MaxWidth); - virtual USHORT Print(SfxProgress &rProgress, BOOL bIsAPI, PrintDialog *pPrintDialog = 0); + virtual USHORT Print(SfxProgress &rProgress, BOOL bIsAPI); virtual SfxPrinter *GetPrinter(BOOL bCreate = FALSE); virtual USHORT SetPrinter(SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false); diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi index 4b9eaedac599..4b9eaedac599 100755..100644 --- a/starmath/sdi/smath.sdi +++ b/starmath/sdi/smath.sdi diff --git a/starmath/sdi/smslots.sdi b/starmath/sdi/smslots.sdi index 69cecf25f308..69cecf25f308 100755..100644 --- a/starmath/sdi/smslots.sdi +++ b/starmath/sdi/smslots.sdi diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index c8db4720b943..b654b22b2d66 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -111,7 +111,8 @@ static const char * aMathPropNames[] = "Print/Frame", "Print/Size", "Print/ZoomFactor", - //"Misc/NoSymbolsWarning", + "LoadSave/IsSaveOnlyUsedSymbols", + //"Misc/NoSymbolsWarning", @deprecated "Misc/IgnoreSpacesRight", "View/ToolboxVisible", "View/AutoRedraw", @@ -206,6 +207,7 @@ struct SmCfgOther BOOL bPrintTitle; BOOL bPrintFormulaText; BOOL bPrintFrame; + BOOL bIsSaveOnlyUsedSymbols; BOOL bIgnoreSpacesRight; BOOL bToolboxVisible; BOOL bAutoRedraw; @@ -223,7 +225,7 @@ SmCfgOther::SmCfgOther() bPrintTitle = bPrintFormulaText = bPrintFrame = bIgnoreSpacesRight = bToolboxVisible = bAutoRedraw = - bFormulaCursor = /*bNoSymbolsWarning =*/ TRUE; + bFormulaCursor = bIsSaveOnlyUsedSymbols = TRUE; } ///////////////////////////////////////////////////////////////// @@ -900,6 +902,10 @@ void SmMathConfig::LoadOther() // Print/ZoomFactor if (pVal->hasValue() && (*pVal >>= nTmp16)) pOther->nPrintZoomFactor = nTmp16; + ++pVal; + // LoadSave/IsSaveOnlyUsedSymbols + if (pVal->hasValue() && (*pVal >>= bTmp)) + pOther->bIsSaveOnlyUsedSymbols = bTmp; /* ++pVal; // Misc/NoSymbolsWarning if (pVal->hasValue() && (*pVal >>= bTmp)) @@ -951,6 +957,8 @@ void SmMathConfig::SaveOther() *pValue++ <<= (INT16) pOther->ePrintSize; // Print/ZoomFactor *pValue++ <<= (INT16) pOther->nPrintZoomFactor; + // LoadSave/IsSaveOnlyUsedSymbols + *pValue++ <<= (BOOL) pOther->bIsSaveOnlyUsedSymbols; /* // Misc/NoSymbolsWarning *pValue++ <<= (BOOL) pOther->bNoSymbolsWarning; */ @@ -1235,6 +1243,22 @@ void SmMathConfig::SetPrintFrame( BOOL bVal ) } +BOOL SmMathConfig::IsSaveOnlyUsedSymbols() const +{ + if (!pOther) + ((SmMathConfig *) this)->LoadOther(); + return pOther->bIsSaveOnlyUsedSymbols; +} + + +void SmMathConfig::SetSaveOnlyUsedSymbols( BOOL bVal ) +{ + if (!pOther) + LoadOther(); + SetOtherIfNotEqual( pOther->bIsSaveOnlyUsedSymbols, bVal ); +} + + BOOL SmMathConfig::IsIgnoreSpacesRight() const { if (!pOther) diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx index 8e3330a6466f..25cfdae309b6 100644 --- a/starmath/source/cfgitem.hxx +++ b/starmath/source/cfgitem.hxx @@ -196,6 +196,9 @@ public: USHORT GetPrintZoomFactor() const; void SetPrintZoomFactor( USHORT nVal ); + BOOL IsSaveOnlyUsedSymbols() const; + void SetSaveOnlyUsedSymbols( BOOL bVal ); + BOOL IsIgnoreSpacesRight() const; void SetIgnoreSpacesRight( BOOL bVal ); BOOL IsAutoRedraw() const; diff --git a/starmath/source/config.cxx b/starmath/source/config.cxx index 16b3b97afd96..c7adf9e07446 100644..100755 --- a/starmath/source/config.cxx +++ b/starmath/source/config.cxx @@ -101,6 +101,10 @@ void SmConfig::ItemSetToConfig(const SfxItemSet &rSet) Broadcast(SfxSimpleHint(HINT_FORMATCHANGED)); } } + if (rSet.GetItemState(SID_SAVE_ONLY_USED_SYMBOLS, TRUE, &pItem) == SFX_ITEM_SET) + { bVal = ((const SfxBoolItem *) pItem)->GetValue(); + SetSaveOnlyUsedSymbols( bVal ); + } SaveOther(); } @@ -120,6 +124,7 @@ void SmConfig::ConfigToItemSet(SfxItemSet &rSet) const rSet.Put(SfxBoolItem(pPool->GetWhich(SID_PRINTFRAME), IsPrintFrame())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_AUTOREDRAW), IsAutoRedraw())); rSet.Put(SfxBoolItem(pPool->GetWhich(SID_NO_RIGHT_SPACES), IsIgnoreSpacesRight())); + rSet.Put(SfxBoolItem(pPool->GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), IsSaveOnlyUsedSymbols())); } diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index a33ab14a98bf..15a644fcfba5 100644..100755 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -188,8 +188,9 @@ SmPrintOptionsTabPage::SmPrintOptionsTabPage(Window *pParent, const SfxItemSet & aSizeScaled (this, SmResId( RB_FIT_TO_PAGE )), aSizeZoomed (this, SmResId( RB_ZOOM )), aZoom (this, SmResId( MF_ZOOM )), - aFixedLine3 (this, SmResId( FL_MISC_OPTIONS )), - aNoRightSpaces (this, SmResId( CB_IGNORE_SPACING )) + aFixedLine3 (this, SmResId( FL_MISC_OPTIONS )), + aNoRightSpaces (this, SmResId( CB_IGNORE_SPACING )), + aSaveOnlyUsedSymbols (this, SmResId( CB_SAVE_ONLY_USED_SYMBOLS )) { FreeResource(); @@ -217,6 +218,7 @@ BOOL SmPrintOptionsTabPage::FillItemSet(SfxItemSet& rSet) rSet.Put(SfxBoolItem(GetWhich(SID_PRINTTEXT), aText.IsChecked())); rSet.Put(SfxBoolItem(GetWhich(SID_PRINTFRAME), aFrame.IsChecked())); rSet.Put(SfxBoolItem(GetWhich(SID_NO_RIGHT_SPACES), aNoRightSpaces.IsChecked())); + rSet.Put(SfxBoolItem(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS), aSaveOnlyUsedSymbols.IsChecked())); return TRUE; } @@ -238,6 +240,7 @@ void SmPrintOptionsTabPage::Reset(const SfxItemSet& rSet) aText.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTTEXT))).GetValue()); aFrame.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_PRINTFRAME))).GetValue()); aNoRightSpaces.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_NO_RIGHT_SPACES))).GetValue()); + aSaveOnlyUsedSymbols.Check(((const SfxBoolItem &)rSet.Get(GetWhich(SID_SAVE_ONLY_USED_SYMBOLS))).GetValue()); } diff --git a/starmath/source/dialog.hrc b/starmath/source/dialog.hrc index 29d87ba1d287..9e3e58493ab3 100644..100755 --- a/starmath/source/dialog.hrc +++ b/starmath/source/dialog.hrc @@ -31,17 +31,18 @@ #define FL_PRINTOPTIONS 10 #define CB_TITLEROW 11 -#define CB_EQUATION_TEXT 12 +#define CB_EQUATION_TEXT 12 #define CB_FRAME 13 #define FL_PRINT_FORMAT 20 -#define RB_ORIGINAL_SIZE 21 -#define RB_FIT_TO_PAGE 22 +#define RB_ORIGINAL_SIZE 21 +#define RB_FIT_TO_PAGE 22 #define RB_ZOOM 23 #define MF_ZOOM 24 #define FL_MISC_OPTIONS 30 -#define CB_IGNORE_SPACING 31 +#define CB_IGNORE_SPACING 31 +#define CB_SAVE_ONLY_USED_SYMBOLS 32 #define FT_FONTS_SUBSET 110 #define LB_FONTS_SUBSET 111 diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index 243e16fb6504..1f7271168e0a 100644..100755 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -78,7 +78,7 @@ #include <editeng/unolingu.hxx> #include <ucbhelper/content.hxx> #include <vcl/mapmod.hxx> -#include <vcl/mapunit.hxx> +#include <tools/mapunit.hxx> #include <vcl/msgbox.hxx> #include <sfx2/sfx.hrc> #include <document.hxx> @@ -98,6 +98,7 @@ #include "mathmlexport.hxx" #include <sfx2/sfxsids.hrc> #include <svx/svxids.hrc> +#include <tools/diagnose_ex.h> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -260,6 +261,8 @@ void SmDocShell::Parse() pTree = aInterpreter.Parse(aText); nModifyCount++; //! see comment for SID_GAPHIC_SM in SmDocShell::GetState SetFormulaArranged( FALSE ); + + aUsedSymbols = aInterpreter.GetUsedSymbols(); } @@ -1006,7 +1009,7 @@ void SmDocShell::Execute(SfxRequest& rReq) SmFormat aNewFormat( aOldFormat ); aNewFormat.SetTextmode(!aOldFormat.IsTextmode()); - SfxUndoManager *pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager(); if (pTmpUndoMgr) pTmpUndoMgr->AddUndoAction( new SmFormatAction(this, aOldFormat, aNewFormat)); @@ -1049,7 +1052,7 @@ void SmDocShell::Execute(SfxRequest& rReq) SmFormat aNewFormat( aOldFormat ); pFontTypeDialog->WriteTo(aNewFormat); - SfxUndoManager *pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager(); if (pTmpUndoMgr) pTmpUndoMgr->AddUndoAction( new SmFormatAction(this, aOldFormat, aNewFormat)); @@ -1073,7 +1076,7 @@ void SmDocShell::Execute(SfxRequest& rReq) pFontSizeDialog->WriteTo(aNewFormat); - SfxUndoManager *pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager(); if (pTmpUndoMgr) pTmpUndoMgr->AddUndoAction( new SmFormatAction(this, aOldFormat, aNewFormat)); @@ -1097,7 +1100,7 @@ void SmDocShell::Execute(SfxRequest& rReq) pDistanceDialog->WriteTo(aNewFormat); - SfxUndoManager *pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager(); if (pTmpUndoMgr) pTmpUndoMgr->AddUndoAction( new SmFormatAction(this, aOldFormat, aNewFormat)); @@ -1126,7 +1129,7 @@ void SmDocShell::Execute(SfxRequest& rReq) pAlignDialog->WriteTo( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt ); - SfxUndoManager *pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager *pTmpUndoMgr = GetUndoManager(); if (pTmpUndoMgr) pTmpUndoMgr->AddUndoAction( new SmFormatAction(this, aOldFormat, aNewFormat)); @@ -1149,7 +1152,7 @@ void SmDocShell::Execute(SfxRequest& rReq) case SID_UNDO: case SID_REDO: { - SfxUndoManager* pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager* pTmpUndoMgr = GetUndoManager(); if( pTmpUndoMgr ) { USHORT nId = rReq.GetSlot(), nCnt = 1; @@ -1158,22 +1161,29 @@ void SmDocShell::Execute(SfxRequest& rReq) if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( nId, FALSE, &pItem )) nCnt = ((SfxUInt16Item*)pItem)->GetValue(); - BOOL (SfxUndoManager:: *fnDo)( USHORT ); + BOOL (::svl::IUndoManager:: *fnDo)(); sal_uInt16 nCount; if( SID_UNDO == rReq.GetSlot() ) { nCount = pTmpUndoMgr->GetUndoActionCount(); - fnDo = &SfxUndoManager::Undo; + fnDo = &::svl::IUndoManager::Undo; } else { nCount = pTmpUndoMgr->GetRedoActionCount(); - fnDo = &SfxUndoManager::Redo; + fnDo = &::svl::IUndoManager::Redo; } - for( ; nCnt && nCount; --nCnt, --nCount ) - (pTmpUndoMgr->*fnDo)( 0 ); + try + { + for( ; nCnt && nCount; --nCnt, --nCount ) + (pTmpUndoMgr->*fnDo)(); + } + catch( const Exception& e ) + { + DBG_UNHANDLED_EXCEPTION(); + } } Repaint(); SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this ); @@ -1256,27 +1266,27 @@ void SmDocShell::GetState(SfxItemSet &rSet) case SID_GETUNDOSTRINGS: case SID_GETREDOSTRINGS: { - SfxUndoManager* pTmpUndoMgr = GetUndoManager(); + ::svl::IUndoManager* pTmpUndoMgr = GetUndoManager(); if( pTmpUndoMgr ) { - UniString(SfxUndoManager:: *fnGetComment)( USHORT ) const; + UniString(::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const; sal_uInt16 nCount; if( SID_GETUNDOSTRINGS == nWh ) { nCount = pTmpUndoMgr->GetUndoActionCount(); - fnGetComment = &SfxUndoManager::GetUndoActionComment; + fnGetComment = &::svl::IUndoManager::GetUndoActionComment; } else { nCount = pTmpUndoMgr->GetRedoActionCount(); - fnGetComment = &SfxUndoManager::GetRedoActionComment; + fnGetComment = &::svl::IUndoManager::GetRedoActionComment; } if( nCount ) { String sList; for( sal_uInt16 n = 0; n < nCount; ++n ) - ( sList += (pTmpUndoMgr->*fnGetComment)( n ) ) + ( sList += (pTmpUndoMgr->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) ) += '\n'; SfxStringListItem aItem( nWh ); @@ -1293,7 +1303,7 @@ void SmDocShell::GetState(SfxItemSet &rSet) } -SfxUndoManager *SmDocShell::GetUndoManager() +::svl::IUndoManager *SmDocShell::GetUndoManager() { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmDocShell::GetUndoManager" ); diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk index 5900fae65b87..c9f0226c8df4 100644..100755 --- a/starmath/source/makefile.mk +++ b/starmath/source/makefile.mk @@ -52,31 +52,31 @@ SRC2FILES = smres.src \ SLO1FILES = \ $(SLO)$/accessibility.obj \ - $(SLO)$/edit.obj \ - $(SLO)$/eqnolefilehdr.obj \ - $(SLO)$/mathmlexport.obj \ - $(SLO)$/mathmlimport.obj \ - $(SLO)$/symbol.obj \ - $(SLO)$/types.obj \ - $(SLO)$/unodoc.obj \ $(SLO)$/action.obj \ $(SLO)$/cfgitem.obj \ $(SLO)$/config.obj \ $(SLO)$/dialog.obj \ $(SLO)$/document.obj \ + $(SLO)$/edit.obj \ + $(SLO)$/eqnolefilehdr.obj \ $(SLO)$/format.obj \ + $(SLO)$/mathmlexport.obj \ + $(SLO)$/mathmlimport.obj \ $(SLO)$/mathtype.obj \ $(SLO)$/node.obj \ $(SLO)$/parse.obj \ + $(SLO)$/rect.obj \ $(SLO)$/register.obj \ $(SLO)$/smdll.obj \ + $(SLO)$/smmod.obj \ + $(SLO)$/symbol.obj \ $(SLO)$/toolbox.obj \ $(SLO)$/typemap.obj \ - $(SLO)$/smmod.obj \ + $(SLO)$/types.obj \ + $(SLO)$/unodoc.obj \ $(SLO)$/utility.obj \ - $(SLO)$/rect.obj \ - $(SLO)$/unomodel.obj \ - $(SLO)$/view.obj + $(SLO)$/view.obj \ + $(SLO)$/unomodel.obj SLO2FILES = \ $(SLO)$/register.obj \ diff --git a/starmath/source/math_pch.cxx b/starmath/source/math_pch.cxx deleted file mode 100644 index bcb768fe600b..000000000000 --- a/starmath/source/math_pch.cxx +++ /dev/null @@ -1,833 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_starmath.hxx" - -#define SMDLL 1 - -#include "starmath.hrc" - -#define ITEMID_FONT 1 -#define ITEMID_FONTHEIGHT 2 -#define ITEMID_LRSPACE 3 -#define ITEMID_WEIGHT 4 - -//--------- ab hier die "generierten" -#include <tools/string.hxx> -#include <tools/solar.h> -#include <tools/list.hxx> -#include <tools/contnr.hxx> -#include <tools/rtti.hxx> -#include <tools/ref.hxx> -#include <tools/link.hxx> -#include <svl/brdcst.hxx> -#include <svl/svarray.hxx> -#include <tools/debug.hxx> -#include <svl/hint.hxx> -#include <svl/smplhint.hxx> -#include <sot/sotref.hxx> -#include <tools/globname.hxx> -#include <sot/factory.hxx> -#include <vcl/sv.h> -#include <basic/sbxdef.hxx> -#include <tools/time.hxx> -#include <tools/gen.hxx> -#include <tools/stream.hxx> -#include <tools/errinf.hxx> -#include <tools/errcode.hxx> -#include <sot/object.hxx> -#include <sot/sotdata.hxx> -#include <sfx2/shell.hxx> -#include <sal/types.h> -#include <sal/config.h> -#include <tools/date.hxx> -#include <tools/ownlist.hxx> -#include <vcl/accel.hxx> -#include <tools/resid.hxx> -#include <tools/rc.hxx> -#include <tools/rc.hxx> -#include <i18npool/lang.h> -#include <tools/resmgr.hxx> -#include <vcl/keycod.hxx> -#include <vcl/keycodes.hxx> -#include <vcl/vclenum.hxx> -#include <vcl/timer.hxx> -#include <vcl/cmdevt.hxx> -#include <vcl/font.hxx> -#include <tools/color.hxx> -#include <vcl/outdev.hxx> -#include <vcl/region.hxx> -#include <vcl/mapmod.hxx> -#include <tools/fract.hxx> -#include <vcl/wall.hxx> -#include <vcl/settings.hxx> -#include <vcl/bitmap.hxx> -#include <vcl/pointr.hxx> -#include <vcl/ptrstyle.hxx> -#include <vcl/wintypes.hxx> -#include <vcl/inputctx.hxx> -#include <vcl/event.hxx> -#include <format.hxx> -#include <utility.hxx> -#include <vcl/fixed.hxx> -#include <vcl/image.hxx> -#include <vcl/ctrl.hxx> -#include <vcl/window.hxx> -#include <sfx2/minarray.hxx> -#include <vcl/combobox.hxx> -#include <vcl/combobox.h> -#include <vcl/edit.hxx> -#include <vcl/menu.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/lstbox.h> -#include <usr/guid.hxx> -#include <usr/sequ.hxx> -#include <uno/types.h> -#include <uno/macros.h> -#include <vos/xception.hxx> -#include <osl/mutex.h> -#include <tools/shl.hxx> -#include <sfx2/module.hxx> -#include <sfx2/imgdef.hxx> -#include <usr/uno.hxx> -#include <usr/xiface.hxx> -#include <usr/ustring.hxx> -#include <vos/refernce.hxx> -#include <vos/types.hxx> -#include <osl/types.h> -#include <osl/interlck.h> -#include <vos/object.hxx> -#include <vos/macros.hxx> -#include <smdll.hxx> -#include <sfx2/sfxsids.hrc> -#include <chaos/cntids.hrc> -#include <svl/cntwids.hrc> -#include <svl/solar.hrc> -#include <svl/lstner.hxx> -#include <starmath.hrc> -#include <basic/sbx.hxx> -#include <basic/sbxform.hxx> -#include <basic/sbxobj.hxx> -#include <basic/sbxvar.hxx> -#include <basic/sbxcore.hxx> -#include <basic/sbxprop.hxx> -#include <basic/sbxmeth.hxx> -#include <tools/unqid.hxx> -#include <tools/unqidx.hxx> -#include <svl/poolitem.hxx> -#include <svtools/args.hxx> -#include <smmod.hxx> -#include <vos/thread.hxx> -#include <osl/thread.h> -#include <vos/runnable.hxx> -#include <vcl/apptypes.hxx> -#include <tools/dynary.hxx> -#include <vcl/metric.hxx> -#include <vcl/svapp.hxx> -#include <vcl/timer.hxx> -#include <sfx2/app.hxx> -#include <sfx2/sfx.hrc> -#include <svl/memberid.hrc> -#include <vcl/syswin.hxx> -#include <vcl/virdev.hxx> -#include <tools/datetime.hxx> -#include <tools/wldcrd.hxx> -#include <parse.hxx> -#include <tools/stack.hxx> -#include <types.hxx> -#include <config.hxx> -#include <svtools/confitem.hxx> -#include <tools/poly.hxx> -#include <svx/xpoly.hxx> -#include <rect.hxx> -#include <vcl/outdev.hxx> -#ifndef _SMART_COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTOR_HXX_ -#include <smart/com/sun/star/frame/XDispatchProviderInterceptor.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XDISPATCH_HXX_ -#include <smart/com/sun/star/frame/XDispatch.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HXX_ -#include <smart/com/sun/star/frame/XDispatchProvider.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XSTATUSLISTENER_HXX_ -#include <smart/com/sun/star/frame/XStatusListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_FRAMESEARCHFLAG_HXX_ -#include <smart/com/sun/star/frame/FrameSearchFlag.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XDISPATCHPROVIDERINTERCEPTION_HXX_ -#include <smart/com/sun/star/frame/XDispatchProviderInterception.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_FEATURESTATEEVENT_HXX_ -#include <smart/com/sun/star/frame/FeatureStateEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_DISPATCHDESCRIPTOR_HXX_ -#include <smart/com/sun/star/frame/DispatchDescriptor.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XFRAMEACTIONLISTENER_HXX_ -#include <smart/com/sun/star/frame/XFrameActionListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HXX_ -#include <smart/com/sun/star/frame/XComponentLoader.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XFRAME_HXX_ -#include <smart/com/sun/star/frame/XFrame.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_FRAMEACTIONEVENT_HXX_ -#include <smart/com/sun/star/frame/FrameActionEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_FRAMEACTION_HXX_ -#include <smart/com/sun/star/frame/FrameAction.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_UTIL_XURLTRANSFORMER_HXX_ -#include <smart/com/sun/star/util/XURLTransformer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_TASK_XSTATUSINDICATORFACTORY_HXX_ -#include <smart/com/sun/star/task/XStatusIndicatorFactory.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_TASK_XSTATUSINDICATORSUPPLIER_HXX_ -#include <smart/com/sun/star/task/XStatusIndicatorSupplier.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_TASK_XSTATUSINDICATOR_HXX_ -#include <smart/com/sun/star/task/XStatusIndicator.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_FRAME_XBROWSEHISTORYREGISTRY_HXX_ -#include <smart/com/sun/star/frame/XBrowseHistoryRegistry.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_IO_BUFFERSIZEEXCEEDEDEXCEPTION_HXX_ -#include <smart/com/sun/star/io/BufferSizeExceededException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_IO_NOTCONNECTEDEXCEPTION_HXX_ -#include <smart/com/sun/star/io/NotConnectedException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_IO_IOEXCEPTION_HXX_ -#include <smart/com/sun/star/io/IOException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_IO_UNEXPECTEDEOFEXCEPTION_HXX_ -#include <smart/com/sun/star/io/UnexpectedEOFException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_IO_WRONGFORMATEXCEPTION_HXX_ -#include <smart/com/sun/star/io/WrongFormatException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_SERVICENOTREGISTEREDEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/ServiceNotRegisteredException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_NULLPOINTEREXCEPTION_HXX_ -#include <smart/com/sun/star/lang/NullPointerException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_CLASSNOTFOUNDEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/ClassNotFoundException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_NOSUCHMETHODEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/NoSuchMethodException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_SECURITYEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/SecurityException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_NOSUCHFIELDEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/NoSuchFieldException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/DisposedException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_ARRAYINDEXOUTOFBOUNDSEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/ArrayIndexOutOfBoundsException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_ILLEGALACCESSEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/IllegalAccessException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_INDEXOUTOFBOUNDSEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/IndexOutOfBoundsException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/IllegalArgumentException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_NOSUPPORTEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/NoSupportException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_WRAPPEDTARGETEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/WrappedTargetException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_PARAMINFO_HXX_ -#include <smart/com/sun/star/reflection/ParamInfo.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLARRAY_HXX_ -#include <smart/com/sun/star/reflection/XIdlArray.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLCLASSPROVIDER_HXX_ -#include <smart/com/sun/star/reflection/XIdlClassProvider.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_FIELDACCESSMODE_HXX_ -#include <smart/com/sun/star/reflection/FieldAccessMode.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLCLASS_HXX_ -#include <smart/com/sun/star/reflection/XIdlClass.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLFIELD_HXX_ -#include <smart/com/sun/star/reflection/XIdlField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_PARAMMODE_HXX_ -#include <smart/com/sun/star/reflection/ParamMode.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_METHODMODE_HXX_ -#include <smart/com/sun/star/reflection/MethodMode.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLMEMBER_HXX_ -#include <smart/com/sun/star/reflection/XIdlMember.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLREFLECTION_HXX_ -#include <smart/com/sun/star/reflection/XIdlReflection.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_XIDLMETHOD_HXX_ -#include <smart/com/sun/star/reflection/XIdlMethod.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_REFLECTION_INVOCATIONTARGETEXCEPTION_HXX_ -#include <smart/com/sun/star/reflection/InvocationTargetException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYVALUES_HXX_ -#include <smart/com/sun/star/beans/PropertyValues.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYSET_HXX_ -#include <smart/com/sun/star/beans/XPropertySet.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_ -#include <smart/com/sun/star/beans/PropertyValue.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYSTATE_HXX_ -#include <smart/com/sun/star/beans/PropertyState.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HXX_ -#include <smart/com/sun/star/beans/XPropertySetInfo.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XMULTIPROPERTYSET_HXX_ -#include <smart/com/sun/star/beans/XMultiPropertySet.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XFASTPROPERTYSET_HXX_ -#include <smart/com/sun/star/beans/XFastPropertySet.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XVETOABLECHANGELISTENER_HXX_ -#include <smart/com/sun/star/beans/XVetoableChangeListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYSTATE_HXX_ -#include <smart/com/sun/star/beans/XPropertyState.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYSTATECHANGELISTENER_HXX_ -#include <smart/com/sun/star/beans/XPropertyStateChangeListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HXX_ -#include <smart/com/sun/star/beans/PropertyAttribute.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTIESCHANGELISTENER_HXX_ -#include <smart/com/sun/star/beans/XPropertiesChangeListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HXX_ -#include <smart/com/sun/star/beans/XPropertyChangeListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYACCESS_HXX_ -#include <smart/com/sun/star/beans/XPropertyAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HXX_ -#include <smart/com/sun/star/beans/XPropertyContainer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYSTATECHANGEEVENT_HXX_ -#include <smart/com/sun/star/beans/PropertyStateChangeEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HXX_ -#include <smart/com/sun/star/beans/PropertyChangeEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_UNKNOWNPROPERTYEXCEPTION_HXX_ -#include <smart/com/sun/star/beans/UnknownPropertyException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_INTROSPECTIONEXCEPTION_HXX_ -#include <smart/com/sun/star/beans/IntrospectionException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYEXISTEXCEPTION_HXX_ -#include <smart/com/sun/star/beans/PropertyExistException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_ILLEGALTYPEEXCEPTION_HXX_ -#include <smart/com/sun/star/beans/IllegalTypeException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_BEANS_PROPERTYVETOEXCEPTION_HXX_ -#include <smart/com/sun/star/beans/PropertyVetoException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HXX_ -#include <smart/com/sun/star/container/XEnumerationAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMEACCESS_HXX_ -#include <smart/com/sun/star/container/XHierarchicalNameAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XNAMEACCESS_HXX_ -#include <smart/com/sun/star/container/XNameAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XCONTENTENUMERATIONACCESS_HXX_ -#include <smart/com/sun/star/container/XContentEnumerationAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XENUMERATION_HXX_ -#include <smart/com/sun/star/container/XEnumeration.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XELEMENTACCESS_HXX_ -#include <smart/com/sun/star/container/XElementAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XINDEXACCESS_HXX_ -#include <smart/com/sun/star/container/XIndexAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_XEVENTLISTENER_HXX_ -#include <smart/com/sun/star/lang/XEventListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_EVENTOBJECT_HXX_ -#include <smart/com/sun/star/lang/EventObject.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_SCRIPT_XALLLISTENERADAPTERSERVICE_HXX_ -#include <smart/com/sun/star/script/XAllListenerAdapterService.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_SCRIPT_XALLLISTENER_HXX_ -#include <smart/com/sun/star/script/XAllListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_SCRIPT_ALLEVENTOBJECT_HXX_ -#include <smart/com/sun/star/script/AllEventObject.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XCOMPONENTENUMERATION_HXX_ -#include <smart/com/sun/star/container/XComponentEnumeration.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_XCOMPONENT_HXX_ -#include <smart/com/sun/star/lang/XComponent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_XCOMPONENTENUMERATIONACCESS_HXX_ -#include <smart/com/sun/star/container/XComponentEnumerationAccess.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_LISTENEREXISTEXCEPTION_HXX_ -#include <smart/com/sun/star/lang/ListenerExistException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_ELEMENTEXISTEXCEPTION_HXX_ -#include <smart/com/sun/star/container/ElementExistException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_LANG_INVALIDLISTENEREXCEPTION_HXX_ -#include <smart/com/sun/star/lang/InvalidListenerException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_CONTAINER_NOSUCHELEMENTEXCEPTION_HXX_ -#include <smart/com/sun/star/container/NoSuchElementException.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XKEYLISTENER_HXX_ -#include <smart/com/sun/star/awt/XKeyListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XPAINTLISTENER_HXX_ -#include <smart/com/sun/star/awt/XPaintListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_KEYEVENT_HXX_ -#include <smart/com/sun/star/awt/KeyEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_KEYMODIFIER_HXX_ -#include <smart/com/sun/star/awt/KeyModifier.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XMOUSEMOTIONLISTENER_HXX_ -#include <smart/com/sun/star/awt/XMouseMotionListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FOCUSEVENT_HXX_ -#include <smart/com/sun/star/awt/FocusEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XWINDOWLISTENER_HXX_ -#include <smart/com/sun/star/awt/XWindowListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XACTIVATELISTENER_HXX_ -#include <smart/com/sun/star/awt/XActivateListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_MOUSEEVENT_HXX_ -#include <smart/com/sun/star/awt/MouseEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTOPWINDOWLISTENER_HXX_ -#include <smart/com/sun/star/awt/XTopWindowListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_PAINTEVENT_HXX_ -#include <smart/com/sun/star/awt/PaintEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_INPUTEVENT_HXX_ -#include <smart/com/sun/star/awt/InputEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_KEYGROUP_HXX_ -#include <smart/com/sun/star/awt/KeyGroup.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_KEY_HXX_ -#include <smart/com/sun/star/awt/Key.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_WINDOWEVENT_HXX_ -#include <smart/com/sun/star/awt/WindowEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XMOUSELISTENER_HXX_ -#include <smart/com/sun/star/awt/XMouseListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_KEYFUNCTION_HXX_ -#include <smart/com/sun/star/awt/KeyFunction.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FOCUSCHANGEREASON_HXX_ -#include <smart/com/sun/star/awt/FocusChangeReason.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_MOUSEBUTTON_HXX_ -#include <smart/com/sun/star/awt/MouseButton.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XFOCUSLISTENER_HXX_ -#include <smart/com/sun/star/awt/XFocusListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XADJUSTMENTLISTENER_HXX_ -#include <smart/com/sun/star/awt/XAdjustmentListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XACTIONLISTENER_HXX_ -#include <smart/com/sun/star/awt/XActionListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTEXTLISTENER_HXX_ -#include <smart/com/sun/star/awt/XTextListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XSPINLISTENER_HXX_ -#include <smart/com/sun/star/awt/XSpinListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XITEMLISTENER_HXX_ -#include <smart/com/sun/star/awt/XItemListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XVCLCONTAINERLISTENER_HXX_ -#include <smart/com/sun/star/awt/XVclContainerListener.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XFILEDIALOG_HXX_ -#include <smart/com/sun/star/awt/XFileDialog.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTEXTCOMPONENT_HXX_ -#include <smart/com/sun/star/awt/XTextComponent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XLISTBOX_HXX_ -#include <smart/com/sun/star/awt/XListBox.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XPROGRESSMONITOR_HXX_ -#include <smart/com/sun/star/awt/XProgressMonitor.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_TEXTALIGN_HXX_ -#include <smart/com/sun/star/awt/TextAlign.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XSCROLLBAR_HXX_ -#include <smart/com/sun/star/awt/XScrollBar.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XVCLCONTAINERPEER_HXX_ -#include <smart/com/sun/star/awt/XVclContainerPeer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTABCONTROLLERMODEL_HXX_ -#include <smart/com/sun/star/awt/XTabControllerModel.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XMESSAGEBOX_HXX_ -#include <smart/com/sun/star/awt/XMessageBox.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTEXTEDITFIELD_HXX_ -#include <smart/com/sun/star/awt/XTextEditField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_STYLE_HXX_ -#include <smart/com/sun/star/awt/Style.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTIMEFIELD_HXX_ -#include <smart/com/sun/star/awt/XTimeField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XVCLWINDOWPEER_HXX_ -#include <smart/com/sun/star/awt/XVclWindowPeer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCONTROLMODEL_HXX_ -#include <smart/com/sun/star/awt/XControlModel.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XSPINFIELD_HXX_ -#include <smart/com/sun/star/awt/XSpinField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XUNOCONTROLCONTAINER_HXX_ -#include <smart/com/sun/star/awt/XUnoControlContainer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTEXTLAYOUTCONSTRAINS_HXX_ -#include <smart/com/sun/star/awt/XTextLayoutConstrains.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XNUMERICFIELD_HXX_ -#include <smart/com/sun/star/awt/XNumericField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XBUTTON_HXX_ -#include <smart/com/sun/star/awt/XButton.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTEXTAREA_HXX_ -#include <smart/com/sun/star/awt/XTextArea.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XIMAGEBUTTON_HXX_ -#include <smart/com/sun/star/awt/XImageButton.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XFIXEDTEXT_HXX_ -#include <smart/com/sun/star/awt/XFixedText.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCONTROLCONTAINER_HXX_ -#include <smart/com/sun/star/awt/XControlContainer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XDIALOG_HXX_ -#include <smart/com/sun/star/awt/XDialog.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SCROLLBARORIENTATION_HXX_ -#include <smart/com/sun/star/awt/ScrollBarOrientation.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XRADIOBUTTON_HXX_ -#include <smart/com/sun/star/awt/XRadioButton.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCURRENCYFIELD_HXX_ -#include <smart/com/sun/star/awt/XCurrencyField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XPATTERNFIELD_HXX_ -#include <smart/com/sun/star/awt/XPatternField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_VCLWINDOWPEERATTRIBUTE_HXX_ -#include <smart/com/sun/star/awt/VclWindowPeerAttribute.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTABCONTROLLER_HXX_ -#include <smart/com/sun/star/awt/XTabController.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XVCLCONTAINER_HXX_ -#include <smart/com/sun/star/awt/XVclContainer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XDATEFIELD_HXX_ -#include <smart/com/sun/star/awt/XDateField.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCOMBOBOX_HXX_ -#include <smart/com/sun/star/awt/XComboBox.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCONTROL_HXX_ -#include <smart/com/sun/star/awt/XControl.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XCHECKBOX_HXX_ -#include <smart/com/sun/star/awt/XCheckBox.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_MESSAGEBOXCOMMAND_HXX_ -#include <smart/com/sun/star/awt/MessageBoxCommand.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XLAYOUTCONSTRAINS_HXX_ -#include <smart/com/sun/star/awt/XLayoutConstrains.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XPROGRESSBAR_HXX_ -#include <smart/com/sun/star/awt/XProgressBar.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SIMPLEFONTMETRIC_HXX_ -#include <smart/com/sun/star/awt/SimpleFontMetric.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTWEIGHT_HXX_ -#include <smart/com/sun/star/awt/FontWeight.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTSLANT_HXX_ -#include <smart/com/sun/star/awt/FontSlant.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_CHARSET_HXX_ -#include <smart/com/sun/star/awt/CharSet.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTDESCRIPTOR_HXX_ -#include <smart/com/sun/star/awt/FontDescriptor.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTWIDTH_HXX_ -#include <smart/com/sun/star/awt/FontWidth.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XFONT_HXX_ -#include <smart/com/sun/star/awt/XFont.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTTYPE_HXX_ -#include <smart/com/sun/star/awt/FontType.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTUNDERLINE_HXX_ -#include <smart/com/sun/star/awt/FontUnderline.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTSTRIKEOUT_HXX_ -#include <smart/com/sun/star/awt/FontStrikeout.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTFAMILY_HXX_ -#include <smart/com/sun/star/awt/FontFamily.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_FONTPITCH_HXX_ -#include <smart/com/sun/star/awt/FontPitch.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTOPWINDOW_HXX_ -#include <smart/com/sun/star/awt/XTopWindow.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XWINDOW_HXX_ -#include <smart/com/sun/star/awt/XWindow.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_POSSIZE_HXX_ -#include <smart/com/sun/star/awt/PosSize.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_VCLCONTAINEREVENT_HXX_ -#include <smart/com/sun/star/awt/VclContainerEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_ITEMEVENT_HXX_ -#include <smart/com/sun/star/awt/ItemEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SPINEVENT_HXX_ -#include <smart/com/sun/star/awt/SpinEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_TEXTEVENT_HXX_ -#include <smart/com/sun/star/awt/TextEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_ADJUSTMENTTYPE_HXX_ -#include <smart/com/sun/star/awt/AdjustmentType.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_ACTIONEVENT_HXX_ -#include <smart/com/sun/star/awt/ActionEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_ADJUSTMENTEVENT_HXX_ -#include <smart/com/sun/star/awt/AdjustmentEvent.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_RECTANGLE_HXX_ -#include <smart/com/sun/star/awt/Rectangle.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SELECTION_HXX_ -#include <smart/com/sun/star/awt/Selection.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SIZE_HXX_ -#include <smart/com/sun/star/awt/Size.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_WINDOWDESCRIPTOR_HXX_ -#include <smart/com/sun/star/awt/WindowDescriptor.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_INVALIDATESTYLE_HXX_ -#include <smart/com/sun/star/awt/InvalidateStyle.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XTOOLKIT_HXX_ -#include <smart/com/sun/star/awt/XToolkit.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XWINDOWPEER_HXX_ -#include <smart/com/sun/star/awt/XWindowPeer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_WINDOWCLASS_HXX_ -#include <smart/com/sun/star/awt/WindowClass.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XSYSTEMDEPENDENTWINDOWPEER_HXX_ -#include <smart/com/sun/star/awt/XSystemDependentWindowPeer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_WINDOWATTRIBUTE_HXX_ -#include <smart/com/sun/star/awt/WindowAttribute.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XPOINTER_HXX_ -#include <smart/com/sun/star/awt/XPointer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_SYSTEMPOINTER_HXX_ -#include <smart/com/sun/star/awt/SystemPointer.hxx> -#endif -#ifndef _SMART_COM_SUN_STAR_AWT_XVIEW_HXX_ -#include <smart/com/sun/star/awt/XView.hxx> -#endif -#include <usr/refl.hxx> -#include <sfx2/msg.hxx> -#include <svl/itemset.hxx> -#include <sfx2/basedlgs.hxx> -#include <vcl/floatwin.hxx> -#include <vcl/dialog.hxx> -#include <vcl/window.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/frame.hxx> -#include <sfx2/objface.hxx> -#include <vcl/event.hxx> -#include <svl/eitem.hxx> -#include <svl/intitem.hxx> -#include <symbol.hxx> -#include <svl/itempool.hxx> -#include <vcl/image.hxx> -#include <vcl/metric.hxx> -#include <sfx2/inimgr.hxx> -#include <node.hxx> -#include <tools/pstm.hxx> -#include <tools/table.hxx> -#include <sfx2/docfac.hxx> -#include <svl/ownlist.hxx> -#include <sfx2/objsh.hxx> -#include <svl/stritem.hxx> -#include <vcl/mapmod.hxx> -#include <sfx2/ipfrm.hxx> -#include <vcl/dialog.hxx> -#include <sfx2/dispatch.hxx> -#include <svl/svstdarr.hxx> -#include <sfx2/bindings.hxx> -#include <dialog.hxx> -#include <vcl/button.hxx> -#include <vcl/symbol.hxx> -#include <sfx2/tabdlg.hxx> -#include <vcl/button.hxx> -#include <vcl/tabdlg.hxx> -#include <vcl/tabpage.hxx> -#include <vcl/tabctrl.hxx> -#include <vcl/group.hxx> -#include <svx/optgenrl.hxx> -#include <vcl/fixed.hxx> -#include <vcl/edit.hxx> -#include <vcl/group.hxx> -#include <document.hxx> -#include <vcl/field.hxx> -#include <vcl/spinfld.hxx> -#include <vcl/menubtn.hxx> -#include <vcl/scrbar.hxx> -#include <svtools/ctrlbox.hxx> -#include <vcl/lstbox.hxx> -#include <vcl/virdev.hxx> -#include <vcl/combobox.hxx> -#include <vcl/field.hxx> -#include <svtools/ctrltool.hxx> -#include <sfx2/interno.hxx> -#include <sfx2/sfxdefs.hxx> -#include <sfx2/childwin.hxx> -#include <sfx2/chalign.hxx> -#include <vcl/floatwin.hxx> -#include <sot/storage.hxx> -#include <rsc/rscsfx.hxx> -#include <vcl/msgbox.hxx> -#include <vcl/btndlg.hxx> -#include <uno/uno.h> -#include <uno/string.h> -#include <uno/sequence.h> -#include <uno/any.h> -#include <uno/exceptn.h> -#include <uno/intrface.h> -#include <uno/factory.h> -#include <uno/api.h> -#include <svx/svxids.hrc> -#include <view.hxx> -#include <sfx2/dockwin.hxx> -#include <vcl/dockwin.hxx> -#include <sfx2/viewsh.hxx> -#include <sfx2/clientsh.hxx> -#include <svtools/scrwin.hxx> -#include <vcl/scrbar.hxx> -#include <sfx2/ctrlitem.hxx> -#include <sfx2/viewfac.hxx> -#include <edit.hxx> -#include <editeng/editdata.hxx> -#include <toolbox.hxx> -#include <vcl/toolbox.hxx> -#include <vcl/dockwin.hxx> -#include <smslots.hxx> -#include <svl/undo.hxx> -#include <sfx2/request.hxx> -#include <svl/whiter.hxx> -#include <vcl/prntypes.hxx> -#include <vcl/jobset.hxx> -#include <vcl/gdimtf.hxx> -#include <sot/exchange.hxx> -#include <vcl/wrkwin.hxx> -#include <tools/sstring.hxx> -#include <action.hxx> -#include <sfx2/filedlg.hxx> -#include <sfx2/iodlg.hxx> diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index bec69eb01b95..711ac2535a9b 100644..100755 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -79,6 +79,7 @@ #include <unomodel.hxx> #include <document.hxx> #include <utility.hxx> +#include <config.hxx> using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; @@ -742,6 +743,9 @@ void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) PropertyValue* pProps = rProps.getArray(); if (pProps) { + SmConfig *pConfig = SM_MOD()->GetConfig(); + const bool bUsedSymbolsOnly = pConfig ? pConfig->IsSaveOnlyUsedSymbols() : false; + const OUString sFormula ( RTL_CONSTASCII_USTRINGPARAM ( "Formula" ) ); const OUString sBasicLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "BasicLibraries" ) ); const OUString sDialogLibraries ( RTL_CONSTASCII_USTRINGPARAM ( "DialogLibraries" ) ); @@ -755,7 +759,14 @@ void SmXMLExport::GetConfigurationSettings( Sequence < PropertyValue > & rProps) rPropName != sRuntimeUID) { pProps->Name = rPropName; - pProps->Value = xProps->getPropertyValue(rPropName); + + rtl::OUString aActualName( rPropName ); + + // handle 'save used symbols only' + if (bUsedSymbolsOnly && rPropName.equalsAscii("Symbols")) + aActualName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "UserDefinedSymbolsInUse" ) ); + + pProps->Value = xProps->getPropertyValue( aActualName ); } } } @@ -784,7 +795,8 @@ void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel) SvXMLElementExport *pRow=0; ULONG nSize = pNode->GetNumSubNodes(); - if (nSize > 1) + // #i115443: nodes of type expression always need to be grouped with mrow statement + if (nSize > 1 || (pNode && pNode->GetType() == NEXPRESSION)) pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, sal_True, sal_True); //if (nSize) diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index 36c009757eac..4364c60b9e10 100644..100755 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -1613,8 +1613,11 @@ public: void SmXMLSubContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup eSubSup) { /*The <msub> element requires exactly 2 arguments.*/ - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, - "Sub has not two arguments"); + const bool bNodeCheck = GetSmImport().GetNodeStack().Count() - nElementCount == 2; + DBG_ASSERT( bNodeCheck, "Sub has not two arguments" ); + if (!bNodeCheck) + return; + SmToken aToken; aToken.cMathChar = '\0'; aToken.nGroup = 0; @@ -1672,8 +1675,10 @@ void SmXMLSubSupContext_Impl::GenericEndElement(SmTokenType eType, SmSubSup aSub,SmSubSup aSup) { /*The <msub> element requires exactly 3 arguments.*/ - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 3, - "SubSup has not three arguments"); + const bool bNodeCheck = GetSmImport().GetNodeStack().Count() - nElementCount == 3; + DBG_ASSERT( bNodeCheck, "SubSup has not three arguments" ); + if (!bNodeCheck) + return; SmToken aToken; aToken.cMathChar = '\0'; @@ -1721,8 +1726,10 @@ void SmXMLUnderContext_Impl::StartElement(const uno::Reference< void SmXMLUnderContext_Impl::HandleAccent() { - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, - "Sub has not two arguments"); + const bool bNodeCheck = GetSmImport().GetNodeStack().Count() - nElementCount == 2; + DBG_ASSERT( bNodeCheck, "Sub has not two arguments" ); + if (!bNodeCheck) + return; /*Just one special case for the underline thing*/ SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); @@ -1803,8 +1810,11 @@ void SmXMLOverContext_Impl::EndElement() void SmXMLOverContext_Impl::HandleAccent() { - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, - "Sub has not two arguments"); + const bool bNodeCheck = GetSmImport().GetNodeStack().Count() - nElementCount == 2; + DBG_ASSERT( bNodeCheck, "Sub has not two arguments" ); + if (!bNodeCheck) + return; + SmToken aToken; aToken.cMathChar = '\0'; aToken.nGroup = 0; @@ -2352,6 +2362,12 @@ void SmXMLDocContext_Impl::EndElement() void SmXMLFracContext_Impl::EndElement() { + SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + const bool bNodeCheck = rNodeStack.Count() - nElementCount == 2; + DBG_ASSERT( bNodeCheck, "Fraction (mfrac) tag is missing component" ); + if (!bNodeCheck) + return; + SmToken aToken; aToken.cMathChar = '\0'; aToken.nGroup = 0; @@ -2359,23 +2375,19 @@ void SmXMLFracContext_Impl::EndElement() aToken.eType = TOVER; SmStructureNode *pSNode = new SmBinVerNode(aToken); SmNode *pOper = new SmRectangleNode(aToken); - SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); - DBG_ASSERT(rNodeStack.Count() - nElementCount == 2, - "Fraction (mfrac) tag is missing component"); - if (rNodeStack.Count() - nElementCount == 2) - { - SmNode *pSecond = rNodeStack.Pop(); - SmNode *pFirst = rNodeStack.Pop(); - pSNode->SetSubNodes(pFirst,pOper,pSecond); - rNodeStack.Push(pSNode); - } + SmNode *pSecond = rNodeStack.Pop(); + SmNode *pFirst = rNodeStack.Pop(); + pSNode->SetSubNodes(pFirst,pOper,pSecond); + rNodeStack.Push(pSNode); } void SmXMLRootContext_Impl::EndElement() { /*The <mroot> element requires exactly 2 arguments.*/ - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount == 2, - "Root tag is missing component"); + const bool bNodeCheck = GetSmImport().GetNodeStack().Count() - nElementCount == 2; + DBG_ASSERT( bNodeCheck, "Root tag is missing component" ); + if (!bNodeCheck) + return; SmToken aToken; aToken.cMathChar = MS_SQRT; //Temporary: alert, based on StarSymbol font @@ -2612,9 +2624,8 @@ void SmXMLMultiScriptsContext_Impl::MiddleElement() { bHasPrescripts=sal_True; - DBG_ASSERT(GetSmImport().GetNodeStack().Count() - nElementCount > 0, - "Sub has no arguments"); SmNodeStack &rNodeStack = GetSmImport().GetNodeStack(); + DBG_ASSERT( rNodeStack.Count() - nElementCount > 0, "Sub has no arguments" ); if (rNodeStack.Count()-nElementCount > 1) { SmToken aToken; @@ -3168,8 +3179,14 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP if ( xInfo->hasPropertyByName( pValues->Name ) ) xProps->setPropertyValue( pValues->Name, pValues->Value ); } - catch( Exception& ) + catch (beans::PropertyVetoException &e) + { + (void) e; + // dealing with read-only properties here. Nothing to do... + } + catch( Exception& e) { + (void) e; DBG_ERROR( "SmXMLImport::SetConfigurationSettings: Exception!" ); } } diff --git a/starmath/source/mathmlimport.hxx b/starmath/source/mathmlimport.hxx index 22c2017c61b1..3225c2f85eb6 100644..100755 --- a/starmath/source/mathmlimport.hxx +++ b/starmath/source/mathmlimport.hxx @@ -251,10 +251,10 @@ public: const SvXMLTokenMap &GetPresTableElemTokenMap(); const SvXMLTokenMap &GetColorTokenMap(); - SmNodeStack & GetNodeStack() {return aNodeStack;} - SmNode *GetTree() { return aNodeStack.Pop();} - sal_Bool GetSuccess() { return bSuccess; } - String &GetText() { return aText;} + SmNodeStack & GetNodeStack() { return aNodeStack; } + SmNode *GetTree() { return aNodeStack.Pop(); } + sal_Bool GetSuccess() { return bSuccess; } + String &GetText() { return aText; } virtual void SetViewSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps); virtual void SetConfigurationSettings(const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aViewProps); diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx index 697e18362d87..042997ee3bea 100755 --- a/starmath/source/parse.cxx +++ b/starmath/source/parse.cxx @@ -392,22 +392,22 @@ BOOL SmParser::IsDelimiter( const String &rTxt, xub_StrLen nPos ) void SmParser::Insert(const String &rText, USHORT nPos) { - BufferString.Insert(rText, nPos); + m_aBufferString.Insert(rText, nPos); xub_StrLen nLen = rText.Len(); - BufferIndex = BufferIndex + nLen; - nTokenIndex = nTokenIndex + nLen; + m_nBufferIndex = m_nBufferIndex + nLen; + m_nTokenIndex = m_nTokenIndex + nLen; } void SmParser::Replace( USHORT nPos, USHORT nLen, const String &rText ) { - DBG_ASSERT( nPos + nLen <= BufferString.Len(), "argument mismatch" ); + DBG_ASSERT( nPos + nLen <= m_aBufferString.Len(), "argument mismatch" ); - BufferString.Replace( nPos, nLen, rText ); + m_aBufferString.Replace( nPos, nLen, rText ); INT16 nChg = rText.Len() - nLen; - BufferIndex = BufferIndex + nChg; - nTokenIndex = nTokenIndex + nChg; + m_nBufferIndex = m_nBufferIndex + nChg; + m_nTokenIndex = m_nTokenIndex + nChg; } @@ -434,7 +434,7 @@ void SmParser::NextToken() { static const String aEmptyStr; - xub_StrLen nBufLen = BufferString.Len(); + xub_StrLen nBufLen = m_aBufferString.Len(); ParseResult aRes; xub_StrLen nRealStart; BOOL bCont; @@ -444,12 +444,12 @@ void SmParser::NextToken() { // skip white spaces while (UnicodeType::SPACE_SEPARATOR == - aCC.getType( BufferString, BufferIndex )) - ++BufferIndex; + aCC.getType( m_aBufferString, m_nBufferIndex )) + ++m_nBufferIndex; sal_Int32 nStartFlags = coStartFlags; sal_Int32 nContFlags = coContFlags; - sal_Unicode cFirstChar = BufferString.GetChar( BufferIndex ); + sal_Unicode cFirstChar = m_aBufferString.GetChar( m_nBufferIndex ); /* removed because of #i11752# bNumStart = cFirstChar == '.' || ('0' <= cFirstChar && cFirstChar <= '9'); @@ -459,7 +459,7 @@ void SmParser::NextToken() nContFlags = coNumContFlags; } */ - aRes = aCC.parseAnyToken( BufferString, BufferIndex, + aRes = aCC.parseAnyToken( m_aBufferString, m_nBufferIndex, nStartFlags, aEmptyStr, nContFlags, aEmptyStr ); @@ -476,7 +476,7 @@ void SmParser::NextToken() aCC.setLocale( aDotLoc ); aTmpRes = aCC.parsePredefinedToken( KParseType::ASC_NUMBER, - BufferString, BufferIndex, + m_aBufferString, m_nBufferIndex, KParseTokens::ASC_DIGIT, aEmptyStr, KParseTokens::ASC_DIGIT | KParseTokens::ASC_DOT, aEmptyStr ); aCC.setLocale( aOldLoc ); @@ -484,29 +484,29 @@ void SmParser::NextToken() aRes.TokenType = aTmpRes.TokenType; } - nRealStart = BufferIndex + sal::static_int_cast< xub_StrLen >(aRes.LeadingWhiteSpace); - BufferIndex = nRealStart; + nRealStart = m_nBufferIndex + sal::static_int_cast< xub_StrLen >(aRes.LeadingWhiteSpace); + m_nBufferIndex = nRealStart; bCont = FALSE; if ( aRes.TokenType == 0 && nRealStart < nBufLen && - '\n' == BufferString.GetChar( nRealStart ) ) + '\n' == m_aBufferString.GetChar( nRealStart ) ) { // keep data needed for tokens row and col entry up to date - ++Row; - BufferIndex = ColOff = nRealStart + 1; + ++m_Row; + m_nBufferIndex = m_nColOff = nRealStart + 1; bCont = TRUE; } else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR) { - String aName( BufferString.Copy( nRealStart, 2 )); + String aName( m_aBufferString.Copy( nRealStart, 2 )); if ( aName.EqualsAscii( "%%" )) { //SkipComment - BufferIndex = nRealStart + 2; - while (BufferIndex < nBufLen && - '\n' != BufferString.GetChar( BufferIndex )) - ++BufferIndex; + m_nBufferIndex = nRealStart + 2; + while (m_nBufferIndex < nBufLen && + '\n' != m_aBufferString.GetChar( m_nBufferIndex )) + ++m_nBufferIndex; bCont = TRUE; } } @@ -514,33 +514,33 @@ void SmParser::NextToken() } while (bCont); // set index of current token - nTokenIndex = BufferIndex; + m_nTokenIndex = m_nBufferIndex; - CurToken.nRow = Row; - CurToken.nCol = nRealStart - ColOff + 1; + m_aCurToken.nRow = m_Row; + m_aCurToken.nCol = nRealStart - m_nColOff + 1; BOOL bHandled = TRUE; if (nRealStart >= nBufLen) { - CurToken.eType = TEND; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 0; - CurToken.aText.Erase(); + m_aCurToken.eType = TEND; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.Erase(); } else if ((aRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER)) || (bNumStart && (aRes.TokenType & KParseType::IDENTNAME))) { INT32 n = aRes.EndPos - nRealStart; DBG_ASSERT( n >= 0, "length < 0" ); - CurToken.eType = TNUMBER; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText = BufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ); + m_aCurToken.eType = TNUMBER; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText = m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ); #if OSL_DEBUG_LEVEL > 1 - if (!IsDelimiter( BufferString, static_cast< xub_StrLen >(aRes.EndPos) )) + if (!IsDelimiter( m_aBufferString, static_cast< xub_StrLen >(aRes.EndPos) )) { DBG_WARNING( "identifier really finished? (compatibility!)" ); } @@ -548,59 +548,59 @@ void SmParser::NextToken() } else if (aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING) { - CurToken.eType = TTEXT; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText = aRes.DequotedNameOrString; - CurToken.nRow = Row; - CurToken.nCol = nRealStart - ColOff + 2; + m_aCurToken.eType = TTEXT; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText = aRes.DequotedNameOrString; + m_aCurToken.nRow = m_Row; + m_aCurToken.nCol = nRealStart - m_nColOff + 2; } else if (aRes.TokenType & KParseType::IDENTNAME) { INT32 n = aRes.EndPos - nRealStart; DBG_ASSERT( n >= 0, "length < 0" ); - String aName( BufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ) ); + String aName( m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(n) ) ); const SmTokenTableEntry *pEntry = GetTokenTableEntry( aName ); if (pEntry) { - CurToken.eType = pEntry->eType; - CurToken.cMathChar = pEntry->cMathChar; - CurToken.nGroup = pEntry->nGroup; - CurToken.nLevel = pEntry->nLevel; - CurToken.aText.AssignAscii( pEntry->pIdent ); + m_aCurToken.eType = pEntry->eType; + m_aCurToken.cMathChar = pEntry->cMathChar; + m_aCurToken.nGroup = pEntry->nGroup; + m_aCurToken.nLevel = pEntry->nLevel; + m_aCurToken.aText.AssignAscii( pEntry->pIdent ); } else { - CurToken.eType = TIDENT; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText = aName; + m_aCurToken.eType = TIDENT; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText = aName; #if OSL_DEBUG_LEVEL > 1 - if (!IsDelimiter( BufferString, static_cast< xub_StrLen >(aRes.EndPos) )) + if (!IsDelimiter( m_aBufferString, static_cast< xub_StrLen >(aRes.EndPos) )) { DBG_WARNING( "identifier really finished? (compatibility!)" ); } #endif } } - else if (aRes.TokenType == 0 && '_' == BufferString.GetChar( nRealStart )) + else if (aRes.TokenType == 0 && '_' == m_aBufferString.GetChar( nRealStart )) { - CurToken.eType = TRSUB; - CurToken.cMathChar = '\0'; - CurToken.nGroup = TGPOWER; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "_" ); + m_aCurToken.eType = TRSUB; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = TGPOWER; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "_" ); aRes.EndPos = nRealStart + 1; } else if (aRes.TokenType & KParseType::BOOLEAN) { sal_Int32 &rnEndPos = aRes.EndPos; - String aName( BufferString.Copy( nRealStart, + String aName( m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(rnEndPos - nRealStart) )); if (2 >= aName.Len()) { @@ -609,91 +609,91 @@ void SmParser::NextToken() { case '<': { - if (BufferString.Copy( nRealStart, 2 ). + if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "<<" )) { - CurToken.eType = TLL; - CurToken.cMathChar = MS_LL; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "<<" ); + m_aCurToken.eType = TLL; + m_aCurToken.cMathChar = MS_LL; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "<<" ); rnEndPos = nRealStart + 2; } - else if (BufferString.Copy( nRealStart, 2 ). + else if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "<=" )) { - CurToken.eType = TLE; - CurToken.cMathChar = MS_LE; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "<=" ); + m_aCurToken.eType = TLE; + m_aCurToken.cMathChar = MS_LE; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "<=" ); rnEndPos = nRealStart + 2; } - else if (BufferString.Copy( nRealStart, 2 ). + else if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "<>" )) { - CurToken.eType = TNEQ; - CurToken.cMathChar = MS_NEQ; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "<>" ); + m_aCurToken.eType = TNEQ; + m_aCurToken.cMathChar = MS_NEQ; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "<>" ); rnEndPos = nRealStart + 2; } - else if (BufferString.Copy( nRealStart, 3 ). + else if (m_aBufferString.Copy( nRealStart, 3 ). EqualsAscii( "<?>" )) { - CurToken.eType = TPLACE; - CurToken.cMathChar = MS_PLACE; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "<?>" ); + m_aCurToken.eType = TPLACE; + m_aCurToken.cMathChar = MS_PLACE; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "<?>" ); rnEndPos = nRealStart + 3; } else { - CurToken.eType = TLT; - CurToken.cMathChar = MS_LT; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "<" ); + m_aCurToken.eType = TLT; + m_aCurToken.cMathChar = MS_LT; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "<" ); } } break; case '>': { - if (BufferString.Copy( nRealStart, 2 ). + if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( ">=" )) { - CurToken.eType = TGE; - CurToken.cMathChar = MS_GE; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( ">=" ); + m_aCurToken.eType = TGE; + m_aCurToken.cMathChar = MS_GE; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( ">=" ); rnEndPos = nRealStart + 2; } - else if (BufferString.Copy( nRealStart, 2 ). + else if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( ">>" )) { - CurToken.eType = TGG; - CurToken.cMathChar = MS_GG; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( ">>" ); + m_aCurToken.eType = TGG; + m_aCurToken.cMathChar = MS_GG; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( ">>" ); rnEndPos = nRealStart + 2; } else { - CurToken.eType = TGT; - CurToken.cMathChar = MS_GT; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( ">" ); + m_aCurToken.eType = TGT; + m_aCurToken.cMathChar = MS_GT; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( ">" ); } } break; @@ -705,7 +705,7 @@ void SmParser::NextToken() else if (aRes.TokenType & KParseType::ONE_SINGLE_CHAR) { sal_Int32 &rnEndPos = aRes.EndPos; - String aName( BufferString.Copy( nRealStart, + String aName( m_aBufferString.Copy( nRealStart, sal::static_int_cast< xub_StrLen >(rnEndPos - nRealStart) ) ); if (1 == aName.Len()) @@ -718,12 +718,12 @@ void SmParser::NextToken() //! modifies aRes.EndPos DBG_ASSERT( rnEndPos >= nBufLen || - '%' != BufferString.GetChar( sal::static_int_cast< xub_StrLen >(rnEndPos) ), + '%' != m_aBufferString.GetChar( sal::static_int_cast< xub_StrLen >(rnEndPos) ), "unexpected comment start" ); // get identifier of user-defined character ParseResult aTmpRes = aCC.parseAnyToken( - BufferString, rnEndPos, + m_aBufferString, rnEndPos, KParseTokens::ANY_LETTER, aEmptyStr, coContFlags, @@ -735,20 +735,20 @@ void SmParser::NextToken() // default setting for the case that no identifier // i.e. a valid symbol-name is following the '%' // character - CurToken.eType = TTEXT; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText = String(); - CurToken.nRow = sal::static_int_cast< xub_StrLen >(Row); - CurToken.nCol = nTmpStart - ColOff; + m_aCurToken.eType = TTEXT; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText = String(); + m_aCurToken.nRow = sal::static_int_cast< xub_StrLen >(m_Row); + m_aCurToken.nCol = nTmpStart - m_nColOff; if (aTmpRes.TokenType & KParseType::IDENTNAME) { xub_StrLen n = sal::static_int_cast< xub_StrLen >(aTmpRes.EndPos - nTmpStart); - CurToken.eType = TSPECIAL; - CurToken.aText = BufferString.Copy( sal::static_int_cast< xub_StrLen >(nTmpStart-1), n+1 ); + m_aCurToken.eType = TSPECIAL; + m_aCurToken.aText = m_aBufferString.Copy( sal::static_int_cast< xub_StrLen >(nTmpStart-1), n+1 ); DBG_ASSERT( aTmpRes.EndPos > rnEndPos, "empty identifier" ); @@ -765,187 +765,187 @@ void SmParser::NextToken() break; case '[': { - CurToken.eType = TLBRACKET; - CurToken.cMathChar = MS_LBRACKET; - CurToken.nGroup = TGLBRACES; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "[" ); + m_aCurToken.eType = TLBRACKET; + m_aCurToken.cMathChar = MS_LBRACKET; + m_aCurToken.nGroup = TGLBRACES; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "[" ); } break; case '\\': { - CurToken.eType = TESCAPE; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "\\" ); + m_aCurToken.eType = TESCAPE; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "\\" ); } break; case ']': { - CurToken.eType = TRBRACKET; - CurToken.cMathChar = MS_RBRACKET; - CurToken.nGroup = TGRBRACES; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "]" ); + m_aCurToken.eType = TRBRACKET; + m_aCurToken.cMathChar = MS_RBRACKET; + m_aCurToken.nGroup = TGRBRACES; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "]" ); } break; case '^': { - CurToken.eType = TRSUP; - CurToken.cMathChar = '\0'; - CurToken.nGroup = TGPOWER; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "^" ); + m_aCurToken.eType = TRSUP; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = TGPOWER; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "^" ); } break; case '`': { - CurToken.eType = TSBLANK; - CurToken.cMathChar = '\0'; - CurToken.nGroup = TGBLANK; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "`" ); + m_aCurToken.eType = TSBLANK; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = TGBLANK; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "`" ); } break; case '{': { - CurToken.eType = TLGROUP; - CurToken.cMathChar = MS_LBRACE; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "{" ); + m_aCurToken.eType = TLGROUP; + m_aCurToken.cMathChar = MS_LBRACE; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "{" ); } break; case '|': { - CurToken.eType = TOR; - CurToken.cMathChar = MS_OR; - CurToken.nGroup = TGSUM; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "|" ); + m_aCurToken.eType = TOR; + m_aCurToken.cMathChar = MS_OR; + m_aCurToken.nGroup = TGSUM; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "|" ); } break; case '}': { - CurToken.eType = TRGROUP; - CurToken.cMathChar = MS_RBRACE; - CurToken.nGroup = 0; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "}" ); + m_aCurToken.eType = TRGROUP; + m_aCurToken.cMathChar = MS_RBRACE; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "}" ); } break; case '~': { - CurToken.eType = TBLANK; - CurToken.cMathChar = '\0'; - CurToken.nGroup = TGBLANK; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "~" ); + m_aCurToken.eType = TBLANK; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = TGBLANK; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "~" ); } break; case '#': { - if (BufferString.Copy( nRealStart, 2 ). + if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "##" )) { - CurToken.eType = TDPOUND; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "##" ); + m_aCurToken.eType = TDPOUND; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "##" ); rnEndPos = nRealStart + 2; } else { - CurToken.eType = TPOUND; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "#" ); + m_aCurToken.eType = TPOUND; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "#" ); } } break; case '&': { - CurToken.eType = TAND; - CurToken.cMathChar = MS_AND; - CurToken.nGroup = TGPRODUCT; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "&" ); + m_aCurToken.eType = TAND; + m_aCurToken.cMathChar = MS_AND; + m_aCurToken.nGroup = TGPRODUCT; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "&" ); } break; case '(': { - CurToken.eType = TLPARENT; - CurToken.cMathChar = MS_LPARENT; - CurToken.nGroup = TGLBRACES; - CurToken.nLevel = 5; //! 0 to continue expression - CurToken.aText.AssignAscii( "(" ); + m_aCurToken.eType = TLPARENT; + m_aCurToken.cMathChar = MS_LPARENT; + m_aCurToken.nGroup = TGLBRACES; + m_aCurToken.nLevel = 5; //! 0 to continue expression + m_aCurToken.aText.AssignAscii( "(" ); } break; case ')': { - CurToken.eType = TRPARENT; - CurToken.cMathChar = MS_RPARENT; - CurToken.nGroup = TGRBRACES; - CurToken.nLevel = 0; //! 0 to terminate expression - CurToken.aText.AssignAscii( ")" ); + m_aCurToken.eType = TRPARENT; + m_aCurToken.cMathChar = MS_RPARENT; + m_aCurToken.nGroup = TGRBRACES; + m_aCurToken.nLevel = 0; //! 0 to terminate expression + m_aCurToken.aText.AssignAscii( ")" ); } break; case '*': { - CurToken.eType = TMULTIPLY; - CurToken.cMathChar = MS_MULTIPLY; - CurToken.nGroup = TGPRODUCT; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "*" ); + m_aCurToken.eType = TMULTIPLY; + m_aCurToken.cMathChar = MS_MULTIPLY; + m_aCurToken.nGroup = TGPRODUCT; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "*" ); } break; case '+': { - if (BufferString.Copy( nRealStart, 2 ). + if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "+-" )) { - CurToken.eType = TPLUSMINUS; - CurToken.cMathChar = MS_PLUSMINUS; - CurToken.nGroup = TGUNOPER | TGSUM; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "+-" ); + m_aCurToken.eType = TPLUSMINUS; + m_aCurToken.cMathChar = MS_PLUSMINUS; + m_aCurToken.nGroup = TGUNOPER | TGSUM; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "+-" ); rnEndPos = nRealStart + 2; } else { - CurToken.eType = TPLUS; - CurToken.cMathChar = MS_PLUS; - CurToken.nGroup = TGUNOPER | TGSUM; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "+" ); + m_aCurToken.eType = TPLUS; + m_aCurToken.cMathChar = MS_PLUS; + m_aCurToken.nGroup = TGUNOPER | TGSUM; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "+" ); } } break; case '-': { - if (BufferString.Copy( nRealStart, 2 ). + if (m_aBufferString.Copy( nRealStart, 2 ). EqualsAscii( "-+" )) { - CurToken.eType = TMINUSPLUS; - CurToken.cMathChar = MS_MINUSPLUS; - CurToken.nGroup = TGUNOPER | TGSUM; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "-+" ); + m_aCurToken.eType = TMINUSPLUS; + m_aCurToken.cMathChar = MS_MINUSPLUS; + m_aCurToken.nGroup = TGUNOPER | TGSUM; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "-+" ); rnEndPos = nRealStart + 2; } else { - CurToken.eType = TMINUS; - CurToken.cMathChar = MS_MINUS; - CurToken.nGroup = TGUNOPER | TGSUM; - CurToken.nLevel = 5; - CurToken.aText.AssignAscii( "-" ); + m_aCurToken.eType = TMINUS; + m_aCurToken.cMathChar = MS_MINUS; + m_aCurToken.nGroup = TGUNOPER | TGSUM; + m_aCurToken.nLevel = 5; + m_aCurToken.aText.AssignAscii( "-" ); } } break; @@ -954,40 +954,40 @@ void SmParser::NextToken() // for compatibility with SO5.2 // texts like .34 ...56 ... h ...78..90 // will be treated as numbers - CurToken.eType = TNUMBER; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; + m_aCurToken.eType = TNUMBER; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; - xub_StrLen nTxtStart = BufferIndex; + xub_StrLen nTxtStart = m_nBufferIndex; sal_Unicode cChar; do { - cChar = BufferString.GetChar( ++BufferIndex ); + cChar = m_aBufferString.GetChar( ++m_nBufferIndex ); } while ( cChar == '.' || IsDigit( cChar ) ); - CurToken.aText = BufferString.Copy( sal::static_int_cast< xub_StrLen >(nTxtStart), - sal::static_int_cast< xub_StrLen >(BufferIndex - nTxtStart) ); - aRes.EndPos = BufferIndex; + m_aCurToken.aText = m_aBufferString.Copy( sal::static_int_cast< xub_StrLen >(nTxtStart), + sal::static_int_cast< xub_StrLen >(m_nBufferIndex - nTxtStart) ); + aRes.EndPos = m_nBufferIndex; } break; case '/': { - CurToken.eType = TDIVIDEBY; - CurToken.cMathChar = MS_SLASH; - CurToken.nGroup = TGPRODUCT; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "/" ); + m_aCurToken.eType = TDIVIDEBY; + m_aCurToken.cMathChar = MS_SLASH; + m_aCurToken.nGroup = TGPRODUCT; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "/" ); } break; case '=': { - CurToken.eType = TASSIGN; - CurToken.cMathChar = MS_ASSIGN; - CurToken.nGroup = TGRELATION; - CurToken.nLevel = 0; - CurToken.aText.AssignAscii( "=" ); + m_aCurToken.eType = TASSIGN; + m_aCurToken.cMathChar = MS_ASSIGN; + m_aCurToken.nGroup = TGRELATION; + m_aCurToken.nLevel = 0; + m_aCurToken.aText.AssignAscii( "=" ); } break; default: @@ -1000,17 +1000,17 @@ void SmParser::NextToken() if (!bHandled) { - CurToken.eType = TCHARACTER; - CurToken.cMathChar = '\0'; - CurToken.nGroup = 0; - CurToken.nLevel = 5; - CurToken.aText = BufferString.Copy( nRealStart, 1 ); + m_aCurToken.eType = TCHARACTER; + m_aCurToken.cMathChar = '\0'; + m_aCurToken.nGroup = 0; + m_aCurToken.nLevel = 5; + m_aCurToken.aText = m_aBufferString.Copy( nRealStart, 1 ); aRes.EndPos = nRealStart + 1; } - if (TEND != CurToken.eType) - BufferIndex = sal::static_int_cast< xub_StrLen >(aRes.EndPos); + if (TEND != m_aCurToken.eType) + m_nBufferIndex = sal::static_int_cast< xub_StrLen >(aRes.EndPos); } @@ -1024,25 +1024,25 @@ void SmParser::Table() SmNodeArray LineArray; Line(); - while (CurToken.eType == TNEWLINE) + while (m_aCurToken.eType == TNEWLINE) { NextToken(); Line(); } - if (CurToken.eType != TEND) + if (m_aCurToken.eType != TEND) Error(PE_UNEXPECTED_CHAR); - ULONG n = NodeStack.Count(); + ULONG n = m_aNodeStack.Count(); LineArray.resize(n); for (ULONG i = 0; i < n; i++) - LineArray[n - (i + 1)] = NodeStack.Pop(); + LineArray[n - (i + 1)] = m_aNodeStack.Pop(); - SmStructureNode *pSNode = new SmTableNode(CurToken); + SmStructureNode *pSNode = new SmTableNode(m_aCurToken); pSNode->SetSubNodes(LineArray); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } @@ -1064,19 +1064,21 @@ void SmParser::Align() // (the dominant one in 4.0) and erase all others (especially old // discarded tokens) from command string. while (TokenInGroup(TGALIGN)) - { if (TokenInGroup(TGDISCARDED) || pSNode) - { BufferIndex = GetTokenIndex(); - BufferString.Erase(BufferIndex, CurToken.aText.Len()); + { + if (TokenInGroup(TGDISCARDED) || pSNode) + { + m_nBufferIndex = GetTokenIndex(); + m_aBufferString.Erase(m_nBufferIndex, m_aCurToken.aText.Len()); } else - pSNode = new SmAlignNode(CurToken); + pSNode = new SmAlignNode(m_aCurToken); NextToken(); } } else { - pSNode = new SmAlignNode(CurToken); + pSNode = new SmAlignNode(m_aCurToken); NextToken(); @@ -1094,8 +1096,8 @@ void SmParser::Align() Insert('}', GetTokenIndex()); if (pSNode) - { pSNode->SetSubNodes(NodeStack.Pop(), 0); - NodeStack.Push(pSNode); + { pSNode->SetSubNodes(m_aNodeStack.Pop(), 0); + m_aNodeStack.Push(pSNode); } } @@ -1110,37 +1112,37 @@ void SmParser::Line() // start with single expression that may have an alignment statement // (and go on with expressions that must not have alignment // statements in 'while' loop below. See also 'Expression()'.) - if (CurToken.eType != TEND && CurToken.eType != TNEWLINE) + if (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE) { Align(); ExpressionArray.resize(++n); - ExpressionArray[n - 1] = NodeStack.Pop(); + ExpressionArray[n - 1] = m_aNodeStack.Pop(); } - while (CurToken.eType != TEND && CurToken.eType != TNEWLINE) + while (m_aCurToken.eType != TEND && m_aCurToken.eType != TNEWLINE) { if (CONVERT_40_TO_50 != GetConversion()) Expression(); else Align(); ExpressionArray.resize(++n); - ExpressionArray[n - 1] = NodeStack.Pop(); + ExpressionArray[n - 1] = m_aNodeStack.Pop(); } - SmStructureNode *pSNode = new SmLineNode(CurToken); + SmStructureNode *pSNode = new SmLineNode(m_aCurToken); pSNode->SetSubNodes(ExpressionArray); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } void SmParser::Expression() { BOOL bUseExtraSpaces = TRUE; - SmNode *pNode = NodeStack.Pop(); + SmNode *pNode = m_aNodeStack.Pop(); if (pNode) { if (pNode->GetToken().eType == TNOSPACE) bUseExtraSpaces = FALSE; else - NodeStack.Push(pNode); // push the node from above again (now to be used as argument to this current 'nospace' node) + m_aNodeStack.Push(pNode); // push the node from above again (now to be used as argument to this current 'nospace' node) } USHORT n = 0; @@ -1150,18 +1152,18 @@ void SmParser::Expression() Relation(); RelationArray.resize(++n); - RelationArray[n - 1] = NodeStack.Pop(); + RelationArray[n - 1] = m_aNodeStack.Pop(); - while (CurToken.nLevel >= 4) + while (m_aCurToken.nLevel >= 4) { Relation(); RelationArray.resize(++n); - RelationArray[n - 1] = NodeStack.Pop(); + RelationArray[n - 1] = m_aNodeStack.Pop(); } - SmExpressionNode *pSNode = new SmExpressionNode(CurToken); + SmExpressionNode *pSNode = new SmExpressionNode(m_aCurToken); pSNode->SetSubNodes(RelationArray); pSNode->SetUseExtraSpaces(bUseExtraSpaces); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } @@ -1170,16 +1172,16 @@ void SmParser::Relation() Sum(); while (TokenInGroup(TGRELATION)) { - SmStructureNode *pSNode = new SmBinHorNode(CurToken); - SmNode *pFirst = NodeStack.Pop(); + SmStructureNode *pSNode = new SmBinHorNode(m_aCurToken); + SmNode *pFirst = m_aNodeStack.Pop(); OpSubSup(); - SmNode *pSecond = NodeStack.Pop(); + SmNode *pSecond = m_aNodeStack.Pop(); Sum(); - pSNode->SetSubNodes(pFirst, pSecond, NodeStack.Pop()); - NodeStack.Push(pSNode); + pSNode->SetSubNodes(pFirst, pSecond, m_aNodeStack.Pop()); + m_aNodeStack.Push(pSNode); } } @@ -1189,16 +1191,16 @@ void SmParser::Sum() Product(); while (TokenInGroup(TGSUM)) { - SmStructureNode *pSNode = new SmBinHorNode(CurToken); - SmNode *pFirst = NodeStack.Pop(); + SmStructureNode *pSNode = new SmBinHorNode(m_aCurToken); + SmNode *pFirst = m_aNodeStack.Pop(); OpSubSup(); - SmNode *pSecond = NodeStack.Pop(); + SmNode *pSecond = m_aNodeStack.Pop(); Product(); - pSNode->SetSubNodes(pFirst, pSecond, NodeStack.Pop()); - NodeStack.Push(pSNode); + pSNode->SetSubNodes(pFirst, pSecond, m_aNodeStack.Pop()); + m_aNodeStack.Push(pSNode); } } @@ -1209,32 +1211,32 @@ void SmParser::Product() while (TokenInGroup(TGPRODUCT)) { SmStructureNode *pSNode; - SmNode *pFirst = NodeStack.Pop(), + SmNode *pFirst = m_aNodeStack.Pop(), *pOper; BOOL bSwitchArgs = FALSE; - SmTokenType eType = CurToken.eType; + SmTokenType eType = m_aCurToken.eType; switch (eType) { case TOVER: - pSNode = new SmBinVerNode(CurToken); - pOper = new SmRectangleNode(CurToken); + pSNode = new SmBinVerNode(m_aCurToken); + pOper = new SmRectangleNode(m_aCurToken); NextToken(); break; case TBOPER: - pSNode = new SmBinHorNode(CurToken); + pSNode = new SmBinHorNode(m_aCurToken); NextToken(); GlyphSpecial(); - pOper = NodeStack.Pop(); + pOper = m_aNodeStack.Pop(); break; case TOVERBRACE : case TUNDERBRACE : - pSNode = new SmVerticalBraceNode(CurToken); - pOper = new SmMathSymbolNode(CurToken); + pSNode = new SmVerticalBraceNode(m_aCurToken); + pOper = new SmMathSymbolNode(m_aCurToken); NextToken(); break; @@ -1242,11 +1244,11 @@ void SmParser::Product() case TWIDEBACKSLASH: case TWIDESLASH: { - SmBinDiagonalNode *pSTmp = new SmBinDiagonalNode(CurToken); + SmBinDiagonalNode *pSTmp = new SmBinDiagonalNode(m_aCurToken); pSTmp->SetAscending(eType == TWIDESLASH); pSNode = pSTmp; - pOper = new SmPolyLineNode(CurToken); + pOper = new SmPolyLineNode(m_aCurToken); NextToken(); bSwitchArgs =TRUE; @@ -1254,20 +1256,20 @@ void SmParser::Product() } default: - pSNode = new SmBinHorNode(CurToken); + pSNode = new SmBinHorNode(m_aCurToken); OpSubSup(); - pOper = NodeStack.Pop(); + pOper = m_aNodeStack.Pop(); } Power(); if (bSwitchArgs) //! vgl siehe SmBinDiagonalNode::Arrange - pSNode->SetSubNodes(pFirst, NodeStack.Pop(), pOper); + pSNode->SetSubNodes(pFirst, m_aNodeStack.Pop(), pOper); else - pSNode->SetSubNodes(pFirst, pOper, NodeStack.Pop()); - NodeStack.Push(pSNode); + pSNode->SetSubNodes(pFirst, pOper, m_aNodeStack.Pop()); + m_aNodeStack.Push(pSNode); } } @@ -1281,8 +1283,8 @@ void SmParser::SubSup(ULONG nActiveGroup) // already finish return; - SmSubSupNode *pNode = new SmSubSupNode(CurToken); - //! Of course 'CurToken' is just the first sub-/supscript token. + SmSubSupNode *pNode = new SmSubSupNode(m_aCurToken); + //! Of course 'm_aCurToken' is just the first sub-/supscript token. //! It should be of no further interest. The positions of the //! sub-/supscripts will be identified by the corresponding subnodes //! index in the 'aSubNodes' array (enum value from 'SmSubSup'). @@ -1292,14 +1294,14 @@ void SmParser::SubSup(ULONG nActiveGroup) // initialize subnodes array SmNodeArray aSubNodes; aSubNodes.resize(1 + SUBSUP_NUM_ENTRIES); - aSubNodes[0] = NodeStack.Pop(); + aSubNodes[0] = m_aNodeStack.Pop(); for (USHORT i = 1; i < aSubNodes.size(); i++) aSubNodes[i] = NULL; // process all sub-/supscripts int nIndex = 0; while (TokenInGroup(nActiveGroup)) - { SmTokenType eType (CurToken.eType); + { SmTokenType eType (m_aCurToken.eType); // skip sub-/supscript token NextToken(); @@ -1332,18 +1334,18 @@ void SmParser::SubSup(ULONG nActiveGroup) // set sub-/supscript if not already done if (aSubNodes[nIndex] != NULL) Error(PE_DOUBLE_SUBSUPSCRIPT); - aSubNodes[nIndex] = NodeStack.Pop(); + aSubNodes[nIndex] = m_aNodeStack.Pop(); } pNode->SetSubNodes(aSubNodes); - NodeStack.Push(pNode); + m_aNodeStack.Push(pNode); } void SmParser::OpSubSup() { // push operator symbol - NodeStack.Push(new SmMathSymbolNode(CurToken)); + m_aNodeStack.Push(new SmMathSymbolNode(m_aCurToken)); // skip operator token NextToken(); // get sub- supscripts if any @@ -1364,28 +1366,28 @@ void SmParser::Power() void SmParser::Blank() { DBG_ASSERT(TokenInGroup(TGBLANK), "Sm : falsches Token"); - SmBlankNode *pBlankNode = new SmBlankNode(CurToken); + SmBlankNode *pBlankNode = new SmBlankNode(m_aCurToken); while (TokenInGroup(TGBLANK)) { - pBlankNode->IncreaseBy(CurToken); + pBlankNode->IncreaseBy(m_aCurToken); NextToken(); } // Blanks am Zeilenende ignorieren wenn die entsprechende Option gesetzt ist - if ( CurToken.eType == TNEWLINE || - (CurToken.eType == TEND && SM_MOD()->GetConfig()->IsIgnoreSpacesRight()) ) + if ( m_aCurToken.eType == TNEWLINE || + (m_aCurToken.eType == TEND && SM_MOD()->GetConfig()->IsIgnoreSpacesRight()) ) { pBlankNode->Clear(); } - NodeStack.Push(pBlankNode); + m_aNodeStack.Push(pBlankNode); } void SmParser::Term() { - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TESCAPE : Escape(); @@ -1394,15 +1396,15 @@ void SmParser::Term() case TNOSPACE : case TLGROUP : { - bool bNoSpace = CurToken.eType == TNOSPACE; + bool bNoSpace = m_aCurToken.eType == TNOSPACE; if (bNoSpace) // push 'no space' node and continue to parse expression { - NodeStack.Push(new SmExpressionNode(CurToken)); + m_aNodeStack.Push(new SmExpressionNode(m_aCurToken)); NextToken(); } - if (CurToken.eType != TLGROUP) + if (m_aCurToken.eType != TLGROUP) { - NodeStack.Pop(); // get rid of the 'no space' node pushed above + m_aNodeStack.Pop(); // get rid of the 'no space' node pushed above Term(); } else @@ -1410,20 +1412,20 @@ void SmParser::Term() NextToken(); // allow for empty group - if (CurToken.eType == TRGROUP) + if (m_aCurToken.eType == TRGROUP) { if (bNoSpace) // get rid of the 'no space' node pushed above - NodeStack.Pop(); - SmStructureNode *pSNode = new SmExpressionNode(CurToken); + m_aNodeStack.Pop(); + SmStructureNode *pSNode = new SmExpressionNode(m_aCurToken); pSNode->SetSubNodes(NULL, NULL); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); NextToken(); } else // go as usual { Align(); - if (CurToken.eType != TRGROUP) + if (m_aCurToken.eType != TRGROUP) Error(PE_RGROUP_EXPECTED); else NextToken(); @@ -1442,16 +1444,16 @@ void SmParser::Term() break; case TTEXT : - NodeStack.Push(new SmTextNode(CurToken, FNT_TEXT)); + m_aNodeStack.Push(new SmTextNode(m_aCurToken, FNT_TEXT)); NextToken(); break; case TIDENT : case TCHARACTER : - NodeStack.Push(new SmTextNode(CurToken, FNT_VARIABLE)); + m_aNodeStack.Push(new SmTextNode(m_aCurToken, FNT_VARIABLE)); NextToken(); break; case TNUMBER : - NodeStack.Push(new SmTextNode(CurToken, FNT_NUMBER)); + m_aNodeStack.Push(new SmTextNode(m_aCurToken, FNT_NUMBER)); NextToken(); break; @@ -1488,12 +1490,12 @@ void SmParser::Term() case TDOTSLOW : case TDOTSUP : case TDOTSVERT : - NodeStack.Push(new SmMathSymbolNode(CurToken)); + m_aNodeStack.Push(new SmMathSymbolNode(m_aCurToken)); NextToken(); break; case TPLACE: - NodeStack.Push(new SmPlaceNode(CurToken)); + m_aNodeStack.Push(new SmPlaceNode(m_aCurToken)); NextToken(); break; @@ -1539,21 +1541,21 @@ void SmParser::Term() FontAttribut(); // check if casting in following line is ok - DBG_ASSERT(!NodeStack.Top()->IsVisible(), "Sm : Ooops..."); + DBG_ASSERT(!m_aNodeStack.Top()->IsVisible(), "Sm : Ooops..."); - aArray[n] = (SmStructureNode *) NodeStack.Pop(); + aArray[n] = (SmStructureNode *) m_aNodeStack.Pop(); n++; } Power(); - SmNode *pFirstNode = NodeStack.Pop(); + SmNode *pFirstNode = m_aNodeStack.Pop(); while (n > 0) { aArray[n - 1]->SetSubNodes(0, pFirstNode); pFirstNode = aArray[n - 1]; n--; } - NodeStack.Push(pFirstNode); + m_aNodeStack.Push(pFirstNode); } else if (TokenInGroup(TGFUNCTION)) { if (CONVERT_40_TO_50 != GetConversion()) @@ -1569,9 +1571,9 @@ void SmParser::Term() // Function(); - SmNode *pFunc = NodeStack.Pop(); + SmNode *pFunc = m_aNodeStack.Pop(); - if (CurToken.eType == TLPARENT) + if (m_aCurToken.eType == TLPARENT) { Term(); } else @@ -1582,8 +1584,8 @@ void SmParser::Term() Insert('}', GetTokenIndex()); SmStructureNode *pSNode = new SmExpressionNode(pFunc->GetToken()); - pSNode->SetSubNodes(pFunc, NodeStack.Pop()); - NodeStack.Push(pSNode); + pSNode->SetSubNodes(pFunc, m_aNodeStack.Pop()); + m_aNodeStack.Push(pSNode); } } else @@ -1597,7 +1599,7 @@ void SmParser::Escape() NextToken(); sal_Unicode cChar; - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TLPARENT : cChar = MS_LPARENT; break; case TRPARENT : cChar = MS_RPARENT; break; case TLBRACKET : cChar = MS_LBRACKET; break; @@ -1622,8 +1624,8 @@ void SmParser::Escape() Error(PE_UNEXPECTED_TOKEN); } - SmNode *pNode = new SmMathSymbolNode(CurToken); - NodeStack.Push(pNode); + SmNode *pNode = new SmMathSymbolNode(m_aCurToken); + m_aNodeStack.Push(pNode); NextToken(); } @@ -1632,27 +1634,27 @@ void SmParser::Escape() void SmParser::Operator() { if (TokenInGroup(TGOPER)) - { SmStructureNode *pSNode = new SmOperNode(CurToken); + { SmStructureNode *pSNode = new SmOperNode(m_aCurToken); // put operator on top of stack Oper(); if (TokenInGroup(TGLIMIT) || TokenInGroup(TGPOWER)) - SubSup(CurToken.nGroup); - SmNode *pOperator = NodeStack.Pop(); + SubSup(m_aCurToken.nGroup); + SmNode *pOperator = m_aNodeStack.Pop(); // get argument Power(); - pSNode->SetSubNodes(pOperator, NodeStack.Pop()); - NodeStack.Push(pSNode); + pSNode->SetSubNodes(pOperator, m_aNodeStack.Pop()); + m_aNodeStack.Push(pSNode); } } void SmParser::Oper() { - SmTokenType eType (CurToken.eType); + SmTokenType eType (m_aCurToken.eType); SmNode *pNode = NULL; switch (eType) @@ -1666,7 +1668,7 @@ void SmParser::Oper() case TLINT : case TLLINT : case TLLLINT : - pNode = new SmMathSymbolNode(CurToken); + pNode = new SmMathSymbolNode(m_aCurToken); break; case TLIM : @@ -1683,27 +1685,27 @@ void SmParser::Oper() break; } if( pLim ) - CurToken.aText.AssignAscii( pLim ); - pNode = new SmTextNode(CurToken, FNT_TEXT); + m_aCurToken.aText.AssignAscii( pLim ); + pNode = new SmTextNode(m_aCurToken, FNT_TEXT); } break; case TOVERBRACE : case TUNDERBRACE : - pNode = new SmMathSymbolNode(CurToken); + pNode = new SmMathSymbolNode(m_aCurToken); break; case TOPER : NextToken(); - DBG_ASSERT(CurToken.eType == TSPECIAL, "Sm: falsches Token"); - pNode = new SmGlyphSpecialNode(CurToken); + DBG_ASSERT(m_aCurToken.eType == TSPECIAL, "Sm: falsches Token"); + pNode = new SmGlyphSpecialNode(m_aCurToken); break; default : DBG_ASSERT(0, "Sm: unbekannter Fall"); } - NodeStack.Push(pNode); + m_aNodeStack.Push(pNode); NextToken(); } @@ -1713,8 +1715,8 @@ void SmParser::UnOper() { DBG_ASSERT(TokenInGroup(TGUNOPER), "Sm: falsches Token"); - SmToken aNodeToken = CurToken; - SmTokenType eType = CurToken.eType; + SmToken aNodeToken = m_aCurToken; + SmTokenType eType = m_aCurToken.eType; BOOL bIsPostfix = eType == TFACT; SmStructureNode *pSNode; @@ -1732,13 +1734,13 @@ void SmParser::UnOper() case TNROOT : NextToken(); Power(); - pExtra = NodeStack.Pop(); + pExtra = m_aNodeStack.Pop(); break; case TUOPER : NextToken(); GlyphSpecial(); - pOper = NodeStack.Pop(); + pOper = m_aNodeStack.Pop(); break; case TPLUS : @@ -1748,7 +1750,7 @@ void SmParser::UnOper() case TNEG : case TFACT : OpSubSup(); - pOper = NodeStack.Pop(); + pOper = m_aNodeStack.Pop(); break; default : @@ -1757,7 +1759,7 @@ void SmParser::UnOper() // get argument Power(); - pArg = NodeStack.Pop(); + pArg = m_aNodeStack.Pop(); if (eType == TABS) { pSNode = new SmBraceNode(aNodeToken); @@ -1791,7 +1793,7 @@ void SmParser::UnOper() pSNode->SetSubNodes(pOper, pArg); } - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } @@ -1799,35 +1801,35 @@ void SmParser::Attribut() { DBG_ASSERT(TokenInGroup(TGATTRIBUT), "Sm: falsche Tokengruppe"); - SmStructureNode *pSNode = new SmAttributNode(CurToken); + SmStructureNode *pSNode = new SmAttributNode(m_aCurToken); SmNode *pAttr; SmScaleMode eScaleMode = SCALE_NONE; // get appropriate node for the attribut itself - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TUNDERLINE : case TOVERLINE : case TOVERSTRIKE : - pAttr = new SmRectangleNode(CurToken); + pAttr = new SmRectangleNode(m_aCurToken); eScaleMode = SCALE_WIDTH; break; case TWIDEVEC : case TWIDEHAT : case TWIDETILDE : - pAttr = new SmMathSymbolNode(CurToken); + pAttr = new SmMathSymbolNode(m_aCurToken); eScaleMode = SCALE_WIDTH; break; default : - pAttr = new SmMathSymbolNode(CurToken); + pAttr = new SmMathSymbolNode(m_aCurToken); } NextToken(); pSNode->SetSubNodes(pAttr, 0); pSNode->SetScaleMode(eScaleMode); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } @@ -1835,14 +1837,14 @@ void SmParser::FontAttribut() { DBG_ASSERT(TokenInGroup(TGFONTATTR), "Sm: falsche Tokengruppe"); - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TITALIC : case TNITALIC : case TBOLD : case TNBOLD : case TPHANTOM : - NodeStack.Push(new SmFontNode(CurToken)); + m_aNodeStack.Push(new SmFontNode(m_aCurToken)); NextToken(); break; @@ -1866,7 +1868,7 @@ void SmParser::FontAttribut() void SmParser::Color() { - DBG_ASSERT(CurToken.eType == TCOLOR, "Sm : Ooops..."); + DBG_ASSERT(m_aCurToken.eType == TCOLOR, "Sm : Ooops..."); // last color rules, get that one SmToken aToken; @@ -1874,20 +1876,20 @@ void SmParser::Color() { NextToken(); if (TokenInGroup(TGCOLOR)) - { aToken = CurToken; + { aToken = m_aCurToken; NextToken(); } else Error(PE_COLOR_EXPECTED); - } while (CurToken.eType == TCOLOR); + } while (m_aCurToken.eType == TCOLOR); - NodeStack.Push(new SmFontNode(aToken)); + m_aNodeStack.Push(new SmFontNode(aToken)); } void SmParser::Font() { - DBG_ASSERT(CurToken.eType == TFONT, "Sm : Ooops..."); + DBG_ASSERT(m_aCurToken.eType == TFONT, "Sm : Ooops..."); // last font rules, get that one SmToken aToken; @@ -1895,14 +1897,14 @@ void SmParser::Font() { NextToken(); if (TokenInGroup(TGFONT)) - { aToken = CurToken; + { aToken = m_aCurToken; NextToken(); } else Error(PE_FONT_EXPECTED); - } while (CurToken.eType == TFONT); + } while (m_aCurToken.eType == TFONT); - NodeStack.Push(new SmFontNode(aToken)); + m_aNodeStack.Push(new SmFontNode(aToken)); } @@ -1930,14 +1932,14 @@ BOOL lcl_IsNumber(const UniString& rText) void SmParser::FontSize() { - DBG_ASSERT(CurToken.eType == TSIZE, "Sm : Ooops..."); + DBG_ASSERT(m_aCurToken.eType == TSIZE, "Sm : Ooops..."); USHORT Type; - SmFontNode *pFontNode = new SmFontNode(CurToken); + SmFontNode *pFontNode = new SmFontNode(m_aCurToken); NextToken(); - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TNUMBER: Type = FNTSIZ_ABSOLUT; break; case TPLUS: Type = FNTSIZ_PLUS; break; @@ -1954,7 +1956,7 @@ void SmParser::FontSize() if (Type != FNTSIZ_ABSOLUT) { NextToken(); - if (CurToken.eType != TNUMBER) + if (m_aCurToken.eType != TNUMBER) { delete pFontNode; Error(PE_SIZE_EXPECTED); @@ -1964,10 +1966,10 @@ void SmParser::FontSize() // get number argument Fraction aValue( 1L ); - if (lcl_IsNumber( CurToken.aText )) + if (lcl_IsNumber( m_aCurToken.aText )) { double fTmp; - if ((fTmp = CurToken.aText.ToDouble()) != 0.0) + if ((fTmp = m_aCurToken.aText.ToDouble()) != 0.0) { aValue = fTmp; @@ -1993,23 +1995,23 @@ void SmParser::FontSize() NextToken(); pFontNode->SetSizeParameter(aValue, Type); - NodeStack.Push(pFontNode); + m_aNodeStack.Push(pFontNode); } void SmParser::Brace() { - DBG_ASSERT(CurToken.eType == TLEFT || TokenInGroup(TGLBRACES), + DBG_ASSERT(m_aCurToken.eType == TLEFT || TokenInGroup(TGLBRACES), "Sm: kein Klammer Ausdruck"); - SmStructureNode *pSNode = new SmBraceNode(CurToken); + SmStructureNode *pSNode = new SmBraceNode(m_aCurToken); SmNode *pBody = 0, *pLeft = 0, *pRight = 0; SmScaleMode eScaleMode = SCALE_NONE; SmParseError eError = PE_NONE; - if (CurToken.eType == TLEFT) + if (m_aCurToken.eType == TLEFT) { NextToken(); eScaleMode = SCALE_HEIGHT; @@ -2017,19 +2019,19 @@ void SmParser::Brace() // check for left bracket if (TokenInGroup(TGLBRACES) || TokenInGroup(TGRBRACES)) { - pLeft = new SmMathSymbolNode(CurToken); + pLeft = new SmMathSymbolNode(m_aCurToken); NextToken(); Bracebody(TRUE); - pBody = NodeStack.Pop(); + pBody = m_aNodeStack.Pop(); - if (CurToken.eType == TRIGHT) + if (m_aCurToken.eType == TRIGHT) { NextToken(); // check for right bracket if (TokenInGroup(TGLBRACES) || TokenInGroup(TGRBRACES)) { - pRight = new SmMathSymbolNode(CurToken); + pRight = new SmMathSymbolNode(m_aCurToken); NextToken(); } else @@ -2045,11 +2047,11 @@ void SmParser::Brace() { if (TokenInGroup(TGLBRACES)) { - pLeft = new SmMathSymbolNode(CurToken); + pLeft = new SmMathSymbolNode(m_aCurToken); NextToken(); Bracebody(FALSE); - pBody = NodeStack.Pop(); + pBody = m_aNodeStack.Pop(); SmTokenType eExpectedType = TUNKNOWN; switch (pLeft->GetToken().eType) @@ -2066,9 +2068,9 @@ void SmParser::Brace() DBG_ASSERT(0, "Sm: unbekannter Fall"); } - if (CurToken.eType == eExpectedType) + if (m_aCurToken.eType == eExpectedType) { - pRight = new SmMathSymbolNode(CurToken); + pRight = new SmMathSymbolNode(m_aCurToken); NextToken(); } else @@ -2083,7 +2085,7 @@ void SmParser::Brace() DBG_ASSERT(pRight, "Sm: NULL pointer"); pSNode->SetSubNodes(pLeft, pBody, pRight); pSNode->SetScaleMode(eScaleMode); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } else { delete pSNode; @@ -2098,7 +2100,7 @@ void SmParser::Brace() void SmParser::Bracebody(BOOL bIsLeftRight) { - SmStructureNode *pBody = new SmBracebodyNode(CurToken); + SmStructureNode *pBody = new SmBracebodyNode(m_aCurToken); SmNodeArray aNodes; USHORT nNum = 0; @@ -2107,28 +2109,28 @@ void SmParser::Bracebody(BOOL bIsLeftRight) { do { - if (CurToken.eType == TMLINE) + if (m_aCurToken.eType == TMLINE) { - NodeStack.Push(new SmMathSymbolNode(CurToken)); + m_aNodeStack.Push(new SmMathSymbolNode(m_aCurToken)); NextToken(); nNum++; } - else if (CurToken.eType != TRIGHT) + else if (m_aCurToken.eType != TRIGHT) { Align(); nNum++; - if (CurToken.eType != TMLINE && CurToken.eType != TRIGHT) + if (m_aCurToken.eType != TMLINE && m_aCurToken.eType != TRIGHT) Error(PE_RIGHT_EXPECTED); } - } while (CurToken.eType != TEND && CurToken.eType != TRIGHT); + } while (m_aCurToken.eType != TEND && m_aCurToken.eType != TRIGHT); } else { do { - if (CurToken.eType == TMLINE) + if (m_aCurToken.eType == TMLINE) { - NodeStack.Push(new SmMathSymbolNode(CurToken)); + m_aNodeStack.Push(new SmMathSymbolNode(m_aCurToken)); NextToken(); nNum++; } @@ -2136,26 +2138,26 @@ void SmParser::Bracebody(BOOL bIsLeftRight) { Align(); nNum++; - if (CurToken.eType != TMLINE && !TokenInGroup(TGRBRACES)) + if (m_aCurToken.eType != TMLINE && !TokenInGroup(TGRBRACES)) Error(PE_RBRACE_EXPECTED); } - } while (CurToken.eType != TEND && !TokenInGroup(TGRBRACES)); + } while (m_aCurToken.eType != TEND && !TokenInGroup(TGRBRACES)); } // build argument vector in parsing order aNodes.resize(nNum); for (USHORT i = 0; i < nNum; i++) - aNodes[nNum - 1 - i] = NodeStack.Pop(); + aNodes[nNum - 1 - i] = m_aNodeStack.Pop(); pBody->SetSubNodes(aNodes); pBody->SetScaleMode(bIsLeftRight ? SCALE_HEIGHT : SCALE_NONE); - NodeStack.Push(pBody); + m_aNodeStack.Push(pBody); } void SmParser::Function() { - switch (CurToken.eType) + switch (m_aCurToken.eType) { case TFUNC: NextToken(); // skip "FUNC"-statement @@ -2180,7 +2182,7 @@ void SmParser::Function() case TLN : case TLOG : case TEXP : - NodeStack.Push(new SmTextNode(CurToken, FNT_FUNCTION)); + m_aNodeStack.Push(new SmTextNode(m_aCurToken, FNT_FUNCTION)); NextToken(); break; @@ -2193,7 +2195,7 @@ void SmParser::Function() void SmParser::Binom() { SmNodeArray ExpressionArray; - SmStructureNode *pSNode = new SmTableNode(CurToken); + SmStructureNode *pSNode = new SmTableNode(m_aCurToken); NextToken(); @@ -2203,10 +2205,10 @@ void SmParser::Binom() ExpressionArray.resize(2); for (int i = 0; i < 2; i++) - ExpressionArray[2 - (i + 1)] = NodeStack.Pop(); + ExpressionArray[2 - (i + 1)] = m_aNodeStack.Pop(); pSNode->SetSubNodes(ExpressionArray); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } @@ -2214,7 +2216,7 @@ void SmParser::Stack() { SmNodeArray ExpressionArray; NextToken(); - if (CurToken.eType == TLGROUP) + if (m_aCurToken.eType == TLGROUP) { USHORT n = 0; @@ -2224,21 +2226,21 @@ void SmParser::Stack() Align(); n++; } - while (CurToken.eType == TPOUND); + while (m_aCurToken.eType == TPOUND); ExpressionArray.resize(n); for (USHORT i = 0; i < n; i++) - ExpressionArray[n - (i + 1)] = NodeStack.Pop(); + ExpressionArray[n - (i + 1)] = m_aNodeStack.Pop(); - if (CurToken.eType != TRGROUP) + if (m_aCurToken.eType != TRGROUP) Error(PE_RGROUP_EXPECTED); NextToken(); - SmStructureNode *pSNode = new SmTableNode(CurToken); + SmStructureNode *pSNode = new SmTableNode(m_aCurToken); pSNode->SetSubNodes(ExpressionArray); - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); } else Error(PE_LGROUP_EXPECTED); @@ -2250,7 +2252,7 @@ void SmParser::Matrix() SmNodeArray ExpressionArray; NextToken(); - if (CurToken.eType == TLGROUP) + if (m_aCurToken.eType == TLGROUP) { USHORT c = 0; @@ -2260,11 +2262,11 @@ void SmParser::Matrix() Align(); c++; } - while (CurToken.eType == TPOUND); + while (m_aCurToken.eType == TPOUND); USHORT r = 1; - while (CurToken.eType == TDPOUND) + while (m_aCurToken.eType == TDPOUND) { NextToken(); for (USHORT i = 0; i < c; i++) @@ -2272,7 +2274,7 @@ void SmParser::Matrix() Align(); if (i < (c - 1)) { - if (CurToken.eType == TPOUND) + if (m_aCurToken.eType == TPOUND) { NextToken(); } @@ -2289,17 +2291,17 @@ void SmParser::Matrix() ExpressionArray.resize(nRC); for (USHORT i = 0; i < (nRC); i++) - ExpressionArray[(nRC) - (i + 1)] = NodeStack.Pop(); + ExpressionArray[(nRC) - (i + 1)] = m_aNodeStack.Pop(); - if (CurToken.eType != TRGROUP) + if (m_aCurToken.eType != TRGROUP) Error(PE_RGROUP_EXPECTED); NextToken(); - SmMatrixNode *pMNode = new SmMatrixNode(CurToken); + SmMatrixNode *pMNode = new SmMatrixNode(m_aCurToken); pMNode->SetSubNodes(ExpressionArray); pMNode->SetRowCol(r, c); - NodeStack.Push(pMNode); + m_aNodeStack.Push(pMNode); } else Error(PE_LGROUP_EXPECTED); @@ -2309,7 +2311,7 @@ void SmParser::Matrix() void SmParser::Special() { BOOL bReplace = FALSE; - String &rName = CurToken.aText; + String &rName = m_aCurToken.aText; String aNewName; if (CONVERT_NONE == GetConversion()) @@ -2376,28 +2378,33 @@ void SmParser::Special() rName = aNewName; } - NodeStack.Push(new SmSpecialNode(CurToken)); + // add symbol name to list of used symbols + const String aSymbolName( m_aCurToken.aText.Copy( 1 ) ); + if (aSymbolName.Len() > 0 ) + AddToUsedSymbols( aSymbolName ); + + m_aNodeStack.Push(new SmSpecialNode(m_aCurToken)); NextToken(); } void SmParser::GlyphSpecial() { - NodeStack.Push(new SmGlyphSpecialNode(CurToken)); + m_aNodeStack.Push(new SmGlyphSpecialNode(m_aCurToken)); NextToken(); } void SmParser::Error(SmParseError eError) { - SmStructureNode *pSNode = new SmExpressionNode(CurToken); - SmErrorNode *pErr = new SmErrorNode(eError, CurToken); + SmStructureNode *pSNode = new SmExpressionNode(m_aCurToken); + SmErrorNode *pErr = new SmErrorNode(eError, m_aCurToken); pSNode->SetSubNodes(pErr, 0); //! put a structure node on the stack (instead of the error node itself) //! because sometimes such a node is expected in order to attach some //! subnodes - NodeStack.Push(pSNode); + m_aNodeStack.Push(pSNode); AddError(eError, pSNode); @@ -2410,34 +2417,36 @@ void SmParser::Error(SmParseError eError) SmParser::SmParser() { - eConversion = CONVERT_NONE; - bImportSymNames = bExportSymNames = FALSE; - nLang = Application::GetSettings().GetUILanguage(); + m_eConversion = CONVERT_NONE; + m_bImportSymNames = m_bExportSymNames = FALSE; + m_nLang = Application::GetSettings().GetUILanguage(); } SmNode *SmParser::Parse(const String &rBuffer) { - BufferString = rBuffer; - BufferString.ConvertLineEnd( LINEEND_LF ); - BufferIndex = - nTokenIndex = 0; - Row = 1; - ColOff = 0; - CurError = -1; + ClearUsedSymbols(); + + m_aBufferString = rBuffer; + m_aBufferString.ConvertLineEnd( LINEEND_LF ); + m_nBufferIndex = + m_nTokenIndex = 0; + m_Row = 1; + m_nColOff = 0; + m_nCurError = -1; - for (USHORT i = 0; i < ErrDescList.Count(); i++) - delete ErrDescList.Remove(i); + for (USHORT i = 0; i < m_aErrDescList.Count(); i++) + delete m_aErrDescList.Remove(i); - ErrDescList.Clear(); + m_aErrDescList.Clear(); - NodeStack.Clear(); + m_aNodeStack.Clear(); SetLanguage( Application::GetSettings().GetUILanguage() ); NextToken(); Table(); - return NodeStack.Pop(); + return m_aNodeStack.Pop(); } @@ -2471,20 +2480,20 @@ USHORT SmParser::AddError(SmParseError Type, SmNode *pNode) } pErrDesc->Text += SmResId(nRID); - ErrDescList.Insert(pErrDesc); + m_aErrDescList.Insert(pErrDesc); - return (USHORT) ErrDescList.GetPos(pErrDesc); + return (USHORT) m_aErrDescList.GetPos(pErrDesc); } const SmErrorDesc *SmParser::NextError() { - if (ErrDescList.Count()) - if (CurError > 0) return ErrDescList.Seek(--CurError); + if (m_aErrDescList.Count()) + if (m_nCurError > 0) return m_aErrDescList.Seek(--m_nCurError); else { - CurError = 0; - return ErrDescList.Seek(CurError); + m_nCurError = 0; + return m_aErrDescList.Seek(m_nCurError); } else return 0; } @@ -2492,12 +2501,12 @@ const SmErrorDesc *SmParser::NextError() const SmErrorDesc *SmParser::PrevError() { - if (ErrDescList.Count()) - if (CurError < (int) (ErrDescList.Count() - 1)) return ErrDescList.Seek(++CurError); + if (m_aErrDescList.Count()) + if (m_nCurError < (int) (m_aErrDescList.Count() - 1)) return m_aErrDescList.Seek(++m_nCurError); else { - CurError = (int) (ErrDescList.Count() - 1); - return ErrDescList.Seek(CurError); + m_nCurError = (int) (m_aErrDescList.Count() - 1); + return m_aErrDescList.Seek(m_nCurError); } else return 0; } @@ -2505,9 +2514,9 @@ const SmErrorDesc *SmParser::PrevError() const SmErrorDesc *SmParser::GetError(USHORT i) { - return (/*i >= 0 &&*/ i < ErrDescList.Count()) - ? ErrDescList.Seek(i) - : ErrDescList.Seek(CurError); + return (/*i >= 0 &&*/ i < m_aErrDescList.Count()) + ? m_aErrDescList.Seek(i) + : m_aErrDescList.Seek(m_nCurError); } diff --git a/starmath/source/smmod.cxx b/starmath/source/smmod.cxx index 9dcd4d05930d..4e3eebf99a65 100644..100755 --- a/starmath/source/smmod.cxx +++ b/starmath/source/smmod.cxx @@ -352,6 +352,7 @@ SfxItemSet* SmModule::CreateItemSet( USHORT nId ) SID_PRINTTEXT, SID_PRINTTEXT, SID_PRINTFRAME, SID_PRINTFRAME, SID_NO_RIGHT_SPACES, SID_NO_RIGHT_SPACES, + SID_SAVE_ONLY_USED_SYMBOLS, SID_SAVE_ONLY_USED_SYMBOLS, 0 ); GetConfig()->ConfigToItemSet(*pRet); diff --git a/starmath/source/smres.src b/starmath/source/smres.src index bef6d0bec106..41edb1790198 100644..100755 --- a/starmath/source/smres.src +++ b/starmath/source/smres.src @@ -1099,6 +1099,13 @@ TabPage RID_PRINTOPTIONPAGE Size = MAP_APPFONT ( 236 , 10 ) ; Text [ en-US ] = "Ig~nore ~~ and ` at the end of the line"; }; + CheckBox CB_SAVE_ONLY_USED_SYMBOLS + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( 12 , 154 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + Text [ en-US ] = "Embed only used symbols (smaller file size)"; + }; }; ModalDialog RID_SYMBOLDIALOG @@ -1755,18 +1762,12 @@ StringArray RID_PRINTUIOPTIONS < "%PRODUCTNAME %s"; >; < "Contents"; >; < "~Title"; >; - < "Specifies whether you want the name of the document to be included in the printout"; >; < "~Formula text"; >; - < "Specifies whether to include the contents of the 'Commands' window at the bottom of the printout."; >; < "B~orders"; >; - < "Applies a thin border to the formula area in the printout."; >; < "Size"; >; < "O~riginal size"; >; - < "Prints the formula without adjusting the current font size."; >; < "Fit to ~page"; >; - < "Adjusts the formula to the page format used in the printout."; >; < "~Scaling"; >; - < "Reduces or enlarges the size of the printed formula by a specified enlargement factor."; >; }; }; diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx index 52d0520ae61b..bd3420773587 100644 --- a/starmath/source/symbol.cxx +++ b/starmath/source/symbol.cxx @@ -218,14 +218,19 @@ bool SmSymbolManager::AddOrReplaceSymbol( const SmSym &rSymbol, bool bForceChang } else if (pFound && !bForceChange && bSymbolConflict) { - // TODO: but what ... - DBG_ASSERT( 0, "symbol conflict, different symbol with same name found!" ); + // TODO: to solve this a document owned symbol manager would be required ... + // But for now we have a global one to easily support availability of all + // symbols in all formulas. A copy of the global one would be needed here + // and then the new symbol has to be forcefully applied. This would keep + // the current formula intact but will leave the set of symbols in the + // global symbol manager somewhat to chance. + DBG_ASSERT( 0, "symbol conflict, different symbol with same name found!" ); } - } - DBG_ASSERT( bAdded, "failed to add symbol" ); - if (bAdded) - m_bModified = true; + if (bAdded) + m_bModified = true; + DBG_ASSERT( bAdded || (pFound && !bSymbolConflict), "AddOrReplaceSymbol: unresolved symbol conflict" ); + } return bAdded; } diff --git a/starmath/source/toolbox.hrc b/starmath/source/toolbox.hrc index 29adff303a3e..29adff303a3e 100755..100644 --- a/starmath/source/toolbox.hrc +++ b/starmath/source/toolbox.hrc diff --git a/starmath/source/toolbox.src b/starmath/source/toolbox.src index ead1b32810c3..ead1b32810c3 100755..100644 --- a/starmath/source/toolbox.src +++ b/starmath/source/toolbox.src diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 108cb9c69e4a..3aa9001f8319 100755 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -81,8 +81,8 @@ using namespace ::com::sun::star::script; SmPrintUIOptions::SmPrintUIOptions() { ResStringArray aLocalizedStrings( SmResId( RID_PRINTUIOPTIONS ) ); - DBG_ASSERT( aLocalizedStrings.Count() >= 15, "resource incomplete" ); - if( aLocalizedStrings.Count() < 15 ) // bad resource ? + DBG_ASSERT( aLocalizedStrings.Count() >= 9, "resource incomplete" ); + if( aLocalizedStrings.Count() < 9 ) // bad resource ? return; SmModule *pp = SM_MOD(); @@ -100,42 +100,42 @@ SmPrintUIOptions::SmPrintUIOptions() String aAppGroupname( aLocalizedStrings.GetString( 0 ) ); aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), aOpt.GetModuleName( SvtModuleOptions::E_SMATH ) ); - m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); + m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) ); // create subgroup for print options m_aUIProperties[1].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() ); // create a bool option for title row (matches to SID_PRINTTITLE) m_aUIProperties[2].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), - aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TitleRow:CheckBox" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_TITLE_ROW ) ), pConfig->IsPrintTitle() ); // create a bool option for formula text (matches to SID_PRINTTEXT) - m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), - aLocalizedStrings.GetString( 5 ), + m_aUIProperties[3].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:FormulaText:CheckBox" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_FORMULA_TEXT ) ), pConfig->IsPrintFormulaText() ); // create a bool option for border (matches to SID_PRINTFRAME) - m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), - aLocalizedStrings.GetString( 7 ), + m_aUIProperties[4].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Border:CheckBox" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_BORDER ) ), pConfig->IsPrintFrame() ); // create subgroup for print format - m_aUIProperties[5].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 8 ), rtl::OUString() ); + m_aUIProperties[5].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 5 ), rtl::OUString() ); // create a radio button group for print format (matches to SID_PRINTSIZE) Sequence< rtl::OUString > aChoices( 3 ); - aChoices[0] = aLocalizedStrings.GetString( 9 ); - aChoices[1] = aLocalizedStrings.GetString( 11 ); - aChoices[2] = aLocalizedStrings.GetString( 13 ); - Sequence< rtl::OUString > aHelpTexts( 3 ); - aHelpTexts[0] = aLocalizedStrings.GetString( 10 ); - aHelpTexts[1] = aLocalizedStrings.GetString( 12 ); - aHelpTexts[2] = aLocalizedStrings.GetString( 14 ); + aChoices[0] = aLocalizedStrings.GetString( 6 ); + aChoices[1] = aLocalizedStrings.GetString( 7 ); + aChoices[2] = aLocalizedStrings.GetString( 8 ); + Sequence< rtl::OUString > aHelpIds( 3 ); + aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:0" ) ); + aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:1" ) ); + aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintFormat:RadioButton:2" ) ); OUString aPrintFormatProp( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_FORMAT ) ); m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(), - aHelpTexts, + aHelpIds, aPrintFormatProp, aChoices, static_cast< sal_Int32 >(pConfig->GetPrintSize()) ); @@ -143,7 +143,7 @@ SmPrintUIOptions::SmPrintUIOptions() // create a numeric box for scale dependent on PrintFormat = "Scaling" (matches to SID_PRINTZOOM) vcl::PrinterOptionsHelper::UIControlOptions aRangeOpt( aPrintFormatProp, 2, sal_True ); m_aUIProperties[ 7 ].Value = getRangeControlOpt( rtl::OUString(), - aLocalizedStrings.GetString( 14 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintScale:NumericField" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( PRTUIOPT_PRINT_SCALE ) ), pConfig->GetPrintZoomFactor(), // initial value 10, // min value @@ -171,7 +171,11 @@ SmPrintUIOptions::SmPrintUIOptions() // // class SmModel // -#define PROPERTY_NONE 0 + +// values from com/sun/star/beans/PropertyAttribute +#define PROPERTY_NONE 0 +#define PROPERTY_READONLY 16 + enum SmModelPropertyHandles { HANDLE_FORMULA, @@ -233,6 +237,7 @@ enum SmModelPropertyHandles HANDLE_PRINTER_NAME, HANDLE_PRINTER_SETUP, HANDLE_SYMBOLS, + HANDLE_USED_SYMBOLS, HANDLE_BASIC_LIBRARIES, /* #93295# */ HANDLE_RUNTIME_UID, // --> PB 2004-08-25 #i33095# Security Options @@ -307,6 +312,7 @@ PropertySetInfo * lcl_createModelPropertyInfo () { RTL_CONSTASCII_STRINGPARAM( "RightMargin" ), HANDLE_RIGHT_MARGIN , &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, DIS_RIGHTSPACE }, { RTL_CONSTASCII_STRINGPARAM( "RuntimeUID" ), HANDLE_RUNTIME_UID , &::getCppuType(static_cast< const rtl::OUString * >(0)), PropertyAttribute::READONLY, 0 }, { RTL_CONSTASCII_STRINGPARAM( "Symbols" ), HANDLE_SYMBOLS , &::getCppuType((const Sequence < SymbolDescriptor > *)0), PROPERTY_NONE, 0 }, + { RTL_CONSTASCII_STRINGPARAM( "UserDefinedSymbolsInUse" ), HANDLE_USED_SYMBOLS , &::getCppuType((const Sequence < SymbolDescriptor > *)0), PropertyAttribute::READONLY, 0 }, { RTL_CONSTASCII_STRINGPARAM( "TopMargin" ), HANDLE_TOP_MARGIN , &::getCppuType((const sal_Int16*)0), PROPERTY_NONE, DIS_TOPSPACE }, // --> PB 2004-08-25 #i33095# Security Options { RTL_CONSTASCII_STRINGPARAM( "LoadReadonly" ), HANDLE_LOAD_READONLY, &::getBooleanCppuType(), PROPERTY_NONE, 0 }, @@ -904,7 +910,11 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu } break; case HANDLE_SYMBOLS: + case HANDLE_USED_SYMBOLS: { + const bool bUsedSymbolsOnly = (*ppEntries)->mnHandle == HANDLE_USED_SYMBOLS; + const std::set< rtl::OUString > &rUsedSymbols = pDocSh->GetUsedSymbols(); + // this is get SmModule *pp = SM_MOD(); const SmSymbolManager &rManager = pp->GetSymbolManager(); @@ -915,7 +925,9 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu for (size_t i = 0; i < aSymbols.size(); ++i) { const SmSym * pSymbol = aSymbols[ i ]; - if (pSymbol && !pSymbol->IsPredefined () ) + const bool bIsUsedSymbol = rUsedSymbols.find( pSymbol->GetName() ) != rUsedSymbols.end(); + if (pSymbol && !pSymbol->IsPredefined() && + (!bUsedSymbolsOnly || bIsUsedSymbol)) { aVector.push_back ( pSymbol ); nCount++; diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 748e62e3536e..5d2d624c285e 100755 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -34,6 +34,9 @@ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/XFramesSupplier.hpp> +#include <com/sun/star/container/XChild.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> @@ -652,7 +655,51 @@ void SmCmdBoxWindow::StateChanged( StateChangedType nStateChange ) IMPL_LINK( SmCmdBoxWindow, InitialFocusTimerHdl, Timer *, EMPTYARG /*pTimer*/ ) { - aEdit.GrabFocus(); + // We want to have the focus in the edit window once Math has been opened + // to allow for immediate typing. + // Problem: There is no proper way to do this + // Thus: this timer based soultion has been implemented (see GrabFocus below) + // + // Follow-up problem (#i114910): grabing the focus may bust the help system since + // it relies on getting the current frame which conflicts with grabbing the focus. + // Thus aside from the 'GrabFocus' call everything else is to get the + // help reliably working despite using 'GrabFocus'. + + try + { + uno::Reference< frame::XDesktop > xDesktop; + uno::Reference< lang::XMultiServiceFactory > xSMGR( comphelper::getProcessServiceFactory() ); + if (xSMGR.is()) + { + xDesktop = uno::Reference< frame::XDesktop >( + xSMGR->createInstance( rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" )), uno::UNO_QUERY_THROW ); + } + + aEdit.GrabFocus(); + + if (xDesktop.is()) + { + bool bInPlace = GetView()->GetViewFrame()->GetFrame().IsInPlace(); + uno::Reference< frame::XFrame > xFrame( GetBindings().GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface()); + if ( bInPlace ) + { + uno::Reference< container::XChild > xModel( GetView()->GetDoc()->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XModel > xParent( xModel->getParent(), uno::UNO_QUERY_THROW ); + uno::Reference< frame::XController > xParentCtrler( xParent->getCurrentController() ); + uno::Reference< frame::XFramesSupplier > xParentFrame( xParentCtrler->getFrame(), uno::UNO_QUERY_THROW ); + xParentFrame->setActiveFrame( xFrame ); + } + else + { + uno::Reference< frame::XFramesSupplier > xFramesSupplier( xDesktop, uno::UNO_QUERY ); + xFramesSupplier->setActiveFrame( xFrame ); + } + } + } + catch (uno::Exception &) + { + DBG_ASSERT( 0, "failed to properly set initial focus to edit window" ); + } return 0; } @@ -1156,7 +1203,7 @@ void SmViewShell::Impl_Print( rOutDev.Pop(); } -USHORT SmViewShell::Print(SfxProgress & /*rProgress*/, BOOL /*bIsAPI*/, PrintDialog * /*pPrintDialog*/) +USHORT SmViewShell::Print(SfxProgress & /*rProgress*/, BOOL /*bIsAPI*/) { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::Print" ); DBG_ASSERT( 0, "SmViewShell::Print: no longer used with new UI print dialog. Should be removed!!" ); diff --git a/starmath/uiconfig/smath/menubar/menubar.xml b/starmath/uiconfig/smath/menubar/menubar.xml index 7c82d733fa70..7c82d733fa70 100755..100644 --- a/starmath/uiconfig/smath/menubar/menubar.xml +++ b/starmath/uiconfig/smath/menubar/menubar.xml diff --git a/sw/Library_msword.mk b/sw/Library_msword.mk index ee33da85561f..34a52e4786c7 100644 --- a/sw/Library_msword.mk +++ b/sw/Library_msword.mk @@ -114,6 +114,21 @@ $(eval $(call gb_Library_add_exception_objects,msword,\ )) ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,msword,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,msword,\ advapi32 \ kernel32 \ @@ -123,4 +138,5 @@ $(eval $(call gb_Library_add_linked_libs,msword,\ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index cc1df51d2dba..e8e127d3ab0f 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -737,6 +737,21 @@ $(eval $(call gb_Library_add_linked_libs,sw,\ endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,sw,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,sw,\ advapi32 \ kernel32 \ @@ -746,6 +761,7 @@ $(eval $(call gb_Library_add_linked_libs,sw,\ uwinapi \ )) endif +endif $(eval $(call gb_SdiTarget_SdiTarget,sw/sdi/swslots,sw/sdi/swriter)) diff --git a/sw/Library_swd.mk b/sw/Library_swd.mk index 17511d3bf4ed..39440092c574 100644 --- a/sw/Library_swd.mk +++ b/sw/Library_swd.mk @@ -70,10 +70,23 @@ $(eval $(call gb_Library_add_exception_objects,swd,\ sw/source/ui/uno/swdetect \ )) ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,swd,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + mingwex \ + kernel32 \ + msvcrt \ +)) +else $(eval $(call gb_Library_add_linked_libs,swd,\ kernel32 \ msvcrt \ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 12227c9a0ae8..927aaab1fd98 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -167,6 +167,21 @@ $(eval $(call gb_Library_add_exception_objects,swui,\ )) ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,swui,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,swui,\ advapi32 \ kernel32 \ @@ -176,4 +191,5 @@ $(eval $(call gb_Library_add_linked_libs,swui,\ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/sw/Library_vbaswobj.mk b/sw/Library_vbaswobj.mk index 44bbfa8a0c6f..645d383dd8f9 100644 --- a/sw/Library_vbaswobj.mk +++ b/sw/Library_vbaswobj.mk @@ -126,6 +126,21 @@ $(eval $(call gb_Library_set_ldflags,vbaswobj,\ endif ifeq ($(OS),WNT) +ifneq ($(USE_MINGW),) +$(eval $(call gb_Library_add_linked_libs,vbaswobj,\ + mingwthrd \ + $(gb_MINGW_LIBSTDCPP) \ + mingw32 \ + $(gb_MINGW_LIBGCC) \ + uwinapi \ + moldname \ + mingwex \ + advapi32 \ + kernel32 \ + msvcrt \ + user32 \ +)) +else $(eval $(call gb_Library_add_linked_libs,vbaswobj,\ advapi32 \ kernel32 \ @@ -135,4 +150,5 @@ $(eval $(call gb_Library_add_linked_libs,vbaswobj,\ uwinapi \ )) endif +endif # vim: set noet sw=4 ts=4: diff --git a/sw/inc/IDocumentDeviceAccess.hxx b/sw/inc/IDocumentDeviceAccess.hxx index 75e6d650a203..42923a2fadf4 100755 --- a/sw/inc/IDocumentDeviceAccess.hxx +++ b/sw/inc/IDocumentDeviceAccess.hxx @@ -129,7 +129,7 @@ @returns the current PrintData */ - virtual SwPrintData* getPrintData() const = 0; + virtual const SwPrintData & getPrintData() const = 0; /** Sets the PrintData diff --git a/sw/inc/IDocumentUndoRedo.hxx b/sw/inc/IDocumentUndoRedo.hxx index a224395429a9..0d78d3b361c9 100644 --- a/sw/inc/IDocumentUndoRedo.hxx +++ b/sw/inc/IDocumentUndoRedo.hxx @@ -29,59 +29,87 @@ #define IDOCUMENTUNDOREDO_HXX_INCLUDED #include <sal/types.h> + #include <swundo.hxx> -class SwUndoIter; class SwRewriter; -class String; -class SwUndoIds; class SwNodes; class SwUndo; +namespace sw { + class RepeatContext; +} + -typedef sal_uInt16 SwUndoNoModifiedPosition; /** IDocumentUndoRedo */ class IDocumentUndoRedo { public: - /** + + /** Enable/Disable Undo. */ - virtual void SetUndoNoResetModified() = 0; + virtual void DoUndo(bool const bDoUndo) = 0; - /** + /** Is Undo enabled? */ - virtual bool IsUndoNoResetModified() const = 0; + virtual bool DoesUndo() const = 0; - /** UndoHistory am Dokument pflegen - bei Save, SaveAs, Create wird UndoHistory zurueckgesetzt ??? + /** Enable/Disable Group Undo. + This determines whether successive Insert/Delete/Overwrite + actions are combined. */ - virtual void DoUndo(bool bUn) = 0; + virtual void DoGroupUndo(bool const bDoUndo) = 0; - /** + /** Is Group Undo enabled? */ - virtual bool DoesUndo() const = 0; + virtual bool DoesGroupUndo() const = 0; + + /** Enable/Disable Undo for Drawing objects. + */ + virtual void DoDrawUndo(bool const bDoUndo) = 0; - /** Zusammenfassen von Kontinuierlichen Insert/Delete/Overwrite von - Charaktern. Default ist ::com::sun::star::sdbcx::Group-Undo. + /** Is Undo for Drawing objects enabled? + for Draw-Undo: writer wants to handle actions on Flys on its own. + */ + virtual bool DoesDrawUndo() const = 0; + + /** Set the position at which the document is in the "unmodified" state + to the current position in the Undo stack. */ - virtual void DoGroupUndo(bool bUn) = 0; + virtual void SetUndoNoModifiedPosition() = 0; - /** + /** Prevent updates to the "unmodified" state position + via SetUndoNoResetModified(). */ - virtual bool DoesGroupUndo() const = 0; + virtual void LockUndoNoModifiedPosition() = 0; - /** macht rueckgaengig: - 0 letzte Aktion, sonst Aktionen bis zum Start der Klammerung nUndoId - In rUndoRange wird der restaurierte Bereich gesetzt. + /** Allow updates to the "unmodified" state position + via SetUndoNoResetModified(). */ - virtual bool Undo( SwUndoIter& ) = 0; // -> #111827# + virtual void UnLockUndoNoModifiedPosition() = 0; + + /** Disable (re)setting the document modified flag on Undo/Redo. + */ + virtual void SetUndoNoResetModified() = 0; + + /** Is setting the document modified flag on Undo/Redo disabled? + */ + virtual bool IsUndoNoResetModified() const = 0; + + /** Execute Undo. + + @return true if executing the last Undo action was successful. + */ + virtual sal_Bool Undo() = 0; /** Opens undo block. - @param nUndoId undo ID for the start object + @remark StartUndo() and EndUndo() do nothing if !DoesUndo(). + + @param nUndoId undo ID for the list action @param pRewriter rewriter for comments @see SwUndo::GetComment If the given nUndoId is equal to zero an undo object with ID @@ -89,105 +117,167 @@ public: @return the undo ID of the created object */ - virtual SwUndoId StartUndo( SwUndoId eUndoId, const SwRewriter * pRewriter) = 0; + virtual SwUndoId StartUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter) = 0; /** Closes undo block. - @param nUndoId undo ID for the closure object - @param pRewriter rewriter for comments @see SwUndo::GetComment + @remark StartUndo() and EndUndo() do nothing if !DoesUndo(). - If the given nUndoId is equal to zero an undo object with ID - UNDO_START will be generated. + @param nUndoId undo ID for the list action + @param pRewriter rewriter for comments @see SwUndo::GetComment - If pRewriter is not equal to zero the given rewriter will be - set for the generated closure object and the corresponding - start object. Otherwise an existent rewriter in theIDocumentRedlineAccess - corresponding start object will be propagated to the generated - closure object. + If the given nUndoId is not UNDO_EMPTY or UNDO_END, the comment of + the resulting list action will be set via the nUndoId, applying the + given pRewriter (if not 0). Otherwise the comment of the resulting + list action is unchanged if it has an UndoId that is not UNDO_START + set by StartUndo, and in case the UndoId is UNDO_START the comment + of the list action defaults to the comment of the last action + contained in the list action. */ - virtual SwUndoId EndUndo( SwUndoId eUndoId, const SwRewriter * pRewriter) = 0; + virtual SwUndoId EndUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter) = 0; /** <- #111827# - loescht die gesamten UndoObjecte ( fuer Methoden die am Nodes - Array drehen ohne entsprechendes Undo !!) + Delete all Undo actions. + Of course Undo will be disabled during deletion. */ virtual void DelAllUndoObj() = 0; - /** liefert die Id der letzten undofaehigen Aktion zurueck - oder USHRT_MAX fuellt ggf. VARARR mit ::com::sun::star::sdbcx::User-UndoIds + /** Get Id and comment of last Undo action. + @param o_pStr if not 0, receives comment of last Undo action. + @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 GetUndoIds(String* pStr, SwUndoIds *pUndoIds) 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. */ - virtual String GetUndoIdsStr(String* pStr, SwUndoIds *pUndoIds) const = 0; + virtual SwUndoComments_t GetUndoComments() const = 0; - /** gibt es Klammerung mit der Id? - */ - virtual bool HasUndoId(SwUndoId eId) const = 0; + /** Execute Redo. - /* @@@MAINTAINABILITY-HORROR@@@ - Implementation details made public. - die drei folgenden Methoden werden beim Undo und nur dort - benoetigt. Sollten sonst nicht aufgerufen werden. + @return true if executing the first Redo action was successful. */ - virtual const SwNodes* GetUndoNds() const = 0; + virtual sal_Bool Redo() = 0; - virtual SwUndo* RemoveLastUndo(SwUndoId eUndoId) = 0; - - /** 2002-05-31 dvo, #95884#: To prevent an undo array overflow when - doing nested undos, undo may have to be disabled. Undo-intensive - actions (like auto-format) should check this manually. + /** Get comment of first Redo action. + @param o_pStr if not 0, receives comment of first Redo action. + @return true if there is a Redo action, false if none */ - virtual bool HasTooManyUndos() const = 0; + virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const = 0; - /** + /** Get comments of Redo actions. + @return comments of all top-level Redo actions. */ - virtual bool Redo( SwUndoIter& ) = 0; + virtual SwUndoComments_t GetRedoComments() const = 0; - /** liefert die Id der letzten Redofaehigen Aktion zurueck - fuellt ggf. VARARR mit RedoIds + /** Repeat the last Undo action. + @return true if repeating the last Undo Redo action was attempted. */ - virtual SwUndoId GetRedoIds( String* pStr, SwUndoIds *pRedoIds) const = 0; - - /** + virtual bool Repeat(::sw::RepeatContext & rContext, + sal_uInt16 const nRepeatCnt) = 0; + + /** Get Id and comment of last Undo action, if it is Repeat capable. + @param o_pStr if not 0, receives comment of last Undo action + if it is Repeat capable. + @return Id of last Undo action if it is Repeat capable, + or UNDO_EMPTY if there is none or it is not Repeat capable. */ - virtual String GetRedoIdsStr( String* pStr, SwUndoIds *pRedoIds) const = 0; + virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const = 0; - /** + /** Add new Undo action. + Takes over ownership of pUndo. + @remark calls ClearRedo(), except for UNDO_START/UNDO_END. + @remark does nothing if !DoesUndo(). */ - virtual bool Repeat( SwUndoIter&, sal_uInt16 nRepeatCnt) = 0; + virtual void AppendUndo(SwUndo *const pUndo) = 0; - /** liefert die Id der letzten Repeatfaehigen Aktion zurueck - fuellt ggf. VARARR mit RedoIds + /** Delete all Redo actions. */ - virtual SwUndoId GetRepeatIds( String* pStr, SwUndoIds *pRedoIds) const = 0; + virtual void ClearRedo() = 0; - /** + /* Is the given nodes array the Undo nodes array? */ - virtual String GetRepeatIdsStr( String* pStr, SwUndoIds *pRedoIds) const = 0; + virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0; - /** interne Verkuerzung fuer Insert am Ende - */ - virtual void AppendUndo(SwUndo*) = 0; +protected: + virtual ~IDocumentUndoRedo() {}; +}; - /** loescht alle UndoObjecte von nUndoPos - bis zum Ende des Undo-Arrays - */ - virtual void ClearRedo() = 0; - /** Manipulates the position of the undo stack which reset the modified flag - */ - virtual void setUndoNoModifiedPosition( SwUndoNoModifiedPosition ) = 0; +namespace sw { - /** Gets the position of the undo stack which reset the modified flag - */ - virtual SwUndoNoModifiedPosition getUndoNoModifiedPosition() const = 0; +class UndoGuard +{ +public: -protected: - virtual ~IDocumentUndoRedo() {}; + UndoGuard(IDocumentUndoRedo & rUndoRedo) + : m_rUndoRedo(rUndoRedo) + , m_bUndoWasEnabled(rUndoRedo.DoesUndo()) + { + m_rUndoRedo.DoUndo(false); + } + ~UndoGuard() + { + m_rUndoRedo.DoUndo(m_bUndoWasEnabled); + } + + bool UndoWasEnabled() const + { + return m_bUndoWasEnabled; + } + +private: + IDocumentUndoRedo & m_rUndoRedo; + bool const m_bUndoWasEnabled; +}; + +class GroupUndoGuard +{ +public: + + GroupUndoGuard(IDocumentUndoRedo & rUndoRedo) + : m_rUndoRedo(rUndoRedo) + , m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo()) + { + m_rUndoRedo.DoGroupUndo(false); + } + ~GroupUndoGuard() + { + m_rUndoRedo.DoGroupUndo(m_bGroupUndoWasEnabled); + } + +private: + IDocumentUndoRedo & m_rUndoRedo; + bool const m_bGroupUndoWasEnabled; }; +class DrawUndoGuard +{ +public: + + DrawUndoGuard(IDocumentUndoRedo & rUndoRedo) + : m_rUndoRedo(rUndoRedo) + , m_bDrawUndoWasEnabled(rUndoRedo.DoesDrawUndo()) + { + m_rUndoRedo.DoDrawUndo(false); + } + ~DrawUndoGuard() + { + m_rUndoRedo.DoDrawUndo(m_bDrawUndoWasEnabled); + } + +private: + IDocumentUndoRedo & m_rUndoRedo; + bool const m_bDrawUndoWasEnabled; +}; + + +} // namespace sw + #endif diff --git a/sw/inc/IShellCursorSupplier.hxx b/sw/inc/IShellCursorSupplier.hxx new file mode 100644 index 000000000000..a160f43d40dd --- /dev/null +++ b/sw/inc/IShellCursorSupplier.hxx @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ISHELLCURSORSUPPLIER_HXX +#define ISHELLCURSORSUPPLIER_HXX + + +class SwPaM; + + +namespace sw { + +/** The Undo actions need to create new Shell cursors. + Just creating new SwPaMs in the Undo actions is not sufficient, + because only Shell cursors are corrected by doccorr.cxx. + */ +class IShellCursorSupplier +{ +public: + virtual ~IShellCursorSupplier() { } + virtual SwPaM & CreateNewShellCursor() = 0; + virtual SwPaM & GetCurrentShellCursor() = 0; +}; + +} // namespace sw + +#endif // ISHELLCURSORSUPPLIER_HXX diff --git a/sw/inc/SwRewriter.hxx b/sw/inc/SwRewriter.hxx index 8d2b9bd04bbe..5c98db3807ab 100644 --- a/sw/inc/SwRewriter.hxx +++ b/sw/inc/SwRewriter.hxx @@ -31,6 +31,12 @@ #include <vector> #include <tools/string.hxx> + +String const UNDO_ARG1("$1", RTL_TEXTENCODING_ASCII_US); +String const UNDO_ARG2("$2", RTL_TEXTENCODING_ASCII_US); +String const UNDO_ARG3("$3", RTL_TEXTENCODING_ASCII_US); + + typedef std::pair<String, String> SwRewriteRule; class SwRewriter diff --git a/sw/inc/SwUndoField.hxx b/sw/inc/SwUndoField.hxx index 33f5cfd85e49..5d8d1bd92e4c 100644 --- a/sw/inc/SwUndoField.hxx +++ b/sw/inc/SwUndoField.hxx @@ -24,11 +24,14 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SW_UNDO_FIELD_HXX -#define _SW_UNDO_FIELD_HXX +#ifndef SW_UNDO_FIELD_HXX +#define SW_UNDO_FIELD_HXX #include <undobj.hxx> +#include <com/sun/star/uno/Any.h> + + class SwDoc; class SwField; class SwMsgPoolItem; @@ -53,16 +56,19 @@ class SwUndoFieldFromDoc : public SwUndoField SwMsgPoolItem * pHnt; BOOL bUpdate; + void DoImpl(); + public: SwUndoFieldFromDoc(const SwPosition & rPos, const SwField & aOldField, const SwField & aNewField, SwMsgPoolItem * pHnt, BOOL bUpdate, SwUndoId nId = UNDO_FIELD ); + virtual ~SwUndoFieldFromDoc(); - virtual void Undo(SwUndoIter & rIt); - virtual void Redo(SwUndoIter & rIt); - virtual void Repeat(SwUndoIter & rIt); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); }; class SwUndoFieldFromAPI : public SwUndoField @@ -70,6 +76,8 @@ class SwUndoFieldFromAPI : public SwUndoField com::sun::star::uno::Any aOldVal, aNewVal; USHORT nWhich; + void DoImpl(); + public: SwUndoFieldFromAPI(const SwPosition & rPos, const com::sun::star::uno::Any & rOldVal, @@ -77,9 +85,9 @@ public: USHORT nWhich); virtual ~SwUndoFieldFromAPI(); - virtual void Undo(SwUndoIter & rIt); - virtual void Redo(SwUndoIter & rIt); - virtual void Repeat(SwUndoIter & rIt); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); }; -#endif // _SW_UNDO_FIELD_HXX +#endif // SW_UNDO_FIELD_HXX diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index ac4222ab1ce9..5e0e3c4eeddb 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -911,6 +911,9 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr // #i972: bool items to be passed to SwFrmPage for evaluation #define FN_OLE_IS_MATH (FN_EXTRA2 + 114) #define FN_MATH_BASELINE_ALIGNMENT (FN_EXTRA2 + 115) + +#define FN_EMBEDDED_OBJECT (FN_EXTRA2 + 116) + /*-------------------------------------------------------------------- Bereich: Hilfe --------------------------------------------------------------------*/ diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 22cb3613502e..a050a28805ae 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -24,14 +24,16 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _CRSRSH_HXX -#define _CRSRSH_HXX +#ifndef SW_CRSRSH_HXX +#define SW_CRSRSH_HXX #include <com/sun/star/i18n/WordType.hpp> #include <tools/string.hxx> #include <tools/link.hxx> #include <tools/rtti.hxx> + +#include <IShellCursorSupplier.hxx> #include "swdllapi.h" #include <swtypes.hxx> // fuer SWPOSDOC #include <viewsh.hxx> // fuer ViewShell @@ -152,7 +154,10 @@ const int CRSR_POSOLD = 0x01, // Cursor bleibt an alter Doc-Position String *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam ); // die Cursor - Shell -class SW_DLLPUBLIC SwCrsrShell : public ViewShell, public SwModify +class SW_DLLPUBLIC SwCrsrShell + : public ViewShell + , public SwModify + , public ::sw::IShellCursorSupplier { friend class SwCallLink; friend class SwVisCrsr; @@ -331,6 +336,10 @@ public: virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); + // IShellCursorSupplier + virtual SwPaM & CreateNewShellCursor(); + virtual SwPaM & GetCurrentShellCursor(); + // neuen Cusror erzeugen und den alten anhaengen SwPaM * CreateCrsr(); // loesche den aktuellen Cursor und der folgende wird zum Aktuellen diff --git a/sw/inc/dbgoutsw.hxx b/sw/inc/dbgoutsw.hxx index e1822bd4ace9..1a33f41f69d3 100644 --- a/sw/inc/dbgoutsw.hxx +++ b/sw/inc/dbgoutsw.hxx @@ -46,7 +46,6 @@ struct SwPosition; class SwPaM; class SwNodeNum; class SwUndo; -class SwUndos; class SwRect; class SwFrmFmt; class SwFrmFmts; @@ -86,7 +85,6 @@ SW_DLLPUBLIC const char * dbg_out(const SwPosition & rPos); SW_DLLPUBLIC const char * dbg_out(const SwPaM & rPam); SW_DLLPUBLIC const char * dbg_out(const SwNodeNum & rNum); SW_DLLPUBLIC const char * dbg_out(const SwUndo & rUndo); -SW_DLLPUBLIC const char * dbg_out(const SwUndos & rUndos); SW_DLLPUBLIC const char * dbg_out(const SwRewriter & rRewriter); SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule); SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt); diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 736fbb70a3b5..5530db9af525 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -24,8 +24,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _DOC_HXX -#define _DOC_HXX +#ifndef SW_DOC_HXX +#define SW_DOC_HXX /** SwDoc interfaces */ @@ -34,7 +34,6 @@ #include <IDocumentDeviceAccess.hxx> #include <IDocumentMarkAccess.hxx> #include <IDocumentRedlineAccess.hxx> -#include <IDocumentUndoRedo.hxx> #include <IDocumentLinksAdministration.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentContentOperations.hxx> @@ -63,7 +62,6 @@ class SwList; #include <vcl/timer.hxx> #include "swdllapi.h" #include <swtypes.hxx> -#include <ndarr.hxx> #include <swatrset.hxx> #include <toxe.hxx> // enums #include <flyenum.hxx> @@ -74,6 +72,7 @@ class SwList; #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> #include <vos/ref.hxx> #include <svx/svdtypes.hxx> +#include <sfx2/objsh.hxx> #include <svl/style.hxx> #include <editeng/numitem.hxx> #include "comphelper/implementationreference.hxx" @@ -94,8 +93,6 @@ class SwList; #include <boost/scoped_ptr.hpp> -class SfxObjectShell; -class SfxObjectShellRef; class SvxForbiddenCharactersTable; class SwExtTextInput; class DateTime; @@ -155,6 +152,7 @@ class SwNewDBMgr; class SwNoTxtNode; class SwNodeIndex; class SwNodeRange; +class SwNodes; class SwNumRule; class SwNumRuleTbl; class SwPageDesc; @@ -188,10 +186,6 @@ class SwTextBlocks; class SwTxtFmtColl; class SwTxtFmtColls; class SwURLStateChanged; -class SwUndo; -class SwUndoIds; -class SwUndoIter; -class SwUndos; class SwUnoCrsr; class SwUnoCrsrTbl; class ViewShell; @@ -221,12 +215,15 @@ class SwPrintData; class SwRenderData; class SwPageFrm; class SwViewOption; +class IDocumentUndoRedo; namespace sw { namespace mark { class MarkManager; }} namespace sw { class MetaFieldManager; + class UndoManager; + class IShellCursorSupplier; } namespace com { namespace sun { namespace star { @@ -262,7 +259,6 @@ class SW_DLLPUBLIC SwDoc : public IDocumentSettingAccess, public IDocumentDeviceAccess, public IDocumentRedlineAccess, - public IDocumentUndoRedo, public IDocumentLinksAdministration, public IDocumentFieldsAccess, public IDocumentContentOperations, @@ -290,9 +286,7 @@ class SW_DLLPUBLIC SwDoc : //---------------- private Member -------------------------------- // ------------------------------------------------------------------- - // die Objecte - SwNodes aNodes; // Inhalt des Dokumentes - SwNodes aUndoNodes; // Inhalt fuer das Undo + ::boost::scoped_ptr<SwNodes> m_pNodes; /// document content (Nodes Array) SwAttrPool* mpAttrPool; // der Attribut Pool SwPageDescs aPageDescs; // PageDescriptoren Link aOle2Link; // OLE 2.0-Benachrichtigung @@ -311,6 +305,7 @@ class SW_DLLPUBLIC SwDoc : const ::boost::scoped_ptr< ::sw::mark::MarkManager> pMarkManager; const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager; + const ::boost::scoped_ptr< ::sw::UndoManager > m_pUndoManager; // ------------------------------------------------------------------- // die Pointer @@ -336,8 +331,6 @@ class SW_DLLPUBLIC SwDoc : SwRootFrm *pLayout; // Rootframe des spezifischen Layouts. SdrModel *pDrawModel; // StarView Drawing - SwUndos *pUndos; // Undo/Redo History - SwDocUpdtFld *pUpdtFlds; // Struktur zum Field-Update SwFldTypes *pFldTypes; // Feldtypen SwNewDBMgr *pNewDBMgr; // Pointer auf den neuen DBMgr fuer @@ -358,9 +351,8 @@ class SW_DLLPUBLIC SwDoc : SvxMacroTableDtor *pMacroTable; // Tabelle der dokumentglobalen Macros SwDocShell *pDocShell; // Ptr auf die SfxDocShell vom Doc - SfxObjectShellRef* pDocShRef; // fuers Kopieren von OLE-Nodes (wenn keine - // DocShell gesetzt ist, muss dieser - // Ref-Pointer gesetzt sein!!!!) + SfxObjectShellLock xTmpDocShell; // A temporary shell that is used to copy OLE-Nodes + sfx2::LinkManager *pLinkMgr; // Liste von Verknuepften (Grafiken/DDE/OLE) SwAutoCorrExceptWord *pACEWord; // fuer die automatische Uebernahme von @@ -428,11 +420,6 @@ private: // ------------------------------------------------------------------- // sonstige - sal_uInt16 nUndoPos; // akt. Undo-InsertPosition (fuers Redo!) - sal_uInt16 nUndoSavePos; // Position im Undo-Array, ab der das Doc - // nicht als modifiziert gilt - sal_uInt16 nUndoCnt; // Anzahl von Undo Aktionen - sal_uInt16 nUndoSttEnd; // != 0 -> innerhalb einer Klammerung sal_uInt16 nAutoFmtRedlnCommentNo; // SeqNo fuers UI-seitige zusammenfassen // von AutoFmt-Redlines. Wird vom SwAutoFmt @@ -464,15 +451,12 @@ private: // leider auch temporaer von // SwSwgReader::InLayout(), wenn fehlerhafte // Frames geloescht werden muessen - bool mbUndo : 1; // TRUE: Undo eingeschaltet - bool mbGroupUndo : 1; // TRUE: Undos werden gruppiert bool mbPageNums : 1; // TRUE: es gibt virtuelle Seitennummern bool mbLoaded : 1; // TRUE: ein geladenes Doc bool mbUpdateExpFld : 1; // TRUE: Expression-Felder updaten bool mbNewDoc : 1; // TRUE: neues Doc bool mbNewFldLst : 1; // TRUE: Felder-Liste neu aufbauen bool mbCopyIsMove : 1; // TRUE: Copy ist ein verstecktes Move - bool mbNoDrawUndoObj : 1; // TRUE: keine DrawUndoObjecte speichern bool mbVisibleLinks : 1; // TRUE: Links werden sichtbar eingefuegt bool mbBrowseMode : 1; // TRUE: Dokument im BrowseModus anzeigen bool mbInReading : 1; // TRUE: Dokument wird gerade gelesen @@ -616,13 +600,10 @@ private: sal_Bool mbStartIdleTimer ; // idle timer mode start/stop static SwAutoCompleteWord *pACmpltWords; // Liste aller Worte fuers AutoComplete - static sal_uInt16 nUndoActions; // anzahl von Undo ::com::sun::star::chaos::Action //---------------- private Methoden ------------------------------ void checkRedlining(RedlineMode_t& _rReadlineMode); - sal_Bool DelUndoObj( sal_uInt16 nEnde ); // loescht alle UndoObjecte vom Anfang - // bis zum angegebenen Ende DECL_LINK( AddDrawUndo, SdrUndoAction * ); // DrawModel void DrawNotifyUndoHdl(); // wegen CLOOKs @@ -737,8 +718,8 @@ public: /* @@@MAINTAINABILITY-HORROR@@@ Implementation details made public. */ - SwNodes& GetNodes() { return aNodes; } - const SwNodes& GetNodes() const { return aNodes; } + SwNodes & GetNodes() { return *m_pNodes; } + SwNodes const& GetNodes() const { return *m_pNodes; } /** IInterface */ @@ -771,7 +752,7 @@ public: virtual void setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes ); virtual const JobSetup* getJobsetup() const; virtual void setJobsetup(/*[in]*/ const JobSetup& rJobSetup ); - virtual SwPrintData* getPrintData() const; + virtual const SwPrintData & getPrintData() const; virtual void setPrintData(/*[in]*/ const SwPrintData& rPrtData); /** IDocumentMarkAccess @@ -812,37 +793,8 @@ public: /** IDocumentUndoRedo */ - virtual void SetUndoNoResetModified(); - virtual bool IsUndoNoResetModified() const; - virtual void DoUndo(bool bUn); - virtual bool DoesUndo() const; - virtual void DoGroupUndo(bool bUn); - virtual bool DoesGroupUndo() const; - virtual bool Undo(SwUndoIter& ); - virtual SwUndoId StartUndo(SwUndoId eUndoId, const SwRewriter * pRewriter); - virtual SwUndoId EndUndo(SwUndoId eUndoId, const SwRewriter * pRewriter); - virtual void DelAllUndoObj(); - virtual SwUndoId GetUndoIds(String* pStr, SwUndoIds *pUndoIds) const; - virtual String GetUndoIdsStr(String* pStr, SwUndoIds *pUndoIds) const; - virtual bool HasUndoId(SwUndoId eId) const; - virtual const SwNodes* GetUndoNds() const; - virtual SwUndo* RemoveLastUndo(SwUndoId eUndoId); - virtual bool HasTooManyUndos() const; - virtual bool Redo(SwUndoIter&); - virtual SwUndoId GetRedoIds(String* pStr, SwUndoIds *pRedoIds) const; - virtual String GetRedoIdsStr(String* pStr, SwUndoIds *pRedoIds) const; - virtual bool Repeat(SwUndoIter&, sal_uInt16 nRepeatCnt); - virtual SwUndoId GetRepeatIds(String* pStr, SwUndoIds *pRedoIds) const; - virtual String GetRepeatIdsStr(String* pStr, SwUndoIds *pRedoIds) const; - virtual void AppendUndo(SwUndo*); - virtual void ClearRedo(); - virtual void setUndoNoModifiedPosition( SwUndoNoModifiedPosition ); - virtual SwUndoNoModifiedPosition getUndoNoModifiedPosition() const; - - - /** abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions */ - static sal_uInt16 GetUndoActionCount(); - static void SetUndoActionCount(sal_uInt16 nNew); + IDocumentUndoRedo & GetIDocumentUndoRedo(); + IDocumentUndoRedo const& GetIDocumentUndoRedo() const; /** IDocumentLinksAdministration */ @@ -1805,6 +1757,7 @@ public: // suche ueber das Layout eine EditShell und ggfs. eine ViewShell SwEditShell* GetEditShell( ViewShell** ppSh = 0 ) const; + ::sw::IShellCursorSupplier * GetIShellCursorSupplier(); // OLE 2.0-Benachrichtung inline void SetOle2Link(const Link& rLink) {aOle2Link = rLink;} @@ -1834,10 +1787,10 @@ public: const SwDocShell* GetDocShell() const { return pDocShell; } void SetDocShell( SwDocShell* pDSh ); - // falls beim Kopieren von OLE-Nodes eine DocShell angelegt werden muss, - // dann MUSS der Ref-Pointer besetzt sein!!!! - SfxObjectShellRef* GetRefForDocShell() { return pDocShRef; } - void SetRefForDocShell( SfxObjectShellRef* p ) { pDocShRef = p; } + // in case during copying of embedded object a new shell is created, + // it should be set here and cleaned later + void SetTmpDocShell( SfxObjectShellLock rLock ) { xTmpDocShell = rLock; } + SfxObjectShellLock GetTmpDocShell() { return xTmpDocShell; } // fuer die TextBausteine - diese habe nur ein SvPersist zur // Verfuegung @@ -1858,9 +1811,6 @@ public: bool IsCopyIsMove() const { return mbCopyIsMove; } void SetCopyIsMove( bool bFlag ) { mbCopyIsMove = bFlag; } - // fuers Draw-Undo: Aktionen auf Flys wollen wir selbst behandeln - bool IsNoDrawUndoObj() const { return mbNoDrawUndoObj; } - void SetNoDrawUndoObj( bool bFlag ) { mbNoDrawUndoObj = bFlag; } SwDrawContact* GroupSelection( SdrView& ); void UnGroupSelection( SdrView& ); sal_Bool DeleteSelection( SwDrawView& ); @@ -1900,12 +1850,11 @@ public: inline SvNumberFormatter* GetNumberFormatter( sal_Bool bCreate = sal_True ); inline const SvNumberFormatter* GetNumberFormatter( sal_Bool bCreate = sal_True ) const; - // loesche den nicht sichtbaren ::com::sun::star::ucb::Content aus dem Document, wie z.B.: - // versteckte Bereiche, versteckte Absaetze - sal_Bool RemoveInvisibleContent(); - sal_Bool HasInvisibleContent() const; - //restore the invisible content if it's available on the undo stack - sal_Bool RestoreInvisibleContent(); + bool HasInvisibleContent() const; + /// delete invisible content, like hidden sections and paragraphs + bool RemoveInvisibleContent(); + /// restore the invisible content if it's available on the undo stack + bool RestoreInvisibleContent(); // replace fields by text - mailmerge support BOOL ConvertFieldsToText(); @@ -2140,6 +2089,8 @@ public: #endif ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); ::sw::MetaFieldManager & GetMetaFieldManager(); + ::sw::UndoManager & GetUndoManager(); + ::sw::UndoManager const& GetUndoManager() const; SfxObjectShell* CreateCopy(bool bCallInitNew) const; }; diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 2b5ad3fd5203..379db4ca0559 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -71,13 +71,6 @@ SV_DECL_PTRARR_DEL( SwFldTypes, SwFldTypePtr, INIT_FLDTYPES, GROW_FLDTYPES ) typedef SwTOXType* SwTOXTypePtr; SV_DECL_PTRARR_DEL( SwTOXTypes, SwTOXTypePtr, 0, 1 ) -// Undo -#define INIT_UNDOS 5 -#define GROW_UNDOS 5 -// Das Array der Undo-History -typedef SwUndo* SwUndoPtr; -SV_DECL_PTRARR_DEL( SwUndos, SwUndoPtr, INIT_UNDOS, GROW_UNDOS ) - typedef SwSectionFmt* SwSectionFmtPtr; SV_DECL_PTRARR_DEL(SwSectionFmts,SwSectionFmtPtr,0,4) diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index 3dd338a5e129..3dd338a5e129 100755..100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 85201ff9b5b9..de590e4b5d78 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -73,7 +73,6 @@ class SwFmtRefMark; class SwNumRule; // Numerierung //class SwNodeNum; // Numerierung -class SwUndoIds; // fuer Undo class SwTxtFmtColl; class SwGrfNode; class SwFlyFrmFmt; @@ -123,6 +122,10 @@ namespace sfx2{ class LinkManager; } +namespace sw { + class UndoRedoContext; +} + #define GETSELTXT_PARABRK_TO_BLANK 0 #define GETSELTXT_PARABRK_KEEP 1 #define GETSELTXT_PARABRK_TO_ONLYCR 2 @@ -533,35 +536,22 @@ public: SwUndoId StartUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 ); // schliesst Klammerung der nUndoId, nicht vom UI benutzt SwUndoId EndUndo( SwUndoId eUndoId = UNDO_EMPTY, const SwRewriter * pRewriter = 0 ); - // liefert die Id der letzten undofaehigen Aktion zurueck - // fuellt ggf. VARARR mit User-UndoIds - SwUndoId GetUndoIds( String* pUndoStr = 0, SwUndoIds *pUndoIds = 0) const; - String GetUndoIdsStr( String* pUndoStr = 0, SwUndoIds *pUndoIds = 0) const; - - // abfragen/setzen der Anzahl von wiederherstellbaren Undo-Actions - static USHORT GetUndoActionCount(); - static void SetUndoActionCount( USHORT nNew ); - - // Redo - // liefert die Id der letzten Redofaehigen Aktion zurueck - // fuellt ggf. VARARR mit RedoIds - SwUndoId GetRedoIds( String* pRedoStr = 0, SwUndoIds *pRedoIds = 0) const; - String GetRedoIdsStr( String* pRedoStr = 0, SwUndoIds *pRedoIds = 0) const; - - // Repeat - // liefert die Id der letzten Repeatfaehigen Aktion zurueck - // fuellt ggf. VARARR mit RedoIds - SwUndoId GetRepeatIds( String* pRepeatStr = 0, SwUndoIds *pRedoIds = 0) const; - String GetRepeatIdsStr( String* pRepeatStr = 0, - SwUndoIds *pRedoIds = 0) const; - - // 0 letzte Aktion, sonst Aktionen bis zum Start der Klammerung nUndoId - // mit KillPaMs, ClearMark - BOOL Undo(SwUndoId nUndoId = UNDO_EMPTY, USHORT nCnt = 1 ); - // wiederholt - USHORT Repeat( USHORT nCount ); - // wiederholt - USHORT Redo( USHORT nCnt = 1 ); + + 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; + + /// is it forbidden to modify cursors via API calls? + bool CursorsLocked() const; + /// set selections to those contained in the UndoRedoContext + /// should only be called by sw::UndoManager! + void HandleUndoRedoContext(::sw::UndoRedoContext & rContext); + + bool Undo(USHORT const nCount = 1); + bool Redo(USHORT const nCount = 1); + bool Repeat(USHORT const nCount); + // fuer alle Sichten auf dieses Dokument void StartAllAction(); void EndAllAction(); diff --git a/sw/inc/modcfg.hxx b/sw/inc/modcfg.hxx index c5d67217ab2a..89c5a7a1a1be 100644 --- a/sw/inc/modcfg.hxx +++ b/sw/inc/modcfg.hxx @@ -28,7 +28,7 @@ #define _MODOPT_HXX #include <tools/string.hxx> -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/field.hxx> #include <svl/svarray.hxx> #include <unotools/configitem.hxx> diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index dd822a11dfdd..6fc7199404fb 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -30,6 +30,8 @@ #include <vector> +#include <boost/utility.hpp> + #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <svl/svarray.hxx> @@ -82,7 +84,9 @@ typedef BOOL (*FnForEach_SwNodes)( const SwNodePtr&, void* pArgs ); SV_DECL_PTRARR_SORT( SwOutlineNodes, SwNodePtr, 0, 10 ) -class SW_DLLPUBLIC SwNodes: private BigPtrArray +class SW_DLLPUBLIC SwNodes + : private BigPtrArray + , private ::boost::noncopyable { friend class SwDoc; friend class SwNode; @@ -141,10 +145,6 @@ public: SwNodePtr operator[]( ULONG n ) const { return (SwNodePtr)BigPtrArray::operator[] ( n ); } -//JP 29.09.97: impl. steht im ndindex.hxx - sollte moeglichst bald auf die -// neue Schnittstelle angepasst werden - inline SwNodePtr operator[]( const SwNodeIndex& rIdx ) const; - ULONG Count() const { return BigPtrArray::Count(); } void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = 0 ) { @@ -342,11 +342,6 @@ public: SwNode * DocumentSectionStartNode(SwNode * pNode) const; SwNode * DocumentSectionEndNode(SwNode * pNode) const; //<- #112139# -private: - // privater Constructor, weil nie kopiert werden darf !! - SwNodes( const SwNodes & rNodes ); }; - - #endif diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx index 3c3a71dd8641..d3969da42f03 100644 --- a/sw/inc/ndindex.hxx +++ b/sw/inc/ndindex.hxx @@ -24,14 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _NDINDEX_HXX -#define _NDINDEX_HXX +#ifndef SW_NDINDEX_HXX +#define SW_NDINDEX_HXX #include <limits.h> + #include <tools/solar.h> -#include "node.hxx" -#include "ndarr.hxx" +#include <node.hxx> + class SwNode; class SwNodes; @@ -239,14 +240,4 @@ inline SwNodeIndex& SwNodeIndex::operator=( ULONG nWert ) return *this; } - - -//JP 29.09.97: impl. steht im ndindex.hxx - sollte moeglichst bald auf die -// neue Schnittstelle angepasst werden -inline SwNode* SwNodes::operator[]( const SwNodeIndex& rIdx ) const -{ - return &rIdx.GetNode(); -} - - #endif diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index 7a5f1e2847b1..13e8cb3ddbdd 100644..100755 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -659,7 +659,6 @@ #include "unotools/pathoptions.hxx" #include "svl/poolitem.hxx" #include "svtools/prgsbar.hxx" -#include "svtools/printdlg.hxx" #include "svtools/prnsetup.hxx" #include "svl/ptitem.hxx" #include "svl/rectitem.hxx" @@ -913,7 +912,7 @@ #include "vcl/event.hxx" #include "vcl/field.hxx" #include "vcl/fixed.hxx" -#include "vcl/fldunit.hxx" +#include "tools/fldunit.hxx" #include "vcl/font.hxx" #include "unotools/fontcvt.hxx" #include "vcl/graph.hxx" @@ -950,7 +949,7 @@ #include "vcl/virdev.hxx" #include "vcl/waitobj.hxx" #include "vcl/window.hxx" -#include "vcl/wintypes.hxx" +#include "tools/wintypes.hxx" #include "vcl/wrkwin.hxx" #include "vos/mutex.hxx" diff --git a/sw/source/ui/inc/prtopt.hxx b/sw/inc/prtopt.hxx index 75f0520e35e8..75f0520e35e8 100644 --- a/sw/source/ui/inc/prtopt.hxx +++ b/sw/inc/prtopt.hxx diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 0e52ce256754..54055242fb03 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -516,8 +516,8 @@ public: SvPtrarr& rArr ); // lege einen neuen PaM an der Position an - static SwPaM* NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray = TRUE ); + static SwPaM * NewSwPaM(SwDoc & rDoc, + ULONG const nStartIdx, ULONG const nEndIdx); // kopiere ggfs. eine lokale Datei ins Internet BOOL CopyLocalFileToINet( String& rFileNm ); diff --git a/sw/inc/swmodule.hxx b/sw/inc/swmodule.hxx index c8e601143877..da2fc80f33ad 100644 --- a/sw/inc/swmodule.hxx +++ b/sw/inc/swmodule.hxx @@ -28,7 +28,7 @@ #define _SWMODULE_HXX #include <tools/link.hxx> #include <tools/string.hxx> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <svl/lstner.hxx> #include <unotools/options.hxx> #include <sfx2/module.hxx> diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx index 02212401d990..3506a7e176b9 100644 --- a/sw/inc/swundo.hxx +++ b/sw/inc/swundo.hxx @@ -24,10 +24,16 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SWUNDO_HXX -#define _SWUNDO_HXX +#ifndef SWUNDO_HXX +#define SWUNDO_HXX + +#include <vector> + +#include <rtl/ustring.hxx> + + +typedef ::std::vector< ::rtl::OUString > SwUndoComments_t; -#include <svl/svarray.hxx> // die Ids fuer StdAktionen enum SwUndoId @@ -177,24 +183,4 @@ enum SwUndoId }; -#define INIT_UNDOIDS 20 -#define GROW_UNDOIDS 32 -// Das Array der verwendeten Undo-Ids -class String; -class SwUndoIdAndName -{ - SwUndoId eUndoId; - String* pUndoStr; - -public: - SwUndoIdAndName() : eUndoId( UNDO_EMPTY ), pUndoStr( 0 ) {} - SwUndoIdAndName( SwUndoId nId, const String* pStr = 0 ); - ~SwUndoIdAndName(); - - SwUndoId GetUndoId() const { return eUndoId; } - const String* GetUndoStr() const { return pUndoStr; } -}; -typedef SwUndoIdAndName* SwUndoIdAndNamePtr; -SV_DECL_PTRARR_DEL( SwUndoIds, SwUndoIdAndNamePtr, INIT_UNDOIDS, GROW_UNDOIDS ) - #endif diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index 7f16e4e4d44c..94601247dce5 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -28,103 +28,37 @@ #define SW_UNDOBJ_HXX #include <vector> -#include <memory> #include <boost/shared_ptr.hpp> -#include <com/sun/star/uno/Sequence.h> +#include <svl/undo.hxx> -#include <tools/mempool.hxx> -#ifndef _SVSTDARR_HXX -#define _SVSTDARR_USHORTS -#define _SVSTDARR_ULONGS -#define _SVSTDARR_BOOLS -#define _SVSTDARR_BYTES -#define _SVSTDARR_USHORTSSORT -#include <svl/svstdarr.hxx> -#endif -#include <svl/itemset.hxx> - -#include <svx/svdundo.hxx> // #111827# - -#include <numrule.hxx> -#include <itabenum.hxx> -#include <format.hxx> #include <SwRewriter.hxx> #include <swundo.hxx> -#include <IMark.hxx> -#include <IDocumentContentOperations.hxx> -class SwUndoIter; class SwHistory; class SwIndex; class SwPaM; struct SwPosition; class SwDoc; -class SwFmt; -class SwFmtColl; class SwTxtFmtColl; -class SwTxtNode; -class SwTableNode; -class SwTable; -class SwTableBox; -struct SwSortOptions; class SwFrmFmt; -class SwHistoryBookmark; -class SwSectionData; -class SwSectionFmt; -class SwTOXBase; -class SvxTabStopItem; -class SwDDEFieldType; -class Graphic; -class SwGrfNode; -class SwUndos; -class SwFtnInfo; -class SwEndNoteInfo; class SwNodeIndex; class SwNodeRange; -class SwFmtAnchor; -struct SwUndoGroupObjImpl; -class SdrMark; -class SdrMarkList; -class SdrObject; -class SdrObjGroup; -class SdrUndoAction; -class SwDrawFrmFmt; -class _SaveTable; -class SwTableAutoFmt; -class SwSelBoxes; -class SwTableSortBoxes; -class SwUndoSaveSections; -class SwUndoMoves; -class SwStartNode; -class _SaveFlyArr; -class SwTblToTxtSaves; class SwRedlineData; -class SwRedlineSaveData; -class SwRedline; -struct SwSaveRowSpan; - -namespace sfx2 { - class MetadatableUndo; -} +class SwRedlineSaveDatas; -namespace utl { - class TransliterationWrapper; +namespace sw { + class UndoRedoContext; + class RepeatContext; } -const String UNDO_ARG1("$1", RTL_TEXTENCODING_ASCII_US); -const String UNDO_ARG2("$2", RTL_TEXTENCODING_ASCII_US); -const String UNDO_ARG3("$3", RTL_TEXTENCODING_ASCII_US); - -typedef SwRedlineSaveData* SwRedlineSaveDataPtr; -SV_DECL_PTRARR_DEL( SwRedlineSaveDatas, SwRedlineSaveDataPtr, 8, 8 ) - class SwUndo + : public SfxUndoAction { - SwUndoId nId; + SwUndoId const m_nId; USHORT nOrigRedlineMode; protected: @@ -135,8 +69,6 @@ protected: void RemoveIdxFromRange( SwPaM& rPam, BOOL bMoveNext ); void RemoveIdxRel( ULONG, const SwPosition& ); - void SetId( SwUndoId nNew ) { nId = nNew; } - static BOOL CanRedlineGroup( SwRedlineSaveDatas& rCurr, const SwRedlineSaveDatas& rCheck, BOOL bCurrIsEnd ); @@ -148,16 +80,31 @@ protected: @return the rewriter for this object */ virtual SwRewriter GetRewriter() const; + + // return type is USHORT because this overrides SfxUndoAction::GetId() + virtual USHORT GetId() const { return static_cast<USHORT>(m_nId); } + + // the 4 methods that derived classes have to override + // base implementation does nothing + virtual void RepeatImpl( ::sw::RepeatContext & ); + virtual bool CanRepeatImpl( ::sw::RepeatContext & ) const; +public: // should not be public, but ran into trouble in untbl.cxx + virtual void UndoImpl( ::sw::UndoRedoContext & ) = 0; + virtual void RedoImpl( ::sw::UndoRedoContext & ) = 0; + +private: + // SfxUndoAction + virtual void Undo(); + virtual void Redo(); + virtual void UndoWithContext(SfxUndoContext &); + virtual void RedoWithContext(SfxUndoContext &); + virtual void Repeat(SfxRepeatTarget &); + virtual BOOL CanRepeat(SfxRepeatTarget &) const; + public: - SwUndo( SwUndoId nI ); + SwUndo(SwUndoId const nId); virtual ~SwUndo(); - SwUndoId GetId() const { return nId; } - virtual SwUndoId GetEffectiveId() const; - virtual void Undo( SwUndoIter& ) = 0; - virtual void Redo( SwUndoIter& ) = 0; - virtual void Repeat( SwUndoIter& ); - // #111827# /** Returns textual comment for this undo object. @@ -279,487 +226,20 @@ public: void SetValues( const SwPaM& rPam ); void SetPaM( SwPaM&, BOOL bCorrToCntnt = FALSE ) const; - void SetPaM( SwUndoIter&, BOOL bCorrToCntnt = FALSE ) const; + SwPaM & AddUndoRedoPaM( + ::sw::UndoRedoContext &, bool const bCorrToCntnt = false) const; }; -class SwUndoStart: public SwUndo -{ - // Um innerhalb von Undo zuerkennen, wann ein Start vorliegt, gibt - // GetId() immer die UNDO_START zurueck. Die UserId kann ueber - // GetUserId() erfragt werden. - SwUndoId nUserId; - // fuer die "Verpointerung" von Start- und End-Undos - USHORT nEndOffset; - - SwRewriter mRewriter; - -public: - SwUndoStart( SwUndoId nId ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - // -> #111827# - virtual String GetComment() const; - void SetRewriter(const SwRewriter & rRewriter); - virtual SwRewriter GetRewriter() const; - // <- #111827# - - virtual SwUndoId GetEffectiveId() const; - SwUndoId GetUserId() const { return nUserId; } - // Setzen vom End-Undo-Offset geschieht im Doc::EndUndo - USHORT GetEndOffset() const { return nEndOffset; } - void SetEndOffset( USHORT n ) { nEndOffset = n; } -}; - -class SwUndoEnd: public SwUndo -{ - // Um innerhalb von Undo zuerkennen, wann ein Ende vorliegt, gibt - // GetId() immer die UNDO_END zurueck. Die UserId kann ueber - // GetUserId() erfragt werden. - SwUndoId nUserId; - // fuer die "Verpointerung" von Start- und End-Undos - USHORT nSttOffset; - - SwRewriter mRewriter; - -public: - SwUndoEnd( SwUndoId nId ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - // -> #111827# - virtual String GetComment() const; - void SetRewriter(const SwRewriter & rRewriter); - virtual SwRewriter GetRewriter() const; - // <- #111827# - - virtual SwUndoId GetEffectiveId() const; - SwUndoId GetUserId() const { return nUserId; } - - // Setzen vom Start-Undo-Offset geschieht im Doc::EndUndo - void SetSttOffset(USHORT _nSttOffSet) { nSttOffset = _nSttOffSet; } - USHORT GetSttOffset() const { return nSttOffset; } -}; - -class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt -{ - SwPosition *pPos; // Inhalt fuers Redo - String *pTxt, *pUndoTxt; - SwRedlineData* pRedlData; - ULONG nNode; - xub_StrLen nCntnt, nLen; - BOOL bIsWordDelim : 1; - BOOL bIsAppend : 1; - - const IDocumentContentOperations::InsertFlags m_nInsertFlags; - - friend class SwDoc; // eigentlich nur SwDoc::Insert( String ) - BOOL CanGrouping( sal_Unicode cIns ); - BOOL CanGrouping( const SwPosition& rPos ); - - SwDoc * pDoc; - - void Init(const SwNodeIndex & rNode); - String * GetTxtFromDoc() const; - -public: - SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen, - const IDocumentContentOperations::InsertFlags nInsertFlags, - BOOL bWDelim = TRUE ); - SwUndoInsert( const SwNodeIndex& rNode ); - virtual ~SwUndoInsert(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - // #111827# - /** - Returns rewriter for this undo object. - - The returned rewriter has the following rule: - - $1 -> '<inserted text>' - - <inserted text> is shortened to a length of nUndoStringLength. - - @return rewriter for this undo object - */ - virtual SwRewriter GetRewriter() const; - - - DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert) -}; - - -class SwUndoDelete: public SwUndo, private SwUndRng, private SwUndoSaveCntnt -{ - SwNodeIndex* pMvStt; // Position der Nodes im UndoNodes-Array - String *pSttStr, *pEndStr; - SwRedlineData* pRedlData; - SwRedlineSaveDatas* pRedlSaveData; - ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; - ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; - - String sTableName; - - ULONG nNode; - ULONG nNdDiff; // Differenz von Nodes vor-nach Delete - ULONG nSectDiff; // Diff. von Nodes vor/nach Move mit SectionNodes - ULONG nReplaceDummy; // Diff. to a temporary dummy object - USHORT nSetPos; - - BOOL bGroup : 1; // TRUE: ist schon eine Gruppe; wird in CanGrouping() ausgwertet !! - BOOL bBackSp : 1; // TRUE: wenn Gruppierung und der Inhalt davor geloescht wird - BOOL bJoinNext: 1; // TRUE: wenn der Bereich von Oben nach unten geht - BOOL bTblDelLastNd : 1; // TRUE: TextNode hinter der Tabelle einf./loeschen - BOOL bDelFullPara : 1; // TRUE: gesamte Nodes wurden geloescht - BOOL bResetPgDesc : 1; // TRUE: am nachfolgenden Node das PgDsc zuruecksetzen - BOOL bResetPgBrk : 1; // TRUE: am nachfolgenden Node das PgBreak zuruecksetzen - BOOL bFromTableCopy : 1; // TRUE: called by SwUndoTblCpyTbl - - BOOL SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, - SwTxtNode* pSttTxtNd, SwTxtNode* pEndTxtNd ); -public: - SwUndoDelete( SwPaM&, BOOL bFullPara = FALSE, BOOL bCalledByTblCpy = FALSE ); - virtual ~SwUndoDelete(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - // #111827# - /** - Returns rewriter for this undo object. - - The rewriter consists of the following rule: - - $1 -> '<deleted text>' - - <deleted text> is shortened to nUndoStringLength characters. - - @return rewriter for this undo object - */ - virtual SwRewriter GetRewriter() const; - - BOOL CanGrouping( SwDoc*, const SwPaM& ); - - void SetTblDelLastNd() { bTblDelLastNd = TRUE; } - - // fuer die PageDesc/PageBreak Attribute einer Tabelle - void SetPgBrkFlags( BOOL bPageBreak, BOOL bPageDesc ) - { bResetPgDesc = bPageDesc; bResetPgBrk = bPageBreak; } - - void SetTableName(const String & rName); - - // SwUndoTblCpyTbl needs this information: - long NodeDiff() const { return nSttNode - nEndNode; } - xub_StrLen ContentStart() const { return nSttCntnt; } - BOOL IsDelFullPara() const { return bDelFullPara; } - - DECL_FIXEDMEMPOOL_NEWDEL(SwUndoDelete) -}; - - -class SwUndoOverwrite: public SwUndo, private SwUndoSaveCntnt -{ - String aDelStr, aInsStr; - SwRedlineSaveDatas* pRedlSaveData; - ULONG nSttNode; - xub_StrLen nSttCntnt; - BOOL bInsChar : 1; // kein Overwrite mehr; sondern Insert - BOOL bGroup : 1; // TRUE: ist schon eine Gruppe; wird in - // CanGrouping() ausgwertet !! -public: - SwUndoOverwrite( SwDoc*, SwPosition&, sal_Unicode cIns ); - virtual ~SwUndoOverwrite(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - // #111827# - /** - Returns the rewriter of this undo object. - - The rewriter contains the following rule: - - $1 -> '<overwritten text>' - - <overwritten text> is shortened to nUndoStringLength characters. - - @return the rewriter of this undo object - */ - virtual SwRewriter GetRewriter() const; - - BOOL CanGrouping( SwDoc*, SwPosition&, sal_Unicode cIns ); -}; - - -class SwUndoSplitNode: public SwUndo -{ - SwHistory* pHistory; - SwRedlineData* pRedlData; - ULONG nNode; - xub_StrLen nCntnt; - BOOL bTblFlag : 1; - BOOL bChkTblStt : 1; -public: - SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, BOOL bChkTbl ); - virtual ~SwUndoSplitNode(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - void SetTblFlag() { bTblFlag = TRUE; } -}; - - -class SwUndoMove : public SwUndo, private SwUndRng, private SwUndoSaveCntnt -{ - // nDest.. - Bereich, in den verschoben wurde (nach dem Move!) - // nIns.. - Position, von der verschoben wurde und wieder die neue InsPos. ist - // nMv.. Position auf die verschoben wird (vor dem Move!) ; fuers REDO - ULONG nDestSttNode, nDestEndNode, nInsPosNode, nMvDestNode; - xub_StrLen nDestSttCntnt, nDestEndCntnt, nInsPosCntnt, nMvDestCntnt; - - USHORT nFtnStt; // StartPos der Fussnoten in der History - - BOOL bJoinNext : 1, - bJoinPrev : 1, - bMoveRange : 1; - - bool bMoveRedlines; // use DOC_MOVEREDLINES when calling SwDoc::Move - - void DelFtn( const SwPaM& ); -public: - SwUndoMove( const SwPaM&, const SwPosition& ); - SwUndoMove( SwDoc* pDoc, const SwNodeRange&, const SwNodeIndex& ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - // setze den Destination-Bereich nach dem Verschieben. - void SetDestRange( const SwPaM&, const SwPosition&, BOOL, BOOL ); - void SetDestRange( const SwNodeIndex& rStt, const SwNodeIndex& rEnd, - const SwNodeIndex& rInsPos ); - - BOOL IsMoveRange() const { return bMoveRange; } - ULONG GetEndNode() const { return nEndNode; } - ULONG GetDestSttNode() const { return nDestSttNode; } - xub_StrLen GetDestSttCntnt() const { return nDestSttCntnt; } - - void SetMoveRedlines( bool b ) { bMoveRedlines = b; } - -}; - - -class SwUndoAttr : public SwUndo, private SwUndRng -{ - SfxItemSet m_AttrSet; // attributes for Redo - const ::std::auto_ptr<SwHistory> m_pHistory; // History for Undo - ::std::auto_ptr<SwRedlineData> m_pRedlineData; // Redlining - ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData; - ULONG m_nNodeIndex; // Offset: for Redlining - const SetAttrMode m_nInsertFlags; // insert flags - - void RemoveIdx( SwDoc& rDoc ); - -public: - SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags ); - SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags ); - virtual ~SwUndoAttr(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - void SaveRedlineData( const SwPaM& rPam, BOOL bInsCntnt ); - - SwHistory& GetHistory() { return *m_pHistory; } - -}; - -class SwUndoResetAttr : public SwUndo, private SwUndRng -{ - const ::std::auto_ptr<SwHistory> m_pHistory; - SvUShortsSort m_Ids; - const USHORT m_nFormatId; // Format-Id for Redo - -public: - SwUndoResetAttr( const SwPaM&, USHORT nFmtId ); - SwUndoResetAttr( const SwPosition&, USHORT nFmtId ); - virtual ~SwUndoResetAttr(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - void SetAttrs( const SvUShortsSort& rArr ); - - SwHistory& GetHistory() { return *m_pHistory; } - -}; - -class SwUndoFmtAttr : public SwUndo -{ - friend class SwUndoDefaultAttr; - SwFmt * m_pFmt; - ::std::auto_ptr<SfxItemSet> m_pOldSet; // old attributes - ULONG m_nNodeIndex; - const USHORT m_nFmtWhich; - const bool m_bSaveDrawPt; - - bool IsFmtInDoc( SwDoc* ); //is the attribute format still in the Doc? - void SaveFlyAnchor( bool bSaveDrawPt = false ); - // --> OD 2004-10-26 #i35443# - Add return value, type <bool>. - // Return value indicates, if anchor attribute is restored. - // Notes: - If anchor attribute is restored, all other existing attributes - // are also restored. - // - Anchor attribute isn't restored successfully, if it contains - // an invalid anchor position and all other existing attributes - // aren't restored. - // This situation occurs for undo of styles. - bool RestoreFlyAnchor( SwUndoIter& rIter ); - // <-- - // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet> - void Init(); - // <-- - -public: - // register at the Format and save old attributes - // --> OD 2008-02-27 #refactorlists# - removed <rNewSet> - SwUndoFmtAttr( const SfxItemSet& rOldSet, - SwFmt& rFmt, - bool bSaveDrawPt = true ); - // <-- - SwUndoFmtAttr( const SfxPoolItem& rItem, - SwFmt& rFmt, - bool bSaveDrawPt = true ); - virtual ~SwUndoFmtAttr(); - virtual void Undo( SwUndoIter& ); - // --> OD 2004-10-26 #i35443# - <Redo(..)> calls <Undo(..)> - nothing else - virtual void Redo( SwUndoIter& ); - // <-- - virtual void Repeat( SwUndoIter& ); - virtual SwRewriter GetRewriter() const; - - void PutAttr( const SfxPoolItem& rItem ); - SwFmt* GetFmt( SwDoc& rDoc ); // checks if it is still in the Doc! -}; - -// --> OD 2008-02-12 #newlistlevelattrs# -class SwUndoFmtResetAttr : public SwUndo -{ - public: - SwUndoFmtResetAttr( SwFmt& rChangedFormat, - const USHORT nWhichId ); - ~SwUndoFmtResetAttr(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - private: - // format at which a certain attribute is reset. - SwFmt * const m_pChangedFormat; - // which ID of the reset attribute - const USHORT m_nWhichId; - // old attribute which has been reset - needed for undo. - ::std::auto_ptr<SfxPoolItem> m_pOldItem; -}; -// <-- - -class SwUndoDontExpandFmt : public SwUndo -{ - const ULONG m_nNodeIndex; - const xub_StrLen m_nContentIndex; +class SwUndoInsLayFmt; -public: - SwUndoDontExpandFmt( const SwPosition& rPos ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - -// helper class to receive changed attribute sets -class SwUndoFmtAttrHelper : public SwClient -{ - ::std::auto_ptr<SwUndoFmtAttr> m_pUndo; - const bool m_bSaveDrawPt; - -public: - SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true ); - - virtual void Modify( SfxPoolItem*, SfxPoolItem* ); - - SwUndoFmtAttr* GetUndo() const { return m_pUndo.get(); } - // release the undo object (so it is not deleted here), and return it - SwUndoFmtAttr* ReleaseUndo() { return m_pUndo.release(); } -}; - - -class SwUndoFmtColl : public SwUndo, private SwUndRng -{ - String aFmtName; - SwHistory* pHistory; - SwFmtColl* pFmtColl; - // --> OD 2008-04-15 #refactorlists# - for correct <ReDo(..)> and <Repeat(..)> - // boolean, which indicates that the attributes are reseted at the nodes - // before the format has been applied. - const bool mbReset; - // boolean, which indicates that the list attributes had been reseted at - // the nodes before the format has been applied. - const bool mbResetListAttrs; - // <-- -public: - // --> OD 2008-04-15 #refactorlists# -// SwUndoFmtColl( const SwPaM&, SwFmtColl* ); - SwUndoFmtColl( const SwPaM&, SwFmtColl*, - const bool bReset, - const bool bResetListAttrs ); - // <-- - virtual ~SwUndoFmtColl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - // #111827# - /** - Returns the rewriter for this undo object. - - The rewriter contains one rule: - - $1 -> <name of format collection> - - <name of format collection> is the name of the format - collection that is applied by the action recorded by this undo - object. - - @return the rewriter for this undo object - */ - virtual SwRewriter GetRewriter() const; - - SwHistory* GetHistory() { return pHistory; } - -}; - - -class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng -{ - const ::std::auto_ptr<SwHistory> m_pHistory; - const bool m_bModulus; - -public: - SwUndoMoveLeftMargin( const SwPaM&, BOOL bRight, BOOL bModulus ); - virtual ~SwUndoMoveLeftMargin(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - SwHistory& GetHistory() { return *m_pHistory; } - -}; - -// Basis-Klasse fuer Insert von Dokument, Glossaries und Kopieren +// base class for insertion of Document, Glossaries and Copy class SwUndoInserts : public SwUndo, public SwUndRng, private SwUndoSaveCntnt { SwTxtFmtColl *pTxtFmtColl, *pLastNdColl; SvPtrarr* pFrmFmts; - SwUndos* pFlyUndos; + ::std::vector< ::boost::shared_ptr<SwUndoInsLayFmt> > m_FlyUndos; SwRedlineData* pRedlData; BOOL bSttWasTxtNd; protected: @@ -771,9 +251,10 @@ protected: public: virtual ~SwUndoInserts(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + // setze den Destination-Bereich nach dem Einlesen. void SetInsertRange( const SwPaM&, BOOL bScanFlys = TRUE, BOOL bSttWasTxtNd = TRUE ); @@ -791,384 +272,6 @@ public: SwUndoCpyDoc( const SwPaM& ); }; -class SwUndoInsTbl : public SwUndo -{ - String sTblNm; - SwInsertTableOptions aInsTblOpts; - SwDDEFieldType* pDDEFldType; - SvUShorts* pColWidth; - SwRedlineData* pRedlData; - SwTableAutoFmt* pAutoFmt; - ULONG nSttNode; - USHORT nRows, nCols; - USHORT nAdjust; - -public: - SwUndoInsTbl( const SwPosition&, USHORT nCols, USHORT nRows, - USHORT eAdjust, const SwInsertTableOptions& rInsTblOpts, - const SwTableAutoFmt* pTAFmt, const SvUShorts* pColArr, - const String & rName); - virtual ~SwUndoInsTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - virtual SwRewriter GetRewriter() const; - -}; - -class SwUndoTxtToTbl : public SwUndo, public SwUndRng -{ - String sTblNm; - SwInsertTableOptions aInsTblOpts; - SvULongs* pDelBoxes; - SwTableAutoFmt* pAutoFmt; - SwHistory* pHistory; - sal_Unicode cTrenner; - USHORT nAdjust; - BOOL bSplitEnd : 1; - -public: - SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode , USHORT, - const SwTableAutoFmt* pAFmt ); - virtual ~SwUndoTxtToTbl(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - SwHistory& GetHistory(); // wird ggfs. angelegt - void AddFillBox( const SwTableBox& rBox ); -}; - -class SwUndoTblToTxt : public SwUndo -{ - String sTblNm; - SwDDEFieldType* pDDEFldType; - _SaveTable* pTblSave; - SwTblToTxtSaves* pBoxSaves; - SwHistory* pHistory; - ULONG nSttNd, nEndNd; - USHORT nAdjust; - sal_Unicode cTrenner; - USHORT nHdlnRpt; - BOOL bCheckNumFmt : 1; - -public: - SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ); - virtual ~SwUndoTblToTxt(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void SetRange( const SwNodeRange& ); - void AddBoxPos( SwDoc& rDoc, ULONG nNdIdx, ULONG nEndIdx, - xub_StrLen nCntntIdx = STRING_MAXLEN); -}; - -class SwUndoAttrTbl : public SwUndo -{ - ULONG nSttNode; - _SaveTable* pSaveTbl; - BOOL bClearTabCol : 1; -public: - SwUndoAttrTbl( const SwTableNode& rTblNd, BOOL bClearTabCols = FALSE ); - virtual ~SwUndoAttrTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - -class SwUndoTblAutoFmt : public SwUndo -{ - ULONG nSttNode; - _SaveTable* pSaveTbl; - SwUndos* pUndos; - BOOL bSaveCntntAttr; - - void UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter ); - -public: - SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& ); - virtual ~SwUndoTblAutoFmt(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - void SaveBoxCntnt( const SwTableBox& rBox ); -}; - -class SwUndoTblNdsChg : public SwUndo -{ - _SaveTable* pSaveTbl; - SvULongs aBoxes; - - union { - SvULongs* pNewSttNds; - SwUndoSaveSections* pDelSects; - } Ptrs; - SvBools aMvBoxes; // fuers SplitRow (aufgeteilte Nodes einer Box) - long nMin, nMax; // for redo of delete column - ULONG nSttNode, nCurrBox; - USHORT nCount, nRelDiff, nAbsDiff, nSetColType; - BOOL bFlag; - BOOL bSameHeight; // only used for SplitRow -public: - SwUndoTblNdsChg( SwUndoId UndoId, - const SwSelBoxes& rBoxes, - const SwTableNode& rTblNd, - long nMn, long nMx, - USHORT nCnt, BOOL bFlg, BOOL bSameHeight ); - - // fuer SetColWidth - SwUndoTblNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes, - const SwTableNode& rTblNd ); - - virtual ~SwUndoTblNdsChg(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld ); - void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld, - const SwSelBoxes& rBoxes, const SvULongs& rNodeCnts ); - void SaveSection( SwStartNode* pSttNd ); - void ReNewBoxes( const SwSelBoxes& rBoxes ); - - - void SetColWidthParam( ULONG nBoxIdx, USHORT nMode, USHORT nType, - SwTwips nAbsDif, SwTwips nRelDif ) - { - nCurrBox = nBoxIdx; - nCount = nMode; - nSetColType = nType; - nAbsDiff = (USHORT)nAbsDif; - nRelDiff = (USHORT)nRelDif; - } - -}; - -class SwUndoTblMerge : public SwUndo, private SwUndRng -{ - ULONG nTblNode; - _SaveTable* pSaveTbl; - SvULongs aBoxes, aNewSttNds; - SwUndoMoves* pMoves; - SwHistory* pHistory; - -public: - SwUndoTblMerge( const SwPaM& rTblSel ); - virtual ~SwUndoTblMerge(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos ); - - void SetSelBoxes( const SwSelBoxes& rBoxes ); - - void AddNewBox( ULONG nSttNdIdx ) - { aNewSttNds.Insert( nSttNdIdx, aNewSttNds.Count() ); } - - void SaveCollection( const SwTableBox& rBox ); - -}; - - -class SwUndoTblNumFmt : public SwUndo -{ - SfxItemSet *pBoxSet; - SwHistory* pHistory; - String aStr, aNewFml; - - ULONG nFmtIdx, nNewFmtIdx; - double fNum, fNewNum; - ULONG nNode; - ULONG nNdPos; - - BOOL bNewFmt : 1; - BOOL bNewFml : 1; - BOOL bNewValue : 1; - -public: - SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 ); - virtual ~SwUndoTblNumFmt(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void SetNumFmt( ULONG nNewNumFmtIdx, const double& rNewNumber ) - { nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; } - void SetBox( const SwTableBox& rBox ); -}; - -class _UndoTblCpyTbl_Entries; - -class SwUndoTblCpyTbl : public SwUndo -{ - _UndoTblCpyTbl_Entries* pArr; - SwUndoTblNdsChg* pInsRowUndo; - - //b6341295: When redlining is active, PrepareRedline has to create the redlining attributes - //for the new and the old table cell content - SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, const SwPosition& rPos, - bool& rJoin, bool bRedo ); -public: - SwUndoTblCpyTbl(); - virtual ~SwUndoTblCpyTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void AddBoxBefore( const SwTableBox& rBox, BOOL bDelCntnt ); - void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, BOOL bDelCntnt ); - - BOOL IsEmpty() const; - BOOL InsertRow( SwTable& rTbl, const SwSelBoxes& rBoxes, USHORT nCnt ); -}; - -class SwUndoCpyTbl : public SwUndo -{ - SwUndoDelete* pDel; - ULONG nTblNode; -public: - SwUndoCpyTbl(); - virtual ~SwUndoCpyTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void SetTableSttIdx( ULONG nIdx ) { nTblNode = nIdx; } -}; - -class SwUndoSplitTbl : public SwUndo -{ - ULONG nTblNode, nOffset; - SwSaveRowSpan* mpSaveRowSpan; // stores the row span values at the splitting row - _SaveTable* pSavTbl; - SwHistory* pHistory; - USHORT nMode, nFmlEnd; - BOOL bCalcNewSize; -public: - SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp, USHORT nMode, BOOL bCalcNewSize ); - virtual ~SwUndoSplitTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void SetTblNodeOffset( ULONG nIdx ) { nOffset = nIdx - nTblNode; } - SwHistory* GetHistory() { return pHistory; } - void SaveFormula( SwHistory& rHistory ); -}; - -class SwUndoMergeTbl : public SwUndo -{ - String aName; - ULONG nTblNode; - _SaveTable* pSavTbl, *pSavHdl; - SwHistory* pHistory; - USHORT nMode; - BOOL bWithPrev; -public: - SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd, - BOOL bWithPrev, USHORT nMode ); - virtual ~SwUndoMergeTbl(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void SaveFormula( SwHistory& rHistory ); -}; - - -class SwUndoBookmark : public SwUndo -{ - const ::std::auto_ptr<SwHistoryBookmark> m_pHistoryBookmark; - -protected: - SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& ); - - void SetInDoc( SwDoc* ); - void ResetInDoc( SwDoc* ); - -public: - virtual ~SwUndoBookmark(); - - // #111827# - /** - Returns the rewriter for this undo object. - - The rewriter contains the following rule: - - $1 -> <name of bookmark> - - <name of bookmark> is the name of the bookmark whose - insertion/deletion is recorded by this undo object. - - @return the rewriter for this undo object - */ - virtual SwRewriter GetRewriter() const; -}; - - -class SwUndoInsBookmark : public SwUndoBookmark -{ -public: - SwUndoInsBookmark( const ::sw::mark::IMark& ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - - -/*-------------------------------------------------------------------- - Beschreibung: Undo auf Sorting - --------------------------------------------------------------------*/ - -struct SwSortUndoElement -{ - union { - struct { - ULONG nKenn; - ULONG nSource, nTarget; - } TXT; - struct { - String *pSource, *pTarget; - } TBL; - } SORT_TXT_TBL; - - SwSortUndoElement( const String& aS, const String& aT ) - { - SORT_TXT_TBL.TBL.pSource = new String( aS ); - SORT_TXT_TBL.TBL.pTarget = new String( aT ); - } - SwSortUndoElement( ULONG nS, ULONG nT ) - { - SORT_TXT_TBL.TXT.nSource = nS; - SORT_TXT_TBL.TXT.nTarget = nT; - SORT_TXT_TBL.TXT.nKenn = 0xffffffff; - } - ~SwSortUndoElement(); -}; - -SV_DECL_PTRARR_DEL(SwSortList, SwSortUndoElement*, 10,30) -SV_DECL_PTRARR(SwUndoSortList, SwNodeIndex*, 10,30) - -class SwUndoSort : public SwUndo, private SwUndRng -{ - SwSortOptions* pSortOpt; // die Optionen mit den Sortier-Kriterien - SwSortList aSortList; - SwUndoAttrTbl* pUndoTblAttr; - SwRedlineData* pRedlData; - ULONG nTblNd; - - void RemoveIdx( SwPaM& rPam ); -public: - SwUndoSort( const SwPaM&, const SwSortOptions& ); - SwUndoSort( ULONG nStt, ULONG nEnd, const SwTableNode&, - const SwSortOptions&, BOOL bSaveTable ); - virtual ~SwUndoSort(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void Insert( const String& rOrgPos, const String& rNewPos ); - void Insert( ULONG nOrgPos, ULONG nNewPos ); - -}; - //-------------------------------------------------------------------- @@ -1182,7 +285,7 @@ protected: USHORT nRndId; BOOL bDelFmt; // loesche das gespeicherte Format - void InsFly( SwUndoIter&, BOOL bShowSel = TRUE ); + void InsFly(::sw::UndoRedoContext & rContext, bool bShowSel = true); void DelFly( SwDoc* ); SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId ); @@ -1193,9 +296,6 @@ protected: public: virtual ~SwUndoFlyBase(); - virtual void Undo( SwUndoIter& ) = 0; - virtual void Redo( SwUndoIter& ) = 0; - }; class SwUndoInsLayFmt : public SwUndoFlyBase @@ -1204,11 +304,12 @@ class SwUndoInsLayFmt : public SwUndoFlyBase xub_StrLen mnCrsrSaveIndexPos; // for undo public: SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen nCntIdx ); - ~SwUndoInsLayFmt(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); + virtual ~SwUndoInsLayFmt(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); String GetComment() const; @@ -1220,700 +321,15 @@ class SwUndoDelLayFmt : public SwUndoFlyBase public: SwUndoDelLayFmt( SwFrmFmt* pFormat ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - void Redo(); // Schnittstelle fuers Rollback - - void ChgShowSel( BOOL bNew ) { bShowSelFrm = bNew; } - - virtual SwRewriter GetRewriter() const; - -}; - - -class SwUndoSetFlyFmt : public SwUndo, public SwClient -{ - SwFrmFmt* pFrmFmt; // das gespeicherte FlyFormat - SwFrmFmt* pOldFmt; // die alte Fly Vorlage - SwFrmFmt* pNewFmt; // die neue Fly Vorlage - SfxItemSet* pItemSet; // die zurueck-/ gesetzten Attribute - ULONG nOldNode, nNewNode; - xub_StrLen nOldCntnt, nNewCntnt; - USHORT nOldAnchorTyp, nNewAnchorTyp; - BOOL bAnchorChgd; - - void PutAttr( USHORT nWhich, const SfxPoolItem* pItem ); - void Modify( SfxPoolItem*, SfxPoolItem* ); - void GetAnchor( SwFmtAnchor& rAnhor, ULONG nNode, xub_StrLen nCntnt ); - -public: - SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt ); - virtual ~SwUndoSetFlyFmt(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - virtual SwRewriter GetRewriter() const; -}; - -//-------------------------------------------------------------------- - -class _UnReplaceData; -SV_DECL_PTRARR_DEL( _UnReplaceDatas, _UnReplaceData*, 10, 25 ) - -class SwUndoReplace : public SwUndo -{ - friend class SwDoc; - - BOOL bOldIterFlag; // Status vom Undo-Iter vorm 1. Aufruf - USHORT nAktPos; // fuer GetUndoRange und Undo/Redo - _UnReplaceDatas aArr; - SwRedlineData* pRedlData; - -public: - SwUndoReplace(); - virtual ~SwUndoReplace(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - // #111827# - /** - Returns the rewriter of this undo object. - - If this undo object represents several replacements the - rewriter contains the following rules: - - $1 -> <number of replacements> - $2 -> occurrences of - $3 -> <replaced text> - - If this undo object represents one replacement the rewriter - contains these rules: - - $1 -> <replaced text> - $2 -> "->" (STR_YIELDS) - $3 -> <replacing text> - - @return the rewriter of this undo object - */ - virtual SwRewriter GetRewriter() const; - - void AddEntry( const SwPaM& rPam, const String& rInsert, BOOL bRegExp ); - void SetEntryEnd( const SwPaM& rPam ); - - BOOL IsFull() const - { return ((USHRT_MAX / sizeof( void* )) - 50 ) < aArr.Count(); } - -}; - - -//-------------------------------------------------------------------- - - -class SwUndoTblHeadline : public SwUndo -{ - ULONG nTblNd; - USHORT nOldHeadline; - USHORT nNewHeadline; -public: - SwUndoTblHeadline( const SwTable&, USHORT nOldHdl, USHORT nNewHdl ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - - -//------------ Undo von Insert-/Delete-Sections ---------------------- - -class SwUndoInsSection : public SwUndo, private SwUndRng -{ -private: - const ::std::auto_ptr<SwSectionData> m_pSectionData; - const ::std::auto_ptr<SwTOXBase> m_pTOXBase; /// set iff section is TOX - const ::std::auto_ptr<SfxItemSet> m_pAttrSet; - ::std::auto_ptr<SwHistory> m_pHistory; - ::std::auto_ptr<SwRedlineData> m_pRedlData; - ULONG m_nSectionNodePos; - bool m_bSplitAtStart : 1; - bool m_bSplitAtEnd : 1; - bool m_bUpdateFtn : 1; - - void Join( SwDoc& rDoc, ULONG nNode ); - -public: - SwUndoInsSection(SwPaM const&, SwSectionData const&, - SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase); - virtual ~SwUndoInsSection(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void SetSectNdPos(ULONG const nPos) { m_nSectionNodePos = nPos; } - void SaveSplitNode(SwTxtNode *const pTxtNd, bool const bAtStart); - void SetUpdtFtnFlag(bool const bFlag) { m_bUpdateFtn = bFlag; } -}; - -SW_DLLPRIVATE SwUndo * MakeUndoDelSection(SwSectionFmt const&); - -SW_DLLPRIVATE SwUndo * MakeUndoUpdateSection(SwSectionFmt const&, bool const); - - -//------------ Undo von verschieben/stufen von Gliederung ---------------- - -class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng -{ - short nOffset; -public: - SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - -//-------------------------------------------------------------------- - -class SwUndoDefaultAttr : public SwUndo -{ - ::std::auto_ptr<SfxItemSet> m_pOldSet; // the old attributes - ::std::auto_ptr<SvxTabStopItem> m_pTabStop; - -public: - // registers at the format and saves old attributes - SwUndoDefaultAttr( const SfxItemSet& rOldSet ); - virtual ~SwUndoDefaultAttr(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - -//-------------------------------------------------------------------- -// ---------- Undo fuer Numerierung ---------------------------------- - -class SwUndoInsNum : public SwUndo, private SwUndRng -{ - SwNumRule aNumRule; - SwHistory* pHistory; - ULONG nSttSet; - SwNumRule* pOldNumRule; - String sReplaceRule; - USHORT nLRSavePos; -public: - SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule ); - SwUndoInsNum( const SwNumRule& rOldRule, const SwNumRule& rNewRule, - SwUndoId nUndoId = UNDO_INSFMTATTR ); - SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule, - const String& rReplaceRule ); - virtual ~SwUndoInsNum(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - virtual SwRewriter GetRewriter() const; - - SwHistory* GetHistory(); // wird ggfs. neu angelegt! - void SetSttNum( ULONG nNdIdx ) { nSttSet = nNdIdx; } - void SaveOldNumRule( const SwNumRule& rOld ); - - void SetLRSpaceEndPos(); - -}; - -class SwUndoDelNum : public SwUndo, private SwUndRng -{ - SvULongs aNodeIdx; - SvBytes aLevels; - SvBools aRstLRSpaces; - SwHistory* pHistory; -public: - SwUndoDelNum( const SwPaM& rPam ); - virtual ~SwUndoDelNum(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - void AddNode( const SwTxtNode& rNd, BOOL bResetLRSpace ); - SwHistory* GetHistory() { return pHistory; } - -}; - -class SwUndoMoveNum : public SwUndo, private SwUndRng -{ - ULONG nNewStt; - long nOffset; -public: - SwUndoMoveNum( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv = FALSE ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - void SetStartNode( ULONG nValue ) { nNewStt = nValue; } -}; - -class SwUndoNumUpDown : public SwUndo, private SwUndRng -{ - short nOffset; -public: - SwUndoNumUpDown( const SwPaM& rPam, short nOffset ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - -class SwUndoNumOrNoNum : public SwUndo -{ - ULONG nIdx; - BOOL mbNewNum, mbOldNum; - -public: - SwUndoNumOrNoNum( const SwNodeIndex& rIdx, BOOL mbOldNum, - BOOL mbNewNum ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - -class SwUndoNumRuleStart : public SwUndo -{ - ULONG nIdx; - USHORT nOldStt, nNewStt; - BOOL bSetSttValue : 1; - BOOL bFlag : 1; -public: - SwUndoNumRuleStart( const SwPosition& rPos, BOOL bDelete ); - SwUndoNumRuleStart( const SwPosition& rPos, USHORT nStt ); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); -}; - -//-------------------------------------------------------------------- -// ---------- Undo fuer DrawObjecte ---------------------------------- - -class SwSdrUndo : public SwUndo -{ - SdrUndoAction* pSdrUndo; - SdrMarkList* pMarkList; // MarkList for all selected SdrObjects -public: - SwSdrUndo( SdrUndoAction* , const SdrMarkList* pMarkList ); - virtual ~SwSdrUndo(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - String GetComment() const; -}; - -class SwUndoDrawGroup : public SwUndo -{ - SwUndoGroupObjImpl* pObjArr; - USHORT nSize; - BOOL bDelFmt; - -public: - SwUndoDrawGroup( USHORT nCnt ); - virtual ~SwUndoDrawGroup(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void AddObj( USHORT nPos, SwDrawFrmFmt*, SdrObject* ); - void SetGroupFmt( SwDrawFrmFmt* ); -}; - -// --> OD 2006-11-01 #130889# -// Action "ungroup drawing object" is now splitted into three parts - see -// method <SwDoc::UnGroupSelection(..)>: -// - creation for <SwDrawFrmFmt> instances for the group members of the -// selected group objects -// - intrinsic ungroup of the selected group objects -// - creation of <SwDrawContact> instances for the former group members and -// connection to the Writer layout. -// Thus, two undo actions (instances of <SwUndo>) are needed: -// - Existing class <SwUndoDrawUnGroup> takes over the part for the formats. -// - New class <SwUndoDrawUnGroupConnectToLayout> takes over the part for -// contact object. -class SwUndoDrawUnGroup : public SwUndo -{ - SwUndoGroupObjImpl* pObjArr; - USHORT nSize; - BOOL bDelFmt; - -public: - SwUndoDrawUnGroup( SdrObjGroup* ); - virtual ~SwUndoDrawUnGroup(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void AddObj( USHORT nPos, SwDrawFrmFmt* ); -}; - -// --> OD 2006-11-01 #130889# -class SwUndoDrawUnGroupConnectToLayout : public SwUndo -{ - private: - std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > > aDrawFmtsAndObjs; - - public: - SwUndoDrawUnGroupConnectToLayout(); - virtual ~SwUndoDrawUnGroupConnectToLayout(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void AddFmtAndObj( SwDrawFrmFmt* pDrawFrmFmt, - SdrObject* pDrawObject ); -}; -// <-- - - -class SwUndoDrawDelete : public SwUndo -{ - SwUndoGroupObjImpl* pObjArr; - SdrMarkList* pMarkLst; // MarkList for all selected SdrObjects - USHORT nSize; - BOOL bDelFmt; - -public: - SwUndoDrawDelete( USHORT nCnt ); - virtual ~SwUndoDrawDelete(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - void AddObj( USHORT nPos, SwDrawFrmFmt*, const SdrMark& ); -}; - -//-------------------------------------------------------------------- - -class SwUndoReRead : public SwUndo -{ - Graphic *pGrf; - String *pNm, *pFltr; - ULONG nPos; - USHORT nMirr; - - void SaveGraphicData( const SwGrfNode& ); - void SetAndSave( SwUndoIter& ); - -public: - SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd ); - virtual ~SwUndoReRead(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - -//-------------------------------------------------------------------- - -class SwUndoInsertLabel : public SwUndo -{ - union { - struct { - // fuer NoTxtFrms - SwUndoInsLayFmt* pUndoFly; - SwUndoFmtAttr* pUndoAttr; - } OBJECT; - struct { - // fuer Tabelle/TextRahmen - SwUndoDelete* pUndoInsNd; - ULONG nNode; - } NODE; - }; - - String sText; - // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style - String sSeparator; - // <-- - String sNumberSeparator; - String sCharacterStyle; - // OD 2004-04-15 #i26791# - re-store of drawing object position no longer needed - USHORT nFldId; - SwLabelType eType; - BYTE nLayerId; // fuer Zeichen-Objekte - BOOL bBefore :1; - BOOL bUndoKeep :1; - BOOL bCpyBrd :1; - -public: - SwUndoInsertLabel( const SwLabelType eTyp, const String &rText, - // --> PB 2005-01-06 #i39983# - the separator will be drawed with a character style - const String& rSeparator, - // <-- - const String& rNumberSeparator, //#i61007# order of captions - const BOOL bBefore, const USHORT nId, - const String& rCharacterStyle, - const BOOL bCpyBrd ); - virtual ~SwUndoInsertLabel(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); - // #111827# - /** - Returns the rewriter of this undo object. - - The rewriter contains this rule: + void RedoForRollback(); - $1 -> '<text of inserted label>' - - <text of inserted label> is shortened to nUndoStringLength - characters. + void ChgShowSel( BOOL bNew ) { bShowSelFrm = bNew; } - @return the rewriter of this undo object - */ virtual SwRewriter GetRewriter() const; - void SetNodePos( ULONG nNd ) - { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; } - - void SetUndoKeep() { bUndoKeep = TRUE; } - void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly ); - void SetDrawObj( BYTE nLayerId ); -}; - -//-------------------------------------------------------------------- - -class SwUndoChangeFootNote : public SwUndo, private SwUndRng -{ - const ::std::auto_ptr<SwHistory> m_pHistory; - const String m_Text; - const USHORT m_nNumber; - const bool m_bEndNote; - -public: - SwUndoChangeFootNote( const SwPaM& rRange, const String& rTxt, - USHORT nNum, bool bIsEndNote ); - virtual ~SwUndoChangeFootNote(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - virtual void Repeat( SwUndoIter& ); - - SwHistory& GetHistory() { return *m_pHistory; } -}; - -class SwUndoFootNoteInfo : public SwUndo -{ - ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo; - -public: - SwUndoFootNoteInfo( const SwFtnInfo &rInfo ); - virtual ~SwUndoFootNoteInfo(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - -class SwUndoEndNoteInfo : public SwUndo -{ - ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo; - -public: - SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ); - virtual ~SwUndoEndNoteInfo(); - - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - - -//-------------------------------------------------------------------- - -struct _UndoTransliterate_Data; -class SwUndoTransliterate : public SwUndo, public SwUndRng -{ - std::vector< _UndoTransliterate_Data * > aChanges; - sal_uInt32 nType; - -public: - SwUndoTransliterate( const SwPaM& rPam, - const utl::TransliterationWrapper& rTrans ); - virtual ~SwUndoTransliterate(); - - virtual void Undo( SwUndoIter& rUndoIter ); - virtual void Redo( SwUndoIter& rUndoIter ); - virtual void Repeat( SwUndoIter& rUndoIter ); - - void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, - ::com::sun::star::uno::Sequence <sal_Int32>& rOffsets ); - BOOL HasData() const { return aChanges.size() > 0; } -}; - -//-------------------------------------------------------------------- - -class SwUndoRedline : public SwUndo, public SwUndRng -{ -protected: - SwRedlineData* pRedlData; - SwRedlineSaveDatas* pRedlSaveData; - SwUndoId nUserId; - BOOL bHiddenRedlines; - - virtual void _Undo( SwUndoIter& ); - virtual void _Redo( SwUndoIter& ); - -public: - SwUndoRedline( SwUndoId nUserId, const SwPaM& rRange ); - virtual ~SwUndoRedline(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); - - SwUndoId GetUserId() const { return nUserId; } - USHORT GetRedlSaveCount() const - { return pRedlSaveData ? pRedlSaveData->Count() : 0; } -}; - -class SwUndoRedlineDelete : public SwUndoRedline -{ - BOOL bCanGroup : 1; - BOOL bIsDelim : 1; - BOOL bIsBackspace : 1; - - virtual void _Undo( SwUndoIter& ); - virtual void _Redo( SwUndoIter& ); - -public: - SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUserId = UNDO_EMPTY ); - - BOOL CanGrouping( const SwUndoRedlineDelete& rPrev ); -}; - -class SwUndoRedlineSort : public SwUndoRedline -{ - SwSortOptions* pOpt; - ULONG nSaveEndNode, nOffset; - xub_StrLen nSaveEndCntnt; - - virtual void _Undo( SwUndoIter& ); - virtual void _Redo( SwUndoIter& ); - -public: - SwUndoRedlineSort( const SwPaM& rRange, const SwSortOptions& rOpt ); - virtual ~SwUndoRedlineSort(); - virtual void Repeat( SwUndoIter& ); - - void SetSaveRange( const SwPaM& rRange ); - void SetOffset( const SwNodeIndex& rIdx ); -}; - -class SwUndoAcceptRedline : public SwUndoRedline -{ - virtual void _Redo( SwUndoIter& ); -public: - SwUndoAcceptRedline( const SwPaM& rRange ); - virtual void Repeat( SwUndoIter& ); -}; - -class SwUndoRejectRedline : public SwUndoRedline -{ - virtual void _Redo( SwUndoIter& ); -public: - SwUndoRejectRedline( const SwPaM& rRange ); - virtual void Repeat( SwUndoIter& ); -}; - -//-------------------------------------------------------------------- - -class SwUndoCompDoc : public SwUndo, public SwUndRng -{ - SwRedlineData* pRedlData; - SwUndoDelete* pUnDel, *pUnDel2; - SwRedlineSaveDatas* pRedlSaveData; - BOOL bInsert; -public: - SwUndoCompDoc( const SwPaM& rRg, BOOL bIns ); - SwUndoCompDoc( const SwRedline& rRedl ); - - virtual ~SwUndoCompDoc(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); -}; - - -//-------------------------------------------------------------------- - -// Object der als Iterator durch die Undo-Liste laeuft, bis die -// letze oder die angegebene Klammerung/Id erreicht ist. - -class SwUndoIter -{ - friend class SwDoc; // um im SwDoc::Undo bWeiter zu stezen - friend void SwUndoEnd::Undo( SwUndoIter& ); - friend void SwUndoStart::Undo( SwUndoIter& ); - friend void SwUndoEnd::Redo( SwUndoIter& ); - friend void SwUndoStart::Redo( SwUndoIter& ); - friend void SwUndoEnd::Repeat( SwUndoIter& ); - friend void SwUndoStart::Repeat( SwUndoIter& ); - friend void SwUndoReplace::Undo( SwUndoIter& ); - friend void SwUndoReplace::Redo( SwUndoIter& ); - - SwUndoId nUndoId; - USHORT nEndCnt; - BOOL bWeiter : 1; - BOOL bUpdateAttr : 1; // Setze das GCAttr an der CursorShell - -public: - SwPaM * pAktPam; // Member fuer das Undo - SwUndo* pLastUndoObj; // fuers Redo, das vorherige UndoObj. - SwFrmFmt* pSelFmt; // ggfs. das Format Rahmen/Object-Selektionen - SdrMarkList* pMarkList; // MarkList for all selected SdrObjects - - SwUndoIter( SwPaM * pPam, SwUndoId nId = UNDO_EMPTY ); - - BOOL IsNextUndo() const { return bWeiter; } - BOOL IsUpdateAttr() const { return bUpdateAttr; } - void SetUpdateAttr( BOOL bNew ) { bUpdateAttr = bNew; } - - inline SwDoc& GetDoc() const; - SwUndoId GetId() const { return nUndoId; } - SwUndoId GetLastUndoId() const - { return pLastUndoObj ? pLastUndoObj->GetId() : UNDO_EMPTY ; } - void ClearSelections() { pSelFmt = 0; pMarkList = 0; } }; - -// -> #111827# -const int nUndoStringLength = 20; - -/** - Shortens a string to a maximum length. - - @param rStr the string to be shortened - @param nLength the maximum length for rStr - @param rFillStr string to replace cut out characters with - - If rStr has less than nLength characters it will be returned unaltered. - - If rStr has more than nLength characters the following algorithm - generates the shortened string: - - frontLength = (nLength - length(rFillStr)) / 2 - rearLength = nLength - length(rFillStr) - frontLength - shortenedString = concat(<first frontLength characters of rStr, - rFillStr, - <last rearLength characters of rStr>) - - Preconditions: - - nLength - length(rFillStr) >= 2 - - @return the shortened string - */ -String ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr); -// <- #111827# - -// #16487# -/** - Denotes special characters in a string. - - The rStr is split into parts containing special characters and - parts not containing special characters. In a part containing - special characters all characters are equal. These parts are - maximal. - - @param rStr the string to denote in - - The resulting string is generated by concatenating the found - parts. The parts without special characters are surrounded by - "'". The parts containing special characters are denoted as "n x", - where n is the length of the part and x is the representation of - the special character (i. e. "tab(s)"). - - @return the denoted string -*/ -String DenoteSpecialCharacters(const String & rStr); - #endif diff --git a/sw/inc/unomailmerge.hxx b/sw/inc/unomailmerge.hxx index 39a9664c4123..9e15051232a4 100644 --- a/sw/inc/unomailmerge.hxx +++ b/sw/inc/unomailmerge.hxx @@ -41,7 +41,7 @@ #include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/text/XMailMergeBroadcaster.hpp> #include <svl/itemprop.hxx> -#include <sfx2/objsh.hxx> // SfxObjectShellRef +#include <sfx2/objsh.hxx> #include <functional> diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 0ea5fa9db598..a12f911efce0 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -806,7 +806,8 @@ enum SwPropNameIds // <-- /* 0738 */ UNO_NAME_META, // #i91565# /* 0739 */ UNO_NAME_NESTED_TEXT_CONTENT, // #i109601# -/* 0740 */ SW_PROPNAME_END +/* 0740 */ UNO_NAME_EMBEDDED_OBJECT, +/* 0741 */ SW_PROPNAME_END }; diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 480876904d59..8e3299dd227c 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -335,7 +335,8 @@ public: /** Provides access to the document undo/redo interface */ - IDocumentUndoRedo* getIDocumentUndoRedoAccess(); + IDocumentUndoRedo const& GetIDocumentUndoRedo() const; + IDocumentUndoRedo & GetIDocumentUndoRedo(); // --> OD 2007-11-14 #i83479# const IDocumentListItems* getIDocumentListItemsAccess() const; diff --git a/sw/prj/build.lst b/sw/prj/build.lst index 71a6b39a261d..f36b0075b70a 100644 --- a/sw/prj/build.lst +++ b/sw/prj/build.lst @@ -1,2 +1,5 @@ sw sw : filter l10n connectivity OOo:writerperfect vbahelper svx stoc writerfilter LIBXSLT:libxslt NULL sw sw\prj nmake - all sw_prj NULL +sw sw\qa\complex\accessibility nmake - all sw_qa_complex_accessibility NULL +sw sw\qa\complex\checkColor nmake - all sw_qa_complex_checkColor NULL +sw sw\qa\unoapi nmake - all sw_qa_unoapi NULL diff --git a/sw/qa/complex/accessibility/makefile.mk b/sw/qa/complex/accessibility/makefile.mk new file mode 100644 index 000000000000..06e7c6a70408 --- /dev/null +++ b/sw/qa/complex/accessibility/makefile.mk @@ -0,0 +1,50 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_accessibility + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/accessibility +JAVATESTFILES = AccessibleRelationSet.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sw/qa/complex/checkColor/makefile.mk b/sw/qa/complex/checkColor/makefile.mk new file mode 100644 index 000000000000..e5b368083ada --- /dev/null +++ b/sw/qa/complex/checkColor/makefile.mk @@ -0,0 +1,50 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_checkColor + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/checkColor +JAVATESTFILES = CheckChangeColor.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index 114359bc3581..114359bc3581 100644..100755 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java diff --git a/sw/qa/unoapi/makefile.mk b/sw/qa/unoapi/makefile.mk new file mode 100644 index 000000000000..f5102c2c9c84 --- /dev/null +++ b/sw/qa/unoapi/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../.. +PRJNAME = sw +TARGET = qa_unoapi + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/sw/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sw/source/core/bastyp/swtypes.cxx b/sw/source/core/bastyp/swtypes.cxx index 1ce5e4b9cf6c..3015d8cf4b44 100644 --- a/sw/source/core/bastyp/swtypes.cxx +++ b/sw/source/core/bastyp/swtypes.cxx @@ -39,7 +39,8 @@ #include <frmfmt.hxx> #include <frmtool.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoDelete.hxx> +#include <UndoInsert.hxx> #include <swtable.hxx> #include <viscrs.hxx> #include <fntcache.hxx> diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 11060352b6c3..18dc67cfc958 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -31,6 +31,7 @@ #include <bookmrk.hxx> #include <IDocumentMarkAccess.hxx> +#include <IDocumentUndoRedo.hxx> #include <doc.hxx> #include <errhdl.hxx> #include <ndtxt.hxx> @@ -38,7 +39,7 @@ #include <swserv.hxx> #include <sfx2/linkmgr.hxx> #include <swtypes.hxx> -#include <undobj.hxx> +#include <UndoBookmark.hxx> #include <unobookmark.hxx> #include <rtl/random.h> #include <xmloff/odffields.hxx> @@ -79,13 +80,14 @@ namespace { SwPosition& rStart = pField->GetMarkStart(); SwPosition& rEnd = pField->GetMarkEnd(); - SwTxtNode const * const pStartTxtNode = io_pDoc->GetNodes()[rStart.nNode]->GetTxtNode(); - SwTxtNode const * const pEndTxtNode = io_pDoc->GetNodes()[rEnd.nNode]->GetTxtNode(); + SwTxtNode const*const pStartTxtNode = + rStart.nNode.GetNode().GetTxtNode(); + SwTxtNode const*const pEndTxtNode = rEnd.nNode.GetNode().GetTxtNode(); const sal_Unicode ch_start=pStartTxtNode->GetTxt().GetChar(rStart.nContent.GetIndex()); const sal_Unicode ch_end=pEndTxtNode->GetTxt().GetChar(rEnd.nContent.GetIndex()-1); SwPaM aStartPaM(rStart); SwPaM aEndPaM(rEnd); - io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL); + io_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_UI_REPLACE, NULL); if(ch_start != aStartMark) { io_pDoc->InsertString(aStartPaM, aStartMark); @@ -94,7 +96,7 @@ namespace { io_pDoc->InsertString(aEndPaM, aEndMark); } - io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL); + io_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_UI_REPLACE, NULL); }; } @@ -231,10 +233,10 @@ namespace sw { namespace mark void Bookmark::InitDoc(SwDoc* const io_pDoc) { - if(io_pDoc->DoesUndo()) + if (io_pDoc->GetIDocumentUndoRedo().DoesUndo()) { - io_pDoc->ClearRedo(); - io_pDoc->AppendUndo(new SwUndoInsBookmark(*this)); + io_pDoc->GetIDocumentUndoRedo().AppendUndo( + new SwUndoInsBookmark(*this)); } io_pDoc->SetModified(); } diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 9cf698a3a709..d1f3473dce5f 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -174,6 +174,21 @@ BOOL SwCrsrShell::DestroyCrsr() } +SwPaM & SwCrsrShell::CreateNewShellCursor() +{ + if (HasSelection()) + { + (void) CreateCrsr(); // n.b. returns old cursor + } + return *GetCrsr(); +} + +SwPaM & SwCrsrShell::GetCurrentShellCursor() +{ + return *GetCrsr(); +} + + // gebe den aktuellen zurueck SwPaM* SwCrsrShell::GetCrsr( BOOL bMakeTblCrsr ) const diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index e16207f03fa0..2b8a7ba91bdf 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -37,6 +37,7 @@ #include <svx/svdobj.hxx> #include <crsrsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagefrm.hxx> #include <cntfrm.hxx> #include <rootfrm.hxx> @@ -1705,7 +1706,8 @@ BOOL SwCrsrShell::GetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode, SET_CURR_SHELL( this ); BOOL bRet = FALSE; - if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() ) + if (!IsTableMode() && !HasSelection() + && GetDoc()->GetIDocumentUndoRedo().DoesUndo()) { Point aPt( rPt ); SwPosition aPos( *pCurCrsr->GetPoint() ); @@ -1730,7 +1732,8 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) SET_CURR_SHELL( this ); BOOL bRet = FALSE; - if( !IsTableMode() && !HasSelection() && GetDoc()->DoesUndo() ) + if (!IsTableMode() && !HasSelection() + && GetDoc()->GetIDocumentUndoRedo().DoesUndo()) { Point aPt( rPt ); SwPosition aPos( *pCurCrsr->GetPoint() ); @@ -1754,7 +1757,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) pCNd && pCNd->Len() ) nUndoId = UNDO_EMPTY; - GetDoc()->StartUndo( nUndoId, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( nUndoId, NULL ); SwTxtFmtColl* pNextFmt = 0; SwTxtNode* pTNd = pCNd->GetTxtNode(); @@ -1860,7 +1863,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) break; } - GetDoc()->EndUndo( nUndoId, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( nUndoId, NULL ); EndAction(); bRet = TRUE; diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index be581b17735d..08b73b887ccc 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -45,13 +45,14 @@ #include <fchrfmt.hxx> #include <charfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <swcrsr.hxx> #include <editsh.hxx> #include <ndtxt.hxx> #include <pamtyp.hxx> #include <swundo.hxx> #include <crsskip.hxx> -#include <undobj.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -1287,9 +1288,11 @@ ULONG SwCursor::Find( const SfxItemSet& rSet, BOOL bNoCollections, BOOL bReplace = ( pSearchOpt && ( pSearchOpt->replaceString.getLength() || !rSet.Count() ) ) || (pReplSet && pReplSet->Count()); - BOOL bSttUndo = pDoc->DoesUndo() && bReplace; - if( bSttUndo ) - pDoc->StartUndo( UNDO_REPLACE, NULL ); + bool const bStartUndo = pDoc->GetIDocumentUndoRedo().DoesUndo() && bReplace; + if (bStartUndo) + { + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_REPLACE, NULL ); + } SwFindParaAttr aSwFindParaAttr( rSet, bNoCollections, pSearchOpt, pReplSet, *this ); @@ -1299,8 +1302,10 @@ ULONG SwCursor::Find( const SfxItemSet& rSet, BOOL bNoCollections, if( nRet && bReplace ) pDoc->SetModified(); - if( bSttUndo ) - pDoc->EndUndo( UNDO_REPLACE, NULL ); + if (bStartUndo) + { + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_REPLACE, NULL ); + } return nRet; } diff --git a/sw/source/core/crsr/findcoll.cxx b/sw/source/core/crsr/findcoll.cxx index 4bb594ceb4ca..ed8fb97e9b54 100644 --- a/sw/source/core/crsr/findcoll.cxx +++ b/sw/source/core/crsr/findcoll.cxx @@ -28,16 +28,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <tools/resid.hxx> #include <swcrsr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pamtyp.hxx> #include <swundo.hxx> -#include <undobj.hxx> -#ifndef _COMCORE_HRC +#include <SwRewriter.hxx> #include <comcore.hrc> -#endif -#include <tools/resid.hxx> //------------------ Methoden der CrsrShell --------------------------- @@ -91,15 +90,17 @@ ULONG SwCursor::Find( const SwTxtFmtColl& rFmtColl, Link aLnk( pDoc->GetOle2Link() ); pDoc->SetOle2Link( Link() ); - BOOL bSttUndo = pDoc->DoesUndo() && pReplFmtColl; - if( bSttUndo ) + bool const bStartUndo = + pDoc->GetIDocumentUndoRedo().DoesUndo() && pReplFmtColl; + if (bStartUndo) { SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, rFmtColl.GetName()); aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); aRewriter.AddRule(UNDO_ARG3, pReplFmtColl->GetName()); - pDoc->StartUndo( UNDO_UI_REPLACE_STYLE, &aRewriter ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE_STYLE, + &aRewriter ); } SwFindParaFmtColl aSwFindParaFmtColl( rFmtColl, pReplFmtColl, *this ); @@ -110,8 +111,10 @@ ULONG SwCursor::Find( const SwTxtFmtColl& rFmtColl, if( nRet && pReplFmtColl ) pDoc->SetModified(); - if( bSttUndo ) - pDoc->EndUndo( UNDO_UI_REPLACE_STYLE, NULL ); + if (bStartUndo) + { + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); + } return nRet; } diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index ed4bcc089957..9f2c6d71ad6d 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -27,15 +27,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/util/SearchFlags.hpp> - - #define _SVSTDARR_USHORTS #define _SVSTDARR_ULONGS #include <svl/svstdarr.hxx> + #include <vcl/svapp.hxx> +#include <vcl/window.hxx> + #include <txatritr.hxx> #include <fldbas.hxx> #include <fmtfld.hxx> @@ -43,15 +45,16 @@ #include <txtfld.hxx> #include <swcrsr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pamtyp.hxx> #include <ndtxt.hxx> #include <swundo.hxx> +#include <UndoInsert.hxx> #include <breakit.hxx> #include <docsh.hxx> #include <PostItMgr.hxx> #include <viewsh.hxx> -#include <vcl/window.hxx> using namespace ::com::sun::star; using namespace util; @@ -643,9 +646,11 @@ ULONG SwCursor::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes, Link aLnk( pDoc->GetOle2Link() ); pDoc->SetOle2Link( Link() ); - BOOL bSttUndo = pDoc->DoesUndo() && bReplace; - if( bSttUndo ) - pDoc->StartUndo( UNDO_REPLACE, NULL ); + bool const bStartUndo = pDoc->GetIDocumentUndoRedo().DoesUndo() && bReplace; + if (bStartUndo) + { + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_REPLACE, NULL ); + } BOOL bSearchSel = 0 != (rSearchOpt.searchFlag & SearchFlags::REG_NOT_BEGINOFLINE); if( bSearchSel ) @@ -656,8 +661,12 @@ ULONG SwCursor::Find( const SearchOptions& rSearchOpt, BOOL bSearchInNotes, if( nRet && bReplace ) pDoc->SetModified(); - if( bSttUndo ) - pDoc->EndUndo( UNDO_REPLACE, NULL ); + if (bStartUndo) + { + SwRewriter rewriter(MakeUndoReplaceRewriter( + nRet, rSearchOpt.searchString, rSearchOpt.replaceString)); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_REPLACE, & rewriter ); + } return nRet; } diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 7637df0a67b4..082e61e3347c 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -43,6 +43,7 @@ #include <swcrsr.hxx> #include <unocrsr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <ndtxt.hxx> #include <section.hxx> @@ -58,9 +59,7 @@ #include <crsskip.hxx> #include <vcl/msgbox.hxx> #include <mdiexp.hxx> // ...Percent() -#ifndef _STATSTR_HRC #include <statstr.hrc> // ResId fuer Statusleiste -#endif #include <redline.hxx> // SwRedline @@ -743,7 +742,7 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, BOOL bInReadOnly, BOOL& bCancel ) { SwDoc* pDoc = pCurCrsr->GetDoc(); - BOOL bDoesUndo = pDoc->DoesUndo(); + bool const bDoesUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); int nFndRet = 0; ULONG nFound = 0; int bSrchBkwrd = fnMove == fnMoveBackward, bEnde = FALSE; @@ -806,14 +805,15 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, break; } - if( coSrchRplcThreshold == nFound && pDoc->DoesUndo() + if ((coSrchRplcThreshold == nFound) + && pDoc->GetIDocumentUndoRedo().DoesUndo() && rParas.IsReplaceMode()) { short nRet = pCurCrsr->MaxReplaceArived(); if( RET_YES == nRet ) { - pDoc->DelAllUndoObj(); - pDoc->DoUndo( FALSE ); + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + pDoc->GetIDocumentUndoRedo().DoUndo(false); } else { @@ -858,7 +858,7 @@ ULONG lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr, pFndRing = pCurCrsr->Create(); delete pPHdl; - pDoc->DoUndo( bDoesUndo ); + pDoc->GetIDocumentUndoRedo().DoUndo(bDoesUndo); return nFound; } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index 3c85091c7d20..daded009ac01 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -42,6 +42,7 @@ #include <docary.hxx> #include <swundo.hxx> #include <undobj.hxx> +#include <numrule.hxx> #include <doc.hxx> #include <frmfmt.hxx> #include <fmtanchr.hxx> @@ -808,43 +809,10 @@ String lcl_dbg_out(const SwUndo & rUndo) { String aStr("[ ", RTL_TEXTENCODING_ASCII_US); - aStr += String::CreateFromInt32(rUndo.GetId()); + aStr += String::CreateFromInt32( + static_cast<SfxUndoAction const&>(rUndo).GetId()); aStr += String(": ", RTL_TEXTENCODING_ASCII_US); - switch(rUndo.GetId()) - { - case UNDO_START: - aStr += String(", ", RTL_TEXTENCODING_ASCII_US); - aStr += - String::CreateFromInt32(dynamic_cast - <const SwUndoStart &>(rUndo). - GetUserId()); - aStr += String(", ", RTL_TEXTENCODING_ASCII_US); - aStr += String::CreateFromInt32(dynamic_cast - <const SwUndoStart &>(rUndo). - GetEndOffset()); - aStr += String(" ", RTL_TEXTENCODING_ASCII_US); - - break; - - case UNDO_END: - aStr += String(", ", RTL_TEXTENCODING_ASCII_US); - aStr += - String::CreateFromInt32(dynamic_cast - <const SwUndoEnd &>(rUndo). - GetId()); - aStr += String(", ", RTL_TEXTENCODING_ASCII_US); - aStr += String::CreateFromInt32(dynamic_cast - <const SwUndoEnd &>(rUndo). - GetSttOffset()); - aStr += String(" ", RTL_TEXTENCODING_ASCII_US); - - break; - - default: - break; - } - aStr += rUndo.GetComment(); aStr += String(" ]", RTL_TEXTENCODING_ASCII_US); @@ -876,39 +844,6 @@ SW_DLLPUBLIC const char * dbg_out(SwOutlineNodes & rNodes) return dbg_out(lcl_dbg_out(rNodes)); } -String lcl_dbg_out(const SwUndos & rUndos) -{ - USHORT nIndent = 0; - - String aStr("[\n", RTL_TEXTENCODING_ASCII_US); - - for (USHORT n = 0; n < rUndos.Count(); n++) - { - SwUndo * pUndo = rUndos[n]; - - if (pUndo->GetId() == UNDO_END) - nIndent--; - - for (USHORT nI = 0; n < nIndent; nI++) - aStr += String(" ", RTL_TEXTENCODING_ASCII_US); - - aStr += lcl_dbg_out(*pUndo); - aStr += String("\n", RTL_TEXTENCODING_ASCII_US); - - if (pUndo->GetId() == UNDO_START) - nIndent++; - } - - aStr += String("]\n", RTL_TEXTENCODING_ASCII_US); - - return aStr; -} - -SW_DLLPUBLIC const char * dbg_out(const SwUndos & rUndos) -{ - return dbg_out(lcl_dbg_out(rUndos)); -} - String lcl_dbg_out(const SwRewriter & rRewriter) { (void) rRewriter; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 9b835a1a4b05..71bd7e26ac71 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -27,7 +27,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <doc.hxx> +#include <UndoManager.hxx> #include <hintids.hxx> #include <tools/shl.hxx> @@ -80,7 +82,10 @@ #include <pam.hxx> #include <ndtxt.hxx> #include <swundo.hxx> // fuer die UndoIds -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoInsert.hxx> +#include <UndoSplitMove.hxx> +#include <UndoTable.hxx> #include <pagedesc.hxx> //DTor #include <breakit.hxx> #include <ndole.hxx> @@ -112,15 +117,15 @@ #include <viewsh.hxx> #include <shellres.hxx> #include <txtfrm.hxx> +#include <wdocsh.hxx> // SwWebDocShell +#include <prtopt.hxx> // SwPrintOptions #include <vector> #include <map> #include <osl/diagnose.h> #include <osl/interlck.h> -#ifdef FUTURE_VBA #include <vbahelper/vbaaccesshelper.hxx> -#endif /* @@@MAINTAINABILITY-HORROR@@@ Probably unwanted dependency on SwDocShell @@ -632,11 +637,23 @@ void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup ) PrtDataChanged(); } -SwPrintData* SwDoc::getPrintData() const +const SwPrintData & SwDoc::getPrintData() const { if(!pPrtData) - ((SwDoc*)this)->pPrtData = new SwPrintData; - return pPrtData; + { + SwDoc * pThis = const_cast< SwDoc * >(this); + pThis->pPrtData = new SwPrintData; + + // SwPrintData should be initialized from the configuration, + // the respective config item is implememted by SwPrintOptions which + // is also derived from SwPrintData + const SwDocShell *pDocSh = GetDocShell(); + DBG_ASSERT( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" ); + bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh); + SwPrintOptions aPrintOptions( bWeb ); + *pThis->pPrtData = aPrintOptions; + } + return *pPrtData; } void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData ) @@ -677,14 +694,14 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) } SwUndoSplitNode* pUndo = 0; - if ( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); // einfuegen vom Undo-Object, z.Z. nur beim TextNode if( pNode->IsTxtNode() ) { pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart ); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } } @@ -791,10 +808,8 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) bool SwDoc::AppendTxtNode( SwPosition& rPos ) { - /* - * Neuen Node vor EndOfContent erzeugen. - */ - SwTxtNode *pCurNode = GetNodes()[ rPos.nNode ]->GetTxtNode(); + // create new node before EndOfContent + SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode(); if( !pCurNode ) { // dann kann ja einer angelegt werden! @@ -808,10 +823,9 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) rPos.nNode++; rPos.nContent.Assign( pCurNode, 0 ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoInsert( rPos.nNode )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) ); } if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) @@ -832,9 +846,9 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, const enum InsertFlags nInsertMode ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called! } const SwPosition& rPos = *rRg.GetPoint(); @@ -856,15 +870,16 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, SwDataChanged aTmp( rRg, 0 ); - if( !DoesUndo() || !DoesGroupUndo() ) + if (!GetIDocumentUndoRedo().DoesUndo() || + !GetIDocumentUndoRedo().DoesGroupUndo()) { pNode->InsertText( rStr, rPos.nContent, nInsertMode ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndoInsert * const pUndo( new SwUndoInsert( rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } } else @@ -875,25 +890,12 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND)) // -> #111827# { - USHORT const nUndoSize = pUndos->Count(); - if (0 != nUndoSize) + SwUndo *const pLastUndo = GetUndoManager().GetLastUndo(); + SwUndoInsert *const pUndoInsert( + dynamic_cast<SwUndoInsert *>(pLastUndo) ); + if (pUndoInsert && pUndoInsert->CanGrouping(rPos)) { - SwUndo * const pLastUndo = (*pUndos)[ nUndoSize - 1 ]; - - switch (pLastUndo->GetId()) - { - case UNDO_INSERT: - case UNDO_TYPING: - if (static_cast<SwUndoInsert*>(pLastUndo) - ->CanGrouping( rPos )) - { - pUndo = static_cast<SwUndoInsert*>(pLastUndo); - } - break; - - default: - break; - } + pUndo = pUndoInsert; } } // <- #111827# @@ -905,7 +907,7 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, { pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode, !rCC.isLetterNumeric( rStr, 0 ) ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } pNode->InsertText( rStr, rPos.nContent, nInsertMode ); @@ -918,7 +920,7 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, { pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode, !rCC.isLetterNumeric( rStr, i ) ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } } } @@ -1339,12 +1341,14 @@ void SwDoc::CalculatePagesForPrinting( // get PageRange value to use OUString aPageRange; - if (bIsPDFExport) - { - // ?? rOptions.getValue( C2U("Selection") ); - aPageRange = rOptions.getStringValue( "PageRange", OUString() ); - } - else + // --> PL, OD #i116085# - adjusting fix for i113919 +// if (bIsPDFExport) +// { +// aPageRange = rOptions.getStringValue( "PageRange", OUString() ); +// } +// else + if ( !bIsPDFExport ) + // <-- { // PageContent : // 0 -> print all pages (default if aPageRange is empty) @@ -1997,7 +2001,7 @@ void SwDoc::ResetModified() // it is correct. In this case we reset the modified flag. if ( 0 != pDocStat->nChar ) pDocStat->bModified = FALSE; - nUndoSavePos = nUndoPos; + GetIDocumentUndoRedo().SetUndoNoModifiedPosition(); if( nCall && aOle2Link.IsSet() ) { mbInCallModified = TRUE; @@ -2016,10 +2020,9 @@ void SwDoc::ReRead( SwPaM& rPam, const String& rGrfName, || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() ) && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoReRead( rPam, *pGrfNd ) ); + GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd)); } // Weil nicht bekannt ist, ob sich die Grafik spiegeln laesst, @@ -2231,10 +2234,10 @@ void SwDoc::Summary( SwDoc* pExtDoc, BYTE nLevel, BYTE nPara, BOOL bImpress ) // loesche den nicht sichtbaren Content aus dem Document, wie z.B.: // versteckte Bereiche, versteckte Absaetze -BOOL SwDoc::RemoveInvisibleContent() +bool SwDoc::RemoveInvisibleContent() { BOOL bRet = FALSE; - StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); { SwTxtNode* pTxtNd; @@ -2398,13 +2401,13 @@ BOOL SwDoc::RemoveInvisibleContent() if( bRet ) SetModified(); - EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL ); return bRet; } /*-- 25.08.2010 14:18:12--------------------------------------------------- -----------------------------------------------------------------------*/ -BOOL SwDoc::HasInvisibleContent() const +bool SwDoc::HasInvisibleContent() const { BOOL bRet = sal_False; @@ -2449,6 +2452,21 @@ BOOL SwDoc::HasInvisibleContent() const } return bRet; } + +bool SwDoc::RestoreInvisibleContent() +{ + bool bRet = false; + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId) + && (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId)) + { + GetIDocumentUndoRedo().Undo(); + GetIDocumentUndoRedo().ClearRedo(); + bRet = true; + } + return bRet; +} + /*-- 11.06.2004 08:34:04--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -2456,7 +2474,7 @@ BOOL SwDoc::ConvertFieldsToText() { BOOL bRet = FALSE; LockExpFlds(); - StartUndo( UNDO_UI_REPLACE, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL ); const SwFldTypes* pMyFldTypes = GetFldTypes(); sal_uInt16 nCount = pMyFldTypes->Count(); @@ -2526,7 +2544,7 @@ BOOL SwDoc::ConvertFieldsToText() if( bRet ) SetModified(); - EndUndo( UNDO_UI_REPLACE, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_UI_REPLACE, NULL ); UnlockExpFlds(); return bRet; @@ -2593,8 +2611,7 @@ bool SwDoc::EmbedAllLinks() const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks(); if( rLinks.Count() ) { - BOOL bDoesUndo = DoesUndo(); - DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); ::sfx2::SvBaseLink* pLnk = 0; while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) ) @@ -2610,8 +2627,7 @@ bool SwDoc::EmbedAllLinks() bRet = TRUE; } - DelAllUndoObj(); - DoUndo( bDoesUndo ); + GetIDocumentUndoRedo().DelAllUndoObj(); SetModified(); } return bRet; @@ -2650,26 +2666,26 @@ void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, BOOL bIsTable ) { SwUndoCpyTbl* pUndo = new SwUndoCpyTbl; pUndo->SetTableSttIdx( pTblNd->GetIndex() ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } } else if( rPam.HasMark() ) { SwUndoCpyDoc* pUndo = new SwUndoCpyDoc( rPam ); pUndo->SetInsertRange( rPam, FALSE ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } } void SwDoc::ChgTOX(SwTOXBase & rTOX, const SwTOXBase & rNew) { - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { - DelAllUndoObj(); + GetIDocumentUndoRedo().DelAllUndoObj(); SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } rTOX = rNew; diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx index 37568933e522..f4ce285d0cf2 100644 --- a/sw/source/core/doc/docbasic.cxx +++ b/sw/source/core/doc/docbasic.cxx @@ -100,7 +100,7 @@ BOOL SwDoc::ExecMacro( const SvxMacro& rMacro, String* pRet, SbxArray* pArgs ) aRef = pRetValue; eErr = pDocShell->CallBasic( rMacro.GetMacName(), rMacro.GetLibName(), - 0, pArgs, pRet ? pRetValue : 0 ); + pArgs, pRet ? pRetValue : 0 ); if( pRet && SbxNULL < pRetValue->GetType() && SbxVOID != pRetValue->GetType() ) @@ -231,7 +231,7 @@ USHORT SwDoc::CallEvent( USHORT nEvent, const SwCallMouseEvent& rCallEvent, if( STARBASIC == rMacro.GetScriptType() ) { nRet += 0 == pDocShell->CallBasic( rMacro.GetMacName(), - rMacro.GetLibName(), 0, pArgs ) ? 1 : 0; + rMacro.GetLibName(), pArgs ) ? 1 : 0; } else if( EXTENDED_STYPE == rMacro.GetScriptType() ) { diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 587c846667f4..4f57a374bb9a 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -58,7 +58,6 @@ #include <swserv.hxx> #include <swundo.hxx> #include <tools/pstm.hxx> -#include <undobj.hxx> #include <unocrsr.hxx> #include <viscrs.hxx> #include <stdio.h> diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 170193778421..67c5d24ab505 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -37,11 +37,12 @@ #include <editeng/boxitem.hxx> #include <editeng/udlnitem.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <redline.hxx> -#include <undobj.hxx> +#include <UndoRedline.hxx> #include <section.hxx> #include <tox.hxx> #include <docsh.hxx> @@ -1216,14 +1217,12 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine, if( nStt != nSEnd ) { { - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); SwPaM aCpyPam( rSrcNd, nStt ); aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSEnd; aCpyPam.GetDoc()->CopyRange( aCpyPam, *aPam.GetPoint(), false ); - pDoc->DoUndo( bUndo ); } SwPaM* pTmp = new SwPaM( *aPam.GetPoint(), rpDelRing ); @@ -1494,8 +1493,11 @@ void SwCompareData::SetRedlinesToDoc( BOOL bUseDocInfo ) rDoc.DeleteRedline( *pTmp, false, USHRT_MAX ); - if( rDoc.DoesUndo() ) - rDoc.AppendUndo( new SwUndoCompDoc( *pTmp, FALSE )); + if (rDoc.GetIDocumentUndoRedo().DoesUndo()) + { + SwUndo *const pUndo(new SwUndoCompDoc( *pTmp, FALSE )) ; + rDoc.GetIDocumentUndoRedo().AppendUndo(pUndo); + } rDoc.AppendRedline( new SwRedline( aRedlnData, *pTmp ), true ); } while( pDelRing != ( pTmp = (SwPaM*)pTmp->GetNext() )); @@ -1560,8 +1562,11 @@ void SwCompareData::SetRedlinesToDoc( BOOL bUseDocInfo ) do { if( rDoc.AppendRedline( new SwRedline( aRedlnData, *pTmp ), true) && - rDoc.DoesUndo() ) - rDoc.AppendUndo( new SwUndoCompDoc( *pTmp, TRUE )); + rDoc.GetIDocumentUndoRedo().DoesUndo()) + { + SwUndo *const pUndo(new SwUndoCompDoc( *pTmp, TRUE )); + rDoc.GetIDocumentUndoRedo().AppendUndo(pUndo); + } } while( pInsRing != ( pTmp = (SwPaM*)pTmp->GetNext() )); } } @@ -1578,7 +1583,7 @@ long SwDoc::CompareDoc( const SwDoc& rDoc ) long nRet = 0; - StartUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); BOOL bDocWasModified = IsModified(); SwDoc& rSrcDoc = (SwDoc&)rDoc; BOOL bSrcModified = rSrcDoc.IsModified(); @@ -1609,14 +1614,12 @@ long SwDoc::CompareDoc( const SwDoc& rDoc ) if( !bSrcModified ) rSrcDoc.ResetModified(); - EndUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); return nRet; } -typedef void (SwDoc::*FNInsUndo)( SwUndo* ); - class _SaveMergeRedlines : public Ring { const SwRedline* pSrcRedl; @@ -1624,7 +1627,7 @@ class _SaveMergeRedlines : public Ring public: _SaveMergeRedlines( const SwNode& rDstNd, const SwRedline& rSrcRedl, Ring* pRing ); - USHORT InsertRedline( FNInsUndo pFn ); + USHORT InsertRedline(); SwRedline* GetDestRedline() { return pDestRedl; } }; @@ -1655,7 +1658,7 @@ _SaveMergeRedlines::_SaveMergeRedlines( const SwNode& rDstNd, } } -USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) +USHORT _SaveMergeRedlines::InsertRedline() { USHORT nIns = 0; SwDoc* pDoc = pDestRedl->GetDoc(); @@ -1663,8 +1666,7 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) if( nsRedlineType_t::REDLINE_INSERT == pDestRedl->GetType() ) { // der Teil wurde eingefuegt, also kopiere ihn aus dem SourceDoc - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwNodeIndex aSaveNd( pDestRedl->GetPoint()->nNode, -1 ); xub_StrLen nSaveCnt = pDestRedl->GetPoint()->nContent.GetIndex(); @@ -1677,7 +1679,6 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) *pDestRedl->GetPoint(), false ); pDoc->SetRedlineMode_intern( eOld ); - pDoc->DoUndo( bUndo ); pDestRedl->SetMark(); aSaveNd++; @@ -1739,13 +1740,16 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) pCpyRedl->SetMark(); *pCpyRedl->GetPoint() = *pRStt; - SwUndoCompDoc* pUndo = pDoc->DoesUndo() + SwUndoCompDoc *const pUndo = + (pDoc->GetIDocumentUndoRedo().DoesUndo()) ? new SwUndoCompDoc( *pCpyRedl ) : 0; // now modify doc: append redline, undo (and count) pDoc->AppendRedline( pCpyRedl, true ); if( pUndo ) - (pDoc->*pFn)( pUndo ); + { + pDoc->GetIDocumentUndoRedo().AppendUndo(pUndo); + } ++nIns; *pDStt = *pREnd; @@ -1772,12 +1776,15 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) if( pDestRedl ) { - SwUndoCompDoc* pUndo = pDoc->DoesUndo() ? new SwUndoCompDoc( *pDestRedl ) : 0; + SwUndoCompDoc *const pUndo = (pDoc->GetIDocumentUndoRedo().DoesUndo()) + ? new SwUndoCompDoc( *pDestRedl ) : 0; // now modify doc: append redline, undo (and count) bool bRedlineAccepted = pDoc->AppendRedline( pDestRedl, true ); if( pUndo ) - (pDoc->*pFn)( pUndo ); + { + pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo ); + } ++nIns; // if AppendRedline has deleted our redline, we may not keep a @@ -1796,7 +1803,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc ) long nRet = 0; - StartUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); SwDoc& rSrcDoc = (SwDoc&)rDoc; BOOL bSrcModified = rSrcDoc.IsModified(); @@ -1853,7 +1860,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc ) _SaveMergeRedlines* pTmp = pRing; do { - nRet += pTmp->InsertRedline( &SwDoc::AppendUndo ); + nRet += pTmp->InsertRedline(); } while( pRing != ( pTmp = (_SaveMergeRedlines*)pTmp->GetNext() )); while( pRing != pRing->GetNext() ) @@ -1868,7 +1875,7 @@ long SwDoc::MergeDoc( const SwDoc& rDoc ) SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)); - EndUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); return nRet; } diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index 0520a9b5c81c..d62a92887d85 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -353,4 +353,8 @@ SwEditShell* SwDoc::GetEditShell( ViewShell** ppSh ) const return 0; } +::sw::IShellCursorSupplier * SwDoc::GetIShellCursorSupplier() +{ + return GetEditShell(0); +} diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 0b56578e0536..7a441480f07f 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <vcl/virdev.hxx> #include <svx/svdmodel.hxx> @@ -48,6 +49,7 @@ #include <ndole.hxx> #include <mdiexp.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pagefrm.hxx> //Fuer DelPageDesc #include <rootfrm.hxx> //Fuer DelPageDesc @@ -55,9 +57,7 @@ #include <frmtool.hxx> #include <pagedesc.hxx> #include <poolfmt.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <ndindex.hxx> #include <ftnidx.hxx> #include <fmtftn.hxx> @@ -69,9 +69,8 @@ #include <swwait.hxx> #include <GetMetricVal.hxx> #include <unotools/syslocale.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif +#include <hints.hxx> #include <SwUndoPageDesc.hxx> @@ -203,12 +202,12 @@ void SwDoc::ChgPageDesc( USHORT i, const SwPageDesc &rChged ) SwPageDesc *pDesc = aPageDescs[i]; - BOOL bDoesUndo = DoesUndo(); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { - AppendUndo(new SwUndoPageDesc(*pDesc, rChged, this)); - DoUndo(FALSE); + SwUndo *const pUndo(new SwUndoPageDesc(*pDesc, rChged, this)); + GetIDocumentUndoRedo().AppendUndo(pUndo); } + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); //Als erstes wird ggf. gespiegelt. if ( rChged.GetUseOn() == nsUseOnPage::PD_MIRROR ) @@ -247,7 +246,7 @@ void SwDoc::ChgPageDesc( USHORT i, const SwPageDesc &rChged ) //Header abgleichen. const SwFmtHeader &rHead = rChged.GetMaster().GetHeader(); - if( bDoesUndo ) + if (undoGuard.UndoWasEnabled()) { // #i46909# no undo if header or footer changed // hat sich an den Nodes etwas veraendert ? @@ -311,7 +310,7 @@ void SwDoc::ChgPageDesc( USHORT i, const SwPageDesc &rChged ) //Footer abgleichen. const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter(); - if( bDoesUndo ) + if (undoGuard.UndoWasEnabled()) { // #i46909# no undo if header or footer changed // hat sich an den Nodes etwas veraendert ? @@ -426,13 +425,10 @@ void SwDoc::ChgPageDesc( USHORT i, const SwPageDesc &rChged ) } SetModified(); - DoUndo(bDoesUndo); - // #i46909# no undo if header or footer changed if( bHeaderFooterChanged ) { - ClearRedo(); - DelAllUndoObj(); + GetIDocumentUndoRedo().DelAllUndoObj(); } } @@ -570,9 +566,10 @@ void SwDoc::DelPageDesc( USHORT i, BOOL bBroadcast ) SFX_STYLESHEET_ERASED); // <- #116530# - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { - AppendUndo(new SwUndoPageDescDelete(*pDel, this)); + SwUndo *const pUndo(new SwUndoPageDescDelete(*pDel, this)); + GetIDocumentUndoRedo().AppendUndo(pUndo); } PreDelPageDesc(pDel); // #i7983# @@ -629,8 +626,11 @@ USHORT SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy, SFX_STYLESHEET_CREATED); // <- #116530# - if (DoesUndo()) - AppendUndo(new SwUndoPageDescCreate(pNew, this)); // #116530# + if (GetIDocumentUndoRedo().DoesUndo()) + { + // #116530# + GetIDocumentUndoRedo().AppendUndo(new SwUndoPageDescCreate(pNew, this)); + } SetModified(); return (aPageDescs.Count()-1); diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx index 1a10428d5a58..000f12892cf9 100644 --- a/sw/source/core/doc/docdraw.cxx +++ b/sw/source/core/doc/docdraw.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <rtl/logfile.hxx> #include <vcl/outdev.hxx> @@ -49,12 +50,13 @@ #include <viewimp.hxx> #include <swhints.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docsh.hxx> #include <rootfrm.hxx> //Damit der RootDtor gerufen wird. #include <poolfmt.hxx> #include <viewsh.hxx> // fuer MakeDrawView #include <drawdoc.hxx> -#include <undobj.hxx> +#include <UndoDraw.hxx> #include <swundo.hxx> // fuer die UndoIds #include <dcontact.hxx> #include <dview.hxx> @@ -227,7 +229,7 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView ) SwDrawContact *pMyContact = (SwDrawContact*)GetUserCall(pObj); const SwFmtAnchor aAnch( pMyContact->GetFmt()->GetAnchor() ); - SwUndoDrawGroup* pUndo = !DoesUndo() + SwUndoDrawGroup *const pUndo = (!GetIDocumentUndoRedo().DoesUndo()) ? 0 : new SwUndoDrawGroup( (USHORT)rMrkList.GetMarkCount() ); @@ -303,14 +305,15 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView ) if( pUndo ) { pUndo->SetGroupFmt( pFmt ); - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } } else { - if ( DoesUndo() ) - ClearRedo(); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().ClearRedo(); + } rDrawView.GroupMarked(); ASSERT( rMrkList.GetMarkCount() == 1, "GroupMarked more or none groups." ); @@ -322,9 +325,11 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView ) void SwDoc::UnGroupSelection( SdrView& rDrawView ) { - const int bUndo = DoesUndo(); + bool const bUndo = GetIDocumentUndoRedo().DoesUndo(); if( bUndo ) - ClearRedo(); + { + GetIDocumentUndoRedo().ClearRedo(); + } // OD 30.06.2003 #108784# - replace marked 'virtual' drawing objects by // the corresponding 'master' drawing objects. @@ -358,7 +363,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView ) if( bUndo ) { pUndo = new SwUndoDrawUnGroup( (SdrObjGroup*)pObj ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } for ( USHORT i2 = 0; i2 < pLst->GetObjCount(); ++i2 ) @@ -403,7 +408,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView ) if( bUndo ) { pUndo = new SwUndoDrawUnGroupConnectToLayout(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } while ( pFmtsAndObjs[i].size() > 0 ) @@ -442,7 +447,7 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) const SdrMarkList &rMrkList = rDrawView.GetMarkedObjectList(); if( rMrkList.GetMarkCount() ) { - StartUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); USHORT i; BOOL bDelMarked = TRUE; @@ -483,7 +488,9 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj(); if( !pObj->GetUpGroup() ) { - SwUndoDrawDelete* pUndo = !DoesUndo() ? 0 + SwUndoDrawDelete *const pUndo = + (!GetIDocumentUndoRedo().DoesUndo()) + ? 0 : new SwUndoDrawDelete( (USHORT)rMrkList.GetMarkCount() ); //ContactObjekte vernichten, Formate sicherstellen. @@ -516,13 +523,15 @@ BOOL SwDoc::DeleteSelection( SwDrawView& rDrawView ) } if( pUndo ) - AppendUndo( pUndo ); + { + GetIDocumentUndoRedo().AppendUndo( pUndo ); + } } bCallBase = TRUE; } SetModified(); - EndUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); } return bCallBase; @@ -625,7 +634,7 @@ void SwDoc::InitDrawModel() //Seite. pDrawModel = new SwDrawDocument( this ); - pDrawModel->EnableUndo( DoesUndo() ); + pDrawModel->EnableUndo( GetIDocumentUndoRedo().DoesUndo() ); String sLayerNm; sLayerNm.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Hell" )); diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index bdcf8caaff7b..782bc556953f 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -48,6 +48,7 @@ #include <cntfrm.hxx> // fuers Spell #include <crsrsh.hxx> #include <doc.hxx> +#include <UndoManager.hxx> #include <docsh.hxx> #include <docary.hxx> #include <doctxm.hxx> // beim Move: Verzeichnisse korrigieren @@ -63,7 +64,12 @@ #include <swtable.hxx> #include <swundo.hxx> // fuer die UndoIds #include <txtfrm.hxx> -#include <undobj.hxx> +#include <hints.hxx> +#include <UndoSplitMove.hxx> +#include <UndoRedline.hxx> +#include <UndoOverwrite.hxx> +#include <UndoInsert.hxx> +#include <UndoDelete.hxx> #include <breakit.hxx> #include <hhcwrp.hxx> #include <breakit.hxx> @@ -773,8 +779,10 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) if(!pNode) return sal_False; - if( DoesUndo() ) - ClearRedo(); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called + } sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints() ? pNode->GetpSwpHints()->Count() : 0; @@ -782,8 +790,6 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) SwIndex& rIdx = rPt.nContent; xub_StrLen nStart = 0; - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; sal_Unicode c; String aStr; @@ -799,16 +805,24 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) lcl_SkipAttr( pNode, rIdx, nStart ); } c = rStr.GetChar( nCnt ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - if( DoesGroupUndo() && nUndoSize && - UNDO_OVERWRITE == ( pUndo = (*pUndos)[ nUndoSize-1 ])->GetId() && - ((SwUndoOverwrite*)pUndo)->CanGrouping( this, rPt, c )) - ;// wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else + bool bMerged(false); + if (GetIDocumentUndoRedo().DoesGroupUndo()) + { + SwUndo *const pUndo = GetUndoManager().GetLastUndo(); + SwUndoOverwrite *const pUndoOW( + dynamic_cast<SwUndoOverwrite *>(pUndo) ); + if (pUndoOW) + { + // if CanGrouping() returns true it's already merged + bMerged = pUndoOW->CanGrouping( this, rPt, c ); + } + } + if (!bMerged) { - AppendUndo( new SwUndoOverwrite( this, rPt, c )); - nUndoSize = pUndos->Count(); + SwUndo *const pUndoOW( new SwUndoOverwrite(this, rPt, c) ); + GetIDocumentUndoRedo().AppendUndo(pUndoOW); } } else @@ -841,7 +855,8 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) } } - if( !DoesUndo() && !IsIgnoreRedline() && GetRedlineTbl().Count() ) + if (!GetIDocumentUndoRedo().DoesUndo() && + !IsIgnoreRedline() && GetRedlineTbl().Count()) { SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); DeleteRedline( aPam, true, USHRT_MAX ); @@ -909,15 +924,13 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // in a particular order, and presence of bookmarks // will change this order. Hence, we delete bookmarks // here without undo. - BOOL bDoesUndo = DoesUndo(); - DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); _DelBookmarks( pStt->nNode, pEnd->nNode, NULL, &pStt->nContent, &pEnd->nContent); - DoUndo( bDoesUndo ); } @@ -926,9 +939,9 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // falls Undo eingeschaltet, erzeuge das UndoMove-Objekt SwUndoMove * pUndoMove = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndoMove = new SwUndoMove( rPaM, rPos ); pUndoMove->SetMoveRedlines( eMvFlags == DOC_MOVEREDLINES ); } @@ -1025,7 +1038,7 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) rPaM.SetMark(); // um den neuen Bereich eine Sel. aufspannen pTNd = aSavePam.GetNode()->GetTxtNode(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { // korrigiere erstmal den Content vom SavePam if( bNullCntnt ) @@ -1069,7 +1082,7 @@ bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // zwischen SPoint und GetMark steht jetzt der neu eingefuegte Bereich pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(), bJoin, bCorrSavePam ); - AppendUndo( pUndoMove ); + GetIDocumentUndoRedo().AppendUndo( pUndoMove ); } else { @@ -1152,11 +1165,15 @@ bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, SwFtnIdxs aTmpFntIdx; SwUndoMove* pUndo = 0; - if( (DOC_CREATEUNDOOBJ & eMvFlags ) && DoesUndo() ) + if ((DOC_CREATEUNDOOBJ & eMvFlags ) && GetIDocumentUndoRedo().DoesUndo()) + { pUndo = new SwUndoMove( this, rRange, rPos ); + } else + { bUpdateFtn = lcl_SaveFtn( rRange.aStart, rRange.aEnd, rPos, GetFtnIdxs(), aTmpFntIdx ); + } _SaveRedlines aSaveRedl( 0, 4 ); SvPtrarr aSavRedlInsPosArr( 0, 4 ); @@ -1246,9 +1263,8 @@ bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, if( pUndo ) { - ClearRedo(); pUndo->SetDestRange( aIdx, rPos, *pSaveInsPos ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if( pSaveInsPos ) @@ -1359,8 +1375,7 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) // falls PageBreaks geloescht / gesetzt werden, darf das // nicht in die Undo-History aufgenommen werden !! // (das loeschen vom Node geht auch am Undo vorbei !!!) - sal_Bool bDoUndo = pDoc->DoesUndo(); - pDoc->DoUndo( sal_False ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); /* PageBreaks, PageDesc, ColumnBreaks */ // Sollte an der Logik zum Kopieren der PageBreak's ... @@ -1412,8 +1427,6 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) if( aBkmkArr.Count() ) ::_RestoreCntntIdx( pDoc, aBkmkArr, aIdx.GetIndex() ); - pDoc->DoUndo( bDoUndo ); - // falls der uebergebene PaM nicht im Crsr-Ring steht, // gesondert behandeln (z.B. Aufruf aus dem Auto-Format) if( pOldTxtNd == rPam.GetBound( sal_True ).nContent.GetIdxReg() ) @@ -1553,21 +1566,19 @@ bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) ASSERT( IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" ); { - sal_uInt16 nUndoSize = 0; SwUndoRedlineDelete* pUndo = 0; RedlineMode_t eOld = GetRedlineMode(); checkRedlining(eOld); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE )); - nUndoSize = pUndos->Count(); - StartUndo(UNDO_EMPTY, NULL); - AppendUndo( pUndo = new SwUndoRedlineDelete( rPam, UNDO_DELETE )); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); + pUndo = new SwUndoRedlineDelete( rPam, UNDO_DELETE ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if( *rPam.GetPoint() != *rPam.GetMark() ) AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_DELETE, rPam ), true); @@ -1575,18 +1586,29 @@ bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) if( pUndo ) { - EndUndo(UNDO_EMPTY, NULL); - SwUndo* pPrevUndo; - if( nUndoSize && DoesGroupUndo() && - nUndoSize + 1 == pUndos->Count() && - UNDO_REDLINE == ( pPrevUndo = (*pUndos)[ nUndoSize-1 ])->GetId() && - UNDO_DELETE == ((SwUndoRedline*)pPrevUndo)->GetUserId() && - ((SwUndoRedlineDelete*)pPrevUndo)->CanGrouping( *pUndo )) + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); + // ??? why the hell is the AppendUndo not below the + // CanGrouping, so this hideous cleanup wouldn't be necessary? + // bah, this is redlining, probably changing this would break it... + if (GetIDocumentUndoRedo().DoesGroupUndo()) { - DoUndo( sal_False ); - pUndos->DeleteAndDestroy( nUndoSize, 1 ); - --nUndoPos, --nUndoCnt; - DoUndo( sal_True ); + SwUndo *const pLastUndo( GetUndoManager().GetLastUndo() ); + SwUndoRedlineDelete *const pUndoRedlineDel( + dynamic_cast<SwUndoRedlineDelete*>(pLastUndo) ); + if (pUndoRedlineDel) + { + bool const bMerged = pUndoRedlineDel->CanGrouping(*pUndo); + if (bMerged) + { + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + SwUndo const*const pDeleted = + GetUndoManager().RemoveLastUndo(); + OSL_ENSURE(pDeleted == pUndo, + "DeleteAndJoinWithRedlineImpl: " + "undo removed is not undo inserted?"); + delete pDeleted; + } + } } //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( eOld ); @@ -1683,17 +1705,25 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam) } - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && nUndoSize-- && - UNDO_DELETE == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoDelete*)pUndo)->CanGrouping( this, rPam )) - ;// wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoDelete( rPam ) ); + GetIDocumentUndoRedo().ClearRedo(); + bool bMerged(false); + if (GetIDocumentUndoRedo().DoesGroupUndo()) + { + SwUndo *const pLastUndo( GetUndoManager().GetLastUndo() ); + SwUndoDelete *const pUndoDelete( + dynamic_cast<SwUndoDelete *>(pLastUndo) ); + if (pUndoDelete) + { + bMerged = pUndoDelete->CanGrouping( this, rPam ); + // if CanGrouping() returns true it's already merged + } + } + if (!bMerged) + { + GetIDocumentUndoRedo().AppendUndo( new SwUndoDelete( rPam ) ); + } SetModified(); @@ -2316,9 +2346,9 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr, { RedlineMode_t eOld = GetRedlineMode(); checkRedlining(eOld); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - StartUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); // Bug 68584 - if any Redline will change (split!) the node const ::sw::mark::IMark* pBkmk = getIDocumentMarkAccess()->makeMark( aDelPam, ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK ); @@ -2398,15 +2428,19 @@ bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr, InsertItemSet( aTmpRange, aSet, 0 ); } - if( DoesUndo() ) - AppendUndo( new SwUndoRedlineDelete( aDelPam, UNDO_REPLACE )); + if (GetIDocumentUndoRedo().DoesUndo()) + { + SwUndo *const pUndoRD = + new SwUndoRedlineDelete( aDelPam, UNDO_REPLACE ); + GetIDocumentUndoRedo().AppendUndo(pUndoRD); + } AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_DELETE, aDelPam ), true); *rPam.GetMark() = *aDelPam.GetMark(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { *aDelPam.GetPoint() = *rPam.GetPoint(); - EndUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); // Bug 68584 - if any Redline will change (split!) the node const ::sw::mark::IMark* pBkmk = getIDocumentMarkAccess()->makeMark( aDelPam, ::rtl::OUString(), IDocumentMarkAccess::UNO_BOOKMARK ); @@ -2433,21 +2467,13 @@ SetRedlineMode( eOld ); DeleteRedline( aDelPam, true, USHRT_MAX ); SwUndoReplace* pUndoRpl = 0; - if( DoesUndo() ) + bool const bDoesUndo = GetIDocumentUndoRedo().DoesUndo(); + if (bDoesUndo) { - ClearRedo(); - SwUndo* pU; - - if( !pUndos->Count() || - UNDO_REPLACE != ( pU = (*pUndos)[ pUndos->Count()-1 ])->GetId() || - ( pUndoRpl = (SwUndoReplace*)pU )->IsFull() ) - { - pUndoRpl = new SwUndoReplace(); - AppendUndo( pUndoRpl ); - } - pUndoRpl->AddEntry( aDelPam, sRepl, bRegExReplace ); - DoUndo( sal_False ); + pUndoRpl = new SwUndoReplace(aDelPam, sRepl, bRegExReplace); + GetIDocumentUndoRedo().AppendUndo(pUndoRpl); } + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); if( aDelPam.GetPoint() != pStt ) aDelPam.Exchange(); @@ -2500,8 +2526,7 @@ SetRedlineMode( eOld ); if( pUndoRpl ) { - pUndoRpl->SetEntryEnd( rPam ); - DoUndo( sal_True ); + pUndoRpl->SetEnd(rPam); } } } @@ -2532,8 +2557,10 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) if ( nSectDiff-2 <= nNodeDiff || IsRedlineOn() || /* #i9185# Prevent getting the node after the end node (see below) */ - rEnd.nNode.GetIndex() + 1 == aNodes.Count() ) + rEnd.nNode.GetIndex() + 1 == GetNodes().Count() ) + { return sal_False; + } // harte SeitenUmbrueche am nachfolgenden Node verschieben sal_Bool bSavePageBreak = sal_False, bSavePageDesc = sal_False; @@ -2541,7 +2568,7 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) /* #i9185# This whould lead to a segmentation fault if not catched above. */ ULONG nNextNd = rEnd.nNode.GetIndex() + 1; - SwTableNode* pTblNd = aNodes[ nNextNd ]->GetTableNode(); + SwTableNode *const pTblNd = GetNodes()[ nNextNd ]->GetTableNode(); if( pTblNd && pNd->IsCntntNode() ) { @@ -2570,7 +2597,7 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) } } - sal_Bool bDoesUndo = DoesUndo(); + bool const bDoesUndo = GetIDocumentUndoRedo().DoesUndo(); if( bDoesUndo ) { if( !rPam.HasMark() ) @@ -2585,7 +2612,7 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) pTmpNode = rPam.GetMark()->nNode.GetNode().GetCntntNode(); rPam.GetMark()->nContent.Assign( pTmpNode, 0 ); - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() ); { @@ -2602,7 +2629,7 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) *rPam.GetPoint() = *aDelPam.GetPoint(); pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } else { @@ -2660,11 +2687,9 @@ void SwDoc::TransliterateText( const SwPaM& rPaM, utl::TransliterationWrapper& rTrans ) { - SwUndoTransliterate* pUndo; - if( DoesUndo() ) - pUndo = new SwUndoTransliterate( rPaM, rTrans ); - else - pUndo = 0; + SwUndoTransliterate *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) + ? new SwUndoTransliterate( rPaM, rTrans ) + : 0; const SwPosition* pStt = rPaM.Start(), * pEnd = rPaM.End(); @@ -2722,8 +2747,7 @@ void SwDoc::TransliterateText( { if( pUndo->HasData() ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } else delete pUndo; diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 7e18e990d070..a54db564a315 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -43,6 +43,7 @@ #include <unotools/charclass.hxx> #include <unotools/transliterationwrapper.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <cntfrm.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -69,9 +70,7 @@ #include <authfld.hxx> #include <txtinet.hxx> #include <fmtcntnt.hxx> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> // fuer InitFldTypes -#endif #include <SwUndoField.hxx> @@ -2725,13 +2724,14 @@ bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, if (pDstFld->GetTyp()->Which() == rSrcFld.GetTyp()->Which()) { - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwPosition aPosition( pDstTxtFld->GetTxtNode() ); aPosition.nContent = *pDstTxtFld->GetStart(); - AppendUndo(new SwUndoFieldFromDoc(aPosition, *pDstFld, rSrcFld, - pMsgHnt, bUpdateFlds)); + SwUndo *const pUndo( new SwUndoFieldFromDoc( + aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } // Das gefundene Feld wird angepasst ... @@ -2818,8 +2818,12 @@ bool SwDoc::PutValueToField(const SwPosition & rPos, SwField * pField = GetField(rPos); - if (DoesUndo() && pField->QueryValue(aOldVal, nWhich)) - AppendUndo(new SwUndoFieldFromAPI(rPos, aOldVal, rVal, nWhich)); + if (GetIDocumentUndoRedo().DoesUndo() && + pField->QueryValue(aOldVal, nWhich)) + { + SwUndo *const pUndo(new SwUndoFieldFromAPI(rPos, aOldVal, rVal, nWhich)); + GetIDocumentUndoRedo().AppendUndo(pUndo); + } return pField->PutValue(rVal, nWhich); } diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index 68c525ad74e1..ad59c85e1844 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <svl/itemiter.hxx> #include <svx/svdobj.hxx> @@ -43,6 +42,7 @@ #include <ndgrf.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <ndindex.hxx> #include <docary.hxx> #include <fmtcntnt.hxx> @@ -61,7 +61,8 @@ #include <swundo.hxx> #include <swtable.hxx> #include <crstate.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoAttribute.hxx> #include <fmtcnct.hxx> #include <dflyobj.hxx> @@ -389,34 +390,26 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms return MAKEFRMS; } -BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) +static bool +lcl_SetFlyFrmAttr(SwDoc & rDoc, + sal_Int8 (SwDoc::*pSetFlyFrmAnchor)(SwFrmFmt &, SfxItemSet &, BOOL), + SwFrmFmt & rFlyFmt, SfxItemSet & rSet) { - if( !rSet.Count() ) - return FALSE; - - ::std::auto_ptr<SwUndoFmtAttrHelper> pSaveUndo; - const bool bDoesUndo = DoesUndo(); - - if( DoesUndo() ) - { - ClearRedo(); - pSaveUndo.reset( new SwUndoFmtAttrHelper( rFlyFmt ) ); - // --> FME 2004-10-13 #i32968# - // Inserting columns in the frame causes MakeFrmFmt to put two - // objects of type SwUndoFrmFmt on the undo stack. We don't want them. - DoUndo( FALSE ); - // <-- - } + // #i32968# Inserting columns in the frame causes MakeFrmFmt to put two + // objects of type SwUndoFrmFmt on the undo stack. We don't want them. + ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); //Ist das Ankerattribut dabei? Falls ja ueberlassen wir die Verarbeitung //desselben einer Spezialmethode. Sie Returnt TRUE wenn der Fly neu //erzeugt werden muss (z.B. weil ein Wechsel des FlyTyps vorliegt). - sal_Int8 nMakeFrms = SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, FALSE )? - SetFlyFrmAnchor( rFlyFmt, rSet, FALSE ) : DONTMAKEFRMS; + sal_Int8 const nMakeFrms = + (SFX_ITEM_SET == rSet.GetItemState( RES_ANCHOR, FALSE )) + ? (rDoc.*pSetFlyFrmAnchor)( rFlyFmt, rSet, FALSE ) + : DONTMAKEFRMS; const SfxPoolItem* pItem; SfxItemIter aIter( rSet ); - SfxItemSet aTmpSet( GetAttrPool(), aFrmFmtSetRange ); + SfxItemSet aTmpSet( rDoc.GetAttrPool(), aFrmFmtSetRange ); USHORT nWhich = aIter.GetCurItem()->Which(); do { switch( nWhich ) @@ -426,7 +419,7 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) case RES_PAGEDESC: case RES_CNTNT: case RES_FOOTER: - ASSERT( !this, ":-) Unbekanntes Attribut fuer Fly." ); + OSL_ENSURE(false, ":-) unknown Attribute for Fly."); // kein break; case RES_CHAIN: rSet.ClearItem( nWhich ); @@ -454,21 +447,36 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) if( MAKEFRMS == nMakeFrms ) rFlyFmt.MakeFrms(); - if ( pSaveUndo.get() ) + return aTmpSet.Count() || MAKEFRMS == nMakeFrms; +} + +BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) +{ + if( !rSet.Count() ) + return FALSE; + + ::std::auto_ptr<SwUndoFmtAttrHelper> pSaveUndo; + + if (GetIDocumentUndoRedo().DoesUndo()) { - // --> FME 2004-10-13 #i32968# - DoUndo( bDoesUndo ); - // <-- + GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it + pSaveUndo.reset( new SwUndoFmtAttrHelper( rFlyFmt ) ); + } + + bool const bRet = + lcl_SetFlyFrmAttr(*this, &SwDoc::SetFlyFrmAnchor, rFlyFmt, rSet); + if ( pSaveUndo.get() ) + { if ( pSaveUndo->GetUndo() ) { - AppendUndo( pSaveUndo->ReleaseUndo() ); + GetIDocumentUndoRedo().AppendUndo( pSaveUndo->ReleaseUndo() ); } } SetModified(); - return aTmpSet.Count() || MAKEFRMS == nMakeFrms; + return bRet; } // --> OD 2009-07-20 #i73249# @@ -480,13 +488,11 @@ void SwDoc::SetFlyFrmTitle( SwFlyFrmFmt& rFlyFrmFmt, return; } - const bool bFormerIsNoDrawUndoObj( IsNoDrawUndoObj() ); - SetNoDrawUndoObj( true ); + ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo()); - if ( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, + GetIDocumentUndoRedo().AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, UNDO_FLYFRMFMT_TITLE, rFlyFrmFmt.GetObjTitle(), sNewTitle ) ); @@ -494,8 +500,6 @@ void SwDoc::SetFlyFrmTitle( SwFlyFrmFmt& rFlyFrmFmt, rFlyFrmFmt.SetObjTitle( sNewTitle, true ); - SetNoDrawUndoObj( bFormerIsNoDrawUndoObj ); - SetModified(); } @@ -507,13 +511,11 @@ void SwDoc::SetFlyFrmDescription( SwFlyFrmFmt& rFlyFrmFmt, return; } - const bool bFormerIsNoDrawUndoObj( IsNoDrawUndoObj() ); - SetNoDrawUndoObj( true ); + ::sw::DrawUndoGuard const drawUndoGuard(GetIDocumentUndoRedo()); - if ( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, + GetIDocumentUndoRedo().AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, UNDO_FLYFRMFMT_DESCRIPTION, rFlyFrmFmt.GetObjDescription(), sNewDescription ) ); @@ -521,8 +523,6 @@ void SwDoc::SetFlyFrmDescription( SwFlyFrmFmt& rFlyFrmFmt, rFlyFrmFmt.SetObjDescription( sNewDescription, true ); - SetNoDrawUndoObj( bFormerIsNoDrawUndoObj ); - SetModified(); } // <-- @@ -544,17 +544,17 @@ BOOL SwDoc::SetFrmFmtToFly( SwFrmFmt& rFmt, SwFrmFmt& rNewFmt, const SwFmtHoriOrient aHori( rFmt.GetHoriOrient() ); SwUndoSetFlyFmt* pUndo = 0; - if( DoesUndo() ) + bool const bUndo = GetIDocumentUndoRedo().DoesUndo(); + if (bUndo) { - ClearRedo(); - AppendUndo( pUndo = new SwUndoSetFlyFmt( rFmt, rNewFmt ) ); - // --> FME 2004-10-13 #i32968# - // Inserting columns in the section causes MakeFrmFmt to put two - // objects of type SwUndoFrmFmt on the undo stack. We don't want them. - DoUndo( FALSE ); - // <-- + pUndo = new SwUndoSetFlyFmt( rFmt, rNewFmt ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } + // #i32968# Inserting columns in the section causes MakeFrmFmt to put + // 2 objects of type SwUndoFrmFmt on the undo stack. We don't want them. + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + //Erstmal die Spalten setzen, sonst gibts nix als Aerger mit dem //Set/Reset/Abgleich usw. const SfxPoolItem* pItem; @@ -621,11 +621,6 @@ BOOL SwDoc::SetFrmFmtToFly( SwFrmFmt& rFmt, SwFrmFmt& rNewFmt, SetModified(); - // --> FME 2004-10-13 #i32968# - if ( pUndo ) - DoUndo( TRUE ); - // <-- - return bChgAnchor; } @@ -660,7 +655,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, return false; } - StartUndo( UNDO_INSATTR, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_INSATTR, NULL ); BOOL bUnmark = FALSE; for ( USHORT i = 0; i < _rMrkList.GetMarkCount(); ++i ) @@ -891,7 +886,7 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, } } - EndUndo( UNDO_END, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); SetModified(); return bUnmark; @@ -1007,7 +1002,7 @@ int SwDoc::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) int nErr = Chainable( rSource, rDest ); if ( !nErr ) { - StartUndo( UNDO_CHAINE, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_CHAINE, NULL ); SwFlyFrmFmt& rDestFmt = (SwFlyFrmFmt&)rDest; @@ -1041,7 +1036,7 @@ int SwDoc::Chain( SwFrmFmt &rSource, const SwFrmFmt &rDest ) } SetAttr( aSet, rSource ); - EndUndo( UNDO_CHAINE, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_CHAINE, NULL ); } return nErr; } @@ -1053,14 +1048,14 @@ void SwDoc::Unchain( SwFrmFmt &rFmt ) SwFmtChain aChain( rFmt.GetChain() ); if ( aChain.GetNext() ) { - StartUndo( UNDO_UNCHAIN, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_UNCHAIN, NULL ); SwFrmFmt *pFollow = aChain.GetNext(); aChain.SetNext( 0 ); SetAttr( aChain, rFmt ); aChain = pFollow->GetChain(); aChain.SetPrev( 0 ); SetAttr( aChain, *pFollow ); - EndUndo( UNDO_UNCHAIN, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_UNCHAIN, NULL ); } } diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index eba51c0354f8..b335f50ed014 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -54,12 +54,14 @@ #include <fmtcntnt.hxx> #include <frmatr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <hints.hxx> // fuer SwHyphenBug (in SetDefault) #include <ndtxt.hxx> #include <pam.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoAttribute.hxx> #include <ndgrf.hxx> #include <pagedesc.hxx> // Fuer Sonderbehandlung in InsFrmFmt #include <rolbck.hxx> // Undo-Attr @@ -357,12 +359,11 @@ void SwDoc::RstTxtAttrs(const SwPaM &rRg, BOOL bInclRefToxMark ) { SwHistory* pHst = 0; SwDataChanged aTmp( rRg, 0 ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, RES_CHRFMT ); pHst = &pUndo->GetHistory(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); ParaRstFmt aPara( pStt, pEnd, pHst ); @@ -441,9 +442,8 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, } // <-- SwHistory* pHst = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg, static_cast<USHORT>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL )); if( pAttrs && pAttrs->Count() ) @@ -451,7 +451,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, pUndo->SetAttrs( *pAttrs ); } pHst = &pUndo->GetHistory(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End(); @@ -1125,9 +1125,9 @@ bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndoAttr = new SwUndoAttr( rRg, rHt, nFlags ); } @@ -1135,8 +1135,10 @@ bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, aSet.Put( rHt ); bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); - if( DoesUndo() ) - AppendUndo( pUndoAttr ); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().AppendUndo( pUndoAttr ); + } if( bRet ) SetModified(); @@ -1148,16 +1150,18 @@ bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet, { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags ); } bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); - if( DoesUndo() ) - AppendUndo( pUndoAttr ); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().AppendUndo( pUndoAttr ); + } if( bRet ) SetModified(); @@ -1179,14 +1183,17 @@ void SwDoc::SetAttr( const SfxPoolItem& rAttr, SwFmt& rFmt ) // das alte in die Undo-History aufgenommen void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); SwUndoFmtAttrHelper aTmp( rFmt ); rFmt.SetFmtAttr( rSet ); if ( aTmp.GetUndo() ) { - AppendUndo( aTmp.ReleaseUndo() ); + GetIDocumentUndoRedo().AppendUndo( aTmp.ReleaseUndo() ); + } + else + { + GetIDocumentUndoRedo().ClearRedo(); } } else @@ -1200,16 +1207,18 @@ void SwDoc::SetAttr( const SfxItemSet& rSet, SwFmt& rFmt ) void SwDoc::ResetAttrAtFormat( const USHORT nWhichId, SwFmt& rChangedFormat ) { - SwUndo* pUndo = 0; - if ( DoesUndo() ) - pUndo = new SwUndoFmtResetAttr( rChangedFormat, nWhichId ); + SwUndo *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) + ? new SwUndoFmtResetAttr( rChangedFormat, nWhichId ) + : 0; const BOOL bAttrReset = rChangedFormat.ResetFmtAttr( nWhichId ); if ( bAttrReset ) { if ( pUndo ) - AppendUndo( pUndo ); + { + GetIDocumentUndoRedo().AppendUndo( pUndo ); + } SetModified(); } @@ -1326,10 +1335,9 @@ void SwDoc::SetDefault( const SfxItemSet& rSet ) if( aNew.Count() && aCallMod.GetDepends() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoDefaultAttr( aOld ) ); + GetIDocumentUndoRedo().AppendUndo( new SwUndoDefaultAttr( aOld ) ); } const SfxPoolItem* pTmpItem; @@ -1396,12 +1404,12 @@ void SwDoc::DelCharFmt(USHORT nFmt, BOOL bBroadcast) BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_CHAR, SFX_STYLESHEET_ERASED); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoCharFmtDelete(pDel, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } pCharFmtTbl->DeleteAndDestroy(nFmt); @@ -1438,11 +1446,11 @@ void SwDoc::DelFrmFmt( SwFrmFmt *pFmt, BOOL bBroadcast ) SFX_STYLE_FAMILY_FRAME, SFX_STYLESHEET_ERASED); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoFrmFmtDelete(pFmt, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } pFrmFmtTbl->DeleteAndDestroy( nPos ); @@ -1491,7 +1499,7 @@ USHORT SwDoc::GetTblFrmFmtCount(BOOL bUsed) const USHORT nCount = pTblFrmFmtTbl->Count(); if(bUsed) { - SwAutoFmtGetDocNode aGetHt( &aNodes ); + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); for ( USHORT i = nCount; i; ) { if((*pTblFrmFmtTbl)[--i]->GetInfo( aGetHt )) @@ -1509,8 +1517,7 @@ SwFrmFmt& SwDoc::GetTblFrmFmt(USHORT nFmt, BOOL bUsed ) const USHORT nRemoved = 0; if(bUsed) { - SwAutoFmtGetDocNode aGetHt( &aNodes ); - + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); for ( USHORT i = 0; i <= nFmt; i++ ) { while ( (*pTblFrmFmtTbl)[ i + nRemoved]->GetInfo( aGetHt )) @@ -1548,11 +1555,11 @@ SwFrmFmt *SwDoc::MakeFrmFmt(const String &rFmtName, BroadcastStyleOperation(rFmtName, SFX_STYLE_FAMILY_PARA, SFX_STYLESHEET_CREATED); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoFrmFmtCreate(pFmt, pDerivedFrom, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } } @@ -1581,11 +1588,11 @@ SwCharFmt *SwDoc::MakeCharFmt( const String &rFmtName, pFmt->SetAuto( FALSE ); SetModified(); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoCharFmtCreate(pFmt, pDerivedFrom, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if (bBroadcast) @@ -1624,11 +1631,11 @@ SwTxtFmtColl* SwDoc::MakeTxtFmtColl( const String &rFmtName, pFmtColl->SetAuto( FALSE ); SetModified(); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoTxtFmtCollCreate(pFmtColl, pDerivedFrom, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if (bBroadcast) @@ -1693,12 +1700,12 @@ void SwDoc::DelTxtFmtColl(USHORT nFmtColl, BOOL bBroadcast) BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PARA, SFX_STYLESHEET_ERASED); - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndoTxtFmtCollDelete * pUndo = new SwUndoTxtFmtCollDelete(pDel, this); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } // Die FmtColl austragen @@ -1807,16 +1814,15 @@ BOOL SwDoc::SetTxtFmtColl( const SwPaM &rRg, SwHistory* pHst = 0; BOOL bRet = TRUE; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); // --> OD 2008-04-15 #refactorlists# SwUndoFmtColl* pUndo = new SwUndoFmtColl( rRg, pFmt, bReset, bResetListAttrs ); // <-- pHst = pUndo->GetHistory(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } ParaRstFmt aPara( pStt, pEnd, pHst ); @@ -2261,8 +2267,7 @@ void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc, void SwDoc::ReplaceStyles( SwDoc& rSource ) { - BOOL bIsUndo = DoesUndo(); - DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); CopyFmtArr( *rSource.pCharFmtTbl, *pCharFmtTbl, &SwDoc::_MakeCharFmt, *pDfltCharFmt ); @@ -2313,15 +2318,13 @@ void SwDoc::ReplaceStyles( SwDoc& rSource ) } } - if( bIsUndo ) + if (undoGuard.UndoWasEnabled()) { - // es wurde am Nodes-Array gedreht! - ClearRedo(); - DelAllUndoObj(); + // nodes array was modified! + GetIDocumentUndoRedo().DelAllUndoObj(); } SetModified(); - DoUndo( bIsUndo ); } SwFmt* SwDoc::FindFmtByName( const SvPtrarr& rFmtArr, @@ -2343,13 +2346,12 @@ SwFmt* SwDoc::FindFmtByName( const SvPtrarr& rFmtArr, void SwDoc::MoveLeftMargin( const SwPaM& rPam, BOOL bRight, BOOL bModulus ) { SwHistory* pHistory = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); SwUndoMoveLeftMargin* pUndo = new SwUndoMoveLeftMargin( rPam, bRight, bModulus ); pHistory = &pUndo->GetHistory(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } const SvxTabStopItem& rTabItem = (SvxTabStopItem&)GetDefault( RES_PARATR_TABSTOP ); @@ -2409,10 +2411,9 @@ BOOL SwDoc::DontExpandFmt( const SwPosition& rPos, BOOL bFlag ) if( pTxtNd ) { bRet = pTxtNd->DontExpandFmt( rPos.nContent, bFlag ); - if( bRet && DoesUndo() ) + if( bRet && GetIDocumentUndoRedo().DoesUndo() ) { - ClearRedo(); - AppendUndo( new SwUndoDontExpandFmt( rPos )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoDontExpandFmt(rPos) ); } } return bRet; @@ -2560,7 +2561,7 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet ) void SwDoc::ChgFmt(SwFmt & rFmt, const SfxItemSet & rSet) { - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { // copying <rSet> to <aSet> SfxItemSet aSet(rSet); @@ -2588,7 +2589,7 @@ void SwDoc::ChgFmt(SwFmt & rFmt, const SfxItemSet & rSet) SwUndo * pUndo = new SwUndoFmtAttr(aOldSet, rFmt); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } rFmt.SetFmtAttr(rSet); @@ -2599,7 +2600,7 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const String & sNewName, { SfxStyleFamily eFamily = SFX_STYLE_FAMILY_ALL; - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = NULL; @@ -2623,7 +2624,9 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const String & sNewName, } if (pUndo) - AppendUndo(pUndo); + { + GetIDocumentUndoRedo().AppendUndo(pUndo); + } } rFmt.SetName(sNewName); diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx index 306f7b3dfcc8..ed4ce39eb8de 100644 --- a/sw/source/core/doc/docftn.cxx +++ b/sw/source/core/doc/docftn.cxx @@ -36,9 +36,11 @@ #include <pam.hxx> #include <pagedesc.hxx> #include <charfmt.hxx> -#include <undobj.hxx> +#include <UndoAttribute.hxx> +#include <hints.hxx> #include <rolbck.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <ndtxt.hxx> #include <poolfmt.hxx> #include <ftninfo.hxx> @@ -259,10 +261,9 @@ void SwDoc::SetFtnInfo(const SwFtnInfo& rInfo) { const SwFtnInfo &rOld = GetFtnInfo(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoFootNoteInfo( rOld ) ); + GetIDocumentUndoRedo().AppendUndo( new SwUndoFootNoteInfo(rOld) ); } BOOL bFtnPos = rInfo.ePos != rOld.ePos; @@ -326,10 +327,10 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo) { if( !(GetEndNoteInfo() == rInfo) ) { - if( DoesUndo() ) + if(GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoEndNoteInfo( GetEndNoteInfo() ) ); + SwUndo *const pUndo( new SwUndoEndNoteInfo( GetEndNoteInfo() ) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } BOOL bNumChg = rInfo.nFtnOffset != GetEndNoteInfo().nFtnOffset; @@ -403,9 +404,9 @@ bool SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, rFtnArr.SeekEntry( pStt->nNode, &nPos ); SwUndoChangeFootNote* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); // AppendUndo far below, so leave it pUndo = new SwUndoChangeFootNote( rPam, rNumStr, nNumber, bIsEndNote ); } @@ -479,8 +480,7 @@ bool SwDoc::SetCurFtn( const SwPaM& rPam, const String& rNumStr, { if( pUndo ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if ( bTypeChgd ) diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 30a385442fc0..f528652ccd2d 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -43,6 +43,7 @@ #include <fmtinfmt.hxx> #include <fmtanchr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -181,7 +182,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, return FALSE; // Undo/Redline aufjedenfall abschalten - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); SetRedlineMode_intern( (RedlineMode_t)(GetRedlineMode() & ~nsRedlineMode_t::REDLINE_ON)); String sExt( pFilter->GetSuffixes().GetToken(0, ',') ); @@ -254,7 +255,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, String sFileName; if( pSttNd->GetIndex() + 1 < aEndIdx.GetIndex() ) { - SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); + SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); if( xDocSh->DoInitNew( 0 ) ) { SwDoc* pDoc = ((SwDocShell*)(&xDocSh))->GetDoc(); @@ -542,7 +543,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) return FALSE; // Undo/Redline aufjedenfall abschalten - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); SetRedlineMode_intern( (RedlineMode_t)(GetRedlineMode() & ~nsRedlineMode_t::REDLINE_ON)); String sExt( pFilter->GetSuffixes().GetToken(0, ',') ); @@ -605,7 +606,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) String sFileName; if( pSttNd->GetIndex() + 1 < aEndIdx.GetIndex() ) { - SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); + SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); if( xDocSh->DoInitNew( 0 ) ) { SwDoc* pDoc = ((SwDocShell*)(&xDocSh))->GetDoc(); diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index 8395c358c495..3a7ac788f04d 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -28,8 +28,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <shellio.hxx> #include <pam.hxx> #include <swundo.hxx> @@ -38,11 +43,6 @@ #include <crsrsh.hxx> #include <docsh.hxx> -#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/document/XDocumentProperties.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> - using namespace ::com::sun::star; @@ -160,7 +160,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, pCntntNd = aCpyPam.GetCntntNode(); aCpyPam.GetPoint()->nContent.Assign( pCntntNd, pCntntNd->Len() ); - StartUndo( UNDO_INSGLOSSARY, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL ); SwPaM *_pStartCrsr = &rPaM, *__pStartCrsr = _pStartCrsr; do { @@ -187,7 +187,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, pShell->SaveTblBoxCntnt( &rInsPos ); } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); - EndUndo( UNDO_INSGLOSSARY, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL ); UnlockExpFlds(); if( !IsExpFldsLocked() ) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index cc29cc8406d0..3a633ec6fed8 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -75,6 +75,7 @@ #include <ndnotxt.hxx> #include <ndole.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <cntfrm.hxx> @@ -85,7 +86,7 @@ #include <dcontact.hxx> #include <swundo.hxx> #include <flypos.hxx> -#include <undobj.hxx> +#include <UndoInsert.hxx> #include <expfld.hxx> // InsertLabel #include <poolfmt.hxx> // PoolVorlagen-Id's #include <docary.hxx> @@ -197,10 +198,10 @@ SwFrmFmt *SwDoc::MakeLayoutFmt( RndStdIds eRequest, const SfxItemSet* pSet ) if( pSet ) // noch ein paar Attribute setzen ? pFmt->SetFmtAttr( *pSet ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoInsLayFmt( pFmt,0,0 )); + GetIDocumentUndoRedo().AppendUndo( + new SwUndoInsLayFmt(pFmt, 0, 0)); } } break; @@ -253,7 +254,7 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) } const SwNodeIndex* pCntIdx = pFmt->GetCntnt().GetCntntIdx(); - if( pCntIdx && !DoesUndo() ) + if (pCntIdx && !GetIDocumentUndoRedo().DoesUndo()) { //Verbindung abbauen, falls es sich um ein OLE-Objekt handelt. SwOLENode* pOLENd = GetNodes()[ pCntIdx->GetIndex()+1 ]->GetOLENode(); @@ -295,11 +296,10 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) // erstmal sind nur Fly's Undofaehig const sal_uInt16 nWh = pFmt->Which(); - if( DoesUndo() && (RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh) ) + if (GetIDocumentUndoRedo().DoesUndo() && + (RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh)) { - // erstmal werden alle Undo - Objecte geloescht. - ClearRedo(); - AppendUndo( new SwUndoDelLayFmt( pFmt )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoDelLayFmt( pFmt )); } else { @@ -494,10 +494,9 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, } } - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoInsLayFmt( pDest,0,0 )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoInsLayFmt(pDest,0,0)); } // sorge dafuer das auch Fly's in Fly's kopiert werden @@ -536,10 +535,9 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, else pDest->SetFmtAttr( rNewAnchor ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoInsLayFmt( pDest,0,0 )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoInsLayFmt(pDest,0,0)); } } @@ -729,12 +727,12 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, if( GetRootFrm() ) pFmt->MakeFrms(); // ??? - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); ULONG nNodeIdx = rAnchPos.nNode.GetIndex(); xub_StrLen nCntIdx = rAnchPos.nContent.GetIndex(); - AppendUndo( new SwUndoInsLayFmt( pFmt, nNodeIdx, nCntIdx )); + GetIDocumentUndoRedo().AppendUndo( + new SwUndoInsLayFmt( pFmt, nNodeIdx, nCntIdx )); } SetModified(); @@ -803,7 +801,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, { SwFmtAnchor& rAnch = (SwFmtAnchor&)rSet.Get( RES_ANCHOR ); - StartUndo( UNDO_INSLAYFMT, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_INSLAYFMT, NULL ); SwFlyFrmFmt* pFmt = MakeFlySection( rAnch.GetAnchorId(), rPam.GetPoint(), &rSet, pParent ); @@ -871,8 +869,11 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, GetNodes().Delete( aIndex, 1 ); //JP erstmal ein Hack, solange keine Flys/Headers/Footers Undofaehig sind -if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. - DelAllUndoObj(); +// werden erstmal alle Undo - Objecte geloescht. +if( GetIDocumentUndoRedo().DoesUndo() ) +{ + GetIDocumentUndoRedo().DelAllUndoObj(); +} } else @@ -888,9 +889,10 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. */ // copy all Pams and then delete all SwPaM* pTmp = (SwPaM*)&rPam; - BOOL bOldFlag = mbCopyIsMove, bOldUndo = mbUndo; + BOOL bOldFlag = mbCopyIsMove; + bool const bOldUndo = GetIDocumentUndoRedo().DoesUndo(); mbCopyIsMove = TRUE; - mbUndo = FALSE; + GetIDocumentUndoRedo().DoUndo(false); do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) @@ -900,7 +902,7 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. pTmp = static_cast<SwPaM*>(pTmp->GetNext()); } while ( &rPam != pTmp ); mbCopyIsMove = bOldFlag; - mbUndo = bOldUndo; + GetIDocumentUndoRedo().DoUndo(bOldUndo); pTmp = (SwPaM*)&rPam; do { @@ -917,7 +919,7 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. SetModified(); - EndUndo( UNDO_INSLAYFMT, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_INSLAYFMT, NULL ); return pFmt; } @@ -1016,10 +1018,9 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, // <-- } - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoInsLayFmt( pFmt,0,0 )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoInsLayFmt(pFmt, 0, 0) ); } SetModified(); @@ -1225,31 +1226,27 @@ void lcl_CpyAttr( SfxItemSet &rNewSet, const SfxItemSet &rOldSet, sal_uInt16 nWh } -SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, const String& rSeparator, +static SwFlyFrmFmt * +lcl_InsertLabel(SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, + SwUndoInsertLabel *const pUndo, + SwLabelType const eType, String const& rTxt, String const& rSeparator, const String& rNumberingSeparator, const sal_Bool bBefore, const sal_uInt16 nId, const ULONG nNdIdx, const String& rCharacterStyle, const sal_Bool bCpyBrd ) { - sal_Bool bWasUndo = DoesUndo(); - SwUndoInsertLabel* pUndo = 0; - if( bWasUndo ) - { - ClearRedo(); - pUndo = new SwUndoInsertLabel( eType, rTxt, rSeparator, rNumberingSeparator, - bBefore, nId, rCharacterStyle, bCpyBrd ); - DoUndo( sal_False ); - } + ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); sal_Bool bTable = sal_False; //Um etwas Code zu sparen. //Erstmal das Feld bauen, weil ueber den Namen die TxtColl besorgt werden //muss - ASSERT( nId == USHRT_MAX || nId < GetFldTypes()->Count(), "FldType ueberindiziert." ); - SwFieldType *pType = nId != USHRT_MAX ? (*GetFldTypes())[nId] : NULL; - ASSERT( !pType || pType->Which() == RES_SETEXPFLD, "Falsche Id fuer Label" ); + OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.GetFldTypes()->Count(), + "FldType index out of bounds." ); + SwFieldType *pType = (nId != USHRT_MAX) ? (*rDoc.GetFldTypes())[nId] : NULL; + OSL_ENSURE(!pType || pType->Which() == RES_SETEXPFLD, "wrong Id for Label"); - SwTxtFmtColl *pColl = NULL; + SwTxtFmtColl * pColl = NULL; if( pType ) { for( sal_uInt16 i = pTxtFmtCollTbl->Count(); i; ) @@ -1264,7 +1261,9 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co } if( !pColl ) - pColl = GetTxtCollFromPool( RES_POOLCOLL_LABEL ); + { + pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_LABEL ); + } SwTxtNode *pNew = NULL; SwFlyFrmFmt* pNewFmt = NULL; @@ -1278,7 +1277,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //Am Anfang/Ende der Fly-Section den entsprechenden Node mit Feld //einfuegen (Frame wird automatisch erzeugt). { - SwStartNode *pSttNd = GetNodes()[nNdIdx]->GetStartNode(); + SwStartNode *pSttNd = rDoc.GetNodes()[nNdIdx]->GetStartNode(); ASSERT( pSttNd, "Kein StartNode in InsertLabel." ); ULONG nNode; if( bBefore ) @@ -1298,8 +1297,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pUndo->SetNodePos( nNode ); //Node fuer Beschriftungsabsatz erzeugen. - SwNodeIndex aIdx( GetNodes(), nNode ); - pNew = GetNodes().MakeTxtNode( aIdx, pColl ); + SwNodeIndex aIdx( rDoc.GetNodes(), nNode ); + pNew = rDoc.GetNodes().MakeTxtNode( aIdx, pColl ); } break; @@ -1311,12 +1310,12 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co // Frames erzeugen. //Erstmal das Format zum Fly besorgen und das Layout entkoppeln. - SwFrmFmt *pOldFmt = GetNodes()[nNdIdx]->GetFlyFmt(); + SwFrmFmt *pOldFmt = rDoc.GetNodes()[nNdIdx]->GetFlyFmt(); ASSERT( pOldFmt, "Format des Fly nicht gefunden." ); pOldFmt->DelFrms(); - pNewFmt = MakeFlyFrmFmt( GetUniqueFrameName(), - GetFrmFmtFromPool( RES_POOLFRM_FRAME )); + pNewFmt = rDoc.MakeFlyFrmFmt( rDoc.GetUniqueFrameName(), + rDoc.GetFrmFmtFromPool(RES_POOLFRM_FRAME) ); /* #i6447#: Only the selected items are copied from the old format. */ @@ -1374,8 +1373,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co aFrmSize.SetHeightSizeType( ATT_MIN_SIZE ); pNewSet->Put( aFrmSize ); - SwStartNode* pSttNd = GetNodes().MakeTextSection( - SwNodeIndex( GetNodes().GetEndOfAutotext() ), + SwStartNode* pSttNd = rDoc.GetNodes().MakeTextSection( + SwNodeIndex( rDoc.GetNodes().GetEndOfAutotext() ), SwFlyStartNode, pColl ); pNewSet->Put( SwFmtCntnt( pSttNd )); @@ -1454,7 +1453,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co break; default: - ASSERT( !this, "Neuer LabelType?." ); + OSL_ENSURE(false, "unknown LabelType?"); } ASSERT( pNew, "No Label inserted" ); if( pNew ) @@ -1496,11 +1495,11 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pNew->InsertItem( aFmt, nIdx, nIdx ); if(rCharacterStyle.Len()) { - SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); + SwCharFmt* pCharFmt = rDoc.FindCharFmtByName(rCharacterStyle); if( !pCharFmt ) { const USHORT nMyId = SwStyleNameMapper::GetPoolIdFromUIName(rCharacterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); - pCharFmt = GetCharFmtFromPool( nMyId ); + pCharFmt = rDoc.GetCharFmtFromPool( nMyId ); } if (pCharFmt) { @@ -1520,7 +1519,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co } else { - SwTableNode *pNd = GetNodes()[nNdIdx]->GetStartNode()->GetTableNode(); + SwTableNode *const pNd = + rDoc.GetNodes()[nNdIdx]->GetStartNode()->GetTableNode(); SwTable &rTbl = pNd->GetTable(); if ( !rTbl.GetFrmFmt()->GetKeep().GetValue() ) rTbl.GetFrmFmt()->SetFmtAttr( SvxFmtKeepItem( sal_True, RES_KEEP ) ); @@ -1528,18 +1528,45 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co pUndo->SetUndoKeep(); } } - SetModified(); + rDoc.SetModified(); } - if( pUndo ) - AppendUndo( pUndo ); + return pNewFmt; +} + +SwFlyFrmFmt * +SwDoc::InsertLabel( + SwLabelType const eType, String const& rTxt, String const& rSeparator, + String const& rNumberingSeparator, + sal_Bool const bBefore, sal_uInt16 const nId, ULONG const nNdIdx, + String const& rCharacterStyle, + sal_Bool const bCpyBrd ) +{ + SwUndoInsertLabel * pUndo(0); + if (GetIDocumentUndoRedo().DoesUndo()) + { + pUndo = new SwUndoInsertLabel( + eType, rTxt, rSeparator, rNumberingSeparator, + bBefore, nId, rCharacterStyle, bCpyBrd ); + } + + SwFlyFrmFmt *const pNewFmt = lcl_InsertLabel(*this, pTxtFmtCollTbl, pUndo, + eType, rTxt, rSeparator, rNumberingSeparator, bBefore, + nId, nNdIdx, rCharacterStyle, bCpyBrd); + + if (pUndo) + { + GetIDocumentUndoRedo().AppendUndo(pUndo); + } else - DelAllUndoObj(); - DoUndo( bWasUndo ); + { + GetIDocumentUndoRedo().DelAllUndoObj(); + } return pNewFmt; } + /************************************************************************* |* |* SwDoc::InsertDrawLabel() @@ -1549,41 +1576,25 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co |* |*************************************************************************/ -SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, +static SwFlyFrmFmt * +lcl_InsertDrawLabel( SwDoc & rDoc, SwTxtFmtColls *const pTxtFmtCollTbl, + SwUndoInsertLabel *const pUndo, SwDrawFrmFmt *const pOldFmt, + String const& rTxt, const String& rSeparator, const String& rNumberSeparator, const sal_uInt16 nId, const String& rCharacterStyle, SdrObject& rSdrObj ) { - - SwDrawContact* pContact = (SwDrawContact*)GetUserCall( &rSdrObj ); - ASSERT( RES_DRAWFRMFMT == pContact->GetFmt()->Which(), - "Kein DrawFrmFmt" ); - if ( !pContact ) - return 0; - - SwDrawFrmFmt* pOldFmt = (SwDrawFrmFmt *)pContact->GetFmt(); - if( !pOldFmt ) - return 0; - - sal_Bool bWasUndo = DoesUndo(); - sal_Bool bWasNoDrawUndo = IsNoDrawUndoObj(); - SwUndoInsertLabel* pUndo = 0; - if( bWasUndo ) - { - ClearRedo(); - pUndo = new SwUndoInsertLabel( - LTYPE_DRAW, rTxt, rSeparator, rNumberSeparator, sal_False, nId, rCharacterStyle, sal_False ); - DoUndo( sal_False ); - SetNoDrawUndoObj( sal_True ); - } + ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); + ::sw::DrawUndoGuard const drawUndoGuard(rDoc.GetIDocumentUndoRedo()); // Erstmal das Feld bauen, weil ueber den Namen die TxtColl besorgt // werden muss - ASSERT( nId == USHRT_MAX || nId < GetFldTypes()->Count(), "FldType overflow" ); - SwFieldType *pType = nId != USHRT_MAX ? (*GetFldTypes())[nId] : 0; - ASSERT( !pType || pType->Which() == RES_SETEXPFLD, "Wrong label id" ); + OSL_ENSURE( nId == USHRT_MAX || nId < rDoc.GetFldTypes()->Count(), + "FldType index out of bounds" ); + SwFieldType *pType = nId != USHRT_MAX ? (*rDoc.GetFldTypes())[nId] : 0; + OSL_ENSURE( !pType || pType->Which() == RES_SETEXPFLD, "Wrong label id" ); SwTxtFmtColl *pColl = NULL; if( pType ) @@ -1600,7 +1611,9 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, } if( !pColl ) - pColl = GetTxtCollFromPool( RES_POOLCOLL_LABEL ); + { + pColl = rDoc.GetTxtCollFromPool( RES_POOLCOLL_LABEL ); + } SwTxtNode* pNew = NULL; SwFlyFrmFmt* pNewFmt = NULL; @@ -1639,8 +1652,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, // Den Rahmen ggf. in den Hintergrund schicken. // OD 02.07.2003 #108784# - consider 'invisible' hell layer. - if ( GetHellId() != nLayerId && - GetInvisibleHellId() != nLayerId ) + if ( rDoc.GetHellId() != nLayerId && + rDoc.GetInvisibleHellId() != nLayerId ) { SvxOpaqueItem aOpaque( RES_OPAQUE ); aOpaque.SetValue( sal_True ); @@ -1669,11 +1682,12 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewSet->Put( pOldFmt->GetULSpace() ); SwStartNode* pSttNd = - GetNodes().MakeTextSection( SwNodeIndex( GetNodes().GetEndOfAutotext() ), + rDoc.GetNodes().MakeTextSection( + SwNodeIndex( rDoc.GetNodes().GetEndOfAutotext() ), SwFlyStartNode, pColl ); - pNewFmt = MakeFlyFrmFmt( GetUniqueFrameName(), - GetFrmFmtFromPool( RES_POOLFRM_FRAME ) ); + pNewFmt = rDoc.MakeFlyFrmFmt( rDoc.GetUniqueFrameName(), + rDoc.GetFrmFmtFromPool( RES_POOLFRM_FRAME ) ); // JP 28.10.99: Bug 69487 - set border and shadow to default if the // template contains any. @@ -1712,11 +1726,15 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNewSet->ClearItem(); pNewSet->Put( SwFmtSurround( SURROUND_NONE ) ); - if( nLayerId == GetHellId() ) - rSdrObj.SetLayer( GetHeavenId() ); + if (nLayerId == rDoc.GetHellId()) + { + rSdrObj.SetLayer( rDoc.GetHeavenId() ); + } // OD 02.07.2003 #108784# - consider drawing objects in 'invisible' hell layer - else if( nLayerId == GetInvisibleHellId() ) - rSdrObj.SetLayer( GetInvisibleHeavenId() ); + else if (nLayerId == rDoc.GetInvisibleHellId()) + { + rSdrObj.SetLayer( rDoc.GetInvisibleHeavenId() ); + } pNewSet->Put( SvxLRSpaceItem( RES_LR_SPACE ) ); pNewSet->Put( SvxULSpaceItem( RES_UL_SPACE ) ); @@ -1785,11 +1803,11 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pNew->InsertItem( aFmt, nIdx, nIdx ); if ( rCharacterStyle.Len() ) { - SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); + SwCharFmt * pCharFmt = rDoc.FindCharFmtByName(rCharacterStyle); if ( !pCharFmt ) { const USHORT nMyId = SwStyleNameMapper::GetPoolIdFromUIName( rCharacterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - pCharFmt = GetCharFmtFromPool( nMyId ); + pCharFmt = rDoc.GetCharFmtFromPool( nMyId ); } if ( pCharFmt ) { @@ -1801,18 +1819,54 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, } } - if( pUndo ) + return pNewFmt; +} + +SwFlyFrmFmt* SwDoc::InsertDrawLabel( + String const& rTxt, + String const& rSeparator, + String const& rNumberSeparator, + sal_uInt16 const nId, + String const& rCharacterStyle, + SdrObject& rSdrObj ) +{ + SwDrawContact *const pContact = + static_cast<SwDrawContact*>(GetUserCall( &rSdrObj )); + OSL_ENSURE( RES_DRAWFRMFMT == pContact->GetFmt()->Which(), + "InsertDrawLabel(): not a DrawFrmFmt" ); + if (!pContact) + return 0; + + SwDrawFrmFmt* pOldFmt = (SwDrawFrmFmt *)pContact->GetFmt(); + if (!pOldFmt) + return 0; + + SwUndoInsertLabel * pUndo = 0; + if (GetIDocumentUndoRedo().DoesUndo()) { - AppendUndo( pUndo ); - SetNoDrawUndoObj( bWasNoDrawUndo ); + GetIDocumentUndoRedo().ClearRedo(); + pUndo = new SwUndoInsertLabel( + LTYPE_DRAW, rTxt, rSeparator, rNumberSeparator, sal_False, + nId, rCharacterStyle, sal_False ); + } + + SwFlyFrmFmt *const pNewFmt = lcl_InsertDrawLabel( + *this, pTxtFmtCollTbl, pUndo, pOldFmt, + rTxt, rSeparator, rNumberSeparator, nId, rCharacterStyle, rSdrObj); + + if (pUndo) + { + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else - DelAllUndoObj(); - DoUndo( bWasUndo ); + { + GetIDocumentUndoRedo().DelAllUndoObj(); + } return pNewFmt; } + /************************************************************************* |* |* IDocumentTimerAccess-methods diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 484b5119d9e5..c20eaa55ce12 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -96,6 +96,7 @@ #include <IGrammarContact.hxx> #include <tblsel.hxx> #include <MarkManager.hxx> +#include <UndoManager.hxx> #include <unochart.hxx> #include <cmdid.h> // fuer den dflt - Printer in SetJob @@ -217,12 +218,14 @@ BOOL lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* ) * exportierte Methoden */ -SwDoc::SwDoc() : - aNodes( this ), - aUndoNodes( this ), +SwDoc::SwDoc() + : m_pNodes( new SwNodes(this) ) + , mpAttrPool(new SwAttrPool(this)), pMarkManager(new ::sw::mark::MarkManager(*this)), m_pMetaFieldManager(new ::sw::MetaFieldManager()), + m_pUndoManager(new ::sw::UndoManager( + ::std::auto_ptr<SwNodes>(new SwNodes(this)), *this, *this, *this)), pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), @@ -240,7 +243,6 @@ SwDoc::SwDoc() : pDefTOXBases( new SwDefTOXBase_Impl() ), pLayout( 0 ), // Rootframe des spezifischen Layouts. pDrawModel( 0 ), - pUndos( new SwUndos( 0, 20 ) ), pUpdtFlds( new SwDocUpdtFld() ), pFldTypes( new SwFldTypes() ), pVirDev( 0 ), @@ -254,7 +256,6 @@ SwDoc::SwDoc() : pFtnIdxs( new SwFtnIdxs ), pDocStat( new SwDocStat ), pDocShell( 0 ), - pDocShRef( 0 ), pLinkMgr( new sfx2::LinkManager( 0 ) ), pACEWord( 0 ), pURLStateChgd( 0 ), @@ -282,10 +283,6 @@ SwDoc::SwDoc() : mpListItemsList( new tImplSortedNodeNumList() ), // <-- m_pXmlIdRegistry(), - nUndoPos( 0 ), - nUndoSavePos( 0 ), - nUndoCnt( 0 ), - nUndoSttEnd( 0 ), nAutoFmtRedlnCommentNo( 0 ), nLinkUpdMode( GLOBALSETTING ), eFldUpdMode( AUTOUPD_GLOBALSETTING ), @@ -310,13 +307,11 @@ SwDoc::SwDoc() : mbGlossDoc = mbModified = mbDtor = - mbUndo = mbPageNums = mbLoaded = mbUpdateExpFld = mbNewDoc = mbCopyIsMove = - mbNoDrawUndoObj = mbBrowseMode = mbInReading = mbInXMLImport = @@ -342,7 +337,6 @@ SwDoc::SwDoc() : // <-- false; - mbGroupUndo = mbNewFldLst = mbVisibleLinks = mbPurgeOLE = @@ -434,8 +428,10 @@ SwDoc::SwDoc() : pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) ); // <-- - new SwTxtNode( SwNodeIndex( aUndoNodes.GetEndOfContent() ), pDfltTxtFmtColl ); - new SwTxtNode( SwNodeIndex( aNodes.GetEndOfContent() ), + new SwTxtNode( + SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()), + pDfltTxtFmtColl ); + new SwTxtNode( SwNodeIndex( GetNodes().GetEndOfContent() ), GetTxtCollFromPool( RES_POOLCOLL_STANDARD )); // den eigenen IdleTimer setzen @@ -475,6 +471,14 @@ SwDoc::SwDoc() : SwDoc::~SwDoc() { + // nothing here should create Undo actions! + GetIDocumentUndoRedo().DoUndo(false); + + if (pDocShell) + { + pDocShell->SetUndoManager(0); + } + // --> OD 2007-03-16 #i73788# SwPauseThreadStarting aPauseThreadStarting; // <-- @@ -523,8 +527,6 @@ SwDoc::~SwDoc() delete pPgPViewPrtData; - mbUndo = FALSE; // immer das Undo abschalten !! - // damit die Fussnotenattribute die Fussnotennodes in Frieden lassen. mbDtor = TRUE; DELETEZ( pLayout ); @@ -550,13 +552,14 @@ SwDoc::~SwDoc() // die KapitelNummern / Nummern muessen vor den Vorlage geloescht werden // ansonsten wird noch staendig geupdatet !!! - aNodes.pOutlineNds->Remove( USHORT(0), aNodes.pOutlineNds->Count() ); - aUndoNodes.pOutlineNds->Remove( USHORT(0), aUndoNodes.pOutlineNds->Count() ); + m_pNodes->pOutlineNds->Remove(USHORT(0), m_pNodes->pOutlineNds->Count()); + SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() ); + rUndoNodes.pOutlineNds->Remove(USHORT(0), rUndoNodes.pOutlineNds->Count()); pFtnIdxs->Remove( USHORT(0), pFtnIdxs->Count() ); - pUndos->DeleteAndDestroy( 0, pUndos->Count() ); //Es koennen in den Attributen noch - //noch indizes angemeldet sein. + // indices could be registered in attributes + m_pUndoManager->DelAllUndoObj(); // in den BookMarks sind Indizies auf den Content. Diese muessen vorm // loesche der Nodes geloescht werden. @@ -599,8 +602,8 @@ SwDoc::~SwDoc() // Inhaltssections loeschen // nicht erst durch den SwNodes-DTOR, damit Formate // keine Abhaengigen mehr haben. - aNodes.DelNodes( SwNodeIndex( aNodes ), aNodes.Count() ); - aUndoNodes.DelNodes( SwNodeIndex( aUndoNodes ), aUndoNodes.Count() ); + m_pNodes->DelNodes( SwNodeIndex(*m_pNodes), m_pNodes->Count() ); + rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() ); // Formate loeschen, spaeter mal permanent machen. @@ -692,7 +695,6 @@ SwDoc::~SwDoc() delete pFtnIdxs; delete pFldTypes; delete pTOXTypes; - delete pUndos; delete pDocStat; delete pEmptyPageFmt; delete pColumnContFmt; @@ -755,7 +757,15 @@ void SwDoc::SetDocShell( SwDocShell* pDSh ) { if( pDocShell != pDSh ) { + if (pDocShell) + { + pDocShell->SetUndoManager(0); + } pDocShell = pDSh; + if (pDocShell) + { + pDocShell->SetUndoManager(& GetUndoManager()); + } pLinkMgr->SetPersist( pDocShell ); //JP 27.08.98: Bug 55570 - DocShell Pointer auch am DrawModel setzen @@ -794,9 +804,8 @@ SfxObjectShell* SwDoc::GetPersist() const void SwDoc::ClearDoc() { - BOOL bOldUndo = mbUndo; - DelAllUndoObj(); - mbUndo = FALSE; // immer das Undo abschalten !! + GetIDocumentUndoRedo().DelAllUndoObj(); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); // Undo-Benachrichtigung vom Draw abschalten if( pDrawModel ) @@ -907,8 +916,6 @@ void SwDoc::ClearDoc() pFirstNd->ResetAllAttr(); // delete now the dummy pagedesc DelPageDesc( nDummyPgDsc ); - - mbUndo = bOldUndo; } void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew ) @@ -1063,6 +1070,30 @@ SwDoc::GetMetaFieldManager() return *m_pMetaFieldManager; } +::sw::UndoManager & +SwDoc::GetUndoManager() +{ + return *m_pUndoManager; +} + +::sw::UndoManager const& +SwDoc::GetUndoManager() const +{ + return *m_pUndoManager; +} + +IDocumentUndoRedo & +SwDoc::GetIDocumentUndoRedo() +{ + return *m_pUndoManager; +} + +IDocumentUndoRedo const& +SwDoc::GetIDocumentUndoRedo() const +{ + return *m_pUndoManager; +} + void SwDoc::InitTOXTypes() { ShellResource* pShellRes = ViewShell::GetShellRes(); @@ -1149,15 +1180,23 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const // COMPATIBILITY FLAGS END // pRet->ReplaceStyles( * const_cast< SwDoc*>( this )); - SfxObjectShellRef aDocShellRef = const_cast< SwDocShell* >( GetDocShell() ); - pRet->SetRefForDocShell( boost::addressof(aDocShellRef) ); - SfxObjectShellRef xRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD ); + + // we have to use pointer here, since the callee has to decide whether SfxObjectShellLock or SfxObjectShellRef should be used + // sometimes the object will be returned with refcount set to 0 ( if no DoInitNew is done ) + SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD ); if( bCallInitNew ) - xRetShell->DoInitNew(); + { + // it could happen that DoInitNew creates model, that increases the refcount of the object + pRetShell->DoInitNew(); + } + //copy content pRet->Paste( *this ); - pRet->SetRefForDocShell( 0 ); - return xRetShell; + + // remove the temporary shell if it is there as it was done before + pRet->SetTmpDocShell( (SfxObjectShell*)NULL ); + + return pRetShell; } /*-- 08.05.2009 10:52:40--------------------------------------------------- copy document content - code from SwFEShell::Paste( SwDoc* , BOOL ) @@ -1175,7 +1214,7 @@ void SwDoc::Paste( const SwDoc& rSource ) aCpyPam.SetMark(); aCpyPam.Move( fnMoveForward, fnGoDoc ); - this->StartUndo( UNDO_INSGLOSSARY, NULL ); + this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL ); this->LockExpFlds(); { @@ -1229,7 +1268,7 @@ void SwDoc::Paste( const SwDoc& rSource ) } } - this->EndUndo( UNDO_INSGLOSSARY, NULL ); + this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL ); UnlockExpFlds(); UpdateFlds(NULL, false); diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 6ba37816b0dc..ed6ece5c8f97 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <tools/date.hxx> #include <tools/time.hxx> @@ -35,11 +36,14 @@ #include <ftninfo.hxx> #include <ftnidx.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <doctxm.hxx> // pTOXBaseRing #include <poolfmt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoRedline.hxx> +#include <UndoNumbering.hxx> #include <swundo.hxx> #include <SwUndoFmt.hxx> #include <rolbck.hxx> @@ -49,9 +53,7 @@ #include <txtfrm.hxx> #include <pamtyp.hxx> #include <redline.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <editeng/adjitem.hxx> #include <editeng/frmdiritem.hxx> #include <frmatr.hxx> @@ -371,11 +373,11 @@ BOOL SwDoc::OutlineUpDown( const SwPaM& rPam, short nOffset ) return FALSE; /* <-- #i13747 # */ - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - StartUndo(UNDO_OUTLINE_LR, NULL); - AppendUndo( new SwUndoOutlineLeftRight( rPam, nOffset ) ); + GetIDocumentUndoRedo().StartUndo(UNDO_OUTLINE_LR, NULL); + SwUndo *const pUndoOLR( new SwUndoOutlineLeftRight( rPam, nOffset ) ); + GetIDocumentUndoRedo().AppendUndo(pUndoOLR); } // 2. allen Nodes die neue Vorlage zuweisen @@ -417,8 +419,10 @@ BOOL SwDoc::OutlineUpDown( const SwPaM& rPam, short nOffset ) n++; // Undo ??? } - if (DoesUndo()) - EndUndo(UNDO_OUTLINE_LR, NULL); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().EndUndo(UNDO_OUTLINE_LR, NULL); + } ChkCondColls(); SetModified(); @@ -436,9 +440,11 @@ BOOL SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) & rEnd = &rStt == rPam.GetPoint() ? *rPam.GetMark() : *rPam.GetPoint(); if( !GetNodes().GetOutLineNds().Count() || !nOffset || - rStt.nNode.GetIndex() < aNodes.GetEndOfExtras().GetIndex() || - rEnd.nNode.GetIndex() < aNodes.GetEndOfExtras().GetIndex() ) + (rStt.nNode.GetIndex() < GetNodes().GetEndOfExtras().GetIndex()) || + (rEnd.nNode.GetIndex() < GetNodes().GetEndOfExtras().GetIndex())) + { return FALSE; + } USHORT nAktPos = 0; SwNodeIndex aSttRg( rStt.nNode ), aEndRg( rEnd.nNode ); @@ -572,7 +578,7 @@ BOOL SwDoc::MoveOutlinePara( const SwPaM& rPam, short nOffset ) // setze die Position auf den Dokumentanfang. // Sollten da Bereiche oder Tabellen stehen, so werden sie nach // hinten verschoben. - nNewPos = Max( nNewPos, aNodes.GetEndOfExtras().GetIndex() + 2 ); + nNewPos = Max( nNewPos, GetNodes().GetEndOfExtras().GetIndex() + 2 ); long nOffs = nNewPos - ( 0 < nOffset ? aEndRg.GetIndex() : aSttRg.GetIndex()); SwPaM aPam( aSttRg, aEndRg, 0, -1 ); @@ -976,11 +982,12 @@ void SwDoc::SetNumRule( const SwPaM& rPam, const bool bResetIndentAttrs ) { SwUndoInsNum * pUndo = NULL; - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - StartUndo( UNDO_INSNUM, NULL ); // Klammerung fuer die Attribute! - AppendUndo( pUndo = new SwUndoInsNum( rPam, rRule ) ); + // Start/End for attributes! + GetIDocumentUndoRedo().StartUndo( UNDO_INSNUM, NULL ); + pUndo = new SwUndoInsNum( rPam, rRule ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } SwNumRule * pNew = FindNumRulePtr( rRule.GetName() ); @@ -1112,8 +1119,10 @@ void SwDoc::SetNumRule( const SwPaM& rPam, } // <-- - if (DoesUndo()) - EndUndo( UNDO_INSNUM, NULL ); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().EndUndo( UNDO_INSNUM, NULL ); + } SetModified(); } @@ -1158,10 +1167,10 @@ void SwDoc::SetNumRuleStart( const SwPosition& rPos, BOOL bFlag ) const SwNumRule* pRule = pTxtNd->GetNumRule(); if( pRule && !bFlag != !pTxtNd->IsListRestart()) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoNumRuleStart( rPos, bFlag )); + SwUndo *const pUndo( new SwUndoNumRuleStart(rPos, bFlag) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } pTxtNd->SetListRestart(bFlag ? true : false); @@ -1193,10 +1202,10 @@ void SwDoc::SetNodeNumStart( const SwPosition& rPos, USHORT nStt ) if ( !pTxtNd->HasAttrListRestartValue() || pTxtNd->GetAttrListRestartValue() != nStt ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoNumRuleStart( rPos, nStt )); + SwUndo *const pUndo( new SwUndoNumRuleStart(rPos, nStt) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } pTxtNd->SetAttrListRestartValue( nStt ); @@ -1222,12 +1231,11 @@ BOOL SwDoc::DelNumRule( const String& rName, BOOL bBroadcast ) if( USHRT_MAX != nPos && !IsUsed( *(*pNumRuleTbl)[ nPos ] )) { - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoNumruleDelete(*(*pNumRuleTbl)[nPos], this); - - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if (bBroadcast) @@ -1279,12 +1287,11 @@ void SwDoc::ChgNumRuleFmts( const SwNumRule& rRule, const String * pName ) if( pRule ) { SwUndoInsNum* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); pUndo = new SwUndoInsNum( *pRule, rRule ); pUndo->GetHistory(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } ::lcl_ChgNumRule( *this, rRule ); @@ -1303,11 +1310,10 @@ sal_Bool SwDoc::RenameNumRule(const String & rOldName, const String & rNewName, if (pNumRule) { - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoNumruleRename(rOldName, rNewName, this); - - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } // --> OD 2008-02-19 #refactorlists# @@ -1390,11 +1396,12 @@ BOOL SwDoc::ReplaceNumRule( const SwPosition& rPos, { // --> OD 2008-02-19 #refactorlists# SwUndoInsNum* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - StartUndo( UNDO_START, NULL ); // Klammerung fuer die Attribute! - AppendUndo( pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ) ); + // Start/End for attributes! + GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); + pUndo = new SwUndoInsNum( rPos, *pNewRule, rOldRule ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } // --> OD 2008-02-19 #refactorlists# @@ -1477,7 +1484,7 @@ BOOL SwDoc::ReplaceNumRule( const SwPosition& rPos, pTxtNd->NumRuleChgd(); } } - EndUndo( UNDO_END, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); SetModified(); bRet = TRUE; // #106897# @@ -1615,10 +1622,10 @@ void SwDoc::DelNumRules( const SwPaM& rPam ) } SwUndoDelNum* pUndo; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( pUndo = new SwUndoDelNum( rPam ) ); + pUndo = new SwUndoDelNum( rPam ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } else pUndo = 0; @@ -1919,8 +1926,8 @@ const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, pNode = &aIdx.GetNode(); } - while (! (pNode == aNodes.DocumentSectionStartNode(pStartFromNode) || - pNode == aNodes.DocumentSectionEndNode(pStartFromNode))); + while (!(pNode == GetNodes().DocumentSectionStartNode(pStartFromNode) || + pNode == GetNodes().DocumentSectionEndNode(pStartFromNode))); // <-- } @@ -2003,10 +2010,10 @@ BOOL SwDoc::NumUpDown( const SwPaM& rPam, BOOL bDown ) if( bRet ) { /* <-- #i24560# */ - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoNumUpDown( rPam, nDiff ) ); + SwUndo *const pUndo( new SwUndoNumUpDown(rPam, nDiff) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } String sNumRule; @@ -2233,7 +2240,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) if( !pOwnRedl ) { - StartUndo( UNDO_START, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); // zuerst das Insert, dann das Loeschen SwPosition aInsPos( aIdx ); @@ -2308,12 +2315,13 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) RedlineMode_t eOld = GetRedlineMode(); checkRedlining(eOld); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)); - AppendUndo( new SwUndoRedlineDelete( aPam, UNDO_DELETE )); + SwUndo *const pUndo(new SwUndoRedlineDelete(aPam, UNDO_DELETE)); + GetIDocumentUndoRedo().AppendUndo(pUndo); } SwRedline* pNewRedline = new SwRedline( nsRedlineType_t::REDLINE_DELETE, aPam ); @@ -2328,7 +2336,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( eOld ); - EndUndo( UNDO_END, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); SetModified(); return TRUE; @@ -2351,7 +2359,7 @@ SetRedlineMode( eOld ); SwUndoMoveNum* pUndo = 0; ULONG nMoved = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { pUndo = new SwUndoMoveNum( rPam, nOffset, bIsOutlMv ); nMoved = rPam.End()->nNode.GetIndex() - rPam.Start()->nNode.GetIndex() + 1; @@ -2362,13 +2370,12 @@ SetRedlineMode( eOld ); if( pUndo ) { - ClearRedo(); // i57907: Under circumstances (sections at the end of a chapter) // the rPam.Start() is not moved to the new position. // But aIdx should be at the new end position and as long as the number of moved paragraphs // is nMoved, I know, where the new position is. pUndo->SetStartNode( aIdx.GetIndex() - nMoved ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if( pOwnRedl ) @@ -2410,12 +2417,12 @@ BOOL SwDoc::NumOrNoNum( const SwNodeIndex& rIdx, BOOL bDel ) bResult = TRUE; - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndoNumOrNoNum * pUndo = new SwUndoNumOrNoNum(rIdx, bOldNum, bNewNum); - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } } else if (bDel && pTxtNd->GetNumRule(FALSE) && @@ -2529,11 +2536,10 @@ USHORT SwDoc::MakeNumRule( const String &rName, AddNumRule(pNew); // #i36749# - if (DoesUndo()) + if (GetIDocumentUndoRedo().DoesUndo()) { SwUndo * pUndo = new SwUndoNumruleCreate(pNew, this); - - AppendUndo(pUndo); + GetIDocumentUndoRedo().AppendUndo(pUndo); } if (bBroadcast) diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 9997eabd79c3..809e560dce21 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -31,20 +31,21 @@ #include <hintids.hxx> #include <tools/shl.hxx> -#ifndef _SFX_ITEMITER_HXX //autogen #include <svl/itemiter.hxx> -#endif #include <sfx2/app.hxx> #include <editeng/colritem.hxx> #include <editeng/udlnitem.hxx> #include <editeng/crsditem.hxx> #include <swmodule.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <ndtxt.hxx> #include <redline.hxx> #include <swundo.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoRedline.hxx> +#include <hints.hxx> #include <pamtyp.hxx> #include <poolfmt.hxx> #include <viewsh.hxx> @@ -1398,13 +1399,12 @@ bool SwDoc::DeleteRedline( const SwPaM& rRange, bool bSaveInUndo, BOOL bChg = FALSE; - if( bSaveInUndo && DoesUndo() ) + if (bSaveInUndo && GetIDocumentUndoRedo().DoesUndo()) { SwUndoRedline* pUndo = new SwUndoRedline( UNDO_REDLINE, rRange ); if( pUndo->GetRedlSaveCount() ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); } else delete pUndo; @@ -2089,13 +2089,13 @@ bool SwDoc::AcceptRedline( USHORT nPos, bool bCallDelete ) SwRedline* pTmp = (*pRedlineTbl)[ nPos ]; if( pTmp->HasMark() && pTmp->IsVisible() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { // #111827# SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr()); - StartUndo( UNDO_ACCEPT_REDLINE, &aRewriter); + GetIDocumentUndoRedo().StartUndo(UNDO_ACCEPT_REDLINE, &aRewriter); } int nLoopCnt = 2; @@ -2103,8 +2103,11 @@ bool SwDoc::AcceptRedline( USHORT nPos, bool bCallDelete ) do { - if( DoesUndo() ) - AppendUndo( new SwUndoAcceptRedline( *pTmp )); + if (GetIDocumentUndoRedo().DoesUndo()) + { + SwUndo *const pUndo( new SwUndoAcceptRedline(*pTmp) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); + } bRet |= lcl_AcceptRedline( *pRedlineTbl, nPos, bCallDelete ); @@ -2133,8 +2136,10 @@ bool SwDoc::AcceptRedline( USHORT nPos, bool bCallDelete ) SetModified(); } - if( DoesUndo() ) - EndUndo( UNDO_ACCEPT_REDLINE, NULL ); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); + } } return bRet; } @@ -2152,10 +2157,10 @@ bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete ) SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); lcl_AdjustRedlineRange( aPam ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - StartUndo( UNDO_ACCEPT_REDLINE, NULL ); - AppendUndo( new SwUndoAcceptRedline( aPam )); + GetIDocumentUndoRedo().StartUndo( UNDO_ACCEPT_REDLINE, NULL ); + GetIDocumentUndoRedo().AppendUndo( new SwUndoAcceptRedline( aPam )); } // #111827# @@ -2166,7 +2171,7 @@ bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete ) CompressRedlines(); SetModified(); } - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { // #111827# String aTmpStr; @@ -2180,7 +2185,7 @@ bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete ) SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, aTmpStr); - EndUndo( UNDO_ACCEPT_REDLINE, &aRewriter ); + GetIDocumentUndoRedo().EndUndo( UNDO_ACCEPT_REDLINE, &aRewriter ); } return nRet != 0; } @@ -2197,13 +2202,13 @@ bool SwDoc::RejectRedline( USHORT nPos, bool bCallDelete ) SwRedline* pTmp = (*pRedlineTbl)[ nPos ]; if( pTmp->HasMark() && pTmp->IsVisible() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { // #111827# SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr()); - StartUndo( UNDO_REJECT_REDLINE, NULL ); + GetIDocumentUndoRedo().StartUndo(UNDO_REJECT_REDLINE, &aRewriter); } int nLoopCnt = 2; @@ -2211,8 +2216,11 @@ bool SwDoc::RejectRedline( USHORT nPos, bool bCallDelete ) do { - if( DoesUndo() ) - AppendUndo( new SwUndoRejectRedline( *pTmp )); + if (GetIDocumentUndoRedo().DoesUndo()) + { + SwUndo *const pUndo( new SwUndoRejectRedline( *pTmp ) ); + GetIDocumentUndoRedo().AppendUndo(pUndo); + } bRet |= lcl_RejectRedline( *pRedlineTbl, nPos, bCallDelete ); @@ -2241,8 +2249,10 @@ bool SwDoc::RejectRedline( USHORT nPos, bool bCallDelete ) SetModified(); } - if( DoesUndo() ) - EndUndo( UNDO_REJECT_REDLINE, NULL ); + if (GetIDocumentUndoRedo().DoesUndo()) + { + GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); + } } return bRet; } @@ -2260,10 +2270,10 @@ bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete ) SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); lcl_AdjustRedlineRange( aPam ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - StartUndo( UNDO_REJECT_REDLINE, NULL ); - AppendUndo( new SwUndoRejectRedline( aPam )); + GetIDocumentUndoRedo().StartUndo( UNDO_REJECT_REDLINE, NULL ); + GetIDocumentUndoRedo().AppendUndo( new SwUndoRejectRedline(aPam) ); } // #111827# @@ -2274,7 +2284,7 @@ bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete ) CompressRedlines(); SetModified(); } - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { // #111827# String aTmpStr; @@ -2288,7 +2298,7 @@ bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete ) SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, aTmpStr); - EndUndo( UNDO_REJECT_REDLINE, &aRewriter ); + GetIDocumentUndoRedo().EndUndo( UNDO_REJECT_REDLINE, &aRewriter ); } return nRet != 0; @@ -3148,8 +3158,7 @@ void SwRedline::Show( USHORT nLoop ) SwDoc* pDoc = GetDoc(); RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); switch( GetType() ) { @@ -3171,7 +3180,6 @@ void SwRedline::Show( USHORT nLoop ) break; } pDoc->SetRedlineMode_intern( eOld ); - pDoc->DoUndo( bUndo ); } } @@ -3180,8 +3188,7 @@ void SwRedline::Hide( USHORT nLoop ) SwDoc* pDoc = GetDoc(); RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); switch( GetType() ) { @@ -3210,7 +3217,6 @@ void SwRedline::Hide( USHORT nLoop ) break; } pDoc->SetRedlineMode_intern( eOld ); - pDoc->DoUndo( bUndo ); } void SwRedline::ShowOriginal( USHORT nLoop ) @@ -3220,8 +3226,7 @@ void SwRedline::ShowOriginal( USHORT nLoop ) SwRedlineData* pCur; pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); // bestimme den Type, ist der erste auf Stack for( pCur = pRedlineData; pCur->pNext; ) @@ -3254,7 +3259,6 @@ void SwRedline::ShowOriginal( USHORT nLoop ) break; } pDoc->SetRedlineMode_intern( eOld ); - pDoc->DoUndo( bUndo ); } @@ -3856,9 +3860,9 @@ String SwRedline::GetDescr(USHORT nPos) bool SwDoc::IsInRedlines(const SwNode & rNode) const { SwPosition aPos(rNode); - SwNode & rEndOfRedlines = aNodes.GetEndOfRedlines(); + SwNode & rEndOfRedlines = GetNodes().GetEndOfRedlines(); SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()), SwPosition(rEndOfRedlines)); - return aPam.ContainsPosition(aPos) ? sal_True : sal_False; + return aPam.ContainsPosition(aPos) ? true : false; } diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index 4a707e1fb1af..a2e9d5cfa0c6 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -28,18 +28,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <string.h> // fuer strchr() -#include <hintids.hxx> -#ifndef _COM_SUN_STAR_I18N_UNICODETYPE_HDL #include <com/sun/star/i18n/UnicodeType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL #include <com/sun/star/i18n/WordType.hdl> -#endif + #include <unotools/charclass.hxx> + +#include <hintids.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <mvsave.hxx> // Strukturen zum Sichern beim Move/Delete #include <ndtxt.hxx> @@ -47,7 +45,6 @@ #include <rubylist.hxx> #include <pam.hxx> #include <swundo.hxx> // fuer die UndoIds -#include <undobj.hxx> #include <breakit.hxx> #include <crsskip.hxx> @@ -112,7 +109,7 @@ USHORT SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList, USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, USHORT nMode ) { - StartUndo( UNDO_SETRUBYATTR, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_SETRUBYATTR, NULL ); SvUShortsSort aDelArr; aDelArr.Insert( RES_TXTATR_CJK_RUBY ); @@ -193,7 +190,7 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, } while( 30 > rList.Count() && (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); - EndUndo( UNDO_SETRUBYATTR, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL ); return nListEntry; } diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index 8923b5322998..33b3b8966f7f 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <rtl/math.hxx> #include <unotools/collatorwrapper.hxx> @@ -39,6 +40,7 @@ #include <fmtanchr.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <node.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -46,7 +48,9 @@ #include <swundo.hxx> #include <sortopt.hxx> #include <docsort.hxx> -#include <undobj.hxx> +#include <UndoSort.hxx> +#include <UndoRedline.hxx> +#include <hints.hxx> #include <tblsel.hxx> #include <cellatr.hxx> #include <redline.hxx> @@ -357,9 +361,11 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) return FALSE; } - BOOL bUndo = DoesUndo(); + bool const bUndo = GetIDocumentUndoRedo().DoesUndo(); if( bUndo ) - StartUndo( UNDO_START, NULL ); + { + GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); + } SwPaM* pRedlPam = 0; SwUndoRedlineSort* pRedlUndo = 0; @@ -377,7 +383,7 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) if( bUndo ) { pRedlUndo = new SwUndoRedlineSort( *pRedlPam,rOpt ); - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); } // erst den Bereich kopieren, dann SwNodeIndex aEndIdx( pEnd->nNode, 1 ); @@ -430,9 +436,12 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) SwNodeRange aRg( aStart, aStart ); if( bUndo && !pRedlUndo ) - AppendUndo( pUndoSort = new SwUndoSort( rPaM, rOpt ) ); + { + pUndoSort = new SwUndoSort(rPaM, rOpt); + GetIDocumentUndoRedo().AppendUndo(pUndoSort); + } - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); for ( USHORT n = 0; n < aSortArr.Count(); ++n ) { @@ -458,7 +467,10 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) if( pRedlUndo ) { pRedlUndo->SetSaveRange( *pRedlPam ); - AppendUndo( pRedlUndo ); + // UGLY: temp. enable Undo + GetIDocumentUndoRedo().DoUndo(true); + GetIDocumentUndoRedo().AppendUndo( pRedlUndo ); + GetIDocumentUndoRedo().DoUndo(false); } // nBeg is start of sorted range @@ -495,9 +507,11 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) delete pRedlPam, pRedlPam = 0; } - DoUndo( bUndo ); + GetIDocumentUndoRedo().DoUndo( bUndo ); if( bUndo ) - EndUndo( UNDO_END, NULL ); + { + GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); + } return TRUE; } @@ -575,18 +589,15 @@ BOOL SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) pTblNd->DelFrms(); // ? TL_CHART2: ? - // Redo loeschen bevor Undo - BOOL bUndo = DoesUndo(); SwUndoSort* pUndoSort = 0; - if(bUndo) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); pUndoSort = new SwUndoSort( rBoxes[0]->GetSttIdx(), rBoxes[rBoxes.Count()-1]->GetSttIdx(), *pTblNd, rOpt, aFlatBox.HasItemSets() ); - AppendUndo(pUndoSort); - DoUndo(FALSE); + GetIDocumentUndoRedo().AppendUndo(pUndoSort); } + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); // SchluesselElemente einsortieren USHORT nCount = (rOpt.eDirection == SRT_ROWS) ? @@ -631,9 +642,6 @@ BOOL SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt) aSortList.DeleteAndDestroy( 0, aSortList.Count() ); SwSortElement::Finit(); - // Undo wieder aktivieren - DoUndo(bUndo); - SetModified(); return TRUE; } diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index b7395402d01d..5b02a00271c1 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -49,6 +49,7 @@ #include <frmatr.hxx> #include <pagedesc.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagefrm.hxx> #include <ndtxt.hxx> #include <swtable.hxx> @@ -58,7 +59,7 @@ #include <poolfmt.hxx> #include <txtfrm.hxx> #include <rootfrm.hxx> -#include <undobj.hxx> +#include <UndoAttribute.hxx> #include <swundo.hxx> #include <mdiexp.hxx> #include <docary.hxx> @@ -140,9 +141,8 @@ USHORT SwDoc::GetTOIKeys( SwTOIKeyType eTyp, SvStringsSort& rArr ) const USHORT SwDoc::GetCurTOXMark( const SwPosition& rPos, SwTOXMarks& rArr ) const { - // suche an der Position rPos nach allen SwTOXMark's - SwTxtNode* pTxtNd = GetNodes()[ rPos.nNode ]->GetTxtNode(); - // kein TextNode oder kein HintsArray vorhanden ?? + // search on Position rPos for all SwTOXMarks + SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode(); if( !pTxtNd || !pTxtNd->GetpSwpHints() ) return 0; @@ -188,14 +188,13 @@ void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark ) SwTxtNode& rTxtNd = const_cast<SwTxtNode&>(pTxtTOXMark->GetTxtNode()); ASSERT( rTxtNd.GetpSwpHints(), "kann nicht geloescht werden" ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - // fuers Undo die Attribute sichern - ClearRedo(); + // save attributes for Undo SwUndoResetAttr* pUndo = new SwUndoResetAttr( SwPosition( rTxtNd, SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ), RES_TXTATR_TOXMARK ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); @@ -203,7 +202,7 @@ void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark ) rTxtNd.DeleteAttribute( const_cast<SwTxtTOXMark*>(pTxtTOXMark) ); - if ( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { if( rTxtNd.GetpSwpHints() ) rTxtNd.GetpSwpHints()->DeRegister(); @@ -364,7 +363,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, const SfxItemSet* pSet, BOOL bExpand ) { - StartUndo( UNDO_INSTOX, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_INSTOX, NULL ); String sSectNm( rTOX.GetTOXName() ); sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), &sSectNm ); @@ -406,7 +405,7 @@ sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" )); } } - EndUndo( UNDO_INSTOX, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_INSTOX, NULL ); return pNewSection; } @@ -548,7 +547,7 @@ BOOL SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, BOOL bDelNodes ) SwSectionFmt* pFmt = rTOXSect.GetFmt(); if( pFmt ) { - StartUndo( UNDO_CLEARTOXRANGE, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_CLEARTOXRANGE, NULL ); /* Save the start node of the TOX' section. */ SwSectionNode * pMyNode = pFmt->GetSectionNode(); @@ -620,7 +619,7 @@ BOOL SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, BOOL bDelNodes ) DelSectionFmt( pFmt, bDelNodes ); - EndUndo( UNDO_CLEARTOXRANGE, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_CLEARTOXRANGE, NULL ); bRet = TRUE; } diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx index f627870932f9..ebc5a66b7694 100644 --- a/sw/source/core/doc/extinput.cxx +++ b/sw/source/core/doc/extinput.cxx @@ -28,19 +28,23 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <com/sun/star/i18n/ScriptType.hpp> + +#include <editeng/langitem.hxx> +#include <editeng/scripttypeitem.hxx> -#include <hintids.hxx> #include <vcl/keycodes.hxx> #include <vcl/cmdevt.hxx> + +#include <hintids.hxx> #include <extinput.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <index.hxx> #include <ndtxt.hxx> #include <txtfrm.hxx> #include <swundo.hxx> -#include <editeng/langitem.hxx> -#include <editeng/scripttypeitem.hxx> -#include <com/sun/star/i18n/ScriptType.hpp> + using namespace ::com::sun::star; @@ -106,12 +110,14 @@ SwExtTextInput::~SwExtTextInput() if( bInsText ) { rIdx = nSttCnt; - pDoc->StartUndo( UNDO_OVERWRITE, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( + UNDO_OVERWRITE, NULL ); pDoc->Overwrite( *this, sTxt.Copy( 0, sOverwriteText.Len() )); pDoc->InsertString( *this, sTxt.Copy( sOverwriteText.Len() ) ); - pDoc->EndUndo( UNDO_OVERWRITE, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( + UNDO_OVERWRITE, NULL ); } } else diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index e5cfc065db2a..464388220c03 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <i18npool/mslangid.hxx> #include <unotools/localedatawrapper.hxx> @@ -54,6 +55,7 @@ #include <editeng/scriptspaceitem.hxx> #include <viewopt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <fmtanchr.hxx> #include <fmtornt.hxx> #include <fmtsrnd.hxx> @@ -67,9 +69,7 @@ #include <fmtcol.hxx> #include <ndtxt.hxx> #include <fmtline.hxx> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif #include <GetMetricVal.hxx> #include <numrule.hxx> @@ -1085,7 +1085,7 @@ bool SwDoc::IsPoolTxtCollUsed( USHORT nId ) const if( !bFnd || !pNewColl->GetDepends() ) return FALSE; - SwAutoFmtGetDocNode aGetHt( &aNodes ); + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); return !pNewColl->GetInfo( aGetHt ); } @@ -1164,24 +1164,21 @@ SwFmt* SwDoc::GetFmtFromPool( USHORT nId ) { BOOL bIsModified = IsModified(); - BOOL bDoesUndo = DoesUndo(); - DoUndo(FALSE); - switch (nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) ) { - case POOLGRP_CHARFMT: - pNewFmt = _MakeCharFmt( aNm, pDeriveFmt, FALSE, TRUE ); - - break; - case POOLGRP_FRAMEFMT: - pNewFmt = _MakeFrmFmt(aNm, pDeriveFmt, FALSE, TRUE ); - - break; - default: - break; + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + switch (nId & (COLL_GET_RANGE_BITS + POOLGRP_NOCOLLID) ) + { + case POOLGRP_CHARFMT: + pNewFmt = _MakeCharFmt(aNm, pDeriveFmt, FALSE, TRUE); + break; + case POOLGRP_FRAMEFMT: + pNewFmt = _MakeFrmFmt(aNm, pDeriveFmt, FALSE, TRUE); + break; + default: + break; + } } - DoUndo(bDoesUndo); - if( !bIsModified ) ResetModified(); pNewFmt->SetPoolFmtId( nId ); @@ -1436,7 +1433,7 @@ bool SwDoc::IsPoolFmtUsed( USHORT nId ) const { // dann teste mal, ob es abhaengige ContentNodes im Nodes Array gibt // (auch indirekte fuer Format-Ableitung! ) - SwAutoFmtGetDocNode aGetHt( &aNodes ); + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); bFnd = !pNewFmt->GetInfo( aGetHt ); } else @@ -1486,10 +1483,10 @@ SwPageDesc* SwDoc::GetPageDescFromPool( sal_uInt16 nId, bool bRegardLanguage ) { BOOL bIsModified = IsModified(); - BOOL bDoesUndo = DoesUndo(); - DoUndo(FALSE); - n = MakePageDesc( aNm, 0, bRegardLanguage ); - DoUndo(bDoesUndo); + { + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + n = MakePageDesc( aNm, 0, bRegardLanguage ); + } pNewPgDsc = aPageDescs[ n ]; pNewPgDsc->SetPoolFmtId( nId ); @@ -2359,7 +2356,7 @@ bool SwDoc::IsPoolPageDescUsed( USHORT nId ) const // dann teste mal, ob es abhaengige ContentNodes im Nodes Array gibt // (auch indirekte fuer Format-Ableitung! ) - SwAutoFmtGetDocNode aGetHt( &aNodes ); + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); return !pNewPgDsc->GetInfo( aGetHt ); } @@ -2368,7 +2365,7 @@ sal_Bool SwDoc::IsUsed( const SwModify& rModify ) const { // dann teste mal, ob es abhaengige ContentNodes im Nodes Array gibt // (auch indirekte fuer Format-Ableitung! ) - SwAutoFmtGetDocNode aGetHt( &aNodes ); + SwAutoFmtGetDocNode aGetHt( &GetNodes() ); return !rModify.GetInfo( aGetHt ); } diff --git a/sw/source/core/doc/tblcpy.cxx b/sw/source/core/doc/tblcpy.cxx index e19e60e645df..06ca1c814688 100644 --- a/sw/source/core/doc/tblcpy.cxx +++ b/sw/source/core/doc/tblcpy.cxx @@ -35,6 +35,7 @@ #include <svl/zforlist.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <cntfrm.hxx> #include <pam.hxx> #include <swtable.hxx> @@ -47,7 +48,8 @@ #include <mvsave.hxx> #include <docary.hxx> #include <fmtanchr.hxx> -#include <undobj.hxx> +#include <hints.hxx> +#include <UndoTable.hxx> #include <redline.hxx> #include <fmtfsize.hxx> #include <list> @@ -558,9 +560,8 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, if( pUndo ) pUndo->AddBoxBefore( *pDstBox, bDelCntnt ); - BOOL bUndo = pDoc->DoesUndo(); bool bUndoRedline = pUndo && pDoc->IsRedlineOn(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwNodeIndex aSavePos( aInsIdx, -1 ); if( pRg.get() ) @@ -628,8 +629,8 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, if( pUndo ) pUndo->AddBoxAfter( *pDstBox, aInsIdx, bDelCntnt ); - // Ueberschrift - SwTxtNode* pTxtNd = pDoc->GetNodes()[ aSavePos ]->GetTxtNode(); + // heading + SwTxtNode *const pTxtNd = aSavePos.GetNode().GetTxtNode(); if( pTxtNd ) { USHORT nPoolId = pTxtNd->GetTxtColl()->GetPoolFmtId(); @@ -685,8 +686,6 @@ void lcl_CpyBox( const SwTable& rCpyTbl, const SwTableBox* pCpyBox, } } } - - pDoc->DoUndo( bUndo ); } BOOL SwTable::InsNewTable( const SwTable& rCpyTbl, const SwSelBoxes& rSelBoxes, diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index fe5beeb006a0..9e24caa26a29 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -52,7 +52,8 @@ #include <swundo.hxx> #include <rowfrm.hxx> #include <ddefld.hxx> -#include <undobj.hxx> +#include <hints.hxx> +#include <UndoTable.hxx> #include <cellatr.hxx> #include <mvsave.hxx> #include <swtblfmt.hxx> diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 9c2ce7af3139..c669e59a2708 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -28,16 +28,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <editeng/brkitem.hxx> #define _ZFORLIST_DECLARE_TABLE #include <hintids.hxx> - - -#include <editeng/brkitem.hxx> #include <fmtpdsc.hxx> #include <fmtanchr.hxx> #include <fmtcntnt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <fldbas.hxx> @@ -142,8 +141,7 @@ namespace const SwDoc* pSrcDoc = rPam.GetDoc(); SwDoc* pDestDoc = rCpyPam.GetDoc(); const IDocumentMarkAccess* const pSrcMarkAccess = pSrcDoc->getIDocumentMarkAccess(); - bool bDoesUndo = pDestDoc->DoesUndo(); - pDestDoc->DoUndo(false); + ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo()); const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End(); SwPosition* pCpyStt = rCpyPam.Start(); @@ -209,7 +207,6 @@ namespace pNewMetadatable->RegisterAsCopyOf(*pMetadatable); } } - pDestDoc->DoUndo(bDoesUndo); } } @@ -647,8 +644,7 @@ void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam ) RedlineMode_t eOld = pDestDoc->GetRedlineMode(); pDestDoc->SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - BOOL bDoesUndo = pDestDoc->DoesUndo(); - pDestDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDestDoc->GetIDocumentUndoRedo()); do { pDestDoc->DeleteAndJoin( *(SwPaM*)pDelPam->GetNext() ); @@ -658,7 +654,6 @@ void lcl_DeleteRedlines( const SwPaM& rPam, SwPaM& rCpyPam ) } while( TRUE ); delete pDelPam; - pDestDoc->DoUndo( bDoesUndo ); pDestDoc->SetRedlineMode_intern( eOld ); } } @@ -737,49 +732,50 @@ SwDoc::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const "please tell me what you did to get here!"); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - BOOL bDoUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); // Auf jedenfall Undo abschalten // dann kopiere den Bereich im unteren DokumentBereich, // (mit Start/End-Nodes geklammert) und verschiebe diese // dann an die gewuenschte Stelle. SwUndoCpyDoc* pUndo = 0; SwPaM aPam( rPos ); // UndoBereich sichern - if( bDoUndo ) + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { - pDoc->ClearRedo(); + pDoc->GetIDocumentUndoRedo().ClearRedo(); pUndo = new SwUndoCpyDoc( aPam ); } - SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( + { + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); + SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( SwNodeIndex( GetNodes().GetEndOfAutotext() )); - aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); - // copy without Frames - pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 ); - - aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); - aPam.SetMark(); - SwCntntNode* pNode = pDoc->GetNodes().GoPrevious( &aPam.GetMark()->nNode ); - pNode->MakeEndIndex( &aPam.GetMark()->nContent ); - - aPam.GetPoint()->nNode = *aPam.GetNode()->StartOfSectionNode(); - pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode ); - pNode->MakeStartIndex( &aPam.GetPoint()->nContent ); - // move to desired position - pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT ); - - pNode = aPam.GetCntntNode(); - *aPam.GetPoint() = rPos; // Cursor umsetzen fuers Undo ! - aPam.SetMark(); // auch den Mark umsetzen !! - aPam.DeleteMark(); // aber keinen Bereich makieren !! - pDoc->DeleteSection( pNode ); // Bereich wieder loeschen - - // falls Undo eingeschaltet ist, so speicher den eingefuegten Bereich - pDoc->DoUndo( bDoUndo ); - if( bDoUndo ) + aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); + // copy without Frames + pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 ); + + aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); + aPam.SetMark(); + SwCntntNode* pNode = + pDoc->GetNodes().GoPrevious( &aPam.GetMark()->nNode ); + pNode->MakeEndIndex( &aPam.GetMark()->nContent ); + + aPam.GetPoint()->nNode = *aPam.GetNode()->StartOfSectionNode(); + pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode ); + pNode->MakeStartIndex( &aPam.GetPoint()->nContent ); + // move to desired position + pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT ); + + pNode = aPam.GetCntntNode(); + *aPam.GetPoint() = rPos; // Cursor umsetzen fuers Undo ! + aPam.SetMark(); // auch den Mark umsetzen !! + aPam.DeleteMark(); // aber keinen Bereich makieren !! + pDoc->DeleteSection( pNode ); // Bereich wieder loeschen + } + + // if Undo is enabled, store the insertion range + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { pUndo->SetInsertRange( aPam ); - pDoc->AppendUndo( pUndo ); + pDoc->GetIDocumentUndoRedo().AppendUndo(pUndo); } if( pRedlineRange ) @@ -889,11 +885,10 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, SwTblNumFmtMerge aTNFM( *this, *pDoc ); - if( pDoc->DoesUndo() ) + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { - pDoc->ClearRedo(); pUndo = new SwUndoCpyDoc( aCpyPam ); - pDoc->AppendUndo( pUndo ); + pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo ); } RedlineMode_t eOld = pDoc->GetRedlineMode(); @@ -976,10 +971,10 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, else if( !bOneNode || bColumnSel ) { xub_StrLen nCntntEnd = pEnd->nContent.GetIndex(); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); - pDoc->SplitNode( rPos, false ); - pDoc->DoUndo( bDoesUndo ); + { + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); + pDoc->SplitNode( rPos, false ); + } if( bCanMoveBack && rPos == *aCpyPam.GetPoint() ) { @@ -1106,10 +1101,10 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, // splitte den TextNode, bei dem Eingefuegt wird. xub_StrLen nCntntEnd = pEnd->nContent.GetIndex(); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); - pDoc->SplitNode( rPos, false ); - pDoc->DoUndo( bDoesUndo ); + { + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); + pDoc->SplitNode( rPos, false ); + } if( bCanMoveBack && rPos == *aCpyPam.GetPoint() ) { @@ -1285,8 +1280,10 @@ bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, lcl_DeleteRedlines( rPam, aCpyPam ); // falls Undo eingeschaltet ist, so speicher den eingefuegten Bereich - if( pDoc->DoesUndo() ) + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) + { pUndo->SetInsertRange( aCpyPam, TRUE, bStartIsTxtNode ); + } if( pCpyRange ) { @@ -1349,11 +1346,10 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndConte } #endif - // Undo abschalten - BOOL bUndo = pDest->DoesUndo(); - pDest->DoUndo( FALSE ); - CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); - pDest->DoUndo( bUndo ); + { + ::sw::UndoGuard const undoGuard(pDest->GetIDocumentUndoRedo()); + CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); + } SwNodeRange aCpyRange( aSavePos, rInsPos ); @@ -1440,7 +1436,7 @@ void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, //last node information is only necessary to know for the last TextNode SwNodeIndex aTmp( pAPos->nNode ); ++aTmp;//goto next node - while( rNodes[aTmp ]->IsEndNode() ) + while (aTmp.GetNode().IsEndNode()) { if( aTmp == rNodes.GetEndOfContent().GetIndex() ) { diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 306560272c6f..60ceac5779c5 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -38,11 +38,13 @@ #include <txtftn.hxx> #include <fmtclds.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <rootfrm.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <section.hxx> -#include <undobj.hxx> +#include <UndoSection.hxx> +#include <UndoDelete.hxx> #include <swundo.hxx> #include <calc.hxx> #include <swtable.hxx> @@ -58,9 +60,7 @@ #include <node2lay.hxx> #include <doctxm.hxx> #include <fmtftntx.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif // --> OD 2005-12-01 #i27138# #include <viewsh.hxx> #include <txtfrm.hxx> @@ -188,12 +188,12 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData, } SwUndoInsSection* pUndoInsSect = 0; - if( DoesUndo() ) + bool const bUndo(GetIDocumentUndoRedo().DoesUndo()); + if (bUndo) { - ClearRedo(); pUndoInsSect = new SwUndoInsSection(rRange, rNewData, pAttr, pTOXBase); - AppendUndo( pUndoInsSect ); - DoUndo( FALSE ); + GetIDocumentUndoRedo().AppendUndo( pUndoInsSect ); + GetIDocumentUndoRedo().DoUndo(false); } SwSectionFmt* const pFmt = MakeSectionFmt( 0 ); @@ -374,7 +374,7 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData & rNewData, { pUndoInsSect->SetSectNdPos( pNewSectNode->GetIndex() ); pUndoInsSect->SetUpdtFtnFlag( bUpdateFtn ); - DoUndo( TRUE ); + GetIDocumentUndoRedo().DoUndo(bUndo); } if (rNewData.IsLinkType()) @@ -527,7 +527,7 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, BOOL bDelNodes ) { USHORT nPos = pSectionFmtTbl->GetPos( pFmt ); - StartUndo(UNDO_DELSECTION, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_DELSECTION, NULL); if( USHRT_MAX != nPos ) { @@ -541,24 +541,22 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, BOOL bDelNodes ) const SwSectionNode* pSectNd; - if( DoesUndo() ) + if( GetIDocumentUndoRedo().DoesUndo() ) { - ClearRedo(); if( bDelNodes && pIdx && &GetNodes() == &pIdx->GetNodes() && 0 != (pSectNd = pIdx->GetNode().GetSectionNode() )) { SwNodeIndex aUpdIdx( *pIdx ); - ClearRedo(); SwPaM aPaM( *pSectNd->EndOfSectionNode(), *pSectNd ); - AppendUndo( new SwUndoDelete( aPaM )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoDelete( aPaM )); if( pFtnEndAtTxtEnd ) GetFtnIdxs().UpdateFtn( aUpdIdx ); SetModified(); //#126178# start/end undo have to be pairs! - EndUndo(UNDO_DELSECTION, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL); return ; } - AppendUndo( MakeUndoDelSection( *pFmt ) ); + GetIDocumentUndoRedo().AppendUndo( MakeUndoDelSection( *pFmt ) ); } else if( bDelNodes && pIdx && &GetNodes() == &pIdx->GetNodes() && 0 != (pSectNd = pIdx->GetNode().GetSectionNode() )) @@ -569,7 +567,7 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, BOOL bDelNodes ) GetFtnIdxs().UpdateFtn( aUpdIdx ); SetModified(); //#126178# start/end undo have to be pairs! - EndUndo(UNDO_DELSECTION, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL); return ; } @@ -613,7 +611,7 @@ void SwDoc::DelSectionFmt( SwSectionFmt *pFmt, BOOL bDelNodes ) //FEATURE::CONDCOLL } - EndUndo(UNDO_DELSECTION, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_DELSECTION, NULL); SetModified(); } @@ -651,23 +649,17 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, if( bOnlyAttrChg ) { - const BOOL bDoesUndo = DoesUndo(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( MakeUndoUpdateSection( *pFmt, true ) ); - // --> FME 2004-10-13 #i32968# - // Inserting columns in the section causes MakeFrmFmt to put two - // objects of type SwUndoFrmFmt on the undo stack. We don't want them. - DoUndo( FALSE ); - // <-- + GetIDocumentUndoRedo().AppendUndo( + MakeUndoUpdateSection( *pFmt, true ) ); } + // #i32968# Inserting columns in the section causes MakeFrmFmt + // to put two objects of type SwUndoFrmFmt on the undo stack. + // We don't want them. + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); pFmt->SetFmtAttr( *pAttr ); SetModified(); - - // --> FME 2004-10-13 #i32968# - DoUndo( bDoesUndo ); - // <-- } return; } @@ -692,17 +684,13 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, } } - const BOOL bDoesUndo = DoesUndo(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( MakeUndoUpdateSection( *pFmt, false ) ); - // --> FME 2004-10-13 #i32968# - // Inserting columns in the section causes MakeFrmFmt to put two - // objects of type SwUndoFrmFmt on the undo stack. We don't want them. - DoUndo( FALSE ); - // <-- + GetIDocumentUndoRedo().AppendUndo(MakeUndoUpdateSection(*pFmt, false)); } + // #i32968# Inserting columns in the section causes MakeFrmFmt to put two + // objects of type SwUndoFrmFmt on the undo stack. We don't want them. + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); // #56167# Der LinkFileName koennte auch nur aus Separatoren bestehen String sCompareString = sfx2::cTokenSeperator; @@ -770,10 +758,6 @@ void SwDoc::UpdateSection(sal_uInt16 const nPos, SwSectionData & rNewData, } SetModified(); - - // --> FME 2004-10-13 #i32968# - DoUndo( bDoesUndo ); - // <-- } /* -----------------19.02.99 09:31------------------- @@ -1097,7 +1081,6 @@ SwSectionNode::~SwSectionNode() pLast = aIter++; } } - SwDoc* pDoc = GetDoc(); SwSectionFmt* pFmt = m_pSection->GetFmt(); if( pFmt ) @@ -1108,12 +1091,6 @@ SwSectionNode::~SwSectionNode() pFmt->ResetFmtAttr( RES_CNTNT ); pFmt->UnlockModify(); } - - BOOL bUndo = pDoc->DoesUndo(); - // verhinder beim Loeschen aus der Undo/Redo-History einen rekursiven Aufruf - if( bUndo && &pDoc->GetNodes() != &GetNodes() ) - pDoc->DoUndo( FALSE ); - pDoc->DoUndo( bUndo ); } @@ -1142,7 +1119,7 @@ void SwSectionNode::MakeFrms(const SwNodeIndex & rIdx ) if( 0 == ( pCNd = rNds.GoPrevSection( &aIdx, TRUE, FALSE )) ) return ; } - pCNd = rNds[ aIdx ]->GetCntntNode(); + pCNd = aIdx.GetNode().GetCntntNode(); pCNd->MakeFrms( (SwCntntNode&)rIdx.GetNode() ); } else @@ -1365,7 +1342,8 @@ SwSectionNode* SwSectionNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) c : CREATE_NONE ); // falls als Server aus dem Undo kopiert wird, wieder eintragen - if (m_pSection->IsServer() && (pDoc->GetUndoNds() == &rNds)) + if (m_pSection->IsServer() + && pDoc->GetIDocumentUndoRedo().IsUndoNodes(rNds)) { pNewSect->SetRefObject( m_pSection->GetObject() ); pDoc->GetLinkManager().InsertServer( pNewSect->GetObject() ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 588ef88f7740..d91506721fb6 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -30,9 +30,6 @@ #include <com/sun/star/chart2/XChartDocument.hpp> -#ifdef WTC -#define private public -#endif #include <hintids.hxx> #include <editeng/lrspitem.hxx> @@ -53,6 +50,8 @@ #include <pagefrm.hxx> #include <tabcol.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> +#include <UndoManager.hxx> #include <cntfrm.hxx> #include <pam.hxx> #include <swcrsr.hxx> @@ -64,7 +63,11 @@ #include <fldbas.hxx> #include <poolfmt.hxx> #include <tabfrm.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoRedline.hxx> +#include <UndoDelete.hxx> +#include <UndoTable.hxx> +#include <hints.hxx> #include <tblafmt.hxx> #include <swcache.hxx> #include <ddefld.hxx> @@ -83,9 +86,7 @@ #include <section.hxx> #include <frmtool.hxx> #include <node2lay.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include "docsh.hxx" #include <tabcol.hxx> #include <unochart.hxx> @@ -137,7 +138,7 @@ public: lcl_DelRedlines::lcl_DelRedlines( SwPaM & rPam) : pDoc( rPam.GetDoc() ) { - pDoc->StartUndo(UNDO_EMPTY, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); if( !pDoc->IsIgnoreRedline() && pDoc->GetRedlineTbl().Count() ) pDoc->AcceptRedline( rPam, true ); } @@ -390,10 +391,10 @@ const SwTable* SwDoc::InsertTable( const SwInsertTableOptions& rInsTblOpts, String aTblName = GetUniqueTblName(); - if( DoesUndo() ) + if( GetIDocumentUndoRedo().DoesUndo() ) { - ClearRedo(); - AppendUndo( new SwUndoInsTbl( rPos, nCols, nRows, static_cast<USHORT>(eAdjust), + GetIDocumentUndoRedo().AppendUndo( + new SwUndoInsTbl( rPos, nCols, nRows, static_cast<USHORT>(eAdjust), rInsTblOpts, pTAFmt, pColArr, aTblName)); } @@ -692,15 +693,15 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts, #endif SwUndoTxtToTbl* pUndo = 0; - if( DoesUndo() ) + if( GetIDocumentUndoRedo().DoesUndo() ) { - StartUndo( UNDO_TEXTTOTABLE, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_TEXTTOTABLE, NULL ); pUndo = new SwUndoTxtToTbl( aOriginal, rInsTblOpts, cCh, static_cast<USHORT>(eAdjust), pTAFmt ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); // das Splitten vom TextNode nicht in die Undohistory aufnehmen - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo( false ); } ::PaMCorrAbs( aOriginal, *pEnd ); @@ -739,7 +740,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts, // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen: SwNode2Layout aNode2Layout( aRg.aStart.GetNode() ); - DoUndo( 0 != pUndo ); + GetIDocumentUndoRedo().DoUndo( 0 != pUndo ); // dann erstelle die Box/Line/Table-Struktur SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt(); @@ -916,7 +917,9 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts, } if( pUndo ) - EndUndo( UNDO_TEXTTOTABLE, NULL ); + { + GetIDocumentUndoRedo().EndUndo( UNDO_TEXTTOTABLE, NULL ); + } SetModified(); SetFieldsDirty(true, NULL, 0); @@ -1146,15 +1149,16 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > lcl_DelRedlines aDelRedl( aOriginal ); #endif - SwUndoTxtToTbl* pUndo = 0; - if( DoesUndo() ) +// SwUndoTxtToTbl* pUndo = 0; + bool const bUndo(GetIDocumentUndoRedo().DoesUndo()); + if (bUndo) { -// StartUndo( UNDO_TEXTTOTABLE ); +// GetIDocumentUndoRedo().StartUndo( UNDO_TEXTTOTABLE ); // pUndo = new SwUndoTxtToTbl( aOriginal, rInsTblOpts, cCh, eAdjust, pTAFmt ); -// AppendUndo( pUndo ); +// GetIDocumentUndoRedo().AppendUndo(pUndo); // das Splitten vom TextNode nicht in die Undohistory aufnehmen - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); } ::PaMCorrAbs( aOriginal, *pEnd ); @@ -1193,7 +1197,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen: SwNode2Layout aNode2Layout( aRg.aStart.GetNode() ); - DoUndo( 0 != pUndo ); + GetIDocumentUndoRedo().DoUndo(bUndo); // dann erstelle die Box/Line/Table-Struktur SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt(); @@ -1264,7 +1268,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > } // if( pUndo ) -// EndUndo( UNDO_TEXTTOTABLE ); +// GetIDocumentUndoRedo().EndUndo( UNDO_TEXTTOTABLE ); SetModified(); SetFieldsDirty( true, NULL, 0 ); @@ -1530,9 +1534,9 @@ BOOL SwDoc::TableToText( const SwTableNode* pTblNd, sal_Unicode cCh ) SwNodeRange aRg( *pTblNd, 0, *pTblNd->EndOfSectionNode() ); SwUndoTblToTxt* pUndo = 0; SwNodeRange* pUndoRg = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndoRg = new SwNodeRange( aRg.aStart, -1, aRg.aEnd, +1 ); pUndo = new SwUndoTblToTxt( pTblNd->GetTable(), cCh ); } @@ -1547,7 +1551,7 @@ BOOL SwDoc::TableToText( const SwTableNode* pTblNd, sal_Unicode cCh ) pUndoRg->aStart++; pUndoRg->aEnd--; pUndo->SetRange( *pUndoRg ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo(pUndo); delete pUndoRg; } @@ -1659,7 +1663,7 @@ BOOL SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh, // ist eine Tabelle selektiert ? SwTableNode* pTblNd; if( rRange.aStart.GetIndex() >= rRange.aEnd.GetIndex() || - 0 == ( pTblNd = (*this)[ rRange.aStart ]->GetTableNode()) || + 0 == ( pTblNd = rRange.aStart.GetNode().GetTableNode()) || &rRange.aEnd.GetNode() != pTblNd->EndOfSectionNode() ) return FALSE; @@ -1802,34 +1806,36 @@ BOOL SwDoc::InsertCol( const SwSelBoxes& rBoxes, USHORT nCnt, BOOL bBehind ) SwTableSortBoxes aTmpLst( 0, 5 ); SwUndoTblNdsChg* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - DoUndo( FALSE ); pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSCOL, rBoxes, *pTblNd, 0, 0, nCnt, bBehind, FALSE ); aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() ); } - SwTableFmlUpdate aMsgHnt( &rTbl ); - aMsgHnt.eFlags = TBL_BOXPTR; - UpdateTblFlds( &aMsgHnt ); - - BOOL bRet = rTbl.InsertCol( this, rBoxes, nCnt, bBehind ); - if( bRet ) + bool bRet(false); { - SetModified(); - ::ClearFEShellTabCols(); - SetFieldsDirty( true, NULL, 0 ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + + SwTableFmlUpdate aMsgHnt( &rTbl ); + aMsgHnt.eFlags = TBL_BOXPTR; + UpdateTblFlds( &aMsgHnt ); + + bRet = rTbl.InsertCol( this, rBoxes, nCnt, bBehind ); + if (bRet) + { + SetModified(); + ::ClearFEShellTabCols(); + SetFieldsDirty( true, NULL, 0 ); + } } if( pUndo ) { - DoUndo( TRUE ); if( bRet ) { - ClearRedo(); pUndo->SaveNewBoxes( *pTblNd, aTmpLst ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -1867,34 +1873,36 @@ BOOL SwDoc::InsertRow( const SwSelBoxes& rBoxes, USHORT nCnt, BOOL bBehind ) SwTableSortBoxes aTmpLst( 0, 5 ); SwUndoTblNdsChg* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - DoUndo( FALSE ); pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSROW,rBoxes, *pTblNd, 0, 0, nCnt, bBehind, FALSE ); aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() ); } - SwTableFmlUpdate aMsgHnt( &rTbl ); - aMsgHnt.eFlags = TBL_BOXPTR; - UpdateTblFlds( &aMsgHnt ); - - BOOL bRet = rTbl.InsertRow( this, rBoxes, nCnt, bBehind ); - if( bRet ) + bool bRet(false); { - SetModified(); - ::ClearFEShellTabCols(); - SetFieldsDirty( true, NULL, 0 ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + + SwTableFmlUpdate aMsgHnt( &rTbl ); + aMsgHnt.eFlags = TBL_BOXPTR; + UpdateTblFlds( &aMsgHnt ); + + bRet = rTbl.InsertRow( this, rBoxes, nCnt, bBehind ); + if (bRet) + { + SetModified(); + ::ClearFEShellTabCols(); + SetFieldsDirty( true, NULL, 0 ); + } } if( pUndo ) { - DoUndo( TRUE ); if( bRet ) { - ClearRedo(); pUndo->SaveNewBoxes( *pTblNd, aTmpLst ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -2004,9 +2012,9 @@ BOOL SwDoc::DeleteRow( const SwCursor& rCursor ) // dann loesche doch die Zeilen - StartUndo(UNDO_ROW_DELETE, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_ROW_DELETE, NULL); BOOL bResult = DeleteRowCol( aBoxes ); - EndUndo(UNDO_ROW_DELETE, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_ROW_DELETE, NULL); return bResult; } @@ -2030,9 +2038,9 @@ BOOL SwDoc::DeleteCol( const SwCursor& rCursor ) } // dann loesche doch die Spalten - StartUndo(UNDO_COL_DELETE, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_COL_DELETE, NULL); BOOL bResult = DeleteRowCol( aBoxes, true ); - EndUndo(UNDO_COL_DELETE, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_COL_DELETE, NULL); return bResult; } @@ -2107,9 +2115,9 @@ BOOL SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) // kein Fly ?? also Kopf- oder Fusszeile: dann immer einen // TextNode ueberig lassen. aIdx++; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); SwPaM aPaM( *pTblNd->EndOfSectionNode(), aIdx.GetNode() ); if( bNewTxtNd ) @@ -2165,7 +2173,7 @@ BOOL SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) pUndo->SetTblDelLastNd(); pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc ); pUndo->SetTableName(pTblNd->GetTable().GetFrmFmt()->GetName()); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else { @@ -2212,39 +2220,41 @@ BOOL SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn ) } SwUndoTblNdsChg* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - DoUndo( FALSE ); pUndo = new SwUndoTblNdsChg( UNDO_TABLE_DELBOX, aSelBoxes, *pTblNd, nMin, nMax, 0, FALSE, FALSE ); } - SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() ); - aMsgHnt.eFlags = TBL_BOXPTR; - UpdateTblFlds( &aMsgHnt ); - - if( rTable.IsNewModel() ) - { - if( bColumn ) - rTable.PrepareDeleteCol( nMin, nMax ); - rTable.FindSuperfluousRows( aSelBoxes ); - if( pUndo ) - pUndo->ReNewBoxes( aSelBoxes ); - } - const BOOL bRet = rTable.DeleteSel( this, aSelBoxes, 0, pUndo, TRUE, TRUE ); - if( bRet ) + bool bRet(false); { - SetModified(); - SetFieldsDirty( true, NULL, 0 ); + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + + SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() ); + aMsgHnt.eFlags = TBL_BOXPTR; + UpdateTblFlds( &aMsgHnt ); + + if (rTable.IsNewModel()) + { + if (bColumn) + rTable.PrepareDeleteCol( nMin, nMax ); + rTable.FindSuperfluousRows( aSelBoxes ); + if (pUndo) + pUndo->ReNewBoxes( aSelBoxes ); + } + bRet = rTable.DeleteSel( this, aSelBoxes, 0, pUndo, TRUE, TRUE ); + if (bRet) + { + SetModified(); + SetFieldsDirty( true, NULL, 0 ); + } } if( pUndo ) { - DoUndo( TRUE ); if( bRet ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -2276,10 +2286,8 @@ BOOL SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, USHORT nCnt, SvULongs aNdsCnts; SwTableSortBoxes aTmpLst( 0, 5 ); SwUndoTblNdsChg* pUndo = 0; - BOOL bDoUndo = DoesUndo(); - if( bDoUndo ) + if (GetIDocumentUndoRedo().DoesUndo()) { - DoUndo( FALSE ); pUndo = new SwUndoTblNdsChg( UNDO_TABLE_SPLIT, rBoxes, *pTblNd, 0, 0, nCnt, bVert, bSameHeight ); @@ -2295,33 +2303,35 @@ BOOL SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, USHORT nCnt, } } - SwTableFmlUpdate aMsgHnt( &rTbl ); - aMsgHnt.eFlags = TBL_BOXPTR; - UpdateTblFlds( &aMsgHnt ); + bool bRet(false); + { + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); - BOOL bRet; - if( bVert ) - bRet = rTbl.SplitCol( this, rBoxes, nCnt ); - else - bRet = rTbl.SplitRow( this, rBoxes, nCnt, bSameHeight ); + SwTableFmlUpdate aMsgHnt( &rTbl ); + aMsgHnt.eFlags = TBL_BOXPTR; + UpdateTblFlds( &aMsgHnt ); - if( bRet ) - { - SetModified(); - SetFieldsDirty( true, NULL, 0 ); + if (bVert) + bRet = rTbl.SplitCol( this, rBoxes, nCnt ); + else + bRet = rTbl.SplitRow( this, rBoxes, nCnt, bSameHeight ); + + if (bRet) + { + SetModified(); + SetFieldsDirty( true, NULL, 0 ); + } } - DoUndo( bDoUndo ); if( pUndo ) { if( bRet ) { - ClearRedo(); if( bVert ) pUndo->SaveNewBoxes( *pTblNd, aTmpLst ); else pUndo->SaveNewBoxes( *pTblNd, aTmpLst, rBoxes, aNdsCnts ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -2350,7 +2360,7 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) } // --> FME 2004-10-08 #i33394# - StartUndo( UNDO_TABLE_MERGE, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_MERGE, NULL ); // <-- #ifdef DEL_TABLE_REDLINES @@ -2360,9 +2370,9 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) RedlineMode_t eOld = GetRedlineMode(); SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - SwUndoTblMerge* pUndo = 0; - if( DoesUndo() ) - pUndo = new SwUndoTblMerge( rPam ); + SwUndoTblMerge *const pUndo( (GetIDocumentUndoRedo().DoesUndo()) + ? new SwUndoTblMerge( rPam ) + : 0 ); // lasse ueber das Layout die Boxen suchen SwSelBoxes aBoxes; @@ -2375,13 +2385,19 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) if( pUndo ) { delete pUndo; - if( UNDO_REDLINE == GetUndoIds(NULL, NULL) ) + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId) + && (UNDO_REDLINE == nLastUndoId)) { - SwUndoRedline* pU = (SwUndoRedline*)RemoveLastUndo( UNDO_REDLINE ); + // FIXME: why is this horrible cleanup necessary? + SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>( + GetUndoManager().RemoveLastUndo()); if( pU->GetRedlSaveCount() ) { - SwUndoIter aUndoIter( &rPam, UNDO_REDLINE ); - pU->Undo( aUndoIter ); + SwEditShell *const pEditShell(GetEditShell(0)); + OSL_ASSERT(pEditShell); + ::sw::UndoRedoContext context(*this, *pEditShell); + static_cast<SfxUndoAction *>(pU)->UndoWithContext(context); } delete pU; } @@ -2418,7 +2434,9 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) SetModified(); SetFieldsDirty( true, NULL, 0 ); if( pUndo ) - AppendUndo( pUndo ); + { + GetIDocumentUndoRedo().AppendUndo( pUndo ); + } } else if( pUndo ) delete pUndo; @@ -2429,7 +2447,7 @@ USHORT SwDoc::MergeTbl( SwPaM& rPam ) ::ClearFEShellTabCols(); SetRedlineMode_intern( eOld ); } - EndUndo( UNDO_TABLE_MERGE, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_MERGE, NULL ); return nRet; } @@ -2929,7 +2947,7 @@ void SwDoc::SetTabRows( const SwTabCols &rNew, BOOL bCurColOnly, const SwCursor* GetTabRows( aOld, 0, pBoxFrm ); - StartUndo( UNDO_TABLE_ATTR, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_ATTR, NULL ); // check for differences between aOld and rNew: const USHORT nCount = rNew.Count(); @@ -3012,7 +3030,7 @@ void SwDoc::SetTabRows( const SwTabCols &rNew, BOOL bCurColOnly, const SwCursor* } } - EndUndo( UNDO_TABLE_ATTR, NULL ); + GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_ATTR, NULL ); ::ClearFEShellTabCols(); } @@ -3023,10 +3041,10 @@ void SwDoc::SetTabRows( const SwTabCols &rNew, BOOL bCurColOnly, const SwCursor* void SwDoc::SetTabCols(SwTable& rTab, const SwTabCols &rNew, const SwTabCols &rOld, const SwTableBox *pStart, BOOL bCurRowOnly ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *rTab.GetTableNode(), TRUE )); + GetIDocumentUndoRedo().AppendUndo( + new SwUndoAttrTbl( *rTab.GetTableNode(), TRUE )); } rTab.SetTabCols( rNew, rOld, pStart, bCurRowOnly ); ::ClearFEShellTabCols(); @@ -3038,10 +3056,10 @@ void SwDoc::SetRowsToRepeat( SwTable &rTable, USHORT nSet ) if( nSet == rTable.GetRowsToRepeat() ) return; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoTblHeadline( rTable, rTable.GetRowsToRepeat() , nSet) ); + GetIDocumentUndoRedo().AppendUndo( + new SwUndoTblHeadline(rTable, rTable.GetRowsToRepeat(), nSet) ); } SwMsgPoolItem aChg( RES_TBLHEADLINECHG ); @@ -3249,8 +3267,10 @@ BOOL SwDoc::SplitTable( const SwPosition& rPos, USHORT eHdlnMode, SwTableFmlUpdate aMsgHnt( &rTbl ); SwHistory aHistory; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) + { aMsgHnt.pHistory = &aHistory; + } { ULONG nSttIdx = pNd->FindTableBoxStartNode()->GetIndex(); @@ -3287,10 +3307,11 @@ BOOL SwDoc::SplitTable( const SwPosition& rPos, USHORT eHdlnMode, { SwSaveRowSpan* pSaveRowSp = pNew->GetTable().CleanUpTopRowSpan( rTbl.GetTabLines().Count() ); SwUndoSplitTbl* pUndo = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( pUndo = new SwUndoSplitTbl( *pNew, pSaveRowSp, eHdlnMode, bCalcNewSize )); + pUndo = new SwUndoSplitTbl( + *pNew, pSaveRowSp, eHdlnMode, bCalcNewSize); + GetIDocumentUndoRedo().AppendUndo(pUndo); if( aHistory.Count() ) pUndo->SaveFormula( aHistory ); } @@ -3612,11 +3633,10 @@ BOOL SwDoc::MergeTable( const SwPosition& rPos, BOOL bWithPrev, USHORT nMode ) // beide Tabellen vorhanden, also kanns losgehen SwUndoMergeTbl* pUndo = 0; SwHistory* pHistory = 0; - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( pUndo = new SwUndoMergeTbl( *pTblNd, *pDelTblNd, - bWithPrev, nMode )); + pUndo = new SwUndoMergeTbl( *pTblNd, *pDelTblNd, bWithPrev, nMode ); + GetIDocumentUndoRedo().AppendUndo(pUndo); pHistory = new SwHistory; } @@ -3873,11 +3893,12 @@ BOOL SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNe // Undo abschalten, Attribute werden sich vorher gemerkt SwUndoTblAutoFmt* pUndo = 0; - if( DoesUndo() ) + bool const bUndo(GetIDocumentUndoRedo().DoesUndo()); + if (bUndo) { - ClearRedo(); - AppendUndo( pUndo = new SwUndoTblAutoFmt( *pTblNd, rNew ) ); - DoUndo( FALSE ); + pUndo = new SwUndoTblAutoFmt( *pTblNd, rNew ); + GetIDocumentUndoRedo().AppendUndo(pUndo); + GetIDocumentUndoRedo().DoUndo(false); } _SetAFmtTabPara aPara( rNew ); @@ -3909,7 +3930,9 @@ BOOL SwDoc::SetTableAutoFmt( const SwSelBoxes& rBoxes, const SwTableAutoFmt& rNe } if( pUndo ) - DoUndo( TRUE ); + { + GetIDocumentUndoRedo().DoUndo(bUndo); + } SetModified(); SetFieldsDirty( true, NULL, 0 ); @@ -4062,6 +4085,7 @@ BOOL SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, USHORT eType, aMsgHnt.eFlags = TBL_BOXPTR; UpdateTblFlds( &aMsgHnt ); + bool const bUndo(GetIDocumentUndoRedo().DoesUndo()); BOOL bRet = FALSE; switch( eType & 0xff ) { @@ -4072,7 +4096,7 @@ BOOL SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, USHORT eType, { bRet = pTblNd->GetTable().SetColWidth( rAktBox, eType, nAbsDiff, nRelDiff, - DoesUndo() ? &pUndo : 0 ); + (bUndo) ? &pUndo : 0 ); } break; case nsTblChgWidthHeightType::WH_ROW_TOP: @@ -4081,15 +4105,14 @@ BOOL SwDoc::SetColRowWidthHeight( SwTableBox& rAktBox, USHORT eType, case nsTblChgWidthHeightType::WH_CELL_BOTTOM: bRet = pTblNd->GetTable().SetRowHeight( rAktBox, eType, nAbsDiff, nRelDiff, - DoesUndo() ? &pUndo : 0 ); + (bUndo) ? &pUndo : 0 ); break; } + GetIDocumentUndoRedo().DoUndo(bUndo); // SetColWidth can turn it off if( pUndo ) { - ClearRedo(); - AppendUndo( pUndo ); - DoUndo( TRUE ); // im SetColWidth kann es abgeschaltet werden! + GetIDocumentUndoRedo().AppendUndo( pUndo ); } if( bRet ) @@ -4123,9 +4146,9 @@ void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, BOOL bCallUpdate ) bChgd = FALSE; else { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - StartUndo( UNDO_TABLE_AUTOFMT, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_AUTOFMT, NULL ); pUndo = new SwUndoTblNumFmt( rBox ); pUndo->SetNumFmt( nFmtIdx, fNumber ); } @@ -4198,9 +4221,9 @@ void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, BOOL bCallUpdate ) SFX_ITEM_SET == pBoxFmt->GetItemState( RES_BOXATR_VALUE, FALSE, &pValueItem )) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - StartUndo( UNDO_TABLE_AUTOFMT, NULL ); + GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_AUTOFMT, NULL ); pUndo = new SwUndoTblNumFmt( rBox ); } @@ -4231,8 +4254,8 @@ void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, BOOL bCallUpdate ) if( pUndo ) { pUndo->SetBox( rBox ); - AppendUndo( pUndo ); - EndUndo( UNDO_END, NULL ); + GetIDocumentUndoRedo().AppendUndo(pUndo); + GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } const SwTableNode* pTblNd = rBox.GetSttNd()->FindTableNode(); @@ -4252,10 +4275,9 @@ void SwDoc::ChkBoxNumFmt( SwTableBox& rBox, BOOL bCallUpdate ) void SwDoc::SetTblBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoTblNumFmt( rBox, &rSet ) ); + GetIDocumentUndoRedo().AppendUndo( new SwUndoTblNumFmt(rBox, &rSet) ); } SwFrmFmt* pBoxFmt = rBox.ClaimFrmFmt(); @@ -4278,7 +4300,7 @@ void SwDoc::SetTblBoxFormulaAttrs( SwTableBox& rBox, const SfxItemSet& rSet ) void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode ) { SwStartNode* pSttNd; - if( 0 != ( pSttNd = GetNodes()[ rNode ]-> + if( 0 != ( pSttNd = rNode.GetNode(). FindSttNodeByType( SwTableBoxStartNode )) && 2 == pSttNd->EndOfSectionIndex() - pSttNd->GetIndex() ) { @@ -4291,10 +4313,9 @@ void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode ) SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMULA, FALSE ) || SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_VALUE, FALSE )) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoTblNumFmt( *pBox ) ); + GetIDocumentUndoRedo().AppendUndo(new SwUndoTblNumFmt(*pBox)); } SwFrmFmt* pBoxFmt = pBox->ClaimFrmFmt(); @@ -4331,32 +4352,38 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, ? pCpyTbl->GetTableNode() : rBoxes[ 0 ]->GetSttNd()->FindTableNode(); - SwTableNode* pInsTblNd = GetNodes()[ rInsPos.nNode ]->FindTableNode(); + SwTableNode * pInsTblNd = rInsPos.nNode.GetNode().FindTableNode(); + bool const bUndo( GetIDocumentUndoRedo().DoesUndo() ); if( !pCpyTbl && !pInsTblNd ) { SwUndoCpyTbl* pUndo = 0; - if( DoesUndo() ) + if (bUndo) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndo = new SwUndoCpyTbl; - DoUndo( FALSE ); } - bRet = pSrcTblNd->GetTable().MakeCopy( this, rInsPos, rBoxes, + { + ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); + bRet = pSrcTblNd->GetTable().MakeCopy( this, rInsPos, rBoxes, TRUE, bCpyName ); + } + if( pUndo ) { if( !bRet ) + { delete pUndo; + pUndo = 0; + } else { pInsTblNd = GetNodes()[ rInsPos.nNode.GetIndex() - 1 ]->FindTableNode(); pUndo->SetTableSttIdx( pInsTblNd->GetIndex() ); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } - DoUndo( TRUE ); } } else @@ -4368,15 +4395,14 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, nsRedlineMode_t::REDLINE_SHOW_DELETE)); SwUndoTblCpyTbl* pUndo = 0; - if( DoesUndo() ) + if (bUndo) { - ClearRedo(); + GetIDocumentUndoRedo().ClearRedo(); pUndo = new SwUndoTblCpyTbl; - DoUndo( FALSE ); + GetIDocumentUndoRedo().DoUndo(false); } SwDoc* pCpyDoc = (SwDoc*)pSrcTblNd->GetDoc(); - SfxObjectShellRef* pRefForDocSh = 0; BOOL bDelCpyDoc = pCpyDoc == this; if( bDelCpyDoc ) @@ -4384,27 +4410,23 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, // kopiere die Tabelle erstmal in ein temp. Doc pCpyDoc = new SwDoc; pCpyDoc->acquire(); - pRefForDocSh = new SfxObjectShellRef(); - pCpyDoc->SetRefForDocShell( pRefForDocSh ); SwPosition aPos( SwNodeIndex( pCpyDoc->GetNodes().GetEndOfContent() )); if( !pSrcTblNd->GetTable().MakeCopy( pCpyDoc, aPos, rBoxes, TRUE, TRUE )) { - delete pRefForDocSh; if( pCpyDoc->release() == 0 ) delete pCpyDoc; if( pUndo ) { - DoUndo( TRUE ); + GetIDocumentUndoRedo().DoUndo(bUndo); delete pUndo; + pUndo = 0; } return FALSE; } aPos.nNode -= 1; // auf den EndNode der Tabelle pSrcTblNd = aPos.nNode.GetNode().FindTableNode(); - - pCpyDoc->SetRefForDocShell( NULL ); } const SwStartNode* pSttNd = rInsPos.nNode.GetNode().FindTableBoxStartNode(); @@ -4443,7 +4465,6 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, if( bDelCpyDoc ) { - delete pRefForDocSh; if( pCpyDoc->release() == 0 ) delete pCpyDoc; } @@ -4452,11 +4473,13 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, { // falls die Tabelle nicht kopiert werden konnte, das Undo-Object // wieder loeschen + GetIDocumentUndoRedo().DoUndo(bUndo); if( !bRet && pUndo->IsEmpty() ) delete pUndo; else - AppendUndo( pUndo ); - DoUndo( TRUE ); + { + GetIDocumentUndoRedo().AppendUndo(pUndo); + } } if( bCorrPos ) @@ -4480,8 +4503,9 @@ BOOL SwDoc::InsCopyOfTbl( SwPosition& rInsPos, const SwSelBoxes& rBoxes, BOOL SwDoc::_UnProtectTblCells( SwTable& rTbl ) { BOOL bChgd = FALSE; - SwUndoAttrTbl* pUndo = DoesUndo() ? new SwUndoAttrTbl( *rTbl.GetTableNode() ) - : 0; + SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) + ? new SwUndoAttrTbl( *rTbl.GetTableNode() ) + : 0; SwTableSortBoxes& rSrtBox = rTbl.GetTabSortBoxes(); for( USHORT i = rSrtBox.Count(); i; ) @@ -4498,8 +4522,7 @@ BOOL SwDoc::_UnProtectTblCells( SwTable& rTbl ) { if( bChgd ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -4527,7 +4550,7 @@ BOOL SwDoc::UnProtectCells( const SwSelBoxes& rBoxes ) BOOL bChgd = FALSE; if( rBoxes.Count() ) { - SwUndoAttrTbl* pUndo = DoesUndo() + SwUndoAttrTbl *const pUndo = (GetIDocumentUndoRedo().DoesUndo()) ? new SwUndoAttrTbl( *rBoxes[0]->GetSttNd()->FindTableNode() ) : 0; @@ -4556,8 +4579,7 @@ BOOL SwDoc::UnProtectCells( const SwSelBoxes& rBoxes ) { if( bChgd ) { - ClearRedo(); - AppendUndo( pUndo ); + GetIDocumentUndoRedo().AppendUndo( pUndo ); } else delete pUndo; @@ -4568,7 +4590,7 @@ BOOL SwDoc::UnProtectCells( const SwSelBoxes& rBoxes ) BOOL SwDoc::UnProtectTbls( const SwPaM& rPam ) { - StartUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); BOOL bChgd = FALSE, bHasSel = rPam.HasMark() || rPam.GetNext() != (SwPaM*)&rPam; @@ -4602,7 +4624,7 @@ BOOL SwDoc::UnProtectTbls( const SwPaM& rPam ) bChgd |= _UnProtectTblCells( *pTbl ); } - EndUndo(UNDO_EMPTY, NULL); + GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); if( bChgd ) SetModified(); diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx index c561f10d0a3f..fea3d66c3ea9 100644 --- a/sw/source/core/docnode/ndtbl1.cxx +++ b/sw/source/core/docnode/ndtbl1.cxx @@ -29,10 +29,6 @@ #include "precompiled_sw.hxx" -#ifdef WTC -#define private public -#endif - #include "hintids.hxx" #include <editeng/lrspitem.hxx> #include <editeng/boxitem.hxx> @@ -49,7 +45,8 @@ #include <cntfrm.hxx> #include <txtfrm.hxx> #include <svx/svxids.hrc> -#include "doc.hxx" +#include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include "pam.hxx" #include "swcrsr.hxx" #include "viscrs.hxx" @@ -59,7 +56,8 @@ #include "swtblfmt.hxx" #include "docary.hxx" #include "ndindex.hxx" -#include "undobj.hxx" +#include <UndoTable.hxx> + using namespace ::com::sun::star; @@ -337,10 +335,9 @@ void SwDoc::SetRowSplit( const SwCursor& rCursor, const SwFmtRowSplit &rNew ) if( aRowArr.Count() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd)); } SvPtrarr aFmtCmp( Max( BYTE(255), BYTE(aRowArr.Count()) ), 255 ); @@ -398,10 +395,9 @@ void SwDoc::SetRowHeight( const SwCursor& rCursor, const SwFmtFrmSize &rNew ) if( aRowArr.Count() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd)); } SvPtrarr aFmtCmp( Max( BYTE(255), BYTE(aRowArr.Count()) ), 255 ); @@ -472,10 +468,10 @@ BOOL SwDoc::BalanceRowHeight( const SwCursor& rCursor, BOOL bTstOnly ) } SwFmtFrmSize aNew( ATT_MIN_SIZE, 0, nHeight ); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo( + new SwUndoAttrTbl(*pTblNd)); } SvPtrarr aFmtCmp( Max( BYTE(255), BYTE(aRowArr.Count()) ), 255 ); @@ -504,10 +500,9 @@ void SwDoc::SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew if( aRowArr.Count() ) { - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd)); } SvPtrarr aFmtCmp( Max( BYTE(255), BYTE(aRowArr.Count()) ), 255 ); @@ -600,10 +595,9 @@ void SwDoc::SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet ) if( aUnions.Count() ) { SwTable& rTable = pTblNd->GetTable(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) ); } SvPtrarr aFmtCmp( 255, 255 ); @@ -849,10 +843,9 @@ void SwDoc::SetTabLineStyle( const SwCursor& rCursor, if( aUnions.Count() ) { SwTable& rTable = pTblNd->GetTable(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd)); } for( USHORT i = 0; i < aUnions.Count(); ++i ) @@ -1132,10 +1125,9 @@ void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew ) if( pTblNd && ::lcl_GetBoxSel( rCursor, aBoxes, TRUE ) ) { SwTable& rTable = pTblNd->GetTable(); - if( DoesUndo() ) + if (GetIDocumentUndoRedo().DoesUndo()) { - ClearRedo(); - AppendUndo( new SwUndoAttrTbl( *pTblNd )); + GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) ); } SvPtrarr aFmtCmp( Max( BYTE(255), BYTE(aBoxes.Count()) ), 255 ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 1d387df76063..efe7d8177ca6 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -29,8 +29,10 @@ #include "precompiled_sw.hxx" #include <stdlib.h> + #include <node.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <txtfld.hxx> #include <fmtfld.hxx> @@ -226,9 +228,12 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, } else { - int bSavePersData = GetDoc()->GetUndoNds() == &rNds; - int bRestPersData = GetDoc()->GetUndoNds() == this; + bool bSavePersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNds)); + bool bRestPersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)); SwDoc* pDestDoc = rNds.GetDoc() != GetDoc() ? rNds.GetDoc() : 0; + OSL_ENSURE(!pDestDoc, "SwNodes::ChgNode(): " + "the code to handle text fields here looks broken\n" + "if the target is in a different document."); if( !bRestPersData && !bSavePersData && pDestDoc ) bSavePersData = bRestPersData = TRUE; @@ -305,7 +310,9 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, // Sonderbehandlung fuer die Felder! if( pHts && pHts->Count() ) { - int bToUndo = &pDestDoc->GetNodes() != &rNds; + // this looks fishy if pDestDoc != 0 + bool const bToUndo = !pDestDoc && + GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNds); for( USHORT i = pHts->Count(); i; ) { USHORT nDelMsg = 0; @@ -658,7 +665,8 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, } } - if( GetDoc()->GetUndoNds() == &rNodes ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes( + rNodes)) { SwFrmFmt* pTblFmt = pTblNd->GetTable().GetFrmFmt(); SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, @@ -695,8 +703,8 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, // noch den EndNode erzeugen new SwEndNode( aIdx, *pTmp ); } - else if( (const SwNodes*)&rNodes == - GetDoc()->GetUndoNds() ) + else if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes( + rNodes)) { // im UndoNodes-Array spendieren wir einen // Platzhalter @@ -762,7 +770,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, case ND_SECTIONNODE: if( !nLevel && - ( (const SwNodes*)&rNodes == GetDoc()->GetUndoNds() ) ) + GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNodes)) { // dann muss an der akt. InsPos ein SectionDummyNode // eingefuegt werden @@ -889,7 +897,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, break; case ND_SECTIONDUMMY: - if( (const SwNodes*)this == GetDoc()->GetUndoNds() ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)) { if( &rNodes == this ) // innerhalb vom UndoNodesArray { @@ -1461,8 +1469,7 @@ USHORT SwNodes::GetSectionLevel(const SwNodeIndex &rIdx) const { * Keine Rekursion! - hier wird das SwNode::GetSectionLevel * aufgerufen */ - return (*this)[rIdx]->GetSectionLevel(); - + return rIdx.GetNode().GetSectionLevel(); } void SwNodes::GoStartOfSection(SwNodeIndex *pIdx) const @@ -1790,8 +1797,8 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) SwNodeIndex aEndIdx( pEnd->nNode ); SwNodeIndex aSttIdx( pStt->nNode ); - SwTxtNode* const pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); - SwTxtNode* pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); + SwTxtNode *const pSrcNd = aSttIdx.GetNode().GetTxtNode(); + SwTxtNode * pDestNd = rPos.nNode.GetNode().GetTxtNode(); BOOL bSplitDestNd = TRUE; BOOL bCopyCollFmt = pDestNd && !pDestNd->GetTxt().Len(); @@ -1841,10 +1848,8 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) if( rNodes.IsDocNodes() ) { SwDoc* const pInsDoc = pDestNd->GetDoc(); - const bool bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( false ); + ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo()); pInsDoc->SplitNode( rPos, false ); - pInsDoc->DoUndo( bIsUndo ); } else { @@ -1872,10 +1877,8 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) if( bCopyCollFmt ) { SwDoc* const pInsDoc = pDestNd->GetDoc(); - const bool bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( false ); + ::sw::UndoGuard const undoGuard(pInsDoc->GetIDocumentUndoRedo()); pSrcNd->CopyCollFmt( *pDestNd ); - pInsDoc->DoUndo( bIsUndo ); bCopyCollFmt = FALSE; } @@ -1911,10 +1914,8 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) if( rNodes.IsDocNodes() ) { SwDoc* const pInsDoc = pDestNd->GetDoc(); - const bool bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( false ); + ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo()); pInsDoc->SplitNode( rPos, false ); - pInsDoc->DoUndo( bIsUndo ); } else { @@ -1933,7 +1934,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) bSplitDestNd = TRUE; } - SwTxtNode* const pEndSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); + SwTxtNode* const pEndSrcNd = aEndIdx.GetNode().GetTxtNode(); if ( pEndSrcNd ) { { @@ -1952,7 +1953,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) } else { - pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); + pDestNd = rPos.nNode.GetNode().GetTxtNode(); } if( pDestNd && pEnd->nContent.GetIndex() ) @@ -1966,10 +1967,8 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) if( bCopyCollFmt ) { SwDoc* const pInsDoc = pDestNd->GetDoc(); - const bool bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( false ); + ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo()); pEndSrcNd->CopyCollFmt( *pDestNd ); - pInsDoc->DoUndo( bIsUndo ); } } } @@ -2009,7 +2008,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) ASSERT( bSuccess, "Move() - no ContentNode here" ); (void) bSuccess; } - pStt->nContent.Assign( (*this)[ pStt->nNode ]->GetCntntNode(), + pStt->nContent.Assign( pStt->nNode.GetNode().GetCntntNode(), pStt->nContent.GetIndex() ); // der PaM wird korrigiert, denn falls ueber Nodegrenzen verschoben // wurde, so stehen sie in unterschielichen Nodes. Auch die Selektion @@ -2054,7 +2053,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange, SwNodeRange aRg( rRange ); // "einfache" StartNodes oder EndNodes ueberspringen - while( ND_STARTNODE == (pAktNode = (*this)[ aRg.aStart ])->GetNodeType() + while( ND_STARTNODE == (pAktNode = & aRg.aStart.GetNode())->GetNodeType() || ( pAktNode->IsEndNode() && !pAktNode->pStartOfSection->IsSectionNode() ) ) aRg.aStart++; @@ -2066,7 +2065,7 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange, // special section nodes and then one before the first. if (aRg.aEnd.GetNode().StartOfSectionIndex() != 0) { - while( (( pAktNode = (*this)[ aRg.aEnd ])->GetStartNode() && + while( ((pAktNode = & aRg.aEnd.GetNode())->GetStartNode() && !pAktNode->IsSectionNode() ) || ( pAktNode->IsEndNode() && ND_STARTNODE == pAktNode->pStartOfSection->GetNodeType()) ) @@ -2214,12 +2213,12 @@ void SwNodes::_CopyNodes( const SwNodeRange& rRange, break; case ND_SECTIONDUMMY: - if( (const SwNodes*)this == GetDoc()->GetUndoNds() ) + if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this)) { // dann muss an der akt. InsPos auch ein SectionNode // (Start/Ende) stehen; dann diesen ueberspringen. // Andernfalls nicht weiter beachten. - SwNode* pTmpNd = pDoc->GetNodes()[ aInsPos ]; + SwNode *const pTmpNd = & aInsPos.GetNode(); if( pTmpNd->IsSectionNode() || pTmpNd->StartOfSectionNode()->IsSectionNode() ) aInsPos++; // ueberspringen @@ -2294,7 +2293,8 @@ SwCntntNode* SwNodes::GoNextSection( SwNodeIndex * pIdx, const SwNode* pNd; while( aTmp < Count() - 1 ) { - if( ND_SECTIONNODE == ( pNd = (*this)[aTmp])->GetNodeType() ) + pNd = & aTmp.GetNode(); + if (ND_SECTIONNODE == pNd->GetNodeType()) { const SwSection& rSect = ((SwSectionNode*)pNd)->GetSection(); if( (bSkipHidden && rSect.IsHiddenFlag()) || @@ -2346,7 +2346,8 @@ SwCntntNode* SwNodes::GoPrevSection( SwNodeIndex * pIdx, const SwNode* pNd; while( aTmp > 0 ) { - if( ND_ENDNODE == ( pNd = (*this)[aTmp])->GetNodeType() ) + pNd = & aTmp.GetNode(); + if (ND_ENDNODE == pNd->GetNodeType()) { if( pNd->pStartOfSection->IsSectionNode() ) { diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index 2d54cb88f2e6..bd517ae0b32a 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -28,8 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <stdlib.h> + #include <hintids.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> @@ -46,6 +46,7 @@ #include <fmtpdsc.hxx> #include <errhdl.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <node.hxx> #include <pam.hxx> #include <frmtool.hxx> @@ -274,10 +275,8 @@ SwSection::~SwSection() { // Bug: 28191 - nicht ins Undo aufnehmen, sollte schon vorher // geschehen sein!! - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); pDoc->DelSectionFmt( pFmt ); // und loeschen - pDoc->DoUndo( bUndo ); } } if (m_RefObj.Is()) @@ -1319,9 +1318,10 @@ void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd ) // Der Return-Wert gibt an, was mit der Shell zu geschehen hat: // 0 - Fehler, konnte DocShell nicht finden // 1 - DocShell ist ein existieren Document -// 2 - DocShell wurde neu angelegt, muss also wieder geschlossen werden +// 2 - DocShell wurde neu angelegt, muss also wieder geschlossen werden ( will be assigned to xLockRef additionaly ) int lcl_FindDocShell( SfxObjectShellRef& xDocSh, + SfxObjectShellLock& xLockRef, const String& rFileName, const String& rPasswd, String& rFilter, @@ -1407,7 +1407,9 @@ int lcl_FindDocShell( SfxObjectShellRef& xDocSh, // ohne Filter geht gar nichts pMed->SetFilter( pSfxFlt ); - xDocSh = new SwDocShell( SFX_CREATE_MODE_INTERNAL ); + // if the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure + xLockRef = new SwDocShell( SFX_CREATE_MODE_INTERNAL ); + xDocSh = (SfxObjectShell*)xLockRef; if( xDocSh->DoLoad( pMed ) ) return 2; } @@ -1444,8 +1446,8 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, // <-- // Undo immer abschalten - BOOL bWasUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); + pDoc->GetIDocumentUndoRedo().DoUndo(false); BOOL bWasVisibleLinks = pDoc->IsVisibleLinks(); pDoc->SetVisibleLinks( FALSE ); @@ -1504,6 +1506,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, RedlineMode_t eOldRedlineMode = nsRedlineMode_t::REDLINE_NONE; SfxObjectShellRef xDocSh; + SfxObjectShellLock xLockRef; int nRet; if( !sFileName.Len() ) { @@ -1512,7 +1515,7 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, } else { - nRet = lcl_FindDocShell( xDocSh, sFileName, + nRet = lcl_FindDocShell( xDocSh, xLockRef, sFileName, rSection.GetLinkFilePassword(), sFilter, 0, pDoc->GetDocShell() ); if( nRet ) @@ -1681,9 +1684,9 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, } - // Alle UndoActions entfernen und Undo wieder einschalten - pDoc->DelAllUndoObj(); - pDoc->DoUndo( bWasUndo ); + // remove all undo actions and turn undo on again + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + pDoc->GetIDocumentUndoRedo().DoUndo(bWasUndo); pDoc->SetVisibleLinks( bWasVisibleLinks ); pDoc->UnlockExpFlds(); diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx index cb804b102c0e..4a88ec8df07c 100644 --- a/sw/source/core/docnode/swbaslnk.cxx +++ b/sw/source/core/docnode/swbaslnk.cxx @@ -354,7 +354,7 @@ BOOL SetGrfFlySize( const Size& rGrfSz, const Size& rFrmSz, SwGrfNode* pGrfNd ) SwNode *pANd; SwTableNode *pTblNd; if( pAPos && - 0 != (pANd = pDoc->GetNodes()[pAPos->nNode]) && + 0 != (pANd = & pAPos->nNode.GetNode()) && 0 != (pTblNd = pANd->FindTableNode()) ) { const BOOL bLastGrf = !pTblNd->GetTable().DecGrfsThatResize(); diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 75111933e0ec..56b33730efa2 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -43,6 +43,7 @@ #include "cntfrm.hxx" #include "frmatr.hxx" #include "doc.hxx" +#include <IDocumentUndoRedo.hxx> #include "dview.hxx" #include "dflyobj.hxx" #include "flyfrm.hxx" @@ -884,7 +885,7 @@ void __EXPORT SwVirtFlyDrawObj::Move(const Size& rSiz) { NbcMove( rSiz ); SetChanged(); - GetFmt()->GetDoc()->SetNoDrawUndoObj( TRUE ); + GetFmt()->GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); } @@ -893,7 +894,7 @@ void __EXPORT SwVirtFlyDrawObj::Resize(const Point& rRef, { NbcResize( rRef, xFact, yFact ); SetChanged(); - GetFmt()->GetDoc()->SetNoDrawUndoObj( TRUE ); + GetFmt()->GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); } diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx index 441b474c6b27..2142053586d2 100644 --- a/sw/source/core/draw/dview.cxx +++ b/sw/source/core/draw/dview.cxx @@ -52,6 +52,7 @@ #include <ndole.hxx> #include <fmtanchr.hxx> #include "shellres.hxx" +#include <IDocumentUndoRedo.hxx> // #i7672# #include <editeng/outliner.hxx> @@ -1085,7 +1086,7 @@ void SwDrawView::DeleteMarked() SwDoc* pDoc = Imp().GetShell()->GetDoc(); if ( pDoc->GetRootFrm() ) pDoc->GetRootFrm()->StartAllAction(); - pDoc->StartUndo(UNDO_EMPTY, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); // OD 18.06.2003 #108784# - replace marked <SwDrawVirtObj>-objects by its // reference objects. { @@ -1104,7 +1105,7 @@ void SwDrawView::DeleteMarked() FmFormView::DeleteMarked(); ::FrameNotify( Imp().GetShell(), FLY_DRAG_END ); } - pDoc->EndUndo(UNDO_EMPTY, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); if( pDoc->GetRootFrm() ) pDoc->GetRootFrm()->EndAllAction(); } diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index b7e92570df42..7601afc663b3 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -32,9 +32,7 @@ #define _STD_VAR_ARRAYS #include <hintids.hxx> -#ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> -#endif #include <editeng/langitem.hxx> #include <fmtinfmt.hxx> #include <txtatr.hxx> @@ -96,17 +94,19 @@ void _PaMIntoCrsrShellRing::RemoveFromRing( SwPaM& rPam, Ring* pPrev ) SwAutoCorrDoc::SwAutoCorrDoc( SwEditShell& rEditShell, SwPaM& rPam, sal_Unicode cIns ) - : rEditSh( rEditShell ), rCrsr( rPam ), pIdx( 0 ), - nUndoId( UNDO_EMPTY ), - bUndoIdInitialized( cIns ? false : true ) + : rEditSh( rEditShell ), rCrsr( rPam ), pIdx( 0 ) + , m_nEndUndoCounter(0) + , bUndoIdInitialized( cIns ? false : true ) { } SwAutoCorrDoc::~SwAutoCorrDoc() { - if( UNDO_EMPTY != nUndoId ) - rEditSh.EndUndo( nUndoId ); + for (int i = 0; i < m_nEndUndoCounter; ++i) + { + rEditSh.EndUndo(); + } delete pIdx; } @@ -146,7 +146,10 @@ BOOL SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt ) { bUndoIdInitialized = true; if( 1 == rTxt.Len() ) - rEditSh.StartUndo( nUndoId = UNDO_AUTOCORRECT ); + { + rEditSh.StartUndo( UNDO_AUTOCORRECT ); + ++m_nEndUndoCounter; + } } return TRUE; } @@ -215,7 +218,10 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) { bUndoIdInitialized = true; if( 1 == rTxt.Len() ) - rEditSh.StartUndo( nUndoId = UNDO_AUTOCORRECT ); + { + rEditSh.StartUndo( UNDO_AUTOCORRECT ); + ++m_nEndUndoCounter; + } } } diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 639bab3c10c5..9029f57f75dc 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -36,7 +36,11 @@ #include <hintids.hxx> #include <svl/svstdarr.hxx> + #include <unotools/charclass.hxx> + +#include <vcl/msgbox.hxx> + #include <editeng/boxitem.hxx> #include <editeng/lrspitem.hxx> #include <editeng/brkitem.hxx> @@ -46,12 +50,13 @@ #include <editeng/langitem.hxx> #include <editeng/cscoitem.hxx> #include <editeng/unolingu.hxx> - #include <editeng/acorrcfg.hxx> + #include <swwait.hxx> #include <fmtpdsc.hxx> #include <fmtanchr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <editsh.hxx> #include <index.hxx> @@ -72,13 +77,8 @@ #include <frmatr.hxx> #include <charatr.hxx> #include <mdiexp.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#include <vcl/msgbox.hxx> #include <numrule.hxx> using namespace ::com::sun::star; @@ -2253,7 +2253,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags, pDoc->SetRedlineMode( eRedlMode ); // save undo state (might be turned off) - sal_Bool bUndoState = pDoc->DoesUndo(); + bool const bUndoState = pDoc->GetIDocumentUndoRedo().DoesUndo(); // wenn mehrere Zeilen, dann erstmal nicht mit // dem nachfolgenden Absatz zusammenfassen. @@ -2271,51 +2271,6 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags, eStat = READ_NEXT_PARA; while( !bEnde ) { - // #95884# limit redline array size to prevent overflow and to conserve - // memory - if( pDoc->HasTooManyUndos() ) - { - DBG_ASSERT( bUndoState, "undo overflow without undo?" ); - - //ask user - short nResult = m_nActionWhileAutoformatUndoBufferOverflow; // TODO: #102007# read the last decision of the user from configuration - if(m_bAskForCancelUndoWhileBufferOverflow) // #102007# TODO: read the last decision of the user from configuration - { - Window* pParent = pEditShell?pEditShell->GetWin():NULL; - WarningBox aWarning( pParent,SW_RES(MSG_DISABLE_UNDO_QUESTION)); - aWarning.SetDefaultCheckBoxText(); - USHORT nDefaultButton = nResult==RET_YES?BUTTONID_YES:(nResult==RET_NO?BUTTONID_NO:BUTTONID_CANCEL); - aWarning.SetFocusButton(nDefaultButton); - nResult = aWarning.Execute(); - m_bAskForCancelUndoWhileBufferOverflow = !aWarning.GetCheckBoxState(); - m_nActionWhileAutoformatUndoBufferOverflow = nResult; - // TODO: #102007# store m_bAskForCancelUndoWhileBufferOverflow in configuration - // TODO: #102007# store m_nActionWhileAutoformatUndoBufferOverflow in configuration - } - - DBG_ASSERT( (nResult == RET_YES) || (nResult == RET_CANCEL) || (nResult == RET_NO), - "unexpected result" ); - - if( nResult == RET_YES ) - { - // turn off undo and continue - pDoc->DoUndo( sal_False ); - pDoc->DelAllUndoObj(); - } - else if( nResult == RET_NO ) - { - //stop autoformatting and keep changes - eStat = IS_ENDE; - } - else if( nResult == RET_CANCEL ) - { - //cancel autoformatting and undo changes - eStat = IS_ENDE; - - // TODO: #102004# undo changes - } - } - switch( eStat ) { case READ_NEXT_PARA: @@ -2709,7 +2664,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags, pDoc->SetRedlineMode( eOldMode ); // restore undo (in case it has been changed) - pDoc->DoUndo( bUndoState ); + pDoc->GetIDocumentUndoRedo().DoUndo(bUndoState); // Prozent-Anzeige wieder abschalten if( !aFlags.bAFmtByInput ) diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index 6fda3a164c32..ea923b77a54d 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <editsh.hxx> #include <doc.hxx> // fuer aNodes +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> // fuer SwPaM #include <edimp.hxx> // fuer MACROS #include <swundo.hxx> // fuer die UndoIds @@ -49,7 +49,9 @@ void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs ) StartAllAction(); BOOL bUndoGroup = GetCrsr()->GetNext() != GetCrsr(); if( bUndoGroup ) - GetDoc()->StartUndo(UNDO_RESETATTR, NULL); + { + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_RESETATTR, NULL); + } FOREACHPAM_START(this) // if ( PCURCRSR->HasMark() ) @@ -57,7 +59,9 @@ void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs ) FOREACHPAM_END() if( bUndoGroup ) - GetDoc()->EndUndo(UNDO_RESETATTR, NULL); + { + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_RESETATTR, NULL); + } CallChgLnk(); EndAllAction(); } @@ -71,12 +75,14 @@ void SwEditShell::GCAttr() // Sonst Probleme im MouseBut.DownHdl - Bug 35562 // StartAllAction(); FOREACHPAM_START(this) - SwTxtNode *pTxtNode; if ( !PCURCRSR->HasMark() ) { - if( 0 != (pTxtNode = GetDoc()->GetNodes()[ - PCURCRSR->GetPoint()->nNode]->GetTxtNode())) + SwTxtNode *const pTxtNode = + PCURCRSR->GetPoint()->nNode.GetNode().GetTxtNode(); + if (pTxtNode) + { pTxtNode->GCAttr(); + } } else { @@ -133,7 +139,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn { BOOL bIsTblMode = IsTableMode(); - GetDoc()->StartUndo(UNDO_INSATTR, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL); FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || @@ -143,7 +149,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) } FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_INSATTR, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL); } else { @@ -163,7 +169,7 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) if( pCrsr->GetNext() != pCrsr ) // Ring von Cursorn { BOOL bIsTblMode = IsTableMode(); - GetDoc()->StartUndo(UNDO_INSATTR, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL); FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || @@ -173,7 +179,7 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) } FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_INSATTR, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL); } else { diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index a996ed802a42..ef4362e2a9fd 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -31,6 +31,7 @@ #include <hintids.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <editsh.hxx> #include <cntfrm.hxx> #include <pam.hxx> @@ -39,7 +40,6 @@ #include <IMark.hxx> #include <docary.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> #include <globals.hrc> #include <comcore.hrc> @@ -68,7 +68,7 @@ void SwEditShell::DeleteSel( SwPaM& rPam, BOOL* pUndo ) // in Tabellen das Undo gruppieren if( pUndo && !*pUndo ) { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); *pUndo = TRUE; } SwPaM aDelPam( *rPam.Start() ); @@ -129,7 +129,7 @@ long SwEditShell::Delete() SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, String(SW_RES(STR_MULTISEL))); - GetDoc()->StartUndo( UNDO_DELETE, &aRewriter ); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_DELETE, &aRewriter); } FOREACHPAM_START(this) @@ -138,7 +138,9 @@ long SwEditShell::Delete() // falls eine Undo-Klammerung, dann hier beenden if( bUndo ) - GetDoc()->EndUndo( UNDO_DELETE, NULL ); + { + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); + } EndAllAction(); nRet = 1; } @@ -207,7 +209,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) // For block selection this list is filled with the insert positions std::list< boost::shared_ptr<SwPosition> >::iterator pNextInsert = aInsertList.begin(); - pDestShell->GetDoc()->StartUndo( UNDO_START, NULL ); + pDestShell->GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); FOREACHPAM_START(this) if( !pPos ) @@ -289,7 +291,7 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) #endif // Undo-Klammerung hier beenden - pDestShell->GetDoc()->EndUndo( UNDO_END, NULL ); + pDestShell->GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); pDestShell->EndAllAction(); pDestShell->SaveTblBoxCntnt( pDestShell->GetCrsr()->GetPoint() ); @@ -312,7 +314,7 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) if( !HasReadonlySel() ) { StartAllAction(); - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START(this) if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) @@ -324,7 +326,7 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) FOREACHPAM_END() // Undo-Klammerung hier beenden - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); EndAllAction(); } return bRet; diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index c3dc53f1ba26..fb430aa053ab 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -33,6 +33,7 @@ #include <editeng/brkitem.hxx> #include <editsh.hxx> #include <doc.hxx> // fuer SwTxtFmtColls +#include <IDocumentUndoRedo.hxx> #include <edimp.hxx> // fuer MACROS #include <ndtxt.hxx> #include <paratr.hxx> @@ -41,7 +42,7 @@ #include <viewopt.hxx> // <-- #include <SwRewriter.hxx> -#include <undobj.hxx> +#include <numrule.hxx> #include <swundo.hxx> /************************************* @@ -77,7 +78,7 @@ void SwEditShell::SetTxtFmtColl( SwTxtFmtColl *pFmt, SwRewriter aRewriter; aRewriter.AddRule(UNDO_ARG1, pLocal->GetName()); - GetDoc()->StartUndo(UNDO_SETFMTCOLL, &aRewriter); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_SETFMTCOLL, &aRewriter); FOREACHPAM_START(this) if( !PCURCRSR->HasReadonlySel( @@ -87,7 +88,7 @@ void SwEditShell::SetTxtFmtColl( SwTxtFmtColl *pFmt, GetDoc()->SetTxtFmtColl( *PCURCRSR, pLocal, true, bResetListAttrs ); FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_SETFMTCOLL, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_SETFMTCOLL, &aRewriter); EndAllAction(); } // <-- diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index 6f884f244326..5edee9f0cb83 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -28,8 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <editsh.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -52,7 +52,9 @@ void SwEditShell::SetGlblDocSaveLinks( BOOL bFlag ) { getIDocumentSettingAccess()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bFlag); if( !GetDoc()->IsModified() ) // Bug 57028 - GetDoc()->SetUndoNoResetModified(); + { + GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } GetDoc()->SetModified(); } @@ -163,13 +165,13 @@ BOOL SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos, BOOL bEndUndo = FALSE; SwDoc* pMyDoc = GetDoc(); - SwTxtNode* pTxtNd = pMyDoc->GetNodes()[ rPos.nNode ]->GetTxtNode(); + SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode(); if( pTxtNd ) rPos.nContent.Assign( pTxtNd, 0 ); else { bEndUndo = TRUE; - pMyDoc->StartUndo( UNDO_START, NULL ); + pMyDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); rPos.nNode--; pMyDoc->AppendTxtNode( rPos ); pCrsr->SetMark(); @@ -178,7 +180,9 @@ BOOL SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos, InsertSection( rNew ); if( bEndUndo ) - pMyDoc->EndUndo( UNDO_END, NULL ); + { + pMyDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); + } EndAllAction(); return TRUE; @@ -209,7 +213,7 @@ BOOL SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos, else { bEndUndo = TRUE; - pMyDoc->StartUndo( UNDO_START, NULL ); + pMyDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); rPos.nNode--; pMyDoc->AppendTxtNode( rPos ); } @@ -217,7 +221,9 @@ BOOL SwEditShell::InsertGlobalDocContent( const SwGlblDocContent& rInsPos, InsertTableOf( rTOX ); if( bEndUndo ) - pMyDoc->EndUndo( UNDO_END, NULL ); + { + pMyDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); + } EndAllAction(); return TRUE; @@ -365,7 +371,7 @@ BOOL SwEditShell::GotoGlobalDocContent( const SwGlblDocContent& rPos ) rCrsrPos.nNode = rPos.GetDocPos(); SwDoc* pMyDoc = GetDoc(); - SwCntntNode* pCNd = pMyDoc->GetNodes()[ rCrsrPos.nNode ]->GetCntntNode(); + SwCntntNode * pCNd = rCrsrPos.nNode.GetNode().GetCntntNode(); if( !pCNd ) pCNd = pMyDoc->GetNodes().GoNext( &rCrsrPos.nNode ); diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 7a143a2d29d9..4dbe56523482 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <tools/list.hxx> #include <tools/urlobj.hxx> @@ -41,6 +42,7 @@ #include <frmfmt.hxx> #include <charfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <editsh.hxx> #include <frame.hxx> @@ -201,7 +203,7 @@ void SwEditShell::Overwrite(const String &rStr) long SwEditShell::SplitNode( BOOL bAutoFormat, BOOL bCheckTableStart ) { StartAllAction(); - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START(this) // eine Tabellen Zelle wird jetzt zu einer normalen Textzelle! @@ -209,7 +211,7 @@ long SwEditShell::SplitNode( BOOL bAutoFormat, BOOL bCheckTableStart ) GetDoc()->SplitNode( *PCURCRSR->GetPoint(), bCheckTableStart ); FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); if( bAutoFormat ) AutoFmtBySplitNode(); @@ -227,14 +229,14 @@ sal_Bool SwEditShell::AppendTxtNode() { sal_Bool bRet = sal_False; StartAllAction(); - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START(this) GetDoc()->ClearBoxNumAttrs( PCURCRSR->GetPoint()->nNode ); bRet = GetDoc()->AppendTxtNode( *PCURCRSR->GetPoint()) || bRet; FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); ClearTblBoxCntnt(); @@ -752,7 +754,7 @@ BOOL SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, BOOL if( !rFmt.GetValue().Len() || ( !rStr.Len() && !HasSelection() ) ) return FALSE; StartAllAction(); - GetDoc()->StartUndo( UNDO_UI_INSERT_URLTXT, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_UI_INSERT_URLTXT, NULL); BOOL bInsTxt = TRUE; if( rStr.Len() ) @@ -796,7 +798,7 @@ BOOL SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, BOOL ClearMark(); if( bInsTxt ) DontExpandFmt(); - GetDoc()->EndUndo( UNDO_UI_INSERT_URLTXT, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_UI_INSERT_URLTXT, NULL ); EndAllAction(); return TRUE; } @@ -1169,14 +1171,14 @@ void SwEditShell::TransliterateText( sal_uInt32 nType ) SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) { - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); FOREACHPAM_START( this ) if( PCURCRSR->HasMark() ) GetDoc()->TransliterateText( *PCURCRSR, aTrans ); FOREACHPAM_END() - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); } else GetDoc()->TransliterateText( *pCrsr, aTrans ); diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index c9ab4a591383..24057039e1ef 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -35,9 +35,7 @@ #include <unoflatpara.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <hintids.hxx> #include <linguistic/lngprops.hxx> #include <vcl/msgbox.hxx> @@ -49,6 +47,7 @@ #include <charatr.hxx> #include <editsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <rootfrm.hxx> // SwRootFrm #include <pam.hxx> #include <swundo.hxx> // fuer die UndoIds @@ -57,9 +56,7 @@ #include <viscrs.hxx> // SwShellCrsr #include <SwGrammarMarkUp.hxx> // SwWrongList #include <mdiexp.hxx> // Statusanzeige -#ifndef _STATSTR_HRC #include <statstr.hrc> // StatLine-String -#endif #include <cntfrm.hxx> #include <crsskip.hxx> #include <splargs.hxx> @@ -1334,7 +1331,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // iterate over the new portions, beginning at the end to take advantage of the previously // saved content positions - pDoc->StartUndo( UNDO_OVERWRITE, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_OVERWRITE, NULL ); StartAction(); SwPaM *pCrsr = GetCrsr(); @@ -1463,7 +1460,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // set continuation position for spell/grammar checking to the end of this sentence pSpellIter->SetCurr( new SwPosition( *pCrsr->Start() ) ); - pDoc->EndUndo( UNDO_OVERWRITE, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_OVERWRITE, NULL ); EndAction(); } } diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index ea1088f36f69..f5b2ef0fb2b9 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -33,6 +33,7 @@ #include <editsh.hxx> #include <edimp.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <ndtxt.hxx> #include <paratr.hxx> #include <swundo.hxx> @@ -153,12 +154,12 @@ BOOL SwEditShell::NoNum() SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ? { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) bRet = bRet && GetDoc()->NoNum( aRangeArr.SetPam( n, aPam )); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else bRet = GetDoc()->NoNum( *pCrsr ); @@ -217,14 +218,14 @@ void SwEditShell::DelNumRules() SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ? { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) { GetDoc()->DelNumRules( aRangeArr.SetPam( n, aPam ) ); } - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else GetDoc()->DelNumRules( *pCrsr ); @@ -255,12 +256,12 @@ BOOL SwEditShell::NumUpDown( BOOL bDown ) bRet = GetDoc()->NumUpDown( *pCrsr, bDown ); else { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) bRet = bRet && GetDoc()->NumUpDown( aRangeArr.SetPam( n, aPam ), bDown ); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } GetDoc()->SetModified(); @@ -517,13 +518,13 @@ BOOL SwEditShell::OutlineUpDown( short nOffset ) bRet = GetDoc()->OutlineUpDown( *pCrsr, nOffset ); else { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) bRet = bRet && GetDoc()->OutlineUpDown( aRangeArr.SetPam( n, aPam ), nOffset ); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } GetDoc()->SetModified(); EndAllAction(); @@ -698,10 +699,11 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule, { StartAllAction(); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); + SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ? { - GetDoc()->StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) @@ -715,21 +717,17 @@ void SwEditShell::SetCurNumRule( const SwNumRule& rRule, // <-- GetDoc()->SetCounted( aPam, true ); } - GetDoc()->EndUndo( UNDO_END, NULL ); } else { - GetDoc()->StartUndo( UNDO_START, NULL ); - // --> OD 2008-02-08 #newlistlevelattrs# // --> OD 2008-03-17 #refactorlists# GetDoc()->SetNumRule( *pCrsr, rRule, bCreateNewList, sContinuedListId, sal_True, bResetIndentAttrs ); GetDoc()->SetCounted( *pCrsr, true ); - - GetDoc()->EndUndo( UNDO_END, NULL ); } + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); EndAllAction(); } @@ -761,12 +759,12 @@ void SwEditShell::SetNumRuleStart( BOOL bFlag ) SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ? { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) GetDoc()->SetNumRuleStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), bFlag ); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else GetDoc()->SetNumRuleStart( *pCrsr->GetPoint(), bFlag ); @@ -790,12 +788,12 @@ void SwEditShell::SetNodeNumStart( USHORT nStt ) SwPaM* pCrsr = GetCrsr(); if( pCrsr->GetNext() != pCrsr ) // Mehrfachselektion ? { - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( *pCrsr ); SwPaM aPam( *pCrsr->GetPoint() ); for( USHORT n = 0; n < aRangeArr.Count(); ++n ) GetDoc()->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), nStt ); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else GetDoc()->SetNodeNumStart( *pCrsr->GetPoint(), nStt ); diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index a936002df9a2..4cdf271c50f0 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - -#include <doc.hxx> #include <editsh.hxx> +#include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <docary.hxx> #include <swundo.hxx> // fuer die UndoIds @@ -50,7 +50,7 @@ SwEditShell::InsertSection( if( !IsTableMode() ) { StartAllAction(); - GetDoc()->StartUndo( UNDO_INSSECTION, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL ); FOREACHPAM_START(this) SwSection const*const pNew = @@ -59,8 +59,7 @@ SwEditShell::InsertSection( pRet = pNew; FOREACHPAM_END() - // Undo-Klammerung hier beenden - GetDoc()->EndUndo( UNDO_INSSECTION, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL ); EndAllAction(); } return pRet; diff --git a/sw/source/core/edit/edtab.cxx b/sw/source/core/edit/edtab.cxx index 76a37e4e8627..d363b0ac845a 100644 --- a/sw/source/core/edit/edtab.cxx +++ b/sw/source/core/edit/edtab.cxx @@ -35,9 +35,7 @@ #define _SVSTDARR_ULONGS #include <svl/svstdarr.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <vcl/window.hxx> #include <editeng/boxitem.hxx> #include <swwait.hxx> @@ -45,6 +43,7 @@ #include <frmatr.hxx> #include <editsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <cntfrm.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -259,7 +258,9 @@ void SwEditShell::SetTblChgMode( TblChgMode eMode ) { ((SwTable&)pTblNd->GetTable()).SetTblChgMode( eMode ); if( !GetDoc()->IsModified() ) // Bug 57028 - GetDoc()->SetUndoNoResetModified(); + { + GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } GetDoc()->SetModified(); } } @@ -331,10 +332,10 @@ void SwEditShell::SetTblBoxFormulaAttrs( const SfxItemSet& rSet ) ClearTblBoxCntnt(); StartAllAction(); - GetDoc()->StartUndo( UNDO_START, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); for( USHORT n = 0; n < aBoxes.Count(); ++n ) GetDoc()->SetTblBoxFormulaAttrs( *aBoxes[ n ], rSet ); - GetDoc()->EndUndo( UNDO_END, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); EndAllAction(); } @@ -407,11 +408,11 @@ BOOL SwEditShell::SplitTable( USHORT eMode ) if( pCrsr->GetNode()->FindTableNode() ) { StartAllAction(); - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); bRet = GetDoc()->SplitTable( *pCrsr->GetPoint(), eMode, TRUE ); - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); ClearFEShellTabCols(); EndAllAction(); } @@ -425,11 +426,11 @@ BOOL SwEditShell::MergeTable( BOOL bWithPrev, USHORT nMode ) if( pCrsr->GetNode()->FindTableNode() ) { StartAllAction(); - GetDoc()->StartUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); bRet = GetDoc()->MergeTable( *pCrsr->GetPoint(), bWithPrev, nMode ); - GetDoc()->EndUndo(UNDO_EMPTY, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL); ClearFEShellTabCols(); EndAllAction(); } diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index b1188588fe4d..93c4e0cd10aa 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -27,38 +27,40 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> - #include <tools/urlobj.hxx> -#include <svtools/txtcmp.hxx> -#ifndef SVTOOLS_FSTATHELPER_HXX + #include <svl/fstathelper.hxx> -#endif + +#include <svtools/txtcmp.hxx> + #include <sfx2/docfile.hxx> -#include "editeng/unolingu.hxx" + +#include <xmloff/odffields.hxx> + +#include <editeng/unolingu.hxx> + #include <swtypes.hxx> #include <editsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <viewopt.hxx> #include <ndtxt.hxx> #include <errhdl.hxx> #include <swundo.hxx> -#include <undobj.hxx> #include <txttxmrk.hxx> #include <edimp.hxx> #include <tox.hxx> #include <doctxm.hxx> #include <docary.hxx> #include <mdiexp.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <bookmrk.hxx> -#include <xmloff/odffields.hxx> using namespace ::com::sun::star; @@ -211,7 +213,7 @@ BOOL SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet ) ::StartProgress( STR_STATSTR_TOX_UPDATE, 0, 0, pDocSh ); ::SetProgressText( STR_STATSTR_TOX_UPDATE, pDocSh ); - pMyDoc->StartUndo(UNDO_TOXCHANGE, NULL); + pMyDoc->GetIDocumentUndoRedo().StartUndo(UNDO_TOXCHANGE, NULL); // Verzeichnisrumpf erzeugen pTOX->Update(pSet); @@ -226,7 +228,7 @@ BOOL SwEditShell::UpdateTableOf( const SwTOXBase& rTOX, const SfxItemSet* pSet ) // Seitennummern eintragen pTOX->UpdatePageNum(); - pMyDoc->EndUndo(UNDO_TOXCHANGE, NULL); + pMyDoc->GetIDocumentUndoRedo().EndUndo(UNDO_TOXCHANGE, NULL); ::EndProgress( pDocSh ); EndAllAction(); diff --git a/sw/source/core/edit/edundo.cxx b/sw/source/core/edit/edundo.cxx index a27b09f5d4ff..fb7a2103a5b1 100644 --- a/sw/source/core/edit/edundo.cxx +++ b/sw/source/core/edit/edundo.cxx @@ -28,18 +28,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <svx/svdview.hxx> + #include <editsh.hxx> #include <fesh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <swundo.hxx> #include <dcontact.hxx> #include <flyfrm.hxx> #include <frmfmt.hxx> #include <viewimp.hxx> +#include <docsh.hxx> /** helper function to select all objects in an SdrMarkList; @@ -47,16 +49,64 @@ void lcl_SelectSdrMarkList( SwEditShell* pShell, const SdrMarkList* pSdrMarkList ); +bool SwEditShell::CursorsLocked() const +{ + + return GetDoc()->GetDocShell()->GetModel()->hasControllersLocked(); +} + +void +SwEditShell::HandleUndoRedoContext(::sw::UndoRedoContext & rContext) +{ + // do nothing if somebody has locked controllers! + if (CursorsLocked()) + { + return; + } + + SwFrmFmt * pSelFmt(0); + SdrMarkList * pMarkList(0); + rContext.GetSelections(pSelFmt, pMarkList); + + if (pSelFmt) // select frame + { + if (RES_DRAWFRMFMT == pSelFmt->Which()) + { + SdrObject* pSObj = pSelFmt->FindSdrObject(); + static_cast<SwFEShell*>(this)->SelectObj( + pSObj->GetCurrentBoundRect().Center() ); + } + else + { + Point aPt; + SwFlyFrm *const pFly = + static_cast<SwFlyFrmFmt*>(pSelFmt)->GetFrm(& aPt, false); + if (pFly) + { + static_cast<SwFEShell*>(this)->SelectFlyFrm(*pFly, true); + } + } + } + else if (pMarkList) + { + lcl_SelectSdrMarkList( this, pMarkList ); + } + else if (GetCrsr()->GetNext() != GetCrsr()) + { + // current cursor is the last one: + // go around the ring, to the first cursor + GoNextCrsr(); + } +} -BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt ) +bool SwEditShell::Undo(USHORT const nCount) { SET_CURR_SHELL( this ); // #105332# current undo state was not saved + ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); BOOL bRet = FALSE; - BOOL bSaveDoesUndo = GetDoc()->DoesUndo(); - GetDoc()->DoUndo( FALSE ); StartAllAction(); { // eigentlich muesste ja nur der aktuelle Cursor berarbeitet @@ -69,8 +119,9 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt ) // JP 02.04.98: Cursor merken - beim Auto-Format/-Korrektur // soll dieser wieder an die Position - SwUndoId nLastUndoId = GetDoc()->GetUndoIds(NULL, NULL); - BOOL bRestoreCrsr = 1 == nCnt && ( UNDO_AUTOFORMAT == nLastUndoId || + SwUndoId nLastUndoId(UNDO_EMPTY); + GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId); + bool bRestoreCrsr = 1 == nCount && (UNDO_AUTOFORMAT == nLastUndoId || UNDO_AUTOCORRECT == nLastUndoId ); Push(); @@ -80,51 +131,19 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt ) RedlineMode_t eOld = GetDoc()->GetRedlineMode(); - SwUndoIter aUndoIter( GetCrsr(), nUndoId ); - while( nCnt-- ) - { - do { - - bRet = GetDoc()->Undo( aUndoIter ) || bRet; - - if( !aUndoIter.IsNextUndo() ) - break; - - // es geht weiter, also erzeuge einen neuen Cursor wenn - // der alte schon eine Selection hat - // JP 02.04.98: aber nicht wenns ein Autoformat ist - if( !bRestoreCrsr && HasSelection() ) - { - CreateCrsr(); - aUndoIter.pAktPam = GetCrsr(); - } - } while( TRUE ); - } - - Pop( !bRestoreCrsr ); - - if( aUndoIter.pSelFmt ) // dann erzeuge eine Rahmen-Selection - { - if( RES_DRAWFRMFMT == aUndoIter.pSelFmt->Which() ) + try { + for (USHORT i = 0; i < nCount; ++i) { - SdrObject* pSObj = aUndoIter.pSelFmt->FindSdrObject(); - ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() ); + bRet = GetDoc()->GetIDocumentUndoRedo().Undo() + || bRet; } - else - { - Point aPt; - SwFlyFrm* pFly = ((SwFlyFrmFmt*)aUndoIter.pSelFmt)->GetFrm( - &aPt, FALSE ); - if( pFly ) - ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE ); - } - } - else if( aUndoIter.pMarkList ) - { - lcl_SelectSdrMarkList( this, aUndoIter.pMarkList ); + } catch (::com::sun::star::uno::Exception & e) { + OSL_TRACE("SwEditShell::Undo(): exception caught:\n %s", + ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8) + .getStr()); } - else if( GetCrsr()->GetNext() != GetCrsr() ) // gehe nach einem - GoNextCrsr(); // Undo zur alten Undo-Position !! + + Pop( !bRestoreCrsr ); GetDoc()->SetRedlineMode( eOld ); GetDoc()->CompressRedlines(); @@ -134,21 +153,18 @@ BOOL SwEditShell::Undo( SwUndoId nUndoId, USHORT nCnt ) } EndAllAction(); - // #105332# undo state was not restored but set to FALSE everytime - GetDoc()->DoUndo( bSaveDoesUndo ); return bRet; } -USHORT SwEditShell::Redo( USHORT nCnt ) +bool SwEditShell::Redo(USHORT const nCount) { SET_CURR_SHELL( this ); BOOL bRet = FALSE; // #105332# undo state was not saved - BOOL bSaveDoesUndo = GetDoc()->DoesUndo(); + ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); - GetDoc()->DoUndo( FALSE ); StartAllAction(); { @@ -166,51 +182,17 @@ USHORT SwEditShell::Redo( USHORT nCnt ) RedlineMode_t eOld = GetDoc()->GetRedlineMode(); - SwUndoIter aUndoIter( GetCrsr(), UNDO_EMPTY ); - while( nCnt-- ) - { - do { - - bRet = GetDoc()->Redo( aUndoIter ) || bRet; - - if( !aUndoIter.IsNextUndo() ) - break; - - // es geht weiter, also erzeugen einen neuen Cursor wenn - // der alte schon eine SSelection hat - if( HasSelection() ) - { - CreateCrsr(); - aUndoIter.pAktPam = GetCrsr(); - } - } while( TRUE ); - } - - if( aUndoIter.IsUpdateAttr() ) - UpdateAttr(); - - if( aUndoIter.pSelFmt ) // dann erzeuge eine Rahmen-Selection - { - if( RES_DRAWFRMFMT == aUndoIter.pSelFmt->Which() ) + try { + for (USHORT i = 0; i < nCount; ++i) { - SdrObject* pSObj = aUndoIter.pSelFmt->FindSdrObject(); - ((SwFEShell*)this)->SelectObj( pSObj->GetCurrentBoundRect().Center() ); + bRet = GetDoc()->GetIDocumentUndoRedo().Redo() + || bRet; } - else - { - Point aPt; - SwFlyFrm* pFly = ((SwFlyFrmFmt*)aUndoIter.pSelFmt)->GetFrm( - &aPt, FALSE ); - if( pFly ) - ((SwFEShell*)this)->SelectFlyFrm( *pFly, TRUE ); - } - } - else if( aUndoIter.pMarkList ) - { - lcl_SelectSdrMarkList( this, aUndoIter.pMarkList ); + } catch (::com::sun::star::uno::Exception & e) { + OSL_TRACE("SwEditShell::Redo(): exception caught:\n %s", + ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8) + .getStr()); } - else if( GetCrsr()->GetNext() != GetCrsr() ) // gehe nach einem - GoNextCrsr(); // Redo zur alten Undo-Position !! GetDoc()->SetRedlineMode( eOld ); GetDoc()->CompressRedlines(); @@ -221,41 +203,31 @@ USHORT SwEditShell::Redo( USHORT nCnt ) EndAllAction(); - // #105332# undo state was not restored but set FALSE everytime - GetDoc()->DoUndo( bSaveDoesUndo ); return bRet; } -USHORT SwEditShell::Repeat( USHORT nCount ) +bool SwEditShell::Repeat(USHORT const nCount) { SET_CURR_SHELL( this ); BOOL bRet = FALSE; StartAllAction(); - SwUndoIter aUndoIter( GetCrsr(), UNDO_EMPTY ); - bRet = GetDoc()->Repeat( aUndoIter, nCount ) || bRet; + try { + ::sw::RepeatContext context(*GetDoc(), *GetCrsr()); + bRet = GetDoc()->GetIDocumentUndoRedo().Repeat( context, nCount ) + || bRet; + } catch (::com::sun::star::uno::Exception & e) { + OSL_TRACE("SwEditShell::Repeat(): exception caught:\n %s", + ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8) + .getStr()); + } EndAllAction(); 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/edit/edws.cxx b/sw/source/core/edit/edws.cxx index 81088bcc0e56..1a681ad2cf29 100644 --- a/sw/source/core/edit/edws.cxx +++ b/sw/source/core/edit/edws.cxx @@ -28,12 +28,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - - #include <vcl/window.hxx> + #include <editsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <docary.hxx> #include <acorrect.hxx> @@ -59,7 +58,7 @@ SwEditShell::SwEditShell( SwEditShell& rEdSH, Window *pWindow ) SwEditShell::SwEditShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions ) : SwCrsrShell( rDoc, pWindow, pOptions ) { - GetDoc()->DoUndo(true); + GetDoc()->GetIDocumentUndoRedo().DoUndo(true); } @@ -98,7 +97,7 @@ void SwEditShell::ResetModified() void SwEditShell::SetUndoNoResetModified() { GetDoc()->SetModified(); - GetDoc()->SetUndoNoResetModified(); + GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified(); } /****************************************************************************** @@ -261,24 +260,24 @@ void SwEditShell::InsertTOXType(const SwTOXType& rTyp) void SwEditShell::DoUndo( sal_Bool bOn ) -{ GetDoc()->DoUndo( bOn ); } +{ GetDoc()->GetIDocumentUndoRedo().DoUndo( bOn ); } sal_Bool SwEditShell::DoesUndo() const -{ return GetDoc()->DoesUndo(); } +{ return GetDoc()->GetIDocumentUndoRedo().DoesUndo(); } void SwEditShell::DoGroupUndo( sal_Bool bOn ) -{ GetDoc()->DoGroupUndo( bOn ); } +{ GetDoc()->GetIDocumentUndoRedo().DoGroupUndo( bOn ); } sal_Bool SwEditShell::DoesGroupUndo() const -{ return GetDoc()->DoesGroupUndo(); } +{ return GetDoc()->GetIDocumentUndoRedo().DoesGroupUndo(); } void SwEditShell::DelAllUndoObj() { - GetDoc()->DelAllUndoObj(); + GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); } // Zusammenfassen von Kontinuierlichen Insert/Delete/Overwrite von @@ -289,44 +288,25 @@ void SwEditShell::DelAllUndoObj() SwUndoId SwEditShell::StartUndo( SwUndoId eUndoId, const SwRewriter *pRewriter ) -{ return GetDoc()->StartUndo( eUndoId, pRewriter ); } +{ return GetDoc()->GetIDocumentUndoRedo().StartUndo( eUndoId, pRewriter ); } // schliesst Klammerung der nUndoId, nicht vom UI benutzt SwUndoId SwEditShell::EndUndo(SwUndoId eUndoId, const SwRewriter *pRewriter) -{ return GetDoc()->EndUndo(eUndoId, pRewriter); } - -// liefert die Id der letzten undofaehigen Aktion zurueck -// fuellt ggf. VARARR mit sdbcx::User-UndoIds - - -SwUndoId SwEditShell::GetUndoIds(String* pStr,SwUndoIds *pUndoIds) const -{ return GetDoc()->GetUndoIds(pStr,pUndoIds); } - -String SwEditShell::GetUndoIdsStr(String* pStr,SwUndoIds *pUndoIds) const -{ return GetDoc()->GetUndoIdsStr(pStr,pUndoIds); } - -// liefert die Id der letzten Redofaehigen Aktion zurueck -// fuellt ggf. VARARR mit RedoIds - - -SwUndoId SwEditShell::GetRedoIds(String* pStr,SwUndoIds *pRedoIds) const -{ return GetDoc()->GetRedoIds(pStr,pRedoIds); } - -String SwEditShell::GetRedoIdsStr(String* pStr,SwUndoIds *pRedoIds) const -{ return GetDoc()->GetRedoIdsStr(pStr,pRedoIds); } +{ return GetDoc()->GetIDocumentUndoRedo().EndUndo(eUndoId, pRewriter); } -// liefert die Id der letzten Repeatfaehigen Aktion zurueck -// fuellt ggf. VARARR mit RedoIds +bool SwEditShell::GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const +{ return GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(o_pStr, o_pId); } -SwUndoId SwEditShell::GetRepeatIds(String* pStr, SwUndoIds *pRedoIds) const -{ return GetDoc()->GetRepeatIds(pStr,pRedoIds); } +bool SwEditShell::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const +{ return GetDoc()->GetIDocumentUndoRedo().GetFirstRedoInfo(o_pStr); } -String SwEditShell::GetRepeatIdsStr(String* pStr, SwUndoIds *pRedoIds) const -{ return GetDoc()->GetRepeatIdsStr(pStr,pRedoIds); } +SwUndoId SwEditShell::GetRepeatInfo(::rtl::OUString *const o_pStr) const +{ return GetDoc()->GetIDocumentUndoRedo().GetRepeatInfo(o_pStr); } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index e55c8598cf90..1be00582a586 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -76,10 +76,18 @@ sal_Int16 lcl_SubTypeToAPI(USHORT nSubType) sal_Int16 nRet = 0; switch(nSubType) { - case nsSwGetSetExpType::GSE_EXPR : nRet = SetVariableType::VAR /*0*/; break; - case nsSwGetSetExpType::GSE_SEQ : nRet = SetVariableType::SEQUENCE /*1*/; break; - case nsSwGetSetExpType::GSE_FORMULA : nRet = SetVariableType::FORMULA /*2*/; break; - case nsSwGetSetExpType::GSE_STRING : nRet = SetVariableType::STRING /*3*/; break; + case nsSwGetSetExpType::GSE_EXPR: + nRet = SetVariableType::VAR; // 0 + break; + case nsSwGetSetExpType::GSE_SEQ: + nRet = SetVariableType::SEQUENCE; // 1 + break; + case nsSwGetSetExpType::GSE_FORMULA: + nRet = SetVariableType::FORMULA; // 2 + break; + case nsSwGetSetExpType::GSE_STRING: + nRet = SetVariableType::STRING; // 3 + break; } return nRet; } diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 1af598eb4e46..2957f696905d 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -863,7 +863,7 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark, const ::sw::mark::IMark* pBkmk = ppMark->get(); const SwPosition* pPos = &pBkmk->GetMarkStart(); - pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); + pTxtNd = pPos->nNode.GetNode().GetTxtNode(); *pStt = pPos->nContent.GetIndex(); if(pEnd) { diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx index ccb10ca03ee1..c745538d2013 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -28,16 +28,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <svl/zforlist.hxx> #include <svl/zformat.hxx> -#include <svx/svdmodel.hxx> +#include <svx/svdmodel.hxx> #include <calbck.hxx> #include <calc.hxx> #include <usrfld.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <editsh.hxx> #include <dpage.hxx> #include <unofldmid.h> @@ -302,7 +302,9 @@ void SwUserFieldType::SetContent( const String& rStr, sal_uInt32 nFmt ) sal_Bool bModified = GetDoc()->IsModified(); GetDoc()->SetModified(); if( !bModified ) // Bug 57028 - GetDoc()->SetUndoNoResetModified(); + { + GetDoc()->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } } } diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index 79a2b64433d9..e973b7f64920 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -68,6 +68,7 @@ #include <txtflcnt.hxx> #include <fesh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <rootfrm.hxx> #include <ndtxt.hxx> #include <pam.hxx> @@ -104,7 +105,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) { ASSERT( pClpDoc, "kein Clipboard-Dokument" ); - pClpDoc->DoUndo( FALSE ); // immer auf FALSE !! + pClpDoc->GetIDocumentUndoRedo().DoUndo(false); // always false! // steht noch Inhalt im ClpDocument, dann muss dieser geloescht werden SwNodeIndex aSttIdx( pClpDoc->GetNodes().GetEndOfExtras(), 2 ); @@ -733,7 +734,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) BOOL bRet = TRUE, bDelTbl = TRUE; StartAllAction(); - GetDoc()->StartUndo( UNDO_INSGLOSSARY, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL ); GetDoc()->LockExpFlds(); // When the clipboard content has been created by a rectangular selection @@ -1112,7 +1113,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) FOREACHPAM_END() } - GetDoc()->EndUndo( UNDO_INSGLOSSARY, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL ); // wurden neue Tabellenformeln eingefuegt ? if( pTblFldTyp->GetDepends() ) @@ -1484,7 +1485,7 @@ void SwFEShell::Paste( SvStream& rStrm, USHORT nAction, const Point* pPt ) if( SW_PASTESDR_INSERT == nAction ) { - GetDoc()->SetNoDrawUndoObj( TRUE ); + ::sw::DrawUndoGuard drawUndoGuard(GetDoc()->GetIDocumentUndoRedo()); sal_Bool bDesignMode = pView->IsDesignMode(); if( !bDesignMode ) @@ -1525,7 +1526,6 @@ void SwFEShell::Paste( SvStream& rStrm, USHORT nAction, const Point* pPt ) if( !bDesignMode ) pView->SetDesignMode( sal_False ); } - GetDoc()->SetNoDrawUndoObj( FALSE ); } EndUndo(); EndAllAction(); diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx index fe73c36016a0..d346cecd0e73 100644 --- a/sw/source/core/frmedt/fedesc.cxx +++ b/sw/source/core/frmedt/fedesc.cxx @@ -28,11 +28,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <tools/ref.hxx> #include <hintids.hxx> -#include <tools/ref.hxx> #include <fesh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagefrm.hxx> #include <rootfrm.hxx> #include <cntfrm.hxx> @@ -42,6 +43,7 @@ #include <tabfrm.hxx> #include <edimp.hxx> #include <SwStyleNameMapper.hxx> + /************************************************************************* |* |* SwFEShell::GetPageDescCnt() @@ -144,11 +146,11 @@ void SwFEShell::ChgPageDesc( USHORT i, const SwPageDesc &rChged ) SET_CURR_SHELL( this ); //Fix i64842: because Undo has a very special way to handle header/footer content // we have to copy the page descriptor before calling ChgPageDesc. - const sal_Bool bDoesUndo( GetDoc()->DoesUndo() ); SwPageDesc aDesc( rChged ); - GetDoc()->DoUndo( sal_False ); - GetDoc()->CopyPageDesc(rChged, aDesc); - GetDoc()->DoUndo( bDoesUndo ); + { + ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); + GetDoc()->CopyPageDesc(rChged, aDesc); + } GetDoc()->ChgPageDesc( i, aDesc ); EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index e4d4f2e9b399..231fb022dcb5 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -55,6 +55,7 @@ #include <viewimp.hxx> #include <viscrs.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <dview.hxx> #include <dflyobj.hxx> #include <dcontact.hxx> @@ -707,7 +708,7 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali SwFlyFrmFmt *pRet; if( bMoveCntnt ) { - GetDoc()->StartUndo( UNDO_INSLAYFMT, NULL ); + GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_INSLAYFMT, NULL ); SwFmtAnchor* pOldAnchor = 0; sal_Bool bHOriChgd = sal_False, bVOriChgd = sal_False; SwFmtVertOrient aOldV; @@ -765,9 +766,18 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali // das verschieben von TabelleSelektion ist noch nicht // Undofaehig - also darf das UmAnkern auch nicht // aufgezeichnet werden. - sal_Bool bDoesUndo = GetDoc()->DoesUndo(); - if( bDoesUndo && UNDO_INSLAYFMT == GetDoc()->GetUndoIds(NULL, NULL) ) - GetDoc()->DoUndo( sal_False ); + bool const bDoesUndo = + GetDoc()->GetIDocumentUndoRedo().DoesUndo(); + SwUndoId nLastUndoId(UNDO_EMPTY); + if (bDoesUndo && + GetDoc()->GetIDocumentUndoRedo().GetLastUndoInfo(0, + & nLastUndoId)) + { + if (UNDO_INSLAYFMT == nLastUndoId) + { + GetDoc()->GetIDocumentUndoRedo().DoUndo(false); + } + } ((SfxItemSet&)rSet).Put( *pOldAnchor ); @@ -777,11 +787,11 @@ const SwFrmFmt *SwFEShell::NewFlyFrm( const SfxItemSet& rSet, sal_Bool bAnchVali ((SfxItemSet&)rSet).Put( aOldV ); GetDoc()->SetFlyFrmAttr( *pRet, (SfxItemSet&)rSet ); - GetDoc()->DoUndo( bDoesUndo ); + GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo); } delete pOldAnchor; } - GetDoc()->EndUndo( UNDO_INSLAYFMT, NULL ); + GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_INSLAYFMT, NULL ); } else /* #109161# If called from a shell try to propagate an diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 0f8a61134595..09e5d20dd058 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -71,6 +71,7 @@ #include "pagefrm.hxx" #include "sectfrm.hxx" #include "doc.hxx" +#include <IDocumentUndoRedo.hxx> #include "dview.hxx" #include "dflyobj.hxx" #include "dcontact.hxx" @@ -722,7 +723,7 @@ long SwFEShell::EndDrag( const Point *, BOOL ) pView->EndDragObj(); // JP 18.08.95: DrawUndo-Action auf FlyFrames werden nicht gespeichert // Die Fly aendern das Flag - GetDoc()->SetNoDrawUndoObj( FALSE ); + GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true); ChgAnchor( 0, TRUE ); EndUndo( UNDO_END ); @@ -1623,10 +1624,12 @@ BOOL SwFEShell::EndCreate( UINT16 eSdrCreateCmd ) // das Undo abschalten ASSERT( Imp()->HasDrawView(), "EndCreate without DrawView?" ); if( !Imp()->GetDrawView()->IsGroupEntered() ) - GetDoc()->SetNoDrawUndoObj( TRUE ); + { + GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); + } BOOL bCreate = Imp()->GetDrawView()->EndCreateObj( SdrCreateCmd( eSdrCreateCmd ) ); - GetDoc()->SetNoDrawUndoObj( FALSE ); + GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true); if ( !bCreate ) { @@ -1852,7 +1855,7 @@ BOOL SwFEShell::ImpEndCreate() //Erzeugtes Object wegwerfen, so kann der Fly am elegentesten //ueber vorhandene SS erzeugt werden. - GetDoc()->SetNoDrawUndoObj( TRUE ); // siehe oben + GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(false); // see above // --> OD 2005-08-08 #i52858# - method name changed SdrPage *pPg = getIDocumentDrawModelAccess()->GetOrCreateDrawModel()->GetPage( 0 ); // <-- @@ -1865,7 +1868,7 @@ BOOL SwFEShell::ImpEndCreate() pPg->RecalcObjOrdNums(); SdrObject* pRemovedObject = pPg->RemoveObject( rSdrObj.GetOrdNumDirect() ); SdrObject::Free( pRemovedObject ); - GetDoc()->SetNoDrawUndoObj( FALSE ); + GetDoc()->GetIDocumentUndoRedo().DoDrawUndo(true); SwFlyFrm* pFlyFrm; if( NewFlyFrm( aSet, TRUE ) && diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index ad2e077e5d7c..85b661c9b95f 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -1017,7 +1017,7 @@ BOOL SwFEShell::HasBoxSelection() const pNd->EndOfSectionIndex()) { SwNodeIndex aIdx( *pNd->EndOfSectionNode(), -1 ); - SwCntntNode* pCNd = GetDoc()->GetNodes()[ aIdx ]->GetCntntNode(); + SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode(); if( !pCNd ) { pCNd = GetDoc()->GetNodes().GoPrevious( &aIdx ); @@ -1309,7 +1309,7 @@ BOOL SwFEShell::IsAdjustCellWidthAllowed( BOOL bBalance ) const if ( pCNd->GetTxt().Len() ) return TRUE; ++aIdx; - pCNd = GetDoc()->GetNodes()[ aIdx ]->GetTxtNode(); + pCNd = aIdx.GetNode().GetTxtNode(); } } } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index deefc2205b67..e5cba746a013 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -28,15 +28,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <hintids.hxx> #include <editeng/boxitem.hxx> #include <editeng/protitem.hxx> + +#include <hintids.hxx> #include <fmtanchr.hxx> #include <fmtfsize.hxx> #include <frmatr.hxx> #include <tblsel.hxx> #include <crsrsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pam.hxx> #include <ndtxt.hxx> @@ -50,7 +52,7 @@ #include <rootfrm.hxx> #include <viscrs.hxx> #include <swtblfmt.hxx> -#include <undobj.hxx> +#include <UndoTable.hxx> #include <mvsave.hxx> // OD 26.08.2003 #i18103# #include <sectfrm.hxx> @@ -1449,11 +1451,16 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, SwNodeIndex aSttNdIdx( *rPt.pSelBox->GetSttNd(), 1 ); // ein Node muss in der Box erhalten bleiben (sonst wird beim // Move die gesamte Section geloescht) + bool const bUndo(pDoc->GetIDocumentUndoRedo().DoesUndo()); if( pUndo ) - pDoc->DoUndo( FALSE ); + { + pDoc->GetIDocumentUndoRedo().DoUndo(false); + } pDoc->AppendTxtNode( *aPam.GetPoint() ); if( pUndo ) - pDoc->DoUndo( TRUE ); + { + pDoc->GetIDocumentUndoRedo().DoUndo(bUndo); + } SwNodeRange aRg( aSttNdIdx, aPam.GetPoint()->nNode ); rInsPosNd++; if( pUndo ) diff --git a/sw/inc/SwUndoFmt.hxx b/sw/source/core/inc/SwUndoFmt.hxx index ea23724fa817..d84983bc4011 100644 --- a/sw/inc/SwUndoFmt.hxx +++ b/sw/source/core/inc/SwUndoFmt.hxx @@ -24,11 +24,13 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SW_UNDO_TXT_FMT_COLL_HXX -#define _SW_UNDO_TXT_FMT_COLL_HXX +#ifndef SW_UNDO_TXT_FMT_COLL_HXX +#define SW_UNDO_TXT_FMT_COLL_HXX #include <undobj.hxx> #include <swundo.hxx> +#include <numrule.hxx> + class SwDoc; class SwTxtFmtColl; @@ -53,8 +55,8 @@ public: SwDoc * pDoc); virtual ~SwUndoFmtCreate(); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); virtual SwRewriter GetRewriter() const; @@ -77,8 +79,8 @@ public: SwUndoFmtDelete(SwUndoId nUndoId, SwFmt * pOld, SwDoc * pDoc); ~SwUndoFmtDelete(); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); virtual SwRewriter GetRewriter() const; @@ -100,8 +102,8 @@ public: SwDoc * pDoc); ~SwUndoRenameFmt(); - void Undo(SwUndoIter & rIter); - void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); SwRewriter GetRewriter() const; @@ -213,8 +215,8 @@ class SwUndoNumruleCreate : public SwUndo public: SwUndoNumruleCreate(const SwNumRule * pNew, SwDoc * pDoc); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); SwRewriter GetRewriter() const; }; @@ -227,8 +229,8 @@ class SwUndoNumruleDelete : public SwUndo public: SwUndoNumruleDelete(const SwNumRule & aRule, SwDoc * pDoc); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); SwRewriter GetRewriter() const; }; @@ -242,9 +244,10 @@ class SwUndoNumruleRename : public SwUndo SwUndoNumruleRename(const String & aOldName, const String & aNewName, SwDoc * pDoc); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); SwRewriter GetRewriter() const; }; -#endif // _SW_UNDO_TXT_FMT_COLL_HXX + +#endif // SW_UNDO_TXT_FMT_COLL_HXX diff --git a/sw/inc/SwUndoPageDesc.hxx b/sw/source/core/inc/SwUndoPageDesc.hxx index 84a734b57937..1de717a453d6 100644 --- a/sw/inc/SwUndoPageDesc.hxx +++ b/sw/source/core/inc/SwUndoPageDesc.hxx @@ -24,8 +24,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SW_UNDO_PAGE_DESC_HXX -#define _SW_UNDO_PAGE_DESC_HXX +#ifndef SW_UNDO_PAGE_DESC_HXX +#define SW_UNDO_PAGE_DESC_HXX #include <undobj.hxx> #include <pagedesc.hxx> @@ -48,9 +48,8 @@ public: SwDoc * pDoc); virtual ~SwUndoPageDesc(); - virtual void Undo(SwUndoIter & rIt); - virtual void Redo(SwUndoIter & rIt); - virtual void Repeat(SwUndoIter & rIt); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); virtual SwRewriter GetRewriter() const; }; @@ -61,13 +60,15 @@ class SwUndoPageDescCreate : public SwUndo SwPageDescExt aNew; SwDoc * pDoc; + void DoImpl(); + public: SwUndoPageDescCreate(const SwPageDesc * pNew, SwDoc * pDoc); // #116530# virtual ~SwUndoPageDescCreate(); - virtual void Undo(SwUndoIter & rIt); - virtual void Redo(SwUndoIter & rIt); - virtual void Repeat(SwUndoIter & rIt); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); virtual SwRewriter GetRewriter() const; }; @@ -77,13 +78,15 @@ class SwUndoPageDescDelete : public SwUndo SwPageDescExt aOld; SwDoc * pDoc; + void DoImpl(); + public: SwUndoPageDescDelete(const SwPageDesc & aOld, SwDoc * pDoc); virtual ~SwUndoPageDescDelete(); - virtual void Undo(SwUndoIter & rIt); - virtual void Redo(SwUndoIter & rIt); - virtual void Repeat(SwUndoIter & rIt); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); virtual SwRewriter GetRewriter() const; }; diff --git a/sw/inc/SwUndoTOXChange.hxx b/sw/source/core/inc/SwUndoTOXChange.hxx index 36498fec9643..5fa221b23979 100644 --- a/sw/inc/SwUndoTOXChange.hxx +++ b/sw/source/core/inc/SwUndoTOXChange.hxx @@ -24,8 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _SW_UNDO_TOX_CHANGE_HXX -#define _SW_UNDO_TOX_CHANGE_HXX +#ifndef SW_UNDO_TOX_CHANGE_HXX +#define SW_UNDO_TOX_CHANGE_HXX + #include <undobj.hxx> #include <tox.hxx> @@ -34,14 +35,15 @@ class SwUndoTOXChange : public SwUndo SwTOXBase * pTOX, aOld, aNew; void UpdateTOXBaseSection(); + void DoImpl(); public: SwUndoTOXChange(SwTOXBase * pTOX, const SwTOXBase & rNew); virtual ~SwUndoTOXChange(); - virtual void Undo(SwUndoIter & rIter); - virtual void Redo(SwUndoIter & rIter); - virtual void Repeat(SwUndoIter & rIter); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); }; -#endif //_SW_UNDO_TOX_CHANGE_HXX +#endif // SW_UNDO_TOX_CHANGE_HXX diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx new file mode 100644 index 000000000000..975e37202982 --- /dev/null +++ b/sw/source/core/inc/UndoAttribute.hxx @@ -0,0 +1,288 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_ATTRIBUTE_HXX +#define SW_UNDO_ATTRIBUTE_HXX + +#include <undobj.hxx> + +#include <memory> + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_USHORTS +#define _SVSTDARR_ULONGS +#define _SVSTDARR_BOOLS +#define _SVSTDARR_BYTES +#define _SVSTDARR_USHORTSSORT +#include <svl/svstdarr.hxx> +#endif +#include <svl/itemset.hxx> + +#include <swtypes.hxx> +#include <calbck.hxx> + + +class SvxTabStopItem; +class SwFmt; +class SwFtnInfo; +class SwEndNoteInfo; + + +class SwUndoAttr : public SwUndo, private SwUndRng +{ + SfxItemSet m_AttrSet; // attributes for Redo + const ::std::auto_ptr<SwHistory> m_pHistory; // History for Undo + ::std::auto_ptr<SwRedlineData> m_pRedlineData; // Redlining + ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData; + ULONG m_nNodeIndex; // Offset: for Redlining + const SetAttrMode m_nInsertFlags; // insert flags + + void RemoveIdx( SwDoc& rDoc ); + +public: + SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags ); + SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags ); + + virtual ~SwUndoAttr(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SaveRedlineData( const SwPaM& rPam, BOOL bInsCntnt ); + + SwHistory& GetHistory() { return *m_pHistory; } + +}; + +class SwUndoResetAttr : public SwUndo, private SwUndRng +{ + const ::std::auto_ptr<SwHistory> m_pHistory; + SvUShortsSort m_Ids; + const USHORT m_nFormatId; // Format-Id for Redo + +public: + SwUndoResetAttr( const SwPaM&, USHORT nFmtId ); + SwUndoResetAttr( const SwPosition&, USHORT nFmtId ); + + virtual ~SwUndoResetAttr(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetAttrs( const SvUShortsSort& rArr ); + + SwHistory& GetHistory() { return *m_pHistory; } + +}; + +class SwUndoFmtAttr : public SwUndo +{ + friend class SwUndoDefaultAttr; + SwFmt * m_pFmt; + ::std::auto_ptr<SfxItemSet> m_pOldSet; // old attributes + ULONG m_nNodeIndex; + const USHORT m_nFmtWhich; + const bool m_bSaveDrawPt; + + bool IsFmtInDoc( SwDoc* ); //is the attribute format still in the Doc? + void SaveFlyAnchor( bool bSaveDrawPt = false ); + // --> OD 2004-10-26 #i35443# - Add return value, type <bool>. + // Return value indicates, if anchor attribute is restored. + // Notes: - If anchor attribute is restored, all other existing attributes + // are also restored. + // - Anchor attribute isn't restored successfully, if it contains + // an invalid anchor position and all other existing attributes + // aren't restored. + // This situation occurs for undo of styles. + bool RestoreFlyAnchor(::sw::UndoRedoContext & rContext); + // <-- + // --> OD 2008-02-27 #refactorlists# - removed <rAffectedItemSet> + void Init(); + // <-- + +public: + // register at the Format and save old attributes + // --> OD 2008-02-27 #refactorlists# - removed <rNewSet> + SwUndoFmtAttr( const SfxItemSet& rOldSet, + SwFmt& rFmt, + bool bSaveDrawPt = true ); + // <-- + SwUndoFmtAttr( const SfxPoolItem& rItem, + SwFmt& rFmt, + bool bSaveDrawPt = true ); + + virtual ~SwUndoFmtAttr(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + virtual SwRewriter GetRewriter() const; + + void PutAttr( const SfxPoolItem& rItem ); + SwFmt* GetFmt( SwDoc& rDoc ); // checks if it is still in the Doc! +}; + +// --> OD 2008-02-12 #newlistlevelattrs# +class SwUndoFmtResetAttr : public SwUndo +{ + public: + SwUndoFmtResetAttr( SwFmt& rChangedFormat, + const USHORT nWhichId ); + ~SwUndoFmtResetAttr(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + private: + // format at which a certain attribute is reset. + SwFmt * const m_pChangedFormat; + // which ID of the reset attribute + const USHORT m_nWhichId; + // old attribute which has been reset - needed for undo. + ::std::auto_ptr<SfxPoolItem> m_pOldItem; +}; +// <-- + +class SwUndoDontExpandFmt : public SwUndo +{ + const ULONG m_nNodeIndex; + const xub_StrLen m_nContentIndex; + +public: + SwUndoDontExpandFmt( const SwPosition& rPos ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +// helper class to receive changed attribute sets +class SwUndoFmtAttrHelper : public SwClient +{ + ::std::auto_ptr<SwUndoFmtAttr> m_pUndo; + const bool m_bSaveDrawPt; + +public: + SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSaveDrawPt = true ); + + virtual void Modify( SfxPoolItem*, SfxPoolItem* ); + + SwUndoFmtAttr* GetUndo() const { return m_pUndo.get(); } + // release the undo object (so it is not deleted here), and return it + SwUndoFmtAttr* ReleaseUndo() { return m_pUndo.release(); } +}; + + +class SwUndoMoveLeftMargin : public SwUndo, private SwUndRng +{ + const ::std::auto_ptr<SwHistory> m_pHistory; + const bool m_bModulus; + +public: + SwUndoMoveLeftMargin( const SwPaM&, BOOL bRight, BOOL bModulus ); + + virtual ~SwUndoMoveLeftMargin(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + SwHistory& GetHistory() { return *m_pHistory; } + +}; + + +//-------------------------------------------------------------------- + +class SwUndoDefaultAttr : public SwUndo +{ + ::std::auto_ptr<SfxItemSet> m_pOldSet; // the old attributes + ::std::auto_ptr<SvxTabStopItem> m_pTabStop; + +public: + // registers at the format and saves old attributes + SwUndoDefaultAttr( const SfxItemSet& rOldSet ); + + virtual ~SwUndoDefaultAttr(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + + +//-------------------------------------------------------------------- + +class SwUndoChangeFootNote : public SwUndo, private SwUndRng +{ + const ::std::auto_ptr<SwHistory> m_pHistory; + const String m_Text; + const USHORT m_nNumber; + const bool m_bEndNote; + +public: + SwUndoChangeFootNote( const SwPaM& rRange, const String& rTxt, + USHORT nNum, bool bIsEndNote ); + virtual ~SwUndoChangeFootNote(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + SwHistory& GetHistory() { return *m_pHistory; } +}; + +class SwUndoFootNoteInfo : public SwUndo +{ + ::std::auto_ptr<SwFtnInfo> m_pFootNoteInfo; + +public: + SwUndoFootNoteInfo( const SwFtnInfo &rInfo ); + + virtual ~SwUndoFootNoteInfo(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +class SwUndoEndNoteInfo : public SwUndo +{ + ::std::auto_ptr<SwEndNoteInfo> m_pEndNoteInfo; + +public: + SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo ); + + virtual ~SwUndoEndNoteInfo(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +#endif // SW_UNDO_ATTRIBUTE_HXX + diff --git a/sw/source/core/inc/UndoBookmark.hxx b/sw/source/core/inc/UndoBookmark.hxx new file mode 100644 index 000000000000..87d774d0c43e --- /dev/null +++ b/sw/source/core/inc/UndoBookmark.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_BOOKMARK_HXX +#define SW_UNDO_BOOKMARK_HXX + +#include <undobj.hxx> + + +class SwHistoryBookmark; + +namespace sw { + namespace mark { + class IMark; + } +} + + +class SwUndoBookmark : public SwUndo +{ + const ::std::auto_ptr<SwHistoryBookmark> m_pHistoryBookmark; + +protected: + SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& ); + + void SetInDoc( SwDoc* ); + void ResetInDoc( SwDoc* ); + +public: + virtual ~SwUndoBookmark(); + + // #111827# + /** + Returns the rewriter for this undo object. + + The rewriter contains the following rule: + + $1 -> <name of bookmark> + + <name of bookmark> is the name of the bookmark whose + insertion/deletion is recorded by this undo object. + + @return the rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const; +}; + + +class SwUndoInsBookmark : public SwUndoBookmark +{ +public: + SwUndoInsBookmark( const ::sw::mark::IMark& ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +#endif // SW_UNDO_BOOKMARK_HXX + diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx new file mode 100644 index 000000000000..ce91ef058032 --- /dev/null +++ b/sw/source/core/inc/UndoCore.hxx @@ -0,0 +1,263 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDOCORE_HXX +#define SW_UNDOCORE_HXX + +#include <undobj.hxx> + +#include <calbck.hxx> + + +class SfxItemSet; +class SwFmtColl; +class SwFmtAnchor; +class SdrMarkList; +class SwUndoDelete; +class SwRedlineSaveData; + +namespace sw { + class UndoManager; + class IShellCursorSupplier; +} + + +typedef SwRedlineSaveData* SwRedlineSaveDataPtr; +SV_DECL_PTRARR_DEL( SwRedlineSaveDatas, SwRedlineSaveDataPtr, 8, 8 ) + + +namespace sw { + +class SW_DLLPRIVATE UndoRedoContext + : public SfxUndoContext +{ +public: + UndoRedoContext(SwDoc & rDoc, IShellCursorSupplier & rCursorSupplier) + : m_rDoc(rDoc) + , m_rCursorSupplier(rCursorSupplier) + , m_pSelFmt(0) + , m_pMarkList(0) + { } + + SwDoc & GetDoc() const { return m_rDoc; } + + IShellCursorSupplier & GetCursorSupplier() { return m_rCursorSupplier; } + + void SetSelections(SwFrmFmt *const pSelFmt, SdrMarkList *const pMarkList) + { + m_pSelFmt = pSelFmt; + m_pMarkList = pMarkList; + } + void GetSelections(SwFrmFmt *& o_rpSelFmt, SdrMarkList *& o_rpMarkList) + { + o_rpSelFmt = m_pSelFmt; + o_rpMarkList = m_pMarkList; + } + +private: + SwDoc & m_rDoc; + IShellCursorSupplier & m_rCursorSupplier; + SwFrmFmt * m_pSelFmt; + SdrMarkList * m_pMarkList; +}; + +class SW_DLLPRIVATE RepeatContext + : public SfxRepeatTarget +{ +public: + RepeatContext(SwDoc & rDoc, SwPaM & rPaM) + : m_rDoc(rDoc) + , m_pCurrentPaM(& rPaM) + , m_bDeleteRepeated(false) + { } + + SwDoc & GetDoc() const { return m_rDoc; } + + SwPaM & GetRepeatPaM() + { + return *m_pCurrentPaM; + } + +private: + friend class ::sw::UndoManager; + friend class ::SwUndoDelete; + + SwDoc & m_rDoc; + SwPaM * m_pCurrentPaM; + bool m_bDeleteRepeated; /// has a delete action been repeated? +}; + +} // namespace sw + + + +class SwUndoFmtColl : public SwUndo, private SwUndRng +{ + String aFmtName; + SwHistory* pHistory; + SwFmtColl* pFmtColl; + // --> OD 2008-04-15 #refactorlists# - for correct <ReDo(..)> and <Repeat(..)> + // boolean, which indicates that the attributes are reseted at the nodes + // before the format has been applied. + const bool mbReset; + // boolean, which indicates that the list attributes had been reseted at + // the nodes before the format has been applied. + const bool mbResetListAttrs; + // <-- + + void DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM); + +public: + // --> OD 2008-04-15 #refactorlists# +// SwUndoFmtColl( const SwPaM&, SwFmtColl* ); + SwUndoFmtColl( const SwPaM&, SwFmtColl*, + const bool bReset, + const bool bResetListAttrs ); + // <-- + virtual ~SwUndoFmtColl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + // #111827# + /** + Returns the rewriter for this undo object. + + The rewriter contains one rule: + + $1 -> <name of format collection> + + <name of format collection> is the name of the format + collection that is applied by the action recorded by this undo + object. + + @return the rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const; + + SwHistory* GetHistory() { return pHistory; } + +}; + + +class SwUndoSetFlyFmt : public SwUndo, public SwClient +{ + SwFrmFmt* pFrmFmt; // das gespeicherte FlyFormat + SwFrmFmt* pOldFmt; // die alte Fly Vorlage + SwFrmFmt* pNewFmt; // die neue Fly Vorlage + SfxItemSet* pItemSet; // die zurueck-/ gesetzten Attribute + ULONG nOldNode, nNewNode; + xub_StrLen nOldCntnt, nNewCntnt; + USHORT nOldAnchorTyp, nNewAnchorTyp; + BOOL bAnchorChgd; + + void PutAttr( USHORT nWhich, const SfxPoolItem* pItem ); + void Modify( SfxPoolItem*, SfxPoolItem* ); + void GetAnchor( SwFmtAnchor& rAnhor, ULONG nNode, xub_StrLen nCntnt ); + +public: + SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt ); + virtual ~SwUndoSetFlyFmt(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + virtual SwRewriter GetRewriter() const; +}; + + +//------------ Undo von verschieben/stufen von Gliederung ---------------- + +class SwUndoOutlineLeftRight : public SwUndo, private SwUndRng +{ + short nOffset; +public: + SwUndoOutlineLeftRight( const SwPaM& rPam, short nOffset ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + + +//-------------------------------------------------------------------- + +// -> #111827# +const int nUndoStringLength = 20; + +/** + Shortens a string to a maximum length. + + @param rStr the string to be shortened + @param nLength the maximum length for rStr + @param rFillStr string to replace cut out characters with + + If rStr has less than nLength characters it will be returned unaltered. + + If rStr has more than nLength characters the following algorithm + generates the shortened string: + + frontLength = (nLength - length(rFillStr)) / 2 + rearLength = nLength - length(rFillStr) - frontLength + shortenedString = concat(<first frontLength characters of rStr, + rFillStr, + <last rearLength characters of rStr>) + + Preconditions: + - nLength - length(rFillStr) >= 2 + + @return the shortened string + */ +String +ShortenString(const String & rStr, xub_StrLen nLength, const String & rFillStr); +// <- #111827# + +// #16487# +/** + Denotes special characters in a string. + + The rStr is split into parts containing special characters and + parts not containing special characters. In a part containing + special characters all characters are equal. These parts are + maximal. + + @param rStr the string to denote in + + The resulting string is generated by concatenating the found + parts. The parts without special characters are surrounded by + "'". The parts containing special characters are denoted as "n x", + where n is the length of the part and x is the representation of + the special character (i. e. "tab(s)"). + + @return the denoted string +*/ +String DenoteSpecialCharacters(const String & rStr); + + +#endif // SW_UNDOCORE_HXX + diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx new file mode 100644 index 000000000000..e8be65ef115b --- /dev/null +++ b/sw/source/core/inc/UndoDelete.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_DELETE_HXX +#define SW_UNDO_DELETE_HXX + +#include <undobj.hxx> + +#include <tools/mempool.hxx> + + +class SwRedlineSaveDatas; +class SwTxtNode; + +namespace sfx2 { + class MetadatableUndo; +} + + +class SwUndoDelete + : public SwUndo + , private SwUndRng + , private SwUndoSaveCntnt +{ + SwNodeIndex* pMvStt; // Position of Nodes in UndoNodes-Array + String *pSttStr, *pEndStr; + SwRedlineData* pRedlData; + SwRedlineSaveDatas* pRedlSaveData; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; + + String sTableName; + + ULONG nNode; + ULONG nNdDiff; // difference of Nodes before/after Delete + ULONG nSectDiff; // diff. of Nodes before/after Move w/ SectionNodes + ULONG nReplaceDummy; // diff. to a temporary dummy object + USHORT nSetPos; + + BOOL bGroup : 1; // TRUE: is already Grouped; see CanGrouping() + BOOL bBackSp : 1; // TRUE: if Grouped and preceding content deleted + BOOL bJoinNext: 1; // TRUE: if range is selected forwards + BOOL bTblDelLastNd : 1; // TRUE: TextNode following Table inserted/deleted + BOOL bDelFullPara : 1; // TRUE: entire Nodes were deleted + BOOL bResetPgDesc : 1; // TRUE: reset PgDsc on following node + BOOL bResetPgBrk : 1; // TRUE: reset PgBreak on following node + BOOL bFromTableCopy : 1; // TRUE: called by SwUndoTblCpyTbl + + BOOL SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, + SwTxtNode* pSttTxtNd, SwTxtNode* pEndTxtNd ); +public: + SwUndoDelete( SwPaM&, + BOOL bFullPara = FALSE, BOOL bCalledByTblCpy = FALSE ); + virtual ~SwUndoDelete(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + // #111827# + /** + Returns rewriter for this undo object. + + The rewriter consists of the following rule: + + $1 -> '<deleted text>' + + <deleted text> is shortened to nUndoStringLength characters. + + @return rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const; + + BOOL CanGrouping( SwDoc*, const SwPaM& ); + + void SetTblDelLastNd() { bTblDelLastNd = TRUE; } + + // for PageDesc/PageBreak Attributes of a table + void SetPgBrkFlags( BOOL bPageBreak, BOOL bPageDesc ) + { bResetPgDesc = bPageDesc; bResetPgBrk = bPageBreak; } + + void SetTableName(const String & rName); + + // SwUndoTblCpyTbl needs this information: + BOOL IsDelFullPara() const { return bDelFullPara; } + + DECL_FIXEDMEMPOOL_NEWDEL(SwUndoDelete) +}; + +#endif // SW_UNDO_DELETE_HXX + diff --git a/sw/source/core/inc/UndoDraw.hxx b/sw/source/core/inc/UndoDraw.hxx new file mode 100644 index 000000000000..1407266279fa --- /dev/null +++ b/sw/source/core/inc/UndoDraw.hxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_DRAW_HXX +#define SW_UNDO_DRAW_HXX + +#include <undobj.hxx> + +#include <svx/svdundo.hxx> + + +struct SwUndoGroupObjImpl; +class SdrMark; +class SdrMarkList; +class SdrObject; +class SdrObjGroup; +class SdrUndoAction; +class SwDrawFrmFmt; + + + +//-------------------------------------------------------------------- +// ----------- Undo for Draw Objects --------------------------------- + +class SwSdrUndo : public SwUndo +{ + SdrUndoAction* pSdrUndo; + SdrMarkList* pMarkList; // MarkList for all selected SdrObjects +public: + SwSdrUndo( SdrUndoAction* , const SdrMarkList* pMarkList ); + + virtual ~SwSdrUndo(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + String GetComment() const; +}; + +class SwUndoDrawGroup : public SwUndo +{ + SwUndoGroupObjImpl* pObjArr; + USHORT nSize; + BOOL bDelFmt; + +public: + SwUndoDrawGroup( USHORT nCnt ); + + virtual ~SwUndoDrawGroup(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void AddObj( USHORT nPos, SwDrawFrmFmt*, SdrObject* ); + void SetGroupFmt( SwDrawFrmFmt* ); +}; + +// --> OD 2006-11-01 #130889# +// Action "ungroup drawing object" is now splitted into three parts - see +// method <SwDoc::UnGroupSelection(..)>: +// - creation for <SwDrawFrmFmt> instances for the group members of the +// selected group objects +// - intrinsic ungroup of the selected group objects +// - creation of <SwDrawContact> instances for the former group members and +// connection to the Writer layout. +// Thus, two undo actions (instances of <SwUndo>) are needed: +// - Existing class <SwUndoDrawUnGroup> takes over the part for the formats. +// - New class <SwUndoDrawUnGroupConnectToLayout> takes over the part for +// contact object. +class SwUndoDrawUnGroup : public SwUndo +{ + SwUndoGroupObjImpl* pObjArr; + USHORT nSize; + BOOL bDelFmt; + +public: + SwUndoDrawUnGroup( SdrObjGroup* ); + + virtual ~SwUndoDrawUnGroup(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void AddObj( USHORT nPos, SwDrawFrmFmt* ); +}; + +// --> OD 2006-11-01 #130889# +class SwUndoDrawUnGroupConnectToLayout : public SwUndo +{ + private: + std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > > aDrawFmtsAndObjs; + + public: + SwUndoDrawUnGroupConnectToLayout(); + + virtual ~SwUndoDrawUnGroupConnectToLayout(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void AddFmtAndObj( SwDrawFrmFmt* pDrawFrmFmt, + SdrObject* pDrawObject ); +}; +// <-- + + +class SwUndoDrawDelete : public SwUndo +{ + SwUndoGroupObjImpl* pObjArr; + SdrMarkList* pMarkLst; // MarkList for all selected SdrObjects + USHORT nSize; + BOOL bDelFmt; + +public: + SwUndoDrawDelete( USHORT nCnt ); + + virtual ~SwUndoDrawDelete(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void AddObj( USHORT nPos, SwDrawFrmFmt*, const SdrMark& ); +}; + +#endif // SW_UNDO_DRAW_HXX + diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx new file mode 100644 index 000000000000..085ce702fcb4 --- /dev/null +++ b/sw/source/core/inc/UndoInsert.hxx @@ -0,0 +1,235 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_INSERT_HXX +#define SW_UNDO_INSERT_HXX + +#include <undobj.hxx> + +#include <tools/mempool.hxx> + +#include <swtypes.hxx> +#include <IDocumentContentOperations.hxx> + + +class Graphic; +class SwGrfNode; +class SwUndoDelete; +class SwUndoFmtAttr; + + +class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt +{ + SwPosition *pPos; // Inhalt fuers Redo + String *pTxt, *pUndoTxt; + SwRedlineData* pRedlData; + ULONG nNode; + xub_StrLen nCntnt, nLen; + BOOL bIsWordDelim : 1; + BOOL bIsAppend : 1; + + const IDocumentContentOperations::InsertFlags m_nInsertFlags; + + friend class SwDoc; // eigentlich nur SwDoc::Insert( String ) + BOOL CanGrouping( sal_Unicode cIns ); + BOOL CanGrouping( const SwPosition& rPos ); + + SwDoc * pDoc; + + void Init(const SwNodeIndex & rNode); + String * GetTxtFromDoc() const; + +public: + SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen, + const IDocumentContentOperations::InsertFlags nInsertFlags, + BOOL bWDelim = TRUE ); + SwUndoInsert( const SwNodeIndex& rNode ); + virtual ~SwUndoInsert(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + // #111827# + /** + Returns rewriter for this undo object. + + The returned rewriter has the following rule: + + $1 -> '<inserted text>' + + <inserted text> is shortened to a length of nUndoStringLength. + + @return rewriter for this undo object + */ + virtual SwRewriter GetRewriter() const; + + + DECL_FIXEDMEMPOOL_NEWDEL(SwUndoInsert) +}; + + +//-------------------------------------------------------------------- + +SwRewriter SW_DLLPRIVATE +MakeUndoReplaceRewriter(ULONG const ocurrences, + ::rtl::OUString const& sOld, ::rtl::OUString const& sNew); + +class SwUndoReplace + : public SwUndo +{ +public: + SwUndoReplace(SwPaM const& rPam, + ::rtl::OUString const& rInsert, bool const bRegExp); + + virtual ~SwUndoReplace(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + // #111827# + /** + Returns the rewriter of this undo object. + + If this undo object represents several replacements the + rewriter contains the following rules: + + $1 -> <number of replacements> + $2 -> occurrences of + $3 -> <replaced text> + + If this undo object represents one replacement the rewriter + contains these rules: + + $1 -> <replaced text> + $2 -> "->" (STR_YIELDS) + $3 -> <replacing text> + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const; + + void SetEnd( const SwPaM& rPam ); + +private: + class Impl; + ::std::auto_ptr<Impl> m_pImpl; +}; + + +//-------------------------------------------------------------------- + +class SwUndoReRead : public SwUndo +{ + Graphic *pGrf; + String *pNm, *pFltr; + ULONG nPos; + USHORT nMirr; + + void SaveGraphicData( const SwGrfNode& ); + void SetAndSave( ::sw::UndoRedoContext & ); + +public: + SwUndoReRead( const SwPaM& rPam, const SwGrfNode& pGrfNd ); + + virtual ~SwUndoReRead(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +//-------------------------------------------------------------------- + +class SwUndoInsertLabel : public SwUndo +{ + union { + struct { + // fuer NoTxtFrms + SwUndoInsLayFmt* pUndoFly; + SwUndoFmtAttr* pUndoAttr; + } OBJECT; + struct { + // fuer Tabelle/TextRahmen + SwUndoDelete* pUndoInsNd; + ULONG nNode; + } NODE; + }; + + String sText; + // --> PB 2005-01-06 #i39983# the separator is drawn with a character style + String sSeparator; + // <-- + String sNumberSeparator; + String sCharacterStyle; + // OD 2004-04-15 #i26791# - re-store of drawing object position no longer needed + USHORT nFldId; + SwLabelType eType; + BYTE nLayerId; // fuer Zeichen-Objekte + BOOL bBefore :1; + BOOL bUndoKeep :1; + BOOL bCpyBrd :1; + +public: + SwUndoInsertLabel( const SwLabelType eTyp, const String &rText, + // --> PB 2005-01-06 #i39983# the separator is drawn with a character style + const String& rSeparator, + // <-- + const String& rNumberSeparator, //#i61007# order of captions + const BOOL bBefore, const USHORT nId, + const String& rCharacterStyle, + const BOOL bCpyBrd ); + virtual ~SwUndoInsertLabel(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + // #111827# + /** + Returns the rewriter of this undo object. + + The rewriter contains this rule: + + $1 -> '<text of inserted label>' + + <text of inserted label> is shortened to nUndoStringLength + characters. + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const; + + void SetNodePos( ULONG nNd ) + { if( LTYPE_OBJECT != eType ) NODE.nNode = nNd; } + + void SetUndoKeep() { bUndoKeep = TRUE; } + void SetFlys( SwFrmFmt& rOldFly, SfxItemSet& rChgSet, SwFrmFmt& rNewFly ); + void SetDrawObj( BYTE nLayerId ); +}; + +#endif // SW_UNDO_INSERT_HXX + diff --git a/sw/source/core/inc/UndoManager.hxx b/sw/source/core/inc/UndoManager.hxx new file mode 100644 index 000000000000..0f734d17abfa --- /dev/null +++ b/sw/source/core/inc/UndoManager.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_MANAGER_HXX +#define SW_UNDO_MANAGER_HXX + +#include <IDocumentUndoRedo.hxx> + +#include <memory> + +#include <svl/undo.hxx> + + +class IDocumentDrawModelAccess; +class IDocumentRedlineAccess; +class IDocumentState; + + +namespace sw { + +class UndoManager + : public IDocumentUndoRedo + , public SfxUndoManager +{ +public: + + UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, + IDocumentDrawModelAccess & rDrawModelAccess, + IDocumentRedlineAccess & rRedlineAccess, + IDocumentState & rState); + + /** IDocumentUndoRedo */ + virtual void DoUndo(bool const bDoUndo); + virtual bool DoesUndo() const; + virtual void DoGroupUndo(bool const bDoUndo); + virtual bool DoesGroupUndo() const; + virtual void DoDrawUndo(bool const bDoUndo); + virtual bool DoesDrawUndo() const; + virtual void SetUndoNoModifiedPosition(); + virtual void LockUndoNoModifiedPosition(); + virtual void UnLockUndoNoModifiedPosition(); + virtual void SetUndoNoResetModified(); + virtual bool IsUndoNoResetModified() const; +// virtual bool Undo(); + virtual SwUndoId StartUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter); + virtual SwUndoId EndUndo(SwUndoId const eUndoId, + SwRewriter const*const pRewriter); + virtual void DelAllUndoObj(); + virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, + SwUndoId *const o_pId) const; + virtual SwUndoComments_t GetUndoComments() const; +// virtual bool Redo(); + virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const; + virtual SwUndoComments_t GetRedoComments() const; + virtual bool Repeat(::sw::RepeatContext & rContext, + sal_uInt16 const nRepeatCnt); + virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const; + virtual void AppendUndo(SwUndo *const pUndo); + virtual void ClearRedo(); + virtual bool IsUndoNodes(SwNodes const& rNodes) const; + + // ::svl::IUndoManager + virtual void AddUndoAction(SfxUndoAction *pAction, + sal_Bool bTryMerg = sal_False); + virtual sal_Bool Undo(); + virtual sal_Bool Redo(); + virtual void EnableUndo(bool bEnable); + + SwUndo * RemoveLastUndo(); + SwUndo * GetLastUndo(); + + SwNodes const& GetUndoNodes() const; + SwNodes & GetUndoNodes(); + +private: + IDocumentDrawModelAccess & m_rDrawModelAccess; + IDocumentRedlineAccess & m_rRedlineAccess; + IDocumentState & m_rState; + + /// Undo nodes array: content not currently in document + ::std::auto_ptr<SwNodes> m_pUndoNodes; + + bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled + bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled + bool m_bLockUndoNoModifiedPosition : 1; + /// position in Undo-Array at which Doc was saved (and is not modified) + UndoStackMark m_UndoSaveMark; + + typedef enum { UNDO = true, REDO = false } UndoOrRedo_t; + bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo); + + // UGLY: should not be called + using SfxUndoManager::Repeat; +}; + +} // namespace sw + +#endif // SW_UNDO_MANAGER_HXX + diff --git a/sw/source/core/inc/UndoNumbering.hxx b/sw/source/core/inc/UndoNumbering.hxx new file mode 100644 index 000000000000..462bd7fae31f --- /dev/null +++ b/sw/source/core/inc/UndoNumbering.hxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_NUMBERING_HXX +#define SW_UNDO_NUMBERING_HXX + +#include <undobj.hxx> + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_USHORTS +#define _SVSTDARR_ULONGS +#define _SVSTDARR_BOOLS +#define _SVSTDARR_BYTES +#define _SVSTDARR_USHORTSSORT +#include <svl/svstdarr.hxx> +#endif + +#include <numrule.hxx> + + +//-------------------------------------------------------------------- +//----------- Undo for Numbering ------------------------------------- + +class SwUndoInsNum : public SwUndo, private SwUndRng +{ + SwNumRule aNumRule; + SwHistory* pHistory; + ULONG nSttSet; + SwNumRule* pOldNumRule; + String sReplaceRule; + USHORT nLRSavePos; +public: + SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule ); + SwUndoInsNum( const SwNumRule& rOldRule, const SwNumRule& rNewRule, + SwUndoId nUndoId = UNDO_INSFMTATTR ); + SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule, + const String& rReplaceRule ); + + virtual ~SwUndoInsNum(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + virtual SwRewriter GetRewriter() const; + + SwHistory* GetHistory(); // will be created if necessary + void SetSttNum( ULONG nNdIdx ) { nSttSet = nNdIdx; } + void SaveOldNumRule( const SwNumRule& rOld ); + + void SetLRSpaceEndPos(); + +}; + +class SwUndoDelNum : public SwUndo, private SwUndRng +{ + SvULongs aNodeIdx; + SvBytes aLevels; + SvBools aRstLRSpaces; + SwHistory* pHistory; +public: + SwUndoDelNum( const SwPaM& rPam ); + + virtual ~SwUndoDelNum(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void AddNode( const SwTxtNode& rNd, BOOL bResetLRSpace ); + SwHistory* GetHistory() { return pHistory; } + +}; + +class SwUndoMoveNum : public SwUndo, private SwUndRng +{ + ULONG nNewStt; + long nOffset; +public: + SwUndoMoveNum( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv = FALSE ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetStartNode( ULONG nValue ) { nNewStt = nValue; } +}; + +class SwUndoNumUpDown : public SwUndo, private SwUndRng +{ + short nOffset; +public: + SwUndoNumUpDown( const SwPaM& rPam, short nOffset ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +class SwUndoNumOrNoNum : public SwUndo +{ + ULONG nIdx; + BOOL mbNewNum, mbOldNum; + +public: + SwUndoNumOrNoNum( const SwNodeIndex& rIdx, BOOL mbOldNum, + BOOL mbNewNum ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +class SwUndoNumRuleStart : public SwUndo +{ + ULONG nIdx; + USHORT nOldStt, nNewStt; + BOOL bSetSttValue : 1; + BOOL bFlag : 1; +public: + SwUndoNumRuleStart( const SwPosition& rPos, BOOL bDelete ); + SwUndoNumRuleStart( const SwPosition& rPos, USHORT nStt ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +#endif // SW_UNDO_NUMBERING_HXX + diff --git a/sw/source/core/inc/UndoOverwrite.hxx b/sw/source/core/inc/UndoOverwrite.hxx new file mode 100644 index 000000000000..c144ab6518d7 --- /dev/null +++ b/sw/source/core/inc/UndoOverwrite.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_OVERWRITE_HXX +#define SW_UNDO_OVERWRITE_HXX + +#include <undobj.hxx> + +#include <com/sun/star/uno/Sequence.h> + + +class SwRedlineSaveDatas; +class SwTxtNode; + +namespace utl { + class TransliterationWrapper; +} + + +class SwUndoOverwrite: public SwUndo, private SwUndoSaveCntnt +{ + String aDelStr, aInsStr; + SwRedlineSaveDatas* pRedlSaveData; + ULONG nSttNode; + xub_StrLen nSttCntnt; + BOOL bInsChar : 1; // no Overwrite, but Insert + BOOL bGroup : 1; // TRUE: is already grouped; evaluated in CanGrouping() + +public: + SwUndoOverwrite( SwDoc*, SwPosition&, sal_Unicode cIns ); + + virtual ~SwUndoOverwrite(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + // #111827# + /** + Returns the rewriter of this undo object. + + The rewriter contains the following rule: + + $1 -> '<overwritten text>' + + <overwritten text> is shortened to nUndoStringLength characters. + + @return the rewriter of this undo object + */ + virtual SwRewriter GetRewriter() const; + + BOOL CanGrouping( SwDoc*, SwPosition&, sal_Unicode cIns ); +}; + +//-------------------------------------------------------------------- + +struct _UndoTransliterate_Data; +class SwUndoTransliterate : public SwUndo, public SwUndRng +{ + std::vector< _UndoTransliterate_Data * > aChanges; + sal_uInt32 nType; + + void DoTransliterate(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoTransliterate( const SwPaM& rPam, + const utl::TransliterationWrapper& rTrans ); + + virtual ~SwUndoTransliterate(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void AddChanges( SwTxtNode& rTNd, xub_StrLen nStart, xub_StrLen nLen, + ::com::sun::star::uno::Sequence <sal_Int32>& rOffsets ); + BOOL HasData() const { return aChanges.size() > 0; } +}; + +#endif // SW_UNDO_OVERWRITE_HXX + diff --git a/sw/source/core/inc/UndoRedline.hxx b/sw/source/core/inc/UndoRedline.hxx new file mode 100644 index 000000000000..520b20b2b450 --- /dev/null +++ b/sw/source/core/inc/UndoRedline.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_REDLINE_HXX +#define SW_UNDO_REDLINE_HXX + +#include <undobj.hxx> + + +struct SwSortOptions; +class SwRedline; +class SwRedlineSaveDatas; +class SwUndoDelete; + + +//-------------------------------------------------------------------- + +class SwUndoRedline : public SwUndo, public SwUndRng +{ +protected: + SwRedlineData* pRedlData; + SwRedlineSaveDatas* pRedlSaveData; + SwUndoId nUserId; + BOOL bHiddenRedlines; + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoRedline( SwUndoId nUserId, const SwPaM& rRange ); + + virtual ~SwUndoRedline(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + SwUndoId GetUserId() const { return nUserId; } + USHORT GetRedlSaveCount() const; +}; + +class SwUndoRedlineDelete : public SwUndoRedline +{ + BOOL bCanGroup : 1; + BOOL bIsDelim : 1; + BOOL bIsBackspace : 1; + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUserId = UNDO_EMPTY ); + + BOOL CanGrouping( const SwUndoRedlineDelete& rPrev ); + + // SwUndoTblCpyTbl needs this information: + long NodeDiff() const { return nSttNode - nEndNode; } + xub_StrLen ContentStart() const { return nSttCntnt; } +}; + +class SwUndoRedlineSort : public SwUndoRedline +{ + SwSortOptions* pOpt; + ULONG nSaveEndNode, nOffset; + xub_StrLen nSaveEndCntnt; + + virtual void UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoRedlineSort( const SwPaM& rRange, const SwSortOptions& rOpt ); + + virtual ~SwUndoRedlineSort(); + + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetSaveRange( const SwPaM& rRange ); + void SetOffset( const SwNodeIndex& rIdx ); +}; + +class SwUndoAcceptRedline : public SwUndoRedline +{ +private: + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoAcceptRedline( const SwPaM& rRange ); + + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +class SwUndoRejectRedline : public SwUndoRedline +{ +private: + virtual void RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam); + +public: + SwUndoRejectRedline( const SwPaM& rRange ); + + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +//-------------------------------------------------------------------- + +class SwUndoCompDoc : public SwUndo, public SwUndRng +{ + SwRedlineData* pRedlData; + SwUndoDelete* pUnDel, *pUnDel2; + SwRedlineSaveDatas* pRedlSaveData; + BOOL bInsert; +public: + SwUndoCompDoc( const SwPaM& rRg, BOOL bIns ); + SwUndoCompDoc( const SwRedline& rRedl ); + + virtual ~SwUndoCompDoc(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +#endif // SW_UNDO_REDLINE_HXX + diff --git a/sw/source/core/inc/UndoSection.hxx b/sw/source/core/inc/UndoSection.hxx new file mode 100644 index 000000000000..a93715f2f113 --- /dev/null +++ b/sw/source/core/inc/UndoSection.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_SECTION_HXX +#define SW_UNDO_SECTION_HXX + +#include <undobj.hxx> + +#include <memory> + +#include <swdllapi.h> + + +class SfxItemSet; +class SwTxtNode; +class SwSectionData; +class SwSectionFmt; +class SwTOXBase; + + +//------------ Undo of Insert-/Delete-Section ---------------------- + +class SwUndoInsSection : public SwUndo, private SwUndRng +{ +private: + const ::std::auto_ptr<SwSectionData> m_pSectionData; + const ::std::auto_ptr<SwTOXBase> m_pTOXBase; /// set iff section is TOX + const ::std::auto_ptr<SfxItemSet> m_pAttrSet; + ::std::auto_ptr<SwHistory> m_pHistory; + ::std::auto_ptr<SwRedlineData> m_pRedlData; + ULONG m_nSectionNodePos; + bool m_bSplitAtStart : 1; + bool m_bSplitAtEnd : 1; + bool m_bUpdateFtn : 1; + + void Join( SwDoc& rDoc, ULONG nNode ); + +public: + SwUndoInsSection(SwPaM const&, SwSectionData const&, + SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase); + + virtual ~SwUndoInsSection(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetSectNdPos(ULONG const nPos) { m_nSectionNodePos = nPos; } + void SaveSplitNode(SwTxtNode *const pTxtNd, bool const bAtStart); + void SetUpdtFtnFlag(bool const bFlag) { m_bUpdateFtn = bFlag; } +}; + +SW_DLLPRIVATE SwUndo * MakeUndoDelSection(SwSectionFmt const&); + +SW_DLLPRIVATE SwUndo * MakeUndoUpdateSection(SwSectionFmt const&, bool const); + +#endif // SW_UNDO_SECTION_HXX + diff --git a/sw/source/core/inc/UndoSort.hxx b/sw/source/core/inc/UndoSort.hxx new file mode 100644 index 000000000000..b89ae502f7db --- /dev/null +++ b/sw/source/core/inc/UndoSort.hxx @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_SORT_HXX +#define SW_UNDO_SORT_HXX + +#include <undobj.hxx> + + +struct SwSortOptions; +class SwTableNode; +class SwUndoAttrTbl; + + +/*-------------------------------------------------------------------- + Undo for Sorting + --------------------------------------------------------------------*/ + +struct SwSortUndoElement +{ + union { + struct { + ULONG nKenn; + ULONG nSource, nTarget; + } TXT; + struct { + String *pSource, *pTarget; + } TBL; + } SORT_TXT_TBL; + + SwSortUndoElement( const String& aS, const String& aT ) + { + SORT_TXT_TBL.TBL.pSource = new String( aS ); + SORT_TXT_TBL.TBL.pTarget = new String( aT ); + } + SwSortUndoElement( ULONG nS, ULONG nT ) + { + SORT_TXT_TBL.TXT.nSource = nS; + SORT_TXT_TBL.TXT.nTarget = nT; + SORT_TXT_TBL.TXT.nKenn = 0xffffffff; + } + ~SwSortUndoElement(); +}; + +SV_DECL_PTRARR_DEL(SwSortList, SwSortUndoElement*, 10,30) +SV_DECL_PTRARR(SwUndoSortList, SwNodeIndex*, 10,30) + +class SwUndoSort : public SwUndo, private SwUndRng +{ + SwSortOptions* pSortOpt; + SwSortList aSortList; + SwUndoAttrTbl* pUndoTblAttr; + SwRedlineData* pRedlData; + ULONG nTblNd; + +public: + SwUndoSort( const SwPaM&, const SwSortOptions& ); + SwUndoSort( ULONG nStt, ULONG nEnd, const SwTableNode&, + const SwSortOptions&, BOOL bSaveTable ); + + virtual ~SwUndoSort(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void Insert( const String& rOrgPos, const String& rNewPos ); + void Insert( ULONG nOrgPos, ULONG nNewPos ); + +}; + +#endif // SW_UNDO_SORT_HXX + diff --git a/sw/source/core/inc/UndoSplitMove.hxx b/sw/source/core/inc/UndoSplitMove.hxx new file mode 100644 index 000000000000..3f6966a871eb --- /dev/null +++ b/sw/source/core/inc/UndoSplitMove.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_MOVE_HXX +#define SW_UNDO_MOVE_HXX + +#include <undobj.hxx> + + +class SwUndoSplitNode: public SwUndo +{ + SwHistory* pHistory; + SwRedlineData* pRedlData; + ULONG nNode; + xub_StrLen nCntnt; + BOOL bTblFlag : 1; + BOOL bChkTblStt : 1; + +public: + SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, BOOL bChkTbl ); + + virtual ~SwUndoSplitNode(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetTblFlag() { bTblFlag = TRUE; } +}; + + +class SwUndoMove : public SwUndo, private SwUndRng, private SwUndoSaveCntnt +{ + // nDest.. - destination range of move (after move!) + // nIns.. - source Position of move (after move!) + // nMv.. - destination position of move (before move!); for REDO + ULONG nDestSttNode, nDestEndNode, nInsPosNode, nMvDestNode; + xub_StrLen nDestSttCntnt, nDestEndCntnt, nInsPosCntnt, nMvDestCntnt; + + USHORT nFtnStt; // StartPos of Footnotes in History + + BOOL bJoinNext : 1, + bJoinPrev : 1, + bMoveRange : 1; + + bool bMoveRedlines; // use DOC_MOVEREDLINES when calling SwDoc::Move + + void DelFtn( const SwPaM& ); + +public: + SwUndoMove( const SwPaM&, const SwPosition& ); + SwUndoMove( SwDoc* pDoc, const SwNodeRange&, const SwNodeIndex& ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + /// set the destination range after the move + void SetDestRange( const SwPaM&, const SwPosition&, BOOL, BOOL ); + void SetDestRange( const SwNodeIndex& rStt, const SwNodeIndex& rEnd, + const SwNodeIndex& rInsPos ); + + BOOL IsMoveRange() const { return bMoveRange; } + ULONG GetEndNode() const { return nEndNode; } + ULONG GetDestSttNode() const { return nDestSttNode; } + xub_StrLen GetDestSttCntnt() const { return nDestSttCntnt; } + + void SetMoveRedlines( bool b ) { bMoveRedlines = b; } + +}; + +#endif // SW_UNDO_MOVE_HXX + diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx new file mode 100644 index 000000000000..87246417b54d --- /dev/null +++ b/sw/source/core/inc/UndoTable.hxx @@ -0,0 +1,391 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNDO_TABLE_HXX +#define SW_UNDO_TABLE_HXX + +#include <undobj.hxx> + +#ifndef _SVSTDARR_HXX +#define _SVSTDARR_USHORTS +#define _SVSTDARR_ULONGS +#define _SVSTDARR_BOOLS +#define _SVSTDARR_BYTES +#define _SVSTDARR_USHORTSSORT +#include <svl/svstdarr.hxx> +#endif + +#include <swtypes.hxx> +#include <itabenum.hxx> + + +class SfxItemSet; + +struct SwSaveRowSpan; +class _SaveTable; +class SwDDEFieldType; +class SwUndoSaveSections; +class SwUndoMoves; +class SwUndoDelete; +class SwSelBoxes; +class SwTblToTxtSaves; +class SwTable; +class SwTableBox; +class SwStartNode; +class SwTableNode; +class SwTableAutoFmt; +class SwTableSortBoxes; + + +class SwUndoInsTbl : public SwUndo +{ + String sTblNm; + SwInsertTableOptions aInsTblOpts; + SwDDEFieldType* pDDEFldType; + SvUShorts* pColWidth; + SwRedlineData* pRedlData; + SwTableAutoFmt* pAutoFmt; + ULONG nSttNode; + USHORT nRows, nCols; + USHORT nAdjust; + +public: + SwUndoInsTbl( const SwPosition&, USHORT nCols, USHORT nRows, + USHORT eAdjust, const SwInsertTableOptions& rInsTblOpts, + const SwTableAutoFmt* pTAFmt, const SvUShorts* pColArr, + const String & rName); + + virtual ~SwUndoInsTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + virtual SwRewriter GetRewriter() const; + +}; + +class SwUndoTxtToTbl : public SwUndo, public SwUndRng +{ + String sTblNm; + SwInsertTableOptions aInsTblOpts; + SvULongs* pDelBoxes; + SwTableAutoFmt* pAutoFmt; + SwHistory* pHistory; + sal_Unicode cTrenner; + USHORT nAdjust; + BOOL bSplitEnd : 1; + +public: + SwUndoTxtToTbl( const SwPaM&, const SwInsertTableOptions&, sal_Unicode, + USHORT, + const SwTableAutoFmt* pAFmt ); + + virtual ~SwUndoTxtToTbl(); + + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + SwHistory& GetHistory(); // will be created if necessary + void AddFillBox( const SwTableBox& rBox ); +}; + +class SwUndoTblToTxt : public SwUndo +{ + String sTblNm; + SwDDEFieldType* pDDEFldType; + _SaveTable* pTblSave; + SwTblToTxtSaves* pBoxSaves; + SwHistory* pHistory; + ULONG nSttNd, nEndNd; + USHORT nAdjust; + sal_Unicode cTrenner; + USHORT nHdlnRpt; + BOOL bCheckNumFmt : 1; + +public: + SwUndoTblToTxt( const SwTable& rTbl, sal_Unicode cCh ); + + virtual ~SwUndoTblToTxt(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetRange( const SwNodeRange& ); + void AddBoxPos( SwDoc& rDoc, ULONG nNdIdx, ULONG nEndIdx, + xub_StrLen nCntntIdx = STRING_MAXLEN); +}; + +class SwUndoAttrTbl : public SwUndo +{ + ULONG nSttNode; + _SaveTable* pSaveTbl; + BOOL bClearTabCol : 1; +public: + SwUndoAttrTbl( const SwTableNode& rTblNd, BOOL bClearTabCols = FALSE ); + + virtual ~SwUndoAttrTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); +}; + +class SwUndoTblNumFmt; + +class SwUndoTblAutoFmt : public SwUndo +{ + ULONG nSttNode; + _SaveTable* pSaveTbl; + ::std::vector< ::boost::shared_ptr<SwUndoTblNumFmt> > m_Undos; + BOOL bSaveCntntAttr; + + void UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext); + +public: + SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& ); + + virtual ~SwUndoTblAutoFmt(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void SaveBoxCntnt( const SwTableBox& rBox ); +}; + +class SwUndoTblNdsChg : public SwUndo +{ + _SaveTable* pSaveTbl; + SvULongs aBoxes; + + union { + SvULongs* pNewSttNds; + SwUndoSaveSections* pDelSects; + } Ptrs; + SvBools aMvBoxes; // for SplitRow (split Nodes of Box) + long nMin, nMax; // for redo of delete column + ULONG nSttNode, nCurrBox; + USHORT nCount, nRelDiff, nAbsDiff, nSetColType; + BOOL bFlag; + BOOL bSameHeight; // only used for SplitRow +public: + SwUndoTblNdsChg( SwUndoId UndoId, + const SwSelBoxes& rBoxes, + const SwTableNode& rTblNd, + long nMn, long nMx, + USHORT nCnt, BOOL bFlg, BOOL bSameHeight ); + + // for SetColWidth + SwUndoTblNdsChg( SwUndoId UndoId, const SwSelBoxes& rBoxes, + const SwTableNode& rTblNd ); + + virtual ~SwUndoTblNdsChg(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld ); + void SaveNewBoxes( const SwTableNode& rTblNd, const SwTableSortBoxes& rOld, + const SwSelBoxes& rBoxes, const SvULongs& rNodeCnts ); + void SaveSection( SwStartNode* pSttNd ); + void ReNewBoxes( const SwSelBoxes& rBoxes ); + + + void SetColWidthParam( ULONG nBoxIdx, USHORT nMode, USHORT nType, + SwTwips nAbsDif, SwTwips nRelDif ) + { + nCurrBox = nBoxIdx; + nCount = nMode; + nSetColType = nType; + nAbsDiff = (USHORT)nAbsDif; + nRelDiff = (USHORT)nRelDif; + } + +}; + +class SwUndoTblMerge : public SwUndo, private SwUndRng +{ + ULONG nTblNode; + _SaveTable* pSaveTbl; + SvULongs aBoxes, aNewSttNds; + SwUndoMoves* pMoves; + SwHistory* pHistory; + +public: + SwUndoTblMerge( const SwPaM& rTblSel ); + + virtual ~SwUndoTblMerge(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos ); + + void SetSelBoxes( const SwSelBoxes& rBoxes ); + + void AddNewBox( ULONG nSttNdIdx ) + { aNewSttNds.Insert( nSttNdIdx, aNewSttNds.Count() ); } + + void SaveCollection( const SwTableBox& rBox ); + +}; + + +class SwUndoTblNumFmt : public SwUndo +{ + SfxItemSet *pBoxSet; + SwHistory* pHistory; + String aStr, aNewFml; + + ULONG nFmtIdx, nNewFmtIdx; + double fNum, fNewNum; + ULONG nNode; + ULONG nNdPos; + + BOOL bNewFmt : 1; + BOOL bNewFml : 1; + BOOL bNewValue : 1; + +public: + SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet = 0 ); + + virtual ~SwUndoTblNumFmt(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void SetNumFmt( ULONG nNewNumFmtIdx, const double& rNewNumber ) + { nFmtIdx = nNewNumFmtIdx; fNum = rNewNumber; } + void SetBox( const SwTableBox& rBox ); +}; + +class _UndoTblCpyTbl_Entries; + +class SwUndoTblCpyTbl : public SwUndo +{ + _UndoTblCpyTbl_Entries* pArr; + SwUndoTblNdsChg* pInsRowUndo; + + //b6341295: When redlining is active, PrepareRedline has to create the + //redlining attributes for the new and the old table cell content + SwUndo* PrepareRedline( SwDoc* pDoc, const SwTableBox& rBox, + const SwPosition& rPos, bool& rJoin, bool bRedo ); +public: + SwUndoTblCpyTbl(); + + virtual ~SwUndoTblCpyTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void AddBoxBefore( const SwTableBox& rBox, BOOL bDelCntnt ); + void AddBoxAfter( const SwTableBox& rBox, const SwNodeIndex& rIdx, + BOOL bDelCntnt ); + + BOOL IsEmpty() const; + BOOL InsertRow( SwTable& rTbl, const SwSelBoxes& rBoxes, USHORT nCnt ); +}; + +class SwUndoCpyTbl : public SwUndo +{ + SwUndoDelete* pDel; + ULONG nTblNode; +public: + SwUndoCpyTbl(); + + virtual ~SwUndoCpyTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + + void SetTableSttIdx( ULONG nIdx ) { nTblNode = nIdx; } +}; + +class SwUndoSplitTbl : public SwUndo +{ + ULONG nTblNode, nOffset; + SwSaveRowSpan* mpSaveRowSpan; // stores row span values at the splitting row + _SaveTable* pSavTbl; + SwHistory* pHistory; + USHORT nMode, nFmlEnd; + BOOL bCalcNewSize; +public: + SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp, + USHORT nMode, BOOL bCalcNewSize ); + + virtual ~SwUndoSplitTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SetTblNodeOffset( ULONG nIdx ) { nOffset = nIdx - nTblNode; } + SwHistory* GetHistory() { return pHistory; } + void SaveFormula( SwHistory& rHistory ); +}; + +class SwUndoMergeTbl : public SwUndo +{ + String aName; + ULONG nTblNode; + _SaveTable* pSavTbl, *pSavHdl; + SwHistory* pHistory; + USHORT nMode; + BOOL bWithPrev; +public: + SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd, + BOOL bWithPrev, USHORT nMode ); + + virtual ~SwUndoMergeTbl(); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); + + void SaveFormula( SwHistory& rHistory ); +}; + + +//-------------------------------------------------------------------- + +class SwUndoTblHeadline : public SwUndo +{ + ULONG nTblNd; + USHORT nOldHeadline; + USHORT nNewHeadline; +public: + SwUndoTblHeadline( const SwTable&, USHORT nOldHdl, USHORT nNewHdl ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); + virtual void RepeatImpl( ::sw::RepeatContext & ); +}; + +#endif // SW_UNDO_TABLE_HXX + diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx index bc2d2d4cb1f3..dcd28bfdd46d 100644 --- a/sw/source/core/inc/acorrect.hxx +++ b/sw/source/core/inc/acorrect.hxx @@ -56,7 +56,7 @@ class SwAutoCorrDoc : public SvxAutoCorrDoc SwEditShell& rEditSh; SwPaM& rCrsr; SwNodeIndex* pIdx; - SwUndoId nUndoId; + int m_nEndUndoCounter; bool bUndoIdInitialized; void DeleteSel( SwPaM& rDelPam ); diff --git a/sw/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx index e2aa129f65e1..e2aa129f65e1 100644 --- a/sw/inc/rolbck.hxx +++ b/sw/source/core/inc/rolbck.hxx diff --git a/sw/source/core/inc/undoflystrattr.hxx b/sw/source/core/inc/undoflystrattr.hxx index 329502ea1d1c..5115f1a37c07 100644 --- a/sw/source/core/inc/undoflystrattr.hxx +++ b/sw/source/core/inc/undoflystrattr.hxx @@ -24,8 +24,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _UNDO_FLY_STR_ATTR_HXX -#define _UNDO_FLY_STR_ATTR_HXX +#ifndef SW_UNDO_FLY_STR_ATTR_HXX +#define SW_UNDO_FLY_STR_ATTR_HXX #include <undobj.hxx> #include <swundo.hxx> @@ -42,9 +42,8 @@ class SwUndoFlyStrAttr : public SwUndo const String& sNewStr ); virtual ~SwUndoFlyStrAttr(); - virtual void Undo( SwUndoIter & rIt ); - virtual void Redo( SwUndoIter & rIt ); - virtual void Repeat( SwUndoIter & rIt ); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); virtual SwRewriter GetRewriter() const; @@ -54,4 +53,4 @@ class SwUndoFlyStrAttr : public SwUndo const String msNewStr; }; -#endif // _UNDO_FLY_STR_ATTR_HXX +#endif // SW_UNDO_FLY_STR_ATTR_HXX diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 37ec80632153..4016f9cb92ef 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -78,6 +78,7 @@ #include <tgrditem.hxx> #include <hfspacingitem.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagefrm.hxx> #include <rootfrm.hxx> #include <cntfrm.hxx> @@ -106,9 +107,7 @@ #include <cmdid.h> #include <unomid.h> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <svx/svdundo.hxx> // #111827# // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> @@ -218,7 +217,7 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt ) // <-- //Wenn in einem der Nodes noch ein Crsr angemeldet ist, muss das //ParkCrsr einer (beliebigen) Shell gerufen werden. - pNode = pDoc->GetNodes()[ aIdx ]; + pNode = & aIdx.GetNode(); sal_uInt32 nEnd = pNode->EndOfSectionIndex(); while ( aIdx < nEnd ) { @@ -237,21 +236,17 @@ void DelHFFormat( SwClient *pToRemove, SwFrmFmt *pFmt ) } while ( aIter++ ); } aIdx++; - pNode = pDoc->GetNodes()[ aIdx ]; + pNode = & aIdx.GetNode(); } } rCnt.SetNewCntntIdx( (const SwNodeIndex*)0 ); // beim Loeschen von Header/Footer-Formaten IMMER das Undo // abschalten! (Bug 31069) - sal_Bool bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( sal_False ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); ASSERT( pNode, "Ein grosses Problem." ); pDoc->DeleteSection( pNode ); - - if( bDoesUndo ) - pDoc->DoUndo( sal_True ); } delete pFmt; } diff --git a/sw/source/core/layout/flycnt.cxx b/sw/source/core/layout/flycnt.cxx index 4d9b654fb79c..ba3652bd0d20 100644 --- a/sw/source/core/layout/flycnt.cxx +++ b/sw/source/core/layout/flycnt.cxx @@ -27,13 +27,15 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <tools/bigint.hxx> #include "pagefrm.hxx" #include "rootfrm.hxx" #include "cntfrm.hxx" #include "flyfrm.hxx" #include "txtfrm.hxx" -#include "doc.hxx" +#include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include "viewsh.hxx" #include "viewimp.hxx" #include "pam.hxx" @@ -1370,7 +1372,7 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) nX = rNew.X() - pFrm->Frm().Left() - nBaseOfstForFly; } } - GetFmt()->GetDoc()->StartUndo( UNDO_START, NULL ); + GetFmt()->GetDoc()->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); if( pCnt != GetAnchorFrm() || ( IsAutoPos() && pCnt->IsTxtFrm() && GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::HTML_MODE)) ) @@ -1421,7 +1423,7 @@ void SwFlyAtCntFrm::SetAbsPos( const Point &rNew ) const Point aRelPos = bVert ? Point( -nY, nX ) : Point( nX, nY ); ChgRelPos( aRelPos ); - GetFmt()->GetDoc()->EndUndo( UNDO_END, NULL ); + GetFmt()->GetDoc()->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); if ( pOldPage != FindPageFrm() ) ::Notify_Background( GetVirtDrawObj(), pOldPage, aOld, PREP_FLY_LEAVE, diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index a85ee7091ff1..e089d5a2d726 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -491,8 +491,7 @@ SwActualSection::SwActualSection( SwActualSection *pUp, if ( !pSectNode ) { const SwNodeIndex *pIndex = pSect->GetFmt()->GetCntnt().GetCntntIdx(); - pSectNode = pSect->GetFmt()->GetDoc()->GetNodes()[*pIndex]-> - FindSectionNode(); + pSectNode = pIndex->GetNode().FindSectionNode(); } } diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 8c54ed8623a6..6d3827a69336 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -892,7 +892,7 @@ BOOL SwCntntFrm::UnitDown( SwPaM* pPam, const SwTwips, BOOL bInReadOnly ) const USHORT SwRootFrm::GetCurrPage( const SwPaM *pActualCrsr ) const { ASSERT( pActualCrsr, "Welche Seite soll's denn sein?" ); - const SwFrm *pActFrm = GetFmt()->GetDoc()->GetNodes()[pActualCrsr->GetPoint()->nNode]-> + SwFrm const*const pActFrm = pActualCrsr->GetPoint()->nNode.GetNode(). GetCntntNode()->GetFrm( 0, pActualCrsr->GetPoint(), FALSE ); @@ -2011,7 +2011,6 @@ inline void Sub( SwRegionRects& rRegion, const SwRect& rRect ) void SwRootFrm::CalcFrmRects( SwShellCrsr &rCrsr, BOOL bIsTblMode ) { - const SwNodes &rNds = GetFmt()->GetDoc()->GetNodes(); SwPosition *pStartPos = rCrsr.Start(), *pEndPos = rCrsr.GetPoint() == pStartPos ? rCrsr.GetMark() : rCrsr.GetPoint(); @@ -2047,10 +2046,10 @@ void SwRootFrm::CalcFrmRects( SwShellCrsr &rCrsr, BOOL bIsTblMode ) //Erstmal die CntntFrms zum Start und End besorgen, die brauch ich auf //jedenfall. - const SwCntntFrm *pStartFrm = rNds[ pStartPos->nNode ]-> + SwCntntFrm const* pStartFrm = pStartPos->nNode.GetNode(). GetCntntNode()->GetFrm( &rCrsr.GetSttPos(), pStartPos ); - const SwCntntFrm *pEndFrm = rNds[ pEndPos->nNode ]-> + SwCntntFrm const* pEndFrm = pEndPos->nNode.GetNode(). GetCntntNode()->GetFrm( &rCrsr.GetEndPos(), pEndPos ); ASSERT( (pStartFrm && pEndFrm), "Keine CntntFrms gefunden." ); diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 1cd0fdd02830..db341c9991ba 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -437,16 +437,14 @@ Size SwOLENode::GetTwipSize() const SwCntntNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const { // Falls bereits eine SvPersist-Instanz existiert, nehmen wir diese - SfxObjectShell* p = pDoc->GetPersist(); - if( !p ) + SfxObjectShell* pPersistShell = pDoc->GetPersist(); + if( !pPersistShell ) { - // TODO/LATER: reicht hier nicht ein EmbeddedObjectContainer? Was passiert mit - // diesem Dokument? - ASSERT( pDoc->GetRefForDocShell(), - "wo ist die Ref-Klasse fuer die DocShell?") - p = new SwDocShell( pDoc, SFX_CREATE_MODE_INTERNAL ); - *pDoc->GetRefForDocShell() = p; - p->DoInitNew( NULL ); + // TODO/LATER: is EmbeddedObjectContainer not enough? + // the created document will be closed by pDoc ( should use SfxObjectShellLock ) + pPersistShell = new SwDocShell( pDoc, SFX_CREATE_MODE_INTERNAL ); + pDoc->SetTmpDocShell( pPersistShell ); + pPersistShell->DoInitNew( NULL ); } // Wir hauen das Ding auf SvPersist-Ebene rein @@ -454,7 +452,7 @@ SwCntntNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const ::rtl::OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/; SfxObjectShell* pSrc = GetDoc()->GetPersist(); - p->GetEmbeddedObjectContainer().CopyAndGetEmbeddedObject( + pPersistShell->GetEmbeddedObjectContainer().CopyAndGetEmbeddedObject( pSrc->GetEmbeddedObjectContainer(), pSrc->GetEmbeddedObjectContainer().GetEmbeddedObject( aOLEObj.aName ), aNewName ); diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 358b00e12ca1..73cff76dcbd9 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -28,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <tools/urlobj.hxx> @@ -39,9 +38,8 @@ #include <comphelper/storagehelper.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX +#include <IDocumentUndoRedo.hxx> #include <docsh.hxx> -#endif #include <pam.hxx> #include <swblocks.hxx> #include <ndtxt.hxx> @@ -81,7 +79,7 @@ SwXMLTextBlocks::SwXMLTextBlocks( const String& rFile ) pDoc = pDocSh->GetDoc(); xDocShellRef = pDocSh; pDoc->SetOle2Link( Link() ); - pDoc->DoUndo( FALSE ); // always FALSE + pDoc->GetIDocumentUndoRedo().DoUndo(false); pDoc->acquire(); uno::Reference< embed::XStorage > refStg; if( !aDateModified.GetDate() || !aTimeModified.GetTime() ) @@ -124,7 +122,7 @@ SwXMLTextBlocks::SwXMLTextBlocks( const uno::Reference < embed::XStorage >& rStg pDoc = pDocSh->GetDoc(); xDocShellRef = pDocSh; pDoc->SetOle2Link( Link() ); - pDoc->DoUndo( FALSE ); + pDoc->GetIDocumentUndoRedo().DoUndo(false); pDoc->acquire(); InitBlockMode ( rStg ); diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index de76b856cda7..c1ad9f4c63ec 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -32,13 +32,14 @@ #include <tblsel.hxx> #include <tblrwcl.hxx> #include <node.hxx> -#include <undobj.hxx> +#include <UndoTable.hxx> #include <pam.hxx> #include <frmfmt.hxx> #include <frmatr.hxx> #include <cellfrm.hxx> #include <fmtfsize.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <vector> #include <set> #include <list> @@ -897,11 +898,16 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, USHORT nL = pCNd ? pCNd->Len() : 0; aPam.GetPoint()->nContent.Assign( pCNd, nL ); SwNodeIndex aSttNdIdx( *pBox->GetSttNd(), 1 ); + bool const bUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); if( pUndo ) - pDoc->DoUndo( FALSE ); + { + pDoc->GetIDocumentUndoRedo().DoUndo(false); + } pDoc->AppendTxtNode( *aPam.GetPoint() ); if( pUndo ) - pDoc->DoUndo( TRUE ); + { + pDoc->GetIDocumentUndoRedo().DoUndo(bUndo); + } SwNodeRange aRg( aSttNdIdx, aPam.GetPoint()->nNode ); if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index 48b3b5f335fb..c4f8abdda65c 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -1769,10 +1769,9 @@ SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, const SwNodeIndex &rIdx, pUpper( pUp ), pImpl( 0 ) { - SwDoc* pDoc = pFmt->GetDoc(); CheckBoxFmt( pFmt )->Add( this ); - pSttNd = pDoc->GetNodes()[ rIdx ]->GetStartNode(); + pSttNd = rIdx.GetNode().GetStartNode(); // an der Table eintragen const SwTableNode* pTblNd = pSttNd->FindTableNode(); diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index 02da2c32be8a..d3076e642ef5 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -28,11 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "hintids.hxx" #include "cntfrm.hxx" // _GetFly #include "doc.hxx" +#include <IDocumentUndoRedo.hxx> #include "pam.hxx" // fuer SwTxtFlyCnt #include "flyfrm.hxx" // fuer SwTxtFlyCnt #include "ndtxt.hxx" // SwFlyFrmFmt @@ -117,9 +116,8 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) // In CopyLayoutFmt (siehe doclay.cxx) wird das FlyFrmFmt erzeugt // und der Inhalt dupliziert. - // fuers kopieren vom Attribut das Undo immer abschalten - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + // disable undo while copying attribute + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwFmtAnchor aAnchor( pFmt->GetAnchor() ); if ((FLY_AT_PAGE != aAnchor.GetAnchorId()) && (pDoc != pFmt->GetDoc())) // different documents? @@ -146,7 +144,6 @@ void SwTxtFlyCnt::CopyFlyFmt( SwDoc* pDoc ) } SwFrmFmt* pNew = pDoc->CopyLayoutFmt( *pFmt, aAnchor, false, false ); - pDoc->DoUndo( bUndo ); ((SwFmtFlyCnt&)GetFlyCnt()).SetFlyFmt( pNew ); } @@ -193,16 +190,13 @@ void SwTxtFlyCnt::SetAnchor( const SwTxtNode *pNode ) // stehen wir noch im falschen Dokument ? if( pDoc != pFmt->GetDoc() ) { - // fuers kopieren vom Attribut das Undo immer abschalten - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + // disable undo while copying attribute + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwFrmFmt* pNew = pDoc->CopyLayoutFmt( *pFmt, aAnchor, false, false ); - pDoc->DoUndo( bUndo ); - bUndo = pFmt->GetDoc()->DoesUndo(); - pFmt->GetDoc()->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuardFmt( + pFmt->GetDoc()->GetIDocumentUndoRedo()); pFmt->GetDoc()->DelLayoutFmt( pFmt ); - pFmt->GetDoc()->DoUndo( bUndo ); ((SwFmtFlyCnt&)GetFlyCnt()).SetFlyFmt( pNew ); } else if( pNode->GetpSwpHints() && diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index d6a6dfb045ac..65ad24d2b8b3 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -64,6 +64,7 @@ #include <charfmt.hxx> #include <ndtxt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <pam.hxx> // fuer SwPosition #include <fldbas.hxx> @@ -163,8 +164,8 @@ SwTxtNode *SwNodes::MakeTxtNode( const SwNodeIndex & rWhere, // 1. den Nachfolger nehmen // 2. den Vorgaenger - SwNode *pNd; - switch( ( pNd = (*this)[aTmp] )->GetNodeType() ) + SwNode * pNd = & aTmp.GetNode(); + switch (pNd->GetNodeType()) { case ND_TABLENODE: ((SwTableNode*)pNd)->MakeFrms( aIdx ); @@ -1628,7 +1629,8 @@ void SwTxtNode::CopyText( SwTxtNode *const pDest, } } - const bool bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + bool const bUndoNodes = !pOtherDoc + && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. @@ -2098,8 +2100,8 @@ void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, const xub_StrLen nEnd = rStart.GetIndex() + nLen; SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? pDest->GetDoc() : 0; - const bool bUndoNodes = - !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + bool const bUndoNodes = !pOtherDoc + && GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); ASSERT(!pOtherDoc, "mst: entering dead and bitrotted code; fasten your seatbelts!"); @@ -5084,7 +5086,7 @@ bool SwTxtNode::IsInClipboard() const bool SwTxtNode::IsInUndo() const { - return &GetNodes() == GetDoc()->GetUndoNds(); + return GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(GetNodes()); } bool SwTxtNode::IsInContent() const diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 4d56942ecef4..4ef913b8a932 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -65,6 +65,7 @@ #include <fmtmeta.hxx> #include <breakit.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <errhdl.hxx> #include <fldbas.hxx> #include <pam.hxx> @@ -1318,11 +1319,9 @@ bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) SwIndex aTmpIdx( this, *pAttr->GetStart() ); Update( aTmpIdx, 1, TRUE ); } - // Format loeschen nicht ins Undo aufnehmen!! - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + // do not record deletion of Format! + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); DestroyAttr( pAttr ); - pDoc->DoUndo( bUndo ); return false; } } @@ -3047,12 +3046,19 @@ sal_Unicode GetCharOfTxtAttr( const SwTxtAttr& rAttr ) case RES_TXTATR_META: case RES_TXTATR_METAFIELD: cRet = CH_TXTATR_INWORD; - break; + break; case RES_TXTATR_FIELD: case RES_TXTATR_FLYCNT: + { cRet = CH_TXTATR_BREAKWORD; - break; + + // #i78149: PostIt fields should not break words for spell and grammar checking + if (rAttr.Which() == RES_TXTATR_FIELD && + RES_POSTITFLD == rAttr.GetFld().GetFld()->GetTyp()->Which()) + cRet = CH_TXTATR_INWORD; + } + break; default: ASSERT(false, "GetCharOfTxtAttr: unknown attr"); diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 0630dbd722b6..cd2a8d3227c4 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -70,7 +70,7 @@ #include <txttypes.hxx> #include <breakit.hxx> #include <crstate.hxx> -#include <undobj.hxx> +#include <UndoOverwrite.hxx> #include <txatritr.hxx> #include <redline.hxx> // SwRedline #include <docary.hxx> // SwRedlineTbl @@ -736,6 +736,7 @@ BOOL SwScanner::NextWord() // get the word boundaries aBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nBegin, pBreakIt->GetLocale( aCurrLang ), nWordType, sal_True ); + ASSERT( aBound.endPos >= aBound.startPos, "broken aBound result" ); //no word boundaries could be found if(aBound.endPos == aBound.startPos) @@ -750,46 +751,54 @@ BOOL SwScanner::NextWord() rCC.setLocale( aOldLocale ); - // we have to differenciate between these cases: - if ( aBound.startPos <= nBegin ) + // #i89042, as discussed with HDU: don't evaluate script changes for word count. Use whole word. + if ( nWordType == i18n::WordType::WORD_COUNT ) { - ASSERT( aBound.endPos >= nBegin, "Unexpected aBound result" ) - - // restrict boundaries to script boundaries and nEndPos - const USHORT nCurrScript = - pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); - - XubString aTmpWord = rText.Copy( nBegin, static_cast<xub_StrLen>(aBound.endPos - nBegin) ); - const sal_Int32 nScriptEnd = nBegin + - pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); - const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); - - // restrict word start to last script change position - sal_Int32 nScriptBegin = 0; - if ( aBound.startPos < nBegin ) - { - // search from nBegin backwards until the next script change - aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), - static_cast<xub_StrLen>(nBegin - aBound.startPos + 1) ); - nScriptBegin = aBound.startPos + - pBreakIt->GetBreakIter()->beginOfScript( aTmpWord, nBegin - aBound.startPos, - nCurrScript ); - } - - nBegin = (xub_StrLen)Max( aBound.startPos, nScriptBegin ); - nLen = (xub_StrLen)(nEnd - nBegin); + nBegin = Max( static_cast< xub_StrLen >(aBound.startPos), nBegin ); + nLen = 0; + if (static_cast< xub_StrLen >(aBound.endPos) > nBegin) + nLen = static_cast< xub_StrLen >(aBound.endPos) - nBegin; } else { - const USHORT nCurrScript = - pBreakIt->GetBreakIter()->getScriptType( rText, aBound.startPos ); - XubString aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), - static_cast<xub_StrLen>(aBound.endPos - aBound.startPos) ); - const sal_Int32 nScriptEnd = aBound.startPos + - pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); - const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); - nBegin = (xub_StrLen)aBound.startPos; - nLen = (xub_StrLen)(nEnd - nBegin); + // we have to differenciate between these cases: + if ( aBound.startPos <= nBegin ) + { + ASSERT( aBound.endPos >= nBegin, "Unexpected aBound result" ) + + // restrict boundaries to script boundaries and nEndPos + const USHORT nCurrScript = pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); + XubString aTmpWord = rText.Copy( nBegin, static_cast<xub_StrLen>(aBound.endPos - nBegin) ); + const sal_Int32 nScriptEnd = nBegin + + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); + const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); + + // restrict word start to last script change position + sal_Int32 nScriptBegin = 0; + if ( aBound.startPos < nBegin ) + { + // search from nBegin backwards until the next script change + aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), + static_cast<xub_StrLen>(nBegin - aBound.startPos + 1) ); + nScriptBegin = aBound.startPos + + pBreakIt->GetBreakIter()->beginOfScript( aTmpWord, nBegin - aBound.startPos, + nCurrScript ); + } + + nBegin = (xub_StrLen)Max( aBound.startPos, nScriptBegin ); + nLen = (xub_StrLen)(nEnd - nBegin); + } + else + { + const USHORT nCurrScript = pBreakIt->GetBreakIter()->getScriptType( rText, aBound.startPos ); + XubString aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), + static_cast<xub_StrLen>(aBound.endPos - aBound.startPos) ); + const sal_Int32 nScriptEnd = aBound.startPos + + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); + const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); + nBegin = (xub_StrLen)aBound.startPos; + nLen = (xub_StrLen)(nEnd - nBegin); + } } // optionally clip the result of getWordBoundaries: diff --git a/sw/source/core/undo/SwUndoField.cxx b/sw/source/core/undo/SwUndoField.cxx index 8a3c6c507c93..3f714561b05b 100644 --- a/sw/source/core/undo/SwUndoField.cxx +++ b/sw/source/core/undo/SwUndoField.cxx @@ -27,10 +27,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <tools/rtti.hxx> + #include <SwUndoField.hxx> #include <swundo.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <txtfld.hxx> #include <fldbas.hxx> #include <ndtxt.hxx> @@ -83,43 +86,41 @@ SwUndoFieldFromDoc::~SwUndoFieldFromDoc() delete pNewField; } -void SwUndoFieldFromDoc::Undo( SwUndoIter& ) +void SwUndoFieldFromDoc::UndoImpl(::sw::UndoRedoContext &) { SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition()); const SwField * pField = pTxtFld->GetFld().GetFld(); if (pField) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->UpdateFld(pTxtFld, *pOldField, pHnt, bUpdate); - pDoc->DoUndo(bUndo); } } -void SwUndoFieldFromDoc::Redo( SwUndoIter& ) +void SwUndoFieldFromDoc::DoImpl() { SwTxtFld * pTxtFld = SwDoc::GetTxtFld(GetPosition()); const SwField * pField = pTxtFld->GetFld().GetFld(); if (pField) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->UpdateFld(pTxtFld, *pNewField, pHnt, bUpdate); SwFmtFld* pDstFmtFld = (SwFmtFld*)&pTxtFld->GetFld(); if ( pDoc->GetFldType(RES_POSTITFLD, aEmptyStr,false) == pDstFmtFld->GetFld()->GetTyp() ) pDoc->GetDocShell()->Broadcast( SwFmtFldHint( pDstFmtFld, SWFMTFLD_INSERTED ) ); - pDoc->DoUndo(bUndo); } } -void SwUndoFieldFromDoc::Repeat(SwUndoIter & rIt) +void SwUndoFieldFromDoc::RedoImpl(::sw::UndoRedoContext &) +{ + DoImpl(); +} + +void SwUndoFieldFromDoc::RepeatImpl(::sw::RepeatContext &) { - Redo(rIt); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); + DoImpl(); } SwUndoFieldFromAPI::SwUndoFieldFromAPI(const SwPosition & rPos, @@ -133,7 +134,7 @@ SwUndoFieldFromAPI::~SwUndoFieldFromAPI() { } -void SwUndoFieldFromAPI::Undo( SwUndoIter& ) +void SwUndoFieldFromAPI::UndoImpl(::sw::UndoRedoContext &) { SwField * pField = SwDoc::GetField(GetPosition()); @@ -141,7 +142,7 @@ void SwUndoFieldFromAPI::Undo( SwUndoIter& ) pField->PutValue(aOldVal, nWhich); } -void SwUndoFieldFromAPI::Redo( SwUndoIter& ) +void SwUndoFieldFromAPI::DoImpl() { SwField * pField = SwDoc::GetField(GetPosition()); @@ -149,8 +150,13 @@ void SwUndoFieldFromAPI::Redo( SwUndoIter& ) pField->PutValue(aNewVal, nWhich); } +void SwUndoFieldFromAPI::RedoImpl(::sw::UndoRedoContext &) +{ + DoImpl(); +} -void SwUndoFieldFromAPI::Repeat(SwUndoIter & rIter) +void SwUndoFieldFromAPI::RepeatImpl(::sw::RepeatContext &) { - Redo(rIter); + DoImpl(); } + diff --git a/sw/source/core/undo/SwUndoFmt.cxx b/sw/source/core/undo/SwUndoFmt.cxx index f3b2fe4d1a25..4c95a6f1049d 100644 --- a/sw/source/core/undo/SwUndoFmt.cxx +++ b/sw/source/core/undo/SwUndoFmt.cxx @@ -29,6 +29,8 @@ #include "precompiled_sw.hxx" #include <tools/resid.hxx> +#include <tools/string.hxx> + #include <poolfmt.hxx> #include <charfmt.hxx> #include <frmfmt.hxx> @@ -37,8 +39,8 @@ #include <swundo.hxx> #include <undobj.hxx> #include <fmtcol.hxx> -#include <tools/string.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <comcore.hrc> SwUndoFmtCreate::SwUndoFmtCreate @@ -54,7 +56,7 @@ SwUndoFmtCreate::~SwUndoFmtCreate() { } -void SwUndoFmtCreate::Undo(SwUndoIter &) +void SwUndoFmtCreate::UndoImpl(::sw::UndoRedoContext &) { if (pNew) { @@ -70,20 +72,13 @@ void SwUndoFmtCreate::Undo(SwUndoIter &) nId = pNew->GetPoolFmtId() & COLL_GET_RANGE_BITS; bAuto = pNew->IsAuto(); - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); Delete(); - pDoc->DoUndo(bDoesUndo); } } } -void SwUndoFmtCreate::Redo(SwUndoIter &) +void SwUndoFmtCreate::RedoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); SwFmt * pDerivedFrom = Find(sDerivedFrom); SwFmt * pFmt = Create(pDerivedFrom); @@ -99,8 +94,6 @@ void SwUndoFmtCreate::Redo(SwUndoIter &) } else pNew = NULL; - - pDoc->DoUndo(bDoesUndo); } SwRewriter SwUndoFmtCreate::GetRewriter() const @@ -130,12 +123,8 @@ SwUndoFmtDelete::~SwUndoFmtDelete() { } -void SwUndoFmtDelete::Undo(SwUndoIter &) +void SwUndoFmtDelete::UndoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - SwFmt * pDerivedFrom = Find(sDerivedFrom); SwFmt * pFmt = Create(pDerivedFrom); @@ -147,23 +136,16 @@ void SwUndoFmtDelete::Undo(SwUndoIter &) pFmt->SetPoolFmtId((pFmt->GetPoolFmtId() & ~COLL_GET_RANGE_BITS) | nId); - } - - pDoc->DoUndo(bDoesUndo); } -void SwUndoFmtDelete::Redo(SwUndoIter &) +void SwUndoFmtDelete::RedoImpl(::sw::UndoRedoContext &) { SwFmt * pOld = Find(sOldName); if (pOld) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); Delete(pOld); - pDoc->DoUndo(bDoesUndo); } } @@ -190,31 +172,23 @@ SwUndoRenameFmt::~SwUndoRenameFmt() { } -void SwUndoRenameFmt::Undo(SwUndoIter &) +void SwUndoRenameFmt::UndoImpl(::sw::UndoRedoContext &) { SwFmt * pFmt = Find(sNewName); if (pFmt) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->RenameFmt(*pFmt, sOldName, TRUE); - pDoc->DoUndo(bDoesUndo); } } -void SwUndoRenameFmt::Redo(SwUndoIter &) +void SwUndoRenameFmt::RedoImpl(::sw::UndoRedoContext &) { SwFmt * pFmt = Find(sOldName); if (pFmt) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->RenameFmt(*pFmt, sNewName, TRUE); - pDoc->DoUndo(bDoesUndo); } } @@ -399,12 +373,8 @@ SwUndoNumruleCreate::SwUndoNumruleCreate(const SwNumRule * _pNew, { } -void SwUndoNumruleCreate::Undo(SwUndoIter &) +void SwUndoNumruleCreate::UndoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - if (! bInitialized) { aNew = *pNew; @@ -412,16 +382,11 @@ void SwUndoNumruleCreate::Undo(SwUndoIter &) } pDoc->DelNumRule(aNew.GetName(), TRUE); - pDoc->DoUndo(bDoesUndo); } -void SwUndoNumruleCreate::Redo(SwUndoIter &) +void SwUndoNumruleCreate::RedoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->MakeNumRule(aNew.GetName(), &aNew, TRUE); - pDoc->DoUndo(bDoesUndo); } SwRewriter SwUndoNumruleCreate::GetRewriter() const @@ -445,22 +410,14 @@ SwUndoNumruleDelete::SwUndoNumruleDelete(const SwNumRule & rRule, { } -void SwUndoNumruleDelete::Undo(SwUndoIter &) +void SwUndoNumruleDelete::UndoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->MakeNumRule(aOld.GetName(), &aOld, TRUE); - pDoc->DoUndo(bDoesUndo); } -void SwUndoNumruleDelete::Redo(SwUndoIter &) +void SwUndoNumruleDelete::RedoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->DelNumRule(aOld.GetName(), TRUE); - pDoc->DoUndo(bDoesUndo); } SwRewriter SwUndoNumruleDelete::GetRewriter() const @@ -480,22 +437,14 @@ SwUndoNumruleRename::SwUndoNumruleRename(const String & _aOldName, { } -void SwUndoNumruleRename::Undo(SwUndoIter &) +void SwUndoNumruleRename::UndoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->RenameNumRule(aNewName, aOldName, TRUE); - pDoc->DoUndo(bDoesUndo); } -void SwUndoNumruleRename::Redo(SwUndoIter &) +void SwUndoNumruleRename::RedoImpl(::sw::UndoRedoContext &) { - BOOL bDoesUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->RenameNumRule(aOldName, aNewName, TRUE); - pDoc->DoUndo(bDoesUndo); } SwRewriter SwUndoNumruleRename::GetRewriter() const diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx index 9a395375eabe..c23811d08f4c 100644 --- a/sw/source/core/undo/SwUndoPageDesc.cxx +++ b/sw/source/core/undo/SwUndoPageDesc.cxx @@ -30,6 +30,7 @@ #include <tools/resid.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <swundo.hxx> #include <pagedesc.hxx> #include <SwUndoPageDesc.hxx> @@ -325,34 +326,20 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes } } -void SwUndoPageDesc::Undo(SwUndoIter &) +void SwUndoPageDesc::UndoImpl(::sw::UndoRedoContext &) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - // Move (header/footer)content node responsibility from new page descriptor to old one again. if( bExchange ) ExchangeContentNodes( (SwPageDesc&)aNew, (SwPageDesc&)aOld ); pDoc->ChgPageDesc(aOld.GetName(), aOld); - pDoc->DoUndo(bUndo); } -void SwUndoPageDesc::Redo(SwUndoIter &) +void SwUndoPageDesc::RedoImpl(::sw::UndoRedoContext &) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - // Move (header/footer)content node responsibility from old page descriptor to new one again. if( bExchange ) ExchangeContentNodes( (SwPageDesc&)aOld, (SwPageDesc&)aNew ); pDoc->ChgPageDesc(aNew.GetName(), aNew); - pDoc->DoUndo(bUndo); -} - -void SwUndoPageDesc::Repeat(SwUndoIter &) -{ } SwRewriter SwUndoPageDesc::GetRewriter() const @@ -379,12 +366,8 @@ SwUndoPageDescCreate::~SwUndoPageDescCreate() { } -void SwUndoPageDescCreate::Undo(SwUndoIter &) +void SwUndoPageDescCreate::UndoImpl(::sw::UndoRedoContext &) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - // -> #116530# if (pDesc) { @@ -394,25 +377,23 @@ void SwUndoPageDescCreate::Undo(SwUndoIter &) // <- #116530# pDoc->DelPageDesc(aNew.GetName(), TRUE); - pDoc->DoUndo(bUndo); } - -void SwUndoPageDescCreate::Redo(SwUndoIter &) +void SwUndoPageDescCreate::DoImpl() { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - SwPageDesc aPageDesc = aNew; pDoc->MakePageDesc(aNew.GetName(), &aPageDesc, FALSE, TRUE); // #116530# +} - pDoc->DoUndo(bUndo); +void SwUndoPageDescCreate::RedoImpl(::sw::UndoRedoContext &) +{ + DoImpl(); } -void SwUndoPageDescCreate::Repeat(SwUndoIter & rIt) +void SwUndoPageDescCreate::RepeatImpl(::sw::RepeatContext &) { - Redo(rIt); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); + DoImpl(); } SwRewriter SwUndoPageDescCreate::GetRewriter() const @@ -439,29 +420,26 @@ SwUndoPageDescDelete::~SwUndoPageDescDelete() { } -void SwUndoPageDescDelete::Undo(SwUndoIter &) +void SwUndoPageDescDelete::UndoImpl(::sw::UndoRedoContext &) { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); - SwPageDesc aPageDesc = aOld; pDoc->MakePageDesc(aOld.GetName(), &aPageDesc, FALSE, TRUE); // #116530# - pDoc->DoUndo(bUndo); } -void SwUndoPageDescDelete::Redo(SwUndoIter &) +void SwUndoPageDescDelete::DoImpl() { - BOOL bUndo = pDoc->DoesUndo(); - - pDoc->DoUndo(FALSE); pDoc->DelPageDesc(aOld.GetName(), TRUE); // #116530# - pDoc->DoUndo(bUndo); } -void SwUndoPageDescDelete::Repeat(SwUndoIter & rIt) +void SwUndoPageDescDelete::RedoImpl(::sw::UndoRedoContext &) +{ + DoImpl(); +} + +void SwUndoPageDescDelete::RepeatImpl(::sw::RepeatContext &) { - Redo(rIt); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); + DoImpl(); } SwRewriter SwUndoPageDescDelete::GetRewriter() const diff --git a/sw/source/core/undo/SwUndoTOXChange.cxx b/sw/source/core/undo/SwUndoTOXChange.cxx index 8628ff70acc7..457ddc366e7c 100644 --- a/sw/source/core/undo/SwUndoTOXChange.cxx +++ b/sw/source/core/undo/SwUndoTOXChange.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <SwUndoTOXChange.hxx> #include <swundo.hxx> #include <doctxm.hxx> @@ -45,27 +46,32 @@ void SwUndoTOXChange::UpdateTOXBaseSection() if (pTOX->ISA(SwTOXBaseSection)) { SwTOXBaseSection * pTOXBase = static_cast<SwTOXBaseSection *>(pTOX); - pTOXBase->Update(); pTOXBase->UpdatePageNum(); } } -void SwUndoTOXChange::Undo(SwUndoIter &) +void SwUndoTOXChange::UndoImpl(::sw::UndoRedoContext &) { *pTOX = aOld; UpdateTOXBaseSection(); } -void SwUndoTOXChange::Redo(SwUndoIter &) +void SwUndoTOXChange::DoImpl() { *pTOX = aNew; UpdateTOXBaseSection(); } -void SwUndoTOXChange::Repeat(SwUndoIter & rIter) +void SwUndoTOXChange::RedoImpl(::sw::UndoRedoContext &) +{ + DoImpl(); +} + +void SwUndoTOXChange::RepeatImpl(::sw::RepeatContext &) { - Redo(rIter); + DoImpl(); } + diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx index 85adbd1c7138..3dce09e66fa9 100644 --- a/sw/source/core/undo/docundo.cxx +++ b/sw/source/core/undo/docundo.cxx @@ -28,1000 +28,553 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" -#include <svx/svdmodel.hxx> +#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> #include <ndtxt.hxx> -#include <swundo.hxx> // fuer die UndoIds -#include <undobj.hxx> +#include <swundo.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> -#include <docary.hxx> -#ifndef _UNDO_HRC #include <undo.hrc> -#endif +#include <editsh.hxx> +#include <unobaseclass.hxx> using namespace ::com::sun::star; -USHORT SwDoc::nUndoActions = UNDO_ACTION_COUNT; // anzahl von Undo-Action - // the undo array should never grow beyond this limit: #define UNDO_ACTION_LIMIT (USHRT_MAX - 1000) -SV_IMPL_PTRARR( SwUndoIds, SwUndoIdAndNamePtr ) - -//#define _SHOW_UNDORANGE -#ifdef _SHOW_UNDORANGE +// UndoManager /////////////////////////////////////////////////////////// +namespace sw { -class UndoArrStatus : public WorkWindow +UndoManager::UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, + IDocumentDrawModelAccess & rDrawModelAccess, + IDocumentRedlineAccess & rRedlineAccess, + IDocumentState & rState) + : m_rDrawModelAccess(rDrawModelAccess) + , m_rRedlineAccess(rRedlineAccess) + , m_rState(rState) + , m_pUndoNodes(pUndoNodes) + , m_bGroupUndo(true) + , m_bDrawUndo(true) + , m_bLockUndoNoModifiedPosition(false) + , m_UndoSaveMark(MARK_INVALID) { - USHORT nUndo, nUndoNds; - virtual void Paint( const Rectangle& ); -public: - UndoArrStatus(); - void Set( USHORT, USHORT ); -}; -static UndoArrStatus* pUndoMsgWin = 0; - - -UndoArrStatus::UndoArrStatus() - : WorkWindow( APP_GETAPPWINDOW() ), nUndo(0), nUndoNds(0) -{ - SetSizePixel( Size( 200, 100 )); - SetFont( Font( "Courier", Size( 0, 10 )) ); - Show(); + OSL_ASSERT(m_pUndoNodes.get()); + // writer expects it to be disabled initially + // Undo is enabled by SwEditShell constructor + SfxUndoManager::EnableUndo(false); } - -void UndoArrStatus::Set( USHORT n1, USHORT n2 ) +SwNodes const& UndoManager::GetUndoNodes() const { - nUndo = n1; nUndoNds = n2; - Invalidate(); + return *m_pUndoNodes; } - -void UndoArrStatus::Paint( const Rectangle& ) +SwNodes & UndoManager::GetUndoNodes() { - String s; - DrawRect( Rectangle( Point(0,0), GetOutputSize() )); - ( s = "Undos: " ) += nUndo; - DrawText( Point( 0, 0 ), s ); - ( s = "UndoNodes: " ) += nUndoNds; - DrawText( Point( 0, 15 ), s ); + return *m_pUndoNodes; } -#endif - -void SwDoc::SetUndoNoResetModified() +bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const { - nUndoSavePos = USHRT_MAX; + return & rNodes == m_pUndoNodes.get(); } -bool SwDoc::IsUndoNoResetModified() const +void UndoManager::DoUndo(bool const bDoUndo) { - return USHRT_MAX == nUndoSavePos; -} + EnableUndo(bDoUndo); -void SwDoc::DoUndo(bool bUn) -{ - mbUndo = bUn; - - SdrModel* pSdrModel = GetDrawModel(); + SdrModel *const pSdrModel = m_rDrawModelAccess.GetDrawModel(); if( pSdrModel ) - pSdrModel->EnableUndo(bUn); + { + pSdrModel->EnableUndo(bDoUndo); + } } -bool SwDoc::DoesUndo() const +bool UndoManager::DoesUndo() const { - return mbUndo; + return IsUndoEnabled(); } -void SwDoc::DoGroupUndo(bool bUn) +void UndoManager::DoGroupUndo(bool const bDoUndo) { - mbGroupUndo = bUn; + m_bGroupUndo = bDoUndo; } -bool SwDoc::DoesGroupUndo() const +bool UndoManager::DoesGroupUndo() const { - return mbGroupUndo; + return m_bGroupUndo; } -sal_uInt16 SwDoc::GetUndoActionCount() +void UndoManager::DoDrawUndo(bool const bDoUndo) { - return nUndoActions; + m_bDrawUndo = bDoUndo; } -void SwDoc::SetUndoActionCount( sal_uInt16 nNew ) +bool UndoManager::DoesDrawUndo() const { - nUndoActions = nNew; + return m_bDrawUndo; } -const SwNodes* SwDoc::GetUndoNds() const -{ - return &aUndoNodes; -} -void SwDoc::AppendUndo( SwUndo* pUndo ) +bool UndoManager::IsUndoNoResetModified() const { - if( nsRedlineMode_t::REDLINE_NONE == pUndo->GetRedlineMode() ) - pUndo->SetRedlineMode( GetRedlineMode() ); - - // Unfortunately, the silly SvPtrArr can only store a little less than - // USHRT_MAX elements. Of course it doesn't see any necessity for asserting - // or even doing error handling. pUndos should definitely be replaced by an - // STL container that doesn't have this problem. cf #95884# - DBG_ASSERT( pUndos->Count() < USHRT_MAX - 16, - "Writer will crash soon. I apologize for the inconvenience." ); - - pUndos->Insert( pUndo, nUndoPos ); - ++nUndoPos; - switch( pUndo->GetId() ) - { - case UNDO_START: ++nUndoSttEnd; - break; - - case UNDO_END: ASSERT( nUndoSttEnd, "Undo-Ende ohne Start" ); - --nUndoSttEnd; - // kein break !!! - default: - if( pUndos->Count() != nUndoPos && UNDO_END != pUndo->GetId() ) - ClearRedo(); - else { - ASSERT( pUndos->Count() == nUndoPos || UNDO_END == pUndo->GetId(), - "Redo history not deleted!" ); - } - if( !nUndoSttEnd ) - ++nUndoCnt; - break; - } - -#ifdef _SHOW_UNDORANGE - // zur Anzeige der aktuellen Undo-Groessen - if( !pUndoMsgWin ) - pUndoMsgWin = new UndoArrStatus; - pUndoMsgWin->Set( pUndos->Count(), aUndoNodes.Count() ); -#endif - - // noch eine offene Klammerung, kann man sich den Rest schenken - if( nUndoSttEnd ) - return; - - // folgende Array-Grenzen muessen ueberwacht werden: - // - Undo, Grenze: fester Wert oder USHRT_MAX - 1000 - // - UndoNodes, Grenze: USHRT_MAX - 1000 - // - AttrHistory Grenze: USHRT_MAX - 1000 - // (defined in UNDO_ACTION_LIMIT at the top of this file) - - USHORT nEnde = UNDO_ACTION_LIMIT; + return MARK_INVALID == m_UndoSaveMark; +} -// nur zum Testen der neuen DOC-Member -#ifdef DBG_UTIL +void UndoManager::SetUndoNoResetModified() { - SwUndoId nId = UNDO_EMPTY; - USHORT nUndosCnt = 0, nSttEndCnt = 0; - for( USHORT nCnt = 0; nCnt < nUndoPos; ++nCnt ) + if (MARK_INVALID != m_UndoSaveMark) { - if( UNDO_START == ( nId = (*pUndos)[ nCnt ]->GetId()) ) - ++nSttEndCnt; - else if( UNDO_END == nId ) - --nSttEndCnt; - if( !nSttEndCnt ) - ++nUndosCnt; + RemoveMark(m_UndoSaveMark); + m_UndoSaveMark = MARK_INVALID; } - ASSERT( nSttEndCnt == nUndoSttEnd, "Start-Ende Count ungleich" ); - ASSERT( nUndosCnt == nUndoCnt, "Undo Count ungleich" ); } -#endif - if( SwDoc::nUndoActions < 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 - SwDoc::nUndoActions ); - else +void UndoManager::SetUndoNoModifiedPosition() +{ + if (!m_bLockUndoNoModifiedPosition) { - USHORT nUndosCnt = nUndoCnt; - // immer 1/10 loeschen bis der "Ausloeser" behoben ist - while( aUndoNodes.Count() && nEnde < aUndoNodes.Count() ) - DelUndoObj( nUndosCnt / 10 ); + m_UndoSaveMark = MarkTopUndoAction(); } } - - -void SwDoc::ClearRedo() +void UndoManager::LockUndoNoModifiedPosition() { - if( DoesUndo() && nUndoPos != pUndos->Count() ) - { -//?? why ?? if( !nUndoSttEnd ) - { - // setze UndoCnt auf den neuen Wert - SwUndo* pUndo; - for( USHORT nCnt = pUndos->Count(); nUndoPos < nCnt; --nUndoCnt ) - // Klammerung ueberspringen - if( UNDO_END == (pUndo = (*pUndos)[ --nCnt ])->GetId() ) - nCnt = nCnt - ((SwUndoEnd*)pUndo)->GetSttOffset(); - } - - // loesche die Undo-Aktionen (immer von hinten !) - pUndos->DeleteAndDestroy( nUndoPos, pUndos->Count() - nUndoPos ); - } + m_bLockUndoNoModifiedPosition = true; } - - // loescht die gesamten UndoObjecte -void SwDoc::DelAllUndoObj() +void UndoManager::UnLockUndoNoModifiedPosition() { - ClearRedo(); - - DoUndo( FALSE ); - - // Offene Undo-Klammerungen erhalten !! - SwUndo* pUndo; - USHORT nSize = pUndos->Count(); - while( nSize ) - if( UNDO_START != ( pUndo = (*pUndos)[ --nSize ] )->GetId() || - ((SwUndoStart*)pUndo)->GetEndOffset() ) - // keine offenen Gruppierung ? - pUndos->DeleteAndDestroy( nSize, 1 ); - - nUndoCnt = 0; - nUndoPos = pUndos->Count(); - -/* - while( nUndoPos ) - aUndos.DelDtor( --nUndoPos, 1 ); - nUndoCnt = nUndoSttEnd = nUndoPos = 0; -*/ - nUndoSavePos = USHRT_MAX; - DoUndo( TRUE ); + m_bLockUndoNoModifiedPosition = false; } - // loescht alle UndoObjecte vom Anfang bis zum angegebenen Ende -BOOL SwDoc::DelUndoObj( USHORT nEnde ) +SwUndo* UndoManager::GetLastUndo() { - if( !nEnde ) // sollte mal 0 uebergeben werden, + if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) { - if( !pUndos->Count() ) - return FALSE; - ++nEnde; // dann korrigiere es auf 1 + return 0; } - - DoUndo( FALSE ); - - // pruefe erstmal, wo das Ende steht - SwUndoId nId = UNDO_EMPTY; - USHORT nSttEndCnt = 0; - USHORT nCnt; - - for( nCnt = 0; nEnde && nCnt < nUndoPos; ++nCnt ) - { - if( UNDO_START == ( nId = (*pUndos)[ nCnt ]->GetId() )) - ++nSttEndCnt; - else if( UNDO_END == nId ) - --nSttEndCnt; - if( !nSttEndCnt ) - --nEnde, --nUndoCnt; - } - - ASSERT( nCnt < nUndoPos || nUndoPos == pUndos->Count(), - "Undo-Del-Ende liegt in einer Redo-Aktion" ); - - // dann setze ab Ende bis Undo-Ende bei allen Undo-Objecte die Werte um - nSttEndCnt = nCnt; // Position merken - if( nUndoSavePos < nSttEndCnt ) // SavePos wird aufgegeben - nUndoSavePos = USHRT_MAX; - else if( nUndoSavePos != USHRT_MAX ) - nUndoSavePos = nUndoSavePos - nSttEndCnt; - - while( nSttEndCnt ) - pUndos->DeleteAndDestroy( --nSttEndCnt, 1 ); - nUndoPos = pUndos->Count(); - - DoUndo( TRUE ); - return TRUE; + SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) ); + return dynamic_cast<SwUndo*>(pAction); } -/**************** UNDO ******************/ - -void SwDoc::setUndoNoModifiedPosition( SwUndoNoModifiedPosition nNew ) -{ - nUndoSavePos = nNew; - if( !pUndos->Count() || nUndoSavePos > pUndos->Count() - 1 ) - nUndoSavePos = USHRT_MAX; -} - -SwUndoNoModifiedPosition SwDoc::getUndoNoModifiedPosition() const +void UndoManager::AppendUndo(SwUndo *const pUndo) { - return nUndoSavePos; + AddUndoAction(pUndo); } - -bool SwDoc::HasUndoId(SwUndoId eId) const +void UndoManager::ClearRedo() { - USHORT nSize = nUndoPos; - SwUndo * pUndo; - while( nSize-- ) - if( ( pUndo = (*pUndos)[nSize])->GetId() == eId || - ( UNDO_START == pUndo->GetId() && - ((SwUndoStart*)pUndo)->GetUserId() == eId ) - || ( UNDO_END == pUndo->GetId() && - ((SwUndoEnd*)pUndo)->GetUserId() == eId ) ) - { - return TRUE; - } - - return FALSE; + return SfxUndoManager::ImplClearRedo_NoLock(TopLevel); } - -bool SwDoc::Undo( SwUndoIter& rUndoIter ) +void UndoManager::DelAllUndoObj() { - if ( (rUndoIter.GetId()!=0) && (!HasUndoId(rUndoIter.GetId())) ) - { - rUndoIter.bWeiter = FALSE; - return FALSE; - } - if( !nUndoPos ) - { - rUndoIter.bWeiter = FALSE; - return FALSE; - } - - SwUndo *pUndo = (*pUndos)[ --nUndoPos ]; + ::sw::UndoGuard const undoGuard(*this); - RedlineMode_t eOld = GetRedlineMode(); - RedlineMode_t eTmpMode = (RedlineMode_t)pUndo->GetRedlineMode(); - if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eOld) && - UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() ) - SetRedlineMode( eTmpMode ); + SfxUndoManager::ClearAllLevels(); - SetRedlineMode_intern((RedlineMode_t)(eTmpMode | nsRedlineMode_t::REDLINE_IGNORE)); - // Undo ausfuehren - - // zum spaeteren ueberpruefen - SwUndoId nAktId = pUndo->GetId(); - //JP 11.05.98: FlyFormate ueber die EditShell selektieren, nicht aus dem - // Undo heraus - switch( nAktId ) - { - case UNDO_START: - case UNDO_END: - case UNDO_INSDRAWFMT: - break; - - default: - rUndoIter.ClearSelections(); - } - - pUndo->Undo( rUndoIter ); - - SetRedlineMode( eOld ); - - // Besonderheit von Undo-Replace (interne History) - if( UNDO_REPLACE == nAktId && ((SwUndoReplace*)pUndo)->nAktPos ) - { - ++nUndoPos; - return TRUE; - } - - // Objekt aus History entfernen und zerstoeren - if( nUndoPos && !rUndoIter.bWeiter && - UNDO_START == ( pUndo = (*pUndos)[ nUndoPos-1 ] )->GetId() ) - --nUndoPos; - - // JP 29.10.96: Start und End setzen kein Modify-Flag. - // Sonst gibt es Probleme mit der autom. Aufnahme von Ausnahmen - // bei der Autokorrektur - if( UNDO_START != nAktId && UNDO_END != nAktId ) - SetModified(); // default: immer setzen, kann zurueck gesetzt werden - - // ist die History leer und wurde nicht wegen Speichermangel - // verworfen, so kann das Dokument als unveraendert gelten - if( nUndoSavePos == nUndoPos ) - ResetModified(); - - return TRUE; + m_UndoSaveMark = MARK_INVALID; } -// setzt Undoklammerung auf, liefert nUndoId der Klammerung - +/**************** UNDO ******************/ -SwUndoId SwDoc::StartUndo( SwUndoId eUndoId, const SwRewriter * pRewriter ) +SwUndoId +UndoManager::StartUndo(SwUndoId const i_eUndoId, + SwRewriter const*const pRewriter) { - if( !mbUndo ) + if (!IsUndoEnabled()) + { return UNDO_EMPTY; + } - if( !eUndoId ) - eUndoId = UNDO_START; - - SwUndoStart * pUndo = new SwUndoStart( eUndoId ); + SwUndoId const eUndoId( (0 == i_eUndoId) ? UNDO_START : i_eUndoId ); + OSL_ASSERT(UNDO_END != eUndoId); + String comment( (UNDO_START == eUndoId) + ? String("??", RTL_TEXTENCODING_ASCII_US) + : String(SW_RES(UNDO_BASE + eUndoId)) ); if (pRewriter) - pUndo->SetRewriter(*pRewriter); + { + OSL_ASSERT(UNDO_START != eUndoId); + comment = pRewriter->Apply(comment); + } - AppendUndo(pUndo); + SfxUndoManager::EnterListAction(comment, comment, eUndoId); return eUndoId; } -// schliesst Klammerung der nUndoId, nicht vom UI benutzt -SwUndoId SwDoc::EndUndo(SwUndoId eUndoId, const SwRewriter * pRewriter) +SwUndoId +UndoManager::EndUndo(SwUndoId const i_eUndoId, SwRewriter const*const pRewriter) { - USHORT nSize = nUndoPos; - if( !mbUndo || !nSize-- ) - return UNDO_EMPTY; - - if( UNDO_START == eUndoId || !eUndoId ) - eUndoId = UNDO_END; - - SwUndo* pUndo = (*pUndos)[ nSize ]; - if( UNDO_START == pUndo->GetId() ) + if (!IsUndoEnabled()) { - // leere Start/End-Klammerung ?? - pUndos->DeleteAndDestroy( nSize ); - --nUndoPos; - --nUndoSttEnd; return UNDO_EMPTY; } - // exist above any redo objects? If yes, delete them - if( nUndoPos != pUndos->Count() ) - { - // setze UndoCnt auf den neuen Wert - for( USHORT nCnt = pUndos->Count(); nUndoPos < nCnt; --nUndoCnt ) - // Klammerung ueberspringen - if( UNDO_END == (pUndo = (*pUndos)[ --nCnt ])->GetId() ) - nCnt = nCnt - ((SwUndoEnd*)pUndo)->GetSttOffset(); - - pUndos->DeleteAndDestroy( nUndoPos, pUndos->Count() - nUndoPos ); - } - - // suche den Anfang dieser Klammerung - SwUndoId nId = UNDO_EMPTY; - while( nSize ) - if( UNDO_START == ( nId = (pUndo = (*pUndos)[ --nSize ] )->GetId()) && - !((SwUndoStart*)pUndo)->GetEndOffset() ) - break; // Start gefunden + SwUndoId const eUndoId( ((0 == i_eUndoId) || (UNDO_START == i_eUndoId)) + ? UNDO_END : i_eUndoId ); + OSL_ENSURE(!((UNDO_END == eUndoId) && pRewriter), + "EndUndo(): no Undo ID, but rewriter given?"); - if( nId != UNDO_START ) - { - // kann eigentlich nur beim Abspielen von Macros passieren, die - // Undo/Redo/Repeat benutzen und die eine exitierende Selection - // durch Einfuegen loeschen - ASSERT( !this, "kein entsprechendes Ende gefunden" ); - // kein entsprechenden Start gefunden -> Ende nicht einfuegen - // und die Member am Doc updaten - - nUndoSttEnd = 0; - nUndoCnt = 0; - // setze UndoCnt auf den neuen Wert - SwUndo* pTmpUndo; - for( USHORT nCnt = 0; nCnt < pUndos->Count(); ++nCnt, ++nUndoCnt ) - // Klammerung ueberspringen - if( UNDO_START == (pTmpUndo = (*pUndos)[ nCnt ])->GetId() ) - nCnt = nCnt + ((SwUndoStart*)pTmpUndo)->GetEndOffset(); - return UNDO_EMPTY; + SfxUndoAction *const pLastUndo( + (0 == SfxUndoManager::GetUndoActionCount(CurrentLevel)) + ? 0 : SfxUndoManager::GetUndoAction(0) ); - } + int const nCount = LeaveListAction(); - // Klammerung um eine einzelne Action muss nicht sein! - // Aussnahme: es ist eine eigene ID definiert - if( 2 == pUndos->Count() - nSize && - (UNDO_END == eUndoId || eUndoId == (*pUndos)[ nSize+1 ]->GetId() )) + if (nCount) // otherwise: empty list action not inserted! { - pUndos->DeleteAndDestroy( nSize ); - nUndoPos = pUndos->Count(); - if( !--nUndoSttEnd ) + OSL_ASSERT(pLastUndo); + OSL_ASSERT(UNDO_START != eUndoId); + SfxUndoAction *const pUndoAction(SfxUndoManager::GetUndoAction(0)); + SfxListUndoAction *const pListAction( + dynamic_cast<SfxListUndoAction*>(pUndoAction)); + OSL_ASSERT(pListAction); + if (pListAction) { - ++nUndoCnt; - if( SwDoc::nUndoActions < 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 - SwDoc::nUndoActions ); + if (UNDO_END != eUndoId) + { + OSL_ENSURE(pListAction->GetId() == eUndoId, + "EndUndo(): given ID different from StartUndo()"); + // comment set by caller of EndUndo + String comment = String(SW_RES(UNDO_BASE + eUndoId)); + if (pRewriter) + { + comment = pRewriter->Apply(comment); + } + pListAction->SetComment(comment); + } + else if ((UNDO_START != pListAction->GetId())) + { + // comment set by caller of StartUndo: nothing to do here + } + else if (pLastUndo) + { + // comment was not set at StartUndo or EndUndo: + // take comment of last contained action + // (note that this works recursively, i.e. the last contained + // action may be a list action created by StartUndo/EndUndo) + String const comment(pLastUndo->GetComment()); + pListAction->SetComment(comment); + } else { - USHORT nEnde = USHRT_MAX - 1000; - USHORT nUndosCnt = nUndoCnt; - // immer 1/10 loeschen bis der "Ausloeser" behoben ist - while( aUndoNodes.Count() && nEnde < aUndoNodes.Count() ) - DelUndoObj( nUndosCnt / 10 ); + OSL_ENSURE(false, "EndUndo(): no comment?"); } } - return eUndoId; } - // setze die Klammerung am Start/End-Undo - nSize = pUndos->Count() - nSize; - ((SwUndoStart*)pUndo)->SetEndOffset( nSize ); - - SwUndoEnd* pUndoEnd = new SwUndoEnd( eUndoId ); - pUndoEnd->SetSttOffset( nSize ); + return eUndoId; +} -// nur zum Testen der Start/End-Verpointerung vom Start/End Undo -#ifdef DBG_UTIL +bool +UndoManager::GetLastUndoInfo( + ::rtl::OUString *const o_pStr, SwUndoId *const o_pId) const +{ + // this is actually expected to work on the current level, + // but that was really not obvious from the previous implementation... + if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) { - USHORT nEndCnt = 1, nCnt = pUndos->Count(); - SwUndoId nTmpId = UNDO_EMPTY; - while( nCnt ) - { - if( UNDO_START == ( nTmpId = (*pUndos)[ --nCnt ]->GetId()) ) - { - if( !nEndCnt ) // falls mal ein Start ohne Ende vorhanden ist - continue; - --nEndCnt; - if( !nEndCnt ) // hier ist der Anfang - break; - } - else if( UNDO_END == nTmpId ) - ++nEndCnt; - else if( !nEndCnt ) - break; - } - ASSERT( nCnt == pUndos->Count() - nSize, - "Start-Ende falsch geklammert" ); + return false; } -#endif - if (pRewriter) + SfxUndoAction *const pAction( SfxUndoManager::GetUndoAction(0) ); + + if (o_pStr) { - ((SwUndoStart *) pUndo)->SetRewriter(*pRewriter); - pUndoEnd->SetRewriter(*pRewriter); + *o_pStr = pAction->GetComment(); + } + if (o_pId) + { + USHORT const nId(pAction->GetId()); + *o_pId = static_cast<SwUndoId>(nId); } - else - pUndoEnd->SetRewriter(((SwUndoStart *) pUndo)->GetRewriter()); - AppendUndo( pUndoEnd ); - return eUndoId; + return true; } -// liefert die Id der letzten Undofaehigen Aktion zurueck oder 0 -// fuellt ggf. VARARR mit User-UndoIds - -String SwDoc::GetUndoIdsStr( String* pStr, SwUndoIds *pUndoIds) const +SwUndoComments_t UndoManager::GetUndoComments() const { - String aTmpStr; + OSL_ENSURE(!SfxUndoManager::IsInListAction(), + "GetUndoComments() called while in list action?"); - if (pStr != NULL) + SwUndoComments_t ret; + USHORT const nUndoCount(SfxUndoManager::GetUndoActionCount(TopLevel)); + for (USHORT n = 0; n < nUndoCount; ++n) { - GetUndoIds( pStr, pUndoIds); - aTmpStr = *pStr; + ::rtl::OUString const comment( + SfxUndoManager::GetUndoActionComment(n, TopLevel)); + ret.push_back(comment); } - else - GetUndoIds( &aTmpStr, pUndoIds); - return aTmpStr; + return ret; } -/*-- 24.11.2004 16:11:21--------------------------------------------------- - -----------------------------------------------------------------------*/ -sal_Bool SwDoc::RestoreInvisibleContent() +/**************** REDO ******************/ + +bool UndoManager::GetFirstRedoInfo(::rtl::OUString *const o_pStr) const { - sal_Bool bRet = sal_False; - if(nUndoPos > 0 ) + if (!SfxUndoManager::GetRedoActionCount(CurrentLevel)) { - SwUndo * pUndo = (*pUndos)[ nUndoPos - 1 ]; - if( ( pUndo->GetId() == UNDO_END && - static_cast<SwUndoEnd *>(pUndo)->GetUserId() == UNDO_UI_DELETE_INVISIBLECNTNT) ) - { - SwPaM aPam( GetNodes().GetEndOfPostIts() ); - SwUndoIter aUndoIter( &aPam ); - do - { - Undo( aUndoIter ); - } - while ( aUndoIter.IsNextUndo() ); - ClearRedo(); - bRet = sal_True; - } + return false; } - return bRet; -} - - -/** - Returns id and comment for a certain undo object in an undo stack. - - Remark: In the following the object type referred to is always the - effective object type. If an UNDO_START or UNDO_END has a user type - it is referred to as this type. - - If the queried object is an UNDO_END and has no user id the result - is taken from the first object that is not an UNDO_END nor an - UNDO_START preceeding the queried object. - - If the queried object is an UNDO_START and has no user id the - result is taken from the first object that is not an UNDO_END nor - an UNDO_START preceeding the UNDO_END object belonging to the - queried object. - In all other cases the result is taken from the queried object. - - @param rUndos the undo stack - @param nPos position of the undo object to query - - @return SwUndoIdAndName object containing the query result - */ -SwUndoIdAndName * lcl_GetUndoIdAndName(const SwUndos & rUndos, sal_uInt16 nPos ) -{ - SwUndo * pUndo = rUndos[ nPos ]; - SwUndoId nId = UNDO_EMPTY; - String sStr("??", RTL_TEXTENCODING_ASCII_US); - - ASSERT( nPos < rUndos.Count(), "nPos out of range"); - - switch (pUndo->GetId()) + if (o_pStr) { - case UNDO_START: - { - SwUndoStart * pUndoStart = (SwUndoStart *) pUndo; - nId = pUndoStart->GetUserId(); - - if (nId <= UNDO_END) - { - /** - Start at the according UNDO_END. Search backwards - for first objects that is not a UNDO_END. - */ - int nTmpPos = nPos + pUndoStart->GetEndOffset(); - int nSubstitute = -1; - - // --> OD 2009-09-30 #i105457# - if ( nTmpPos > 0 ) - // <-- - { - SwUndo * pTmpUndo; - do - { - nTmpPos--; - pTmpUndo = rUndos[ static_cast<USHORT>(nTmpPos) ]; - - if (pTmpUndo->GetEffectiveId() > UNDO_END) - nSubstitute = nTmpPos; - } - while (nSubstitute < 0 && nTmpPos > nPos); - - if (nSubstitute >= 0) - { - SwUndo * pSubUndo = rUndos[ static_cast<USHORT>(nSubstitute) ]; - nId = pSubUndo->GetEffectiveId(); - sStr = pSubUndo->GetComment(); - } - } - } - else - sStr = pUndo->GetComment(); - } - - break; - - case UNDO_END: - { - SwUndoEnd * pUndoEnd = (SwUndoEnd *) pUndo; - nId = pUndoEnd->GetUserId(); - - if (nId <= UNDO_END) - { - /** - Start at this UNDO_END. Search backwards - for first objects that is not a UNDO_END. - */ - - int nTmpPos = nPos; - int nUndoStart = nTmpPos - pUndoEnd->GetSttOffset(); - int nSubstitute = -1; - - if (nTmpPos > 0) - { - SwUndo * pTmpUndo; - - do - { - nTmpPos--; - pTmpUndo = rUndos[ static_cast<USHORT>(nTmpPos) ]; - - if (pTmpUndo->GetEffectiveId() > UNDO_END) - nSubstitute = nTmpPos; - } - while (nSubstitute < 0 && nTmpPos > nUndoStart); - - if (nSubstitute >= 0) - { - SwUndo * pSubUndo = rUndos[ static_cast<USHORT>(nSubstitute) ]; - nId = pSubUndo->GetEffectiveId(); - sStr = pSubUndo->GetComment(); - } - } - } - else - sStr = pUndo->GetComment(); - } - - break; - - default: - nId = pUndo->GetId(); - sStr = pUndo->GetComment(); + *o_pStr = SfxUndoManager::GetRedoActionComment(0, CurrentLevel); } - return new SwUndoIdAndName(nId, &sStr); + return true; } -SwUndoId SwDoc::GetUndoIds( String* pStr, SwUndoIds *pUndoIds) const + +SwUndoComments_t UndoManager::GetRedoComments() const { - int nTmpPos = nUndoPos - 1; - SwUndoId nId = UNDO_EMPTY; + OSL_ENSURE(!SfxUndoManager::IsInListAction(), + "GetRedoComments() called while in list action?"); - while (nTmpPos >= 0) + SwUndoComments_t ret; + USHORT const nRedoCount(SfxUndoManager::GetRedoActionCount(TopLevel)); + for (USHORT n = 0; n < nRedoCount; ++n) { - SwUndo * pUndo = (*pUndos)[ static_cast<USHORT>(nTmpPos) ]; - - SwUndoIdAndName * pIdAndName = lcl_GetUndoIdAndName( *pUndos, static_cast<sal_uInt16>(nTmpPos) ); - - if (nTmpPos == nUndoPos - 1) - { - nId = pIdAndName->GetUndoId(); - - if (pStr) - *pStr = *pIdAndName->GetUndoStr(); - } - - if (pUndoIds) - pUndoIds->Insert(pIdAndName, pUndoIds->Count()); - else - break; - - if (pUndo->GetId() == UNDO_END) - nTmpPos -= ((SwUndoEnd *) pUndo)->GetSttOffset(); - - nTmpPos--; + ::rtl::OUString const comment( + SfxUndoManager::GetRedoActionComment(n, TopLevel)); + ret.push_back(comment); } - return nId; + return ret; } -bool SwDoc::HasTooManyUndos() const -{ - // AppendUndo checks the UNDO_ACTION_LIMIT, unless there's a nested undo. - // So HasTooManyUndos() may only occur when undos are nested; else - // AppendUndo has some sort of bug. - DBG_ASSERT( (nUndoSttEnd != 0) || (pUndos->Count() < UNDO_ACTION_LIMIT), - "non-nested undos should have been handled in AppendUndo" ); - return (pUndos->Count() >= UNDO_ACTION_LIMIT); -} - - -/**************** REDO ******************/ - +/**************** REPEAT ******************/ -bool SwDoc::Redo( SwUndoIter& rUndoIter ) +SwUndoId UndoManager::GetRepeatInfo(::rtl::OUString *const o_pStr) const { - if( rUndoIter.GetId() && !HasUndoId( rUndoIter.GetId() ) ) + SwUndoId nRepeatId(UNDO_EMPTY); + GetLastUndoInfo(o_pStr, & nRepeatId); + if( REPEAT_START <= nRepeatId && REPEAT_END > nRepeatId ) { - rUndoIter.bWeiter = FALSE; - return FALSE; + return nRepeatId; } - if( nUndoPos == pUndos->Count() ) + if (o_pStr) // not repeatable -> clear comment { - rUndoIter.bWeiter = FALSE; - return FALSE; + *o_pStr = String(); } + return UNDO_EMPTY; +} - SwUndo *pUndo = (*pUndos)[ nUndoPos++ ]; - - RedlineMode_t eOld = GetRedlineMode(); - RedlineMode_t eTmpMode = (RedlineMode_t)pUndo->GetRedlineMode(); - if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eOld) && - UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() ) - SetRedlineMode( eTmpMode ); - SetRedlineMode_intern( (RedlineMode_t)(eTmpMode | nsRedlineMode_t::REDLINE_IGNORE)); - - //JP 11.05.98: FlyFormate ueber die EditShell selektieren, nicht aus dem - // Undo heraus - if( UNDO_START != pUndo->GetId() && UNDO_END != pUndo->GetId() ) - rUndoIter.ClearSelections(); - - pUndo->Redo( rUndoIter ); - - SetRedlineMode( eOld ); - - // Besonderheit von Undo-Replace (interne History) - if( UNDO_REPLACE == pUndo->GetId() && - USHRT_MAX != ((SwUndoReplace*)pUndo)->nAktPos ) +SwUndo * UndoManager::RemoveLastUndo() +{ + if (SfxUndoManager::GetRedoActionCount(CurrentLevel) || + SfxUndoManager::GetRedoActionCount(TopLevel)) { - --nUndoPos; - return TRUE; + OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?"); + return 0; } - - if( rUndoIter.bWeiter && nUndoPos >= pUndos->Count() ) - rUndoIter.bWeiter = FALSE; - - // ist die History leer und wurde nicht wegen Speichermangel - // verworfen, so kann das Dokument als unveraendert gelten - if( nUndoSavePos == nUndoPos ) - ResetModified(); - else - SetModified(); - return TRUE; + if (!SfxUndoManager::GetUndoActionCount(CurrentLevel)) + { + OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions"); + return 0; + } + SfxUndoAction *const pLastUndo(GetUndoAction(0)); + SfxUndoManager::RemoveLastUndoAction(); + return dynamic_cast<SwUndo *>(pLastUndo); } +// svl::IUndoManager ///////////////////////////////////////////////////// -// liefert die Id der letzten Redofaehigen Aktion zurueck oder 0 -// fuellt ggf. VARARR mit User-RedoIds - -String SwDoc::GetRedoIdsStr( String* pStr, SwUndoIds *pRedoIds ) const +void UndoManager::EnableUndo(bool bEnable) { - String aTmpStr; - - if (pStr != NULL) + // UGLY: SfxUndoManager has a counter to match enable/disable calls + // but the writer code expects that a single call switches + while (IsUndoEnabled() != bEnable) { - GetRedoIds( pStr, pRedoIds ); - aTmpStr = *pStr; + SfxUndoManager::EnableUndo(bEnable); } - else - GetRedoIds( &aTmpStr, pRedoIds ); - - - return aTmpStr; } - -SwUndoId SwDoc::GetRedoIds( String* pStr, SwUndoIds *pRedoIds ) const +void UndoManager::AddUndoAction(SfxUndoAction *pAction, sal_Bool bTryMerge) { - sal_uInt16 nTmpPos = nUndoPos; - SwUndoId nId = UNDO_EMPTY; - - while (nTmpPos < pUndos->Count()) + SwUndo *const pUndo( dynamic_cast<SwUndo *>(pAction) ); + if (pUndo) { - SwUndo * pUndo = (*pUndos)[nTmpPos]; - - SwUndoIdAndName * pIdAndName = lcl_GetUndoIdAndName(*pUndos, nTmpPos); - - if (nTmpPos == nUndoPos) + if (nsRedlineMode_t::REDLINE_NONE == pUndo->GetRedlineMode()) { - nId = pIdAndName->GetUndoId(); - - if (pStr) - *pStr = *pIdAndName->GetUndoStr(); + pUndo->SetRedlineMode( m_rRedlineAccess.GetRedlineMode() ); } - - if (pRedoIds) - pRedoIds->Insert(pIdAndName, pRedoIds->Count()); - else - break; - - if (pUndo->GetId() == UNDO_START) - nTmpPos = nTmpPos + ((SwUndoStart *) pUndo)->GetEndOffset(); - - nTmpPos++; } - - return nId; + SfxUndoManager::AddUndoAction(pAction, bTryMerge); + // if the undo nodes array is too large, delete some actions + while (UNDO_ACTION_LIMIT < GetUndoNodes().Count()) + { + RemoveOldestUndoActions(1); + } } -/**************** REPEAT ******************/ - - -bool SwDoc::Repeat( SwUndoIter& rUndoIter, sal_uInt16 nRepeatCnt ) +class CursorGuard { - if( rUndoIter.GetId() && !HasUndoId( rUndoIter.GetId() ) ) +public: + CursorGuard(SwEditShell & rShell, bool const bSave) + : m_rShell(rShell) + , m_bSaveCursor(bSave) { - rUndoIter.bWeiter = FALSE; - return FALSE; + if (m_bSaveCursor) + { + m_rShell.Push(); // prevent modification of current cursor + } } - USHORT nSize = nUndoPos; - if( !nSize ) + ~CursorGuard() { - rUndoIter.bWeiter = FALSE; - return FALSE; + if (m_bSaveCursor) + { + m_rShell.Pop(); + } } +private: + SwEditShell & m_rShell; + bool const m_bSaveCursor; +}; - // dann suche jetzt ueber die End/Start-Gruppen die gueltige Repeat-Aktion - SwUndo *pUndo = (*pUndos)[ --nSize ]; - if( UNDO_END == pUndo->GetId() ) - nSize = nSize - ((SwUndoEnd*)pUndo)->GetSttOffset(); +bool UndoManager::impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo) +{ + SwDoc & rDoc(*GetUndoNodes().GetDoc()); - USHORT nEndCnt = nUndoPos; - BOOL bOneUndo = nSize + 1 == nUndoPos; + UnoActionContext c(& rDoc); // exception-safe StartAllAction/EndAllAction - SwPaM* pTmpCrsr = rUndoIter.pAktPam; - SwUndoId nId = UNDO_EMPTY; + SwEditShell *const pEditShell( rDoc.GetEditShell() ); - if( pTmpCrsr != pTmpCrsr->GetNext() || !bOneUndo ) // Undo-Klammerung aufbauen + OSL_ENSURE(pEditShell, "sw::UndoManager needs a SwEditShell!"); + if (!pEditShell) { - if (pUndo->GetId() == UNDO_END) - { - SwUndoStart * pStartUndo = - (SwUndoStart *) (*pUndos)[nSize]; - - nId = pStartUndo->GetUserId(); - } - - StartUndo( nId, NULL ); + throw uno::RuntimeException(); } - do { // dann durchlaufe mal den gesamten Ring - for( USHORT nRptCnt = nRepeatCnt; nRptCnt > 0; --nRptCnt ) - { - rUndoIter.pLastUndoObj = 0; - for( USHORT nCnt = nSize; nCnt < nEndCnt; ++nCnt ) - (*pUndos)[ nCnt ]->Repeat( rUndoIter ); // Repeat ausfuehren - } - } while( pTmpCrsr != - ( rUndoIter.pAktPam = (SwPaM*)rUndoIter.pAktPam->GetNext() )); - if( pTmpCrsr != pTmpCrsr->GetNext() || !bOneUndo ) - EndUndo( nId, NULL ); - return TRUE; -} + // in case the model has controllers locked, the Undo should not + // change the view cursors! + bool const bSaveCursors(pEditShell->CursorsLocked()); + CursorGuard(*pEditShell, bSaveCursors); + if (!bSaveCursors) + { + // (in case Undo was called via API) clear the cursors: + pEditShell->KillPams(); + pEditShell->SetMark(); + pEditShell->ClearMark(); + } -// liefert die Id der letzten Repeatfaehigen Aktion zurueck oder 0 -// fuellt ggf. VARARR mit User-RedoIds + bool bRet(false); -String SwDoc::GetRepeatIdsStr(String* pStr, SwUndoIds *pRepeatIds) const -{ - String aTmpStr; - SwUndoId nId; + ::sw::UndoRedoContext context(rDoc, *pEditShell); - if ( pStr != NULL) + // N.B. these may throw! + if (UNDO == undoOrRedo) { - nId = GetRepeatIds(pStr, pRepeatIds); - aTmpStr = *pStr; + bRet = SfxUndoManager::UndoWithContext(context); } else - nId = GetRepeatIds(&aTmpStr, pRepeatIds); + { + bRet = SfxUndoManager::RedoWithContext(context); + } - if (nId <= UNDO_END) - return String(); + if (bRet) + { + // if we are at the "last save" position, the document is not modified + if (SfxUndoManager::HasTopUndoActionMark(m_UndoSaveMark)) + { + m_rState.ResetModified(); + } + else + { + m_rState.SetModified(); + } + } + + pEditShell->HandleUndoRedoContext(context); - return aTmpStr; + return bRet; } -SwUndoId SwDoc::GetRepeatIds(String* pStr, SwUndoIds *pRepeatIds) const +sal_Bool UndoManager::Undo() { - SwUndoId nRepeatId = GetUndoIds( pStr, pRepeatIds ); - if( REPEAT_START <= nRepeatId && REPEAT_END > nRepeatId ) - return nRepeatId; - return UNDO_EMPTY; + bool const bRet = impl_DoUndoRedo(UNDO); + return bRet; } +sal_Bool UndoManager::Redo() +{ + bool const bRet = impl_DoUndoRedo(REDO); + return bRet; +} -SwUndo* SwDoc::RemoveLastUndo( SwUndoId eUndoId ) +/** N.B.: this does _not_ call SfxUndoManager::Repeat because it is not + possible to wrap a list action around it: + calling EnterListAction here will cause SfxUndoManager::Repeat + to repeat the list action! + */ +bool +UndoManager::Repeat(::sw::RepeatContext & rContext, + sal_uInt16 const nRepeatCount) { - SwUndo* pUndo = (*pUndos)[ nUndoPos - 1 ]; - if( eUndoId == pUndo->GetId() && nUndoPos == pUndos->Count() ) + if (SfxUndoManager::IsInListAction()) { - if( !nUndoSttEnd ) - --nUndoCnt; - --nUndoPos; - pUndos->Remove( nUndoPos, 1 ); + OSL_ENSURE(false, "repeat in open list action???"); + return false; } - else + if (!SfxUndoManager::GetUndoActionCount(TopLevel)) { - pUndo = 0; - ASSERT( !this, "falsches Undo-Object" ); + return false; + } + SfxUndoAction *const pRepeatAction(GetUndoAction(0)); + OSL_ASSERT(pRepeatAction); + if (!pRepeatAction || !pRepeatAction->CanRepeat(rContext)) + { + return false; } - return pUndo; -} -SwUndoIdAndName::SwUndoIdAndName( SwUndoId nId, const String* pStr ) - : eUndoId( nId ), pUndoStr( pStr ? new String( *pStr ) : 0 ) -{ -} + ::rtl::OUString const comment(pRepeatAction->GetComment()); + ::rtl::OUString const rcomment(pRepeatAction->GetRepeatComment(rContext)); + USHORT const nId(pRepeatAction->GetId()); + if (DoesUndo()) + { + EnterListAction(comment, rcomment, nId); + } -SwUndoIdAndName::~SwUndoIdAndName() -{ - delete pUndoStr; -} + SwPaM *const pFirstCursor(& rContext.GetRepeatPaM()); + do { // iterate over ring + for (USHORT nRptCnt = nRepeatCount; nRptCnt > 0; --nRptCnt) + { + pRepeatAction->Repeat(rContext); + } + rContext.m_bDeleteRepeated = false; // reset for next PaM + rContext.m_pCurrentPaM = + static_cast<SwPaM*>(rContext.m_pCurrentPaM->GetNext()); + } while (pFirstCursor != & rContext.GetRepeatPaM()); + if (DoesUndo()) + { + LeaveListAction(); + } + return true; +} +} // namespace sw diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index d9a0cc8514a4..d2844658df0c 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -28,9 +28,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <rolbck.hxx> + +#include <tools/resid.hxx> -#include <hintids.hxx> #include <svl/itemiter.hxx> + +#include <editeng/brkitem.hxx> + +#include <hints.hxx> +#include <hintids.hxx> #include <fmtftn.hxx> #include <fchrfmt.hxx> #include <fmtflcnt.hxx> @@ -47,6 +54,7 @@ #include <frmfmt.hxx> #include <ftnidx.hxx> #include <doc.hxx> // SwDoc.GetNodes() +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <ndtxt.hxx> // SwTxtNode #include <paratr.hxx> // @@ -54,19 +62,12 @@ #include <fldbas.hxx> // fuer Felder #include <pam.hxx> // fuer SwPaM #include <swtable.hxx> -#include <rolbck.hxx> #include <ndgrf.hxx> // SwGrfNode -#include <undobj.hxx> // fuer UndoDelete +#include <UndoCore.hxx> #include <IMark.hxx> // fuer SwBookmark #include <charfmt.hxx> // #i27615# -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#include <tools/resid.hxx> -#ifndef _UNDO_HRC #include <undo.hrc> -#endif -#include <editeng/brkitem.hxx> #include <bookmrk.hxx> SV_IMPL_PTRARR( SwpHstry, SwHistoryHintPtr) @@ -580,9 +581,10 @@ SwHistoryTxtFlyCnt::~SwHistoryTxtFlyCnt() void SwHistoryTxtFlyCnt::SetInDoc( SwDoc* pDoc, bool ) { - SwPaM aPam( pDoc->GetNodes().GetEndOfPostIts() ); - SwUndoIter aUndoIter( &aPam ); - m_pUndo->Undo( aUndoIter ); + ::sw::IShellCursorSupplier *const pISCS(pDoc->GetIShellCursorSupplier()); + OSL_ASSERT(pISCS); + ::sw::UndoRedoContext context(*pDoc, *pISCS); + m_pUndo->UndoImpl(context); } @@ -626,8 +628,7 @@ SwHistoryBookmark::SwHistoryBookmark( void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { - bool bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo(false); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwNodes& rNds = pDoc->GetNodes(); IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess(); @@ -698,7 +699,6 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) } } } - pDoc->DoUndo(bDoesUndo); } @@ -793,8 +793,7 @@ SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet, void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwNode * pNode = pDoc->GetNodes()[ m_nNodeIndex ]; if ( pNode->IsCntntNode() ) @@ -815,8 +814,6 @@ void SwHistorySetAttrSet::SetInDoc( SwDoc* pDoc, bool ) rFmt.ResetFmtAttr( *m_ResetArray.GetData() ); } } - - pDoc->DoUndo( bDoesUndo ); } /*************************************************************************/ @@ -879,8 +876,7 @@ SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) { - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); SwCntntNode * pCntntNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetCntntNode(); ASSERT( pCntntNd, "SwHistoryResetAttrSet: no CntntNode" ); @@ -906,8 +902,6 @@ void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) } } } - - pDoc->DoUndo( bDoesUndo ); } @@ -927,8 +921,7 @@ SwHistoryChangeFlyAnchor::SwHistoryChangeFlyAnchor( SwFrmFmt& rFmt ) void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) { - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); USHORT nPos = pDoc->GetSpzFrmFmts()->GetPos( &m_rFmt ); if ( USHRT_MAX != nPos ) // Format does still exist @@ -956,7 +949,6 @@ void SwHistoryChangeFlyAnchor::SetInDoc( SwDoc* pDoc, bool ) m_rFmt.SetFmtAttr( aTmp ); } - pDoc->DoUndo( bDoesUndo ); } @@ -1276,7 +1268,7 @@ USHORT SwHistory::SetTmpEnd( USHORT nNewTmpEnd ) if ( HSTRY_FLYCNT == (*this)[ n ]->Which() ) { static_cast<SwHistoryTxtFlyCnt*>((*this)[ n ]) - ->GetUDelLFmt()->Redo(); + ->GetUDelLFmt()->RedoForRollback(); } } diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index e3b54c59b142..d1b92a8049e3 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -28,16 +28,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #define _SVSTDARR_USHORTS #define _SVSTDARR_USHORTSSORT -#include <hintids.hxx> -#include <svx/svdmodel.hxx> -#include <editeng/tstpitem.hxx> -#include <svx/svdpage.hxx> +#include <UndoAttribute.hxx> + #include <svl/itemiter.hxx> +#include <editeng/tstpitem.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdpage.hxx> + +#include <hintids.hxx> #include <fmtflcnt.hxx> #include <txtftn.hxx> #include <fmtornt.hxx> @@ -47,13 +49,16 @@ #include <fmtcntnt.hxx> #include <ftnidx.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> +#include <IShellCursorSupplier.hxx> #include <docary.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> #include <swtable.hxx> #include <swtblfmt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <hints.hxx> #include <rolbck.hxx> #include <ndnotxt.hxx> #include <dcontact.hxx> @@ -64,9 +69,6 @@ -inline SwDoc& SwUndoIter::GetDoc() const -{ return *pAktPam->GetDoc(); } - // ----------------------------------------------------- SwUndoFmtAttrHelper::SwUndoFmtAttrHelper( SwFmt& rFmt, bool bSvDrwPt ) @@ -194,12 +196,12 @@ SwUndoFmtAttr::~SwUndoFmtAttr() { } -void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) +void SwUndoFmtAttr::UndoImpl(::sw::UndoRedoContext & rContext) { // OD 2004-10-26 #i35443# // Important note: <Undo(..)> also called by <ReDo(..)> - if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rUndoIter.GetDoc() )) + if ( !m_pOldSet.get() || !m_pFmt || !IsFmtInDoc( &rContext.GetDoc() )) return; // --> OD 2004-10-26 #i35443# - If anchor attribute has been successfull @@ -208,7 +210,7 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) bool bAnchorAttrRestored( false ); if ( SFX_ITEM_SET == m_pOldSet->GetItemState( RES_ANCHOR, FALSE )) { - bAnchorAttrRestored = RestoreFlyAnchor( rUndoIter ); + bAnchorAttrRestored = RestoreFlyAnchor(rContext); if ( bAnchorAttrRestored ) { // Anchor attribute successfull restored. @@ -240,7 +242,7 @@ void SwUndoFmtAttr::Undo( SwUndoIter& rUndoIter) if ( RES_FLYFRMFMT == m_nFmtWhich || RES_DRAWFRMFMT == m_nFmtWhich ) { - rUndoIter.pSelFmt = static_cast<SwFrmFmt*>(m_pFmt); + rContext.SetSelections(static_cast<SwFrmFmt*>(m_pFmt), 0); } } } @@ -330,49 +332,41 @@ SwFmt* SwUndoFmtAttr::GetFmt( SwDoc& rDoc ) return m_pFmt && IsFmtInDoc( &rDoc ) ? m_pFmt : 0; } -void SwUndoFmtAttr::Redo( SwUndoIter& rUndoIter) +void SwUndoFmtAttr::RedoImpl(::sw::UndoRedoContext & rContext) { // --> OD 2004-10-26 #i35443# - Because the undo stores the attributes for // redo, the same code as for <Undo(..)> can be applied for <Redo(..)> - Undo( rUndoIter ); + UndoImpl(rContext); // <-- } -void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) +void SwUndoFmtAttr::RepeatImpl(::sw::RepeatContext & rContext) { if ( !m_pOldSet.get() ) return; - if ( UNDO_INSFMTATTR == rUndoIter.GetLastUndoId()) - { - SwUndoFmtAttr* pLast - = static_cast<SwUndoFmtAttr*>(rUndoIter.pLastUndoObj); - if (pLast->m_pOldSet.get() && pLast->m_pFmt) - { - return; - } - } + SwDoc & rDoc(rContext.GetDoc()); switch ( m_nFmtWhich ) { case RES_GRFFMTCOLL: { - SwNoTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetNoTxtNode(); + SwNoTxtNode *const pNd = + rContext.GetRepeatPaM().GetNode()->GetNoTxtNode(); if( pNd ) { - rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), - *pNd->GetFmtColl() ); + rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); } } break; case RES_TXTFMTCOLL: { - SwTxtNode * pNd = rUndoIter.pAktPam->GetNode()->GetTxtNode(); + SwTxtNode *const pNd = + rContext.GetRepeatPaM().GetNode()->GetTxtNode(); if( pNd ) { - rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), - *pNd->GetFmtColl() ); + rDoc.SetAttr( m_pFmt->GetAttrSet(), *pNd->GetFmtColl() ); } } break; @@ -386,7 +380,8 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) // Rahmen steht. Der Weg ist: suche in allen FlyFrmFormaten // nach dem FlyCntnt-Attribut und teste ob der Cursor in der // entsprechenden Section liegt. - SwFrmFmt* pFly = rUndoIter.pAktPam->GetNode()->GetFlyFmt(); + SwFrmFmt *const pFly = + rContext.GetRepeatPaM().GetNode()->GetFlyFmt(); if( pFly ) { // Bug 43672: es duerfen nicht alle Attribute gesetzt werden! @@ -396,18 +391,18 @@ void SwUndoFmtAttr::Repeat( SwUndoIter& rUndoIter) SfxItemSet aTmpSet( m_pFmt->GetAttrSet() ); aTmpSet.ClearItem( RES_CNTNT ); if( aTmpSet.Count() ) - rUndoIter.GetDoc().SetAttr( aTmpSet, *pFly ); + { + rDoc.SetAttr( aTmpSet, *pFly ); + } } else { - rUndoIter.GetDoc().SetAttr( m_pFmt->GetAttrSet(), *pFly ); + rDoc.SetAttr( m_pFmt->GetAttrSet(), *pFly ); } } break; } } - - rUndoIter.pLastUndoObj = this; } SwRewriter SwUndoFmtAttr::GetRewriter() const @@ -477,9 +472,9 @@ void SwUndoFmtAttr::SaveFlyAnchor( bool bSvDrwPt ) // Return value indicates, if anchor attribute is restored. // Note: If anchor attribute is restored, all other existing attributes // are also restored. -bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) +bool SwUndoFmtAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); SwFlyFrmFmt* pFrmFmt = static_cast<SwFlyFrmFmt*>(m_pFmt); const SwFmtAnchor& rAnchor = static_cast<const SwFmtAnchor&>( m_pOldSet->Get( RES_ANCHOR, FALSE ) ); @@ -622,7 +617,7 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) if( RES_DRAWFRMFMT != pFrmFmt->Which() ) pFrmFmt->MakeFrms(); - rIter.pSelFmt = pFrmFmt; + rContext.SetSelections(pFrmFmt, 0); // --> OD 2004-10-26 #i35443# - anchor attribute restored. return true; @@ -650,7 +645,7 @@ SwUndoFmtResetAttr::~SwUndoFmtResetAttr() { } -void SwUndoFmtResetAttr::Undo( SwUndoIter& ) +void SwUndoFmtResetAttr::UndoImpl(::sw::UndoRedoContext &) { if ( m_pOldItem.get() ) { @@ -658,7 +653,7 @@ void SwUndoFmtResetAttr::Undo( SwUndoIter& ) } } -void SwUndoFmtResetAttr::Redo( SwUndoIter& ) +void SwUndoFmtResetAttr::RedoImpl(::sw::UndoRedoContext &) { if ( m_pOldItem.get() ) { @@ -689,10 +684,10 @@ SwUndoResetAttr::~SwUndoResetAttr() { } -void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::UndoImpl(::sw::UndoRedoContext & rContext) { // reset old values - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); m_pHistory->TmpRollback( &rDoc, 0 ); m_pHistory->SetTmpEnd( m_pHistory->Count() ); @@ -707,28 +702,25 @@ void SwUndoResetAttr::Undo( SwUndoIter& rUndoIter ) } } - // setze noch den Cursor auf den Undo-Bereich - SetPaM( rUndoIter ); + AddUndoRedoPaM(rContext); } -void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext) { - // setze Attribut in dem Bereich: - SetPaM( rUndoIter ); - SwDoc& rDoc = rUndoIter.GetDoc(); - rUndoIter.pLastUndoObj = 0; + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam = AddUndoRedoPaM(rContext); SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0; switch ( m_nFormatId ) { case RES_CHRFMT: - rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); + rDoc.RstTxtAttrs(rPam); break; case RES_TXTFMTCOLL: - rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, FALSE, pIdArr ); + rDoc.ResetAttrs(rPam, FALSE, pIdArr ); break; case RES_CONDTXTFMTCOLL: - rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, TRUE, pIdArr ); + rDoc.ResetAttrs(rPam, TRUE, pIdArr ); break; case RES_TXTATR_TOXMARK: @@ -770,15 +762,11 @@ void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) } break; } - rUndoIter.pLastUndoObj = 0; } -void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter ) +void SwUndoResetAttr::RepeatImpl(::sw::RepeatContext & rContext) { - if ( (RES_FMT_BEGIN > m_nFormatId) || - ( (UNDO_RESETATTR == rUndoIter.GetLastUndoId()) && - (m_nFormatId == static_cast<SwUndoResetAttr*>(rUndoIter.pLastUndoObj) - ->m_nFormatId) ) ) + if (m_nFormatId < RES_FMT_BEGIN) { return; } @@ -787,16 +775,15 @@ void SwUndoResetAttr::Repeat( SwUndoIter& rUndoIter ) switch ( m_nFormatId ) { case RES_CHRFMT: - rUndoIter.GetDoc().RstTxtAttrs( *rUndoIter.pAktPam ); + rContext.GetDoc().RstTxtAttrs(rContext.GetRepeatPaM()); break; case RES_TXTFMTCOLL: - rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, FALSE, pIdArr ); + rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, pIdArr); break; case RES_CONDTXTFMTCOLL: - rUndoIter.GetDoc().ResetAttrs( *rUndoIter.pAktPam, TRUE, pIdArr ); + rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, pIdArr); break; } - rUndoIter.pLastUndoObj = this; } @@ -865,29 +852,29 @@ void SwUndoAttr::SaveRedlineData( const SwPaM& rPam, BOOL bIsCntnt ) } } -void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) +void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rUndoIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); RemoveIdx( *pDoc ); if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { - SwPaM& rPam = *rUndoIter.pAktPam; + SwPaM aPam(pDoc->GetNodes().GetEndOfContent()); if ( ULONG_MAX != m_nNodeIndex ) { - rPam.DeleteMark(); - rPam.GetPoint()->nNode = m_nNodeIndex; - rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSttCntnt ); - rPam.SetMark(); - rPam.GetPoint()->nContent++; - pDoc->DeleteRedline( rPam, false, USHRT_MAX ); + aPam.DeleteMark(); + aPam.GetPoint()->nNode = m_nNodeIndex; + aPam.GetPoint()->nContent.Assign( aPam.GetCntntNode(), nSttCntnt ); + aPam.SetMark(); + aPam.GetPoint()->nContent++; + pDoc->DeleteRedline(aPam, false, USHRT_MAX); } else { // alle Format-Redlines entfernen, werden ggfs. neu gesetzt - SetPaM( rUndoIter ); - pDoc->DeleteRedline( rPam, false, nsRedlineType_t::REDLINE_FORMAT ); + SetPaM(aPam); + pDoc->DeleteRedline(aPam, false, nsRedlineType_t::REDLINE_FORMAT); if ( m_pRedlineSaveData.get() ) { SetSaveData( *pDoc, *m_pRedlineSaveData ); @@ -904,67 +891,30 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) m_pHistory->SetTmpEnd( m_pHistory->Count() ); // set cursor onto Undo area - SetPaM( rUndoIter ); + AddUndoRedoPaM(rContext); } -int lcl_HasEqualItems( const SfxItemSet& rSet1, const SfxItemSet& rSet2 ) +void SwUndoAttr::RepeatImpl(::sw::RepeatContext & rContext) { - int nRet = -1; - SfxItemIter aIter1( rSet1 ), aIter2( rSet2 ); - const SfxPoolItem *pI1 = aIter1.FirstItem(), *pI2 = aIter2.FirstItem(); - - while( pI1 && pI2 ) - { - if( pI1->Which() != pI2->Which() || - aIter1.IsAtEnd() != aIter2.IsAtEnd() ) - { - nRet = 0; - break; - } - if( aIter1.IsAtEnd() ) - break; - pI1 = aIter1.NextItem(); - pI2 = aIter2.NextItem(); - } - return nRet; -} - -void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) -{ - if ( UNDO_INSATTR == rUndoIter.GetLastUndoId() ) - { - SwUndoAttr* pLast = static_cast<SwUndoAttr*>(rUndoIter.pLastUndoObj); - if ((pLast->m_AttrSet.Count() == m_AttrSet.Count()) && - (pLast->m_nInsertFlags == m_nInsertFlags ) && - lcl_HasEqualItems( m_AttrSet, pLast->m_AttrSet )) - { - return; - } - } - - // RefMarks are not repeat capable if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(), m_AttrSet, m_nInsertFlags ); } else if ( 1 < m_AttrSet.Count() ) { SfxItemSet aTmpSet( m_AttrSet ); aTmpSet.ClearItem( RES_TXTATR_REFMARK ); - rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + rContext.GetDoc().InsertItemSet( rContext.GetRepeatPaM(), aTmpSet, m_nInsertFlags ); } - rUndoIter.pLastUndoObj = this; } -void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) +void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext) { - // setze Attribut in dem Bereich: - SetPaM( rUndoIter ); - SwPaM& rPam = *rUndoIter.pAktPam; - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam = AddUndoRedoPaM(rContext); if ( m_pRedlineData.get() && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) @@ -995,8 +945,6 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) { rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); } - - rUndoIter.pLastUndoObj = 0; } @@ -1096,9 +1044,9 @@ SwUndoDefaultAttr::~SwUndoDefaultAttr() { } -void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter) +void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if ( m_pOldSet.get() ) { SwUndoFmtAttrHelper aTmp( @@ -1120,9 +1068,9 @@ void SwUndoDefaultAttr::Undo( SwUndoIter& rUndoIter) } } -void SwUndoDefaultAttr::Redo( SwUndoIter& rUndoIter) +void SwUndoDefaultAttr::RedoImpl(::sw::UndoRedoContext & rContext) { - Undo( rUndoIter ); + UndoImpl(rContext); } // ----------------------------------------------------- @@ -1140,34 +1088,31 @@ SwUndoMoveLeftMargin::~SwUndoMoveLeftMargin() { } -void SwUndoMoveLeftMargin::Undo( SwUndoIter& rIter ) +void SwUndoMoveLeftMargin::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + SwDoc & rDoc = rContext.GetDoc(); // restore old values - m_pHistory->TmpRollback( pDoc, 0 ); + m_pHistory->TmpRollback( & rDoc, 0 ); m_pHistory->SetTmpEnd( m_pHistory->Count() ); - pDoc->DoUndo( bUndo ); - SetPaM( rIter ); + AddUndoRedoPaM(rContext); } -void SwUndoMoveLeftMargin::Redo( SwUndoIter& rIter ) +void SwUndoMoveLeftMargin::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); - SetPaM( rIter ); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, - m_bModulus ); + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam = AddUndoRedoPaM(rContext); + + rDoc.MoveLeftMargin( rPam, + GetId() == UNDO_INC_LEFTMARGIN, m_bModulus ); } -void SwUndoMoveLeftMargin::Repeat( SwUndoIter& rIter ) +void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); - pDoc->MoveLeftMargin( *rIter.pAktPam, GetId() == UNDO_INC_LEFTMARGIN, + SwDoc & rDoc = rContext.GetDoc(); + rDoc.MoveLeftMargin(rContext.GetRepeatPaM(), GetId() == UNDO_INC_LEFTMARGIN, m_bModulus ); - rIter.pLastUndoObj = this; } // ----------------------------------------------------- @@ -1187,35 +1132,30 @@ SwUndoChangeFootNote::~SwUndoChangeFootNote() { } -void SwUndoChangeFootNote::Undo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); - SetPaM( rIter ); - - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + SwDoc & rDoc = rContext.GetDoc(); m_pHistory->TmpRollback( &rDoc, 0 ); m_pHistory->SetTmpEnd( m_pHistory->Count() ); rDoc.GetFtnIdxs().UpdateAllFtn(); - SetPaM( rIter ); - rDoc.DoUndo( bUndo ); + AddUndoRedoPaM(rContext); } -void SwUndoChangeFootNote::Redo( SwUndoIter& rIter ) +void SwUndoChangeFootNote::RedoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rIter ); - rIter.GetDoc().SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); - SetPaM( rIter ); + SwDoc & rDoc( rContext.GetDoc() ); + SwPaM & rPaM = AddUndoRedoPaM(rContext); + rDoc.SetCurFtn(rPaM, m_Text, m_nNumber, m_bEndNote); + SetPaM(rPaM); } -void SwUndoChangeFootNote::Repeat( SwUndoIter& rIter ) +void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); - rDoc.SetCurFtn( *rIter.pAktPam, m_Text, m_nNumber, m_bEndNote ); - rIter.pLastUndoObj = this; + SwDoc & rDoc = rContext.GetDoc(); + rDoc.SetCurFtn( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote ); } @@ -1232,17 +1172,17 @@ SwUndoFootNoteInfo::~SwUndoFootNoteInfo() { } -void SwUndoFootNoteInfo::Undo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc &rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); rDoc.SetFtnInfo( *m_pFootNoteInfo ); m_pFootNoteInfo.reset( pInf ); } -void SwUndoFootNoteInfo::Redo( SwUndoIter &rIter ) +void SwUndoFootNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc &rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwFtnInfo *pInf = new SwFtnInfo( rDoc.GetFtnInfo() ); rDoc.SetFtnInfo( *m_pFootNoteInfo ); m_pFootNoteInfo.reset( pInf ); @@ -1261,17 +1201,17 @@ SwUndoEndNoteInfo::~SwUndoEndNoteInfo() { } -void SwUndoEndNoteInfo::Undo( SwUndoIter &rIter ) +void SwUndoEndNoteInfo::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc &rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); m_pEndNoteInfo.reset( pInf ); } -void SwUndoEndNoteInfo::Redo( SwUndoIter &rIter ) +void SwUndoEndNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc &rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwEndNoteInfo *pInf = new SwEndNoteInfo( rDoc.GetEndNoteInfo() ); rDoc.SetEndNoteInfo( *m_pEndNoteInfo ); m_pEndNoteInfo.reset( pInf ); @@ -1286,10 +1226,10 @@ SwUndoDontExpandFmt::SwUndoDontExpandFmt( const SwPosition& rPos ) { } -void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter ) +void SwUndoDontExpandFmt::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); + SwDoc *const pDoc = & rContext.GetDoc(); SwPosition& rPos = *pPam->GetPoint(); rPos.nNode = m_nNodeIndex; @@ -1298,10 +1238,10 @@ void SwUndoDontExpandFmt::Undo( SwUndoIter& rIter ) } -void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter ) +void SwUndoDontExpandFmt::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); + SwDoc *const pDoc = & rContext.GetDoc(); SwPosition& rPos = *pPam->GetPoint(); rPos.nNode = m_nNodeIndex; @@ -1309,10 +1249,10 @@ void SwUndoDontExpandFmt::Redo( SwUndoIter& rIter ) pDoc->DontExpandFmt( rPos ); } -void SwUndoDontExpandFmt::Repeat( SwUndoIter& rIter ) +void SwUndoDontExpandFmt::RepeatImpl(::sw::RepeatContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); - pDoc->DontExpandFmt( *pPam->GetPoint() ); + SwPaM & rPam = rContext.GetRepeatPaM(); + SwDoc & rDoc = rContext.GetDoc(); + rDoc.DontExpandFmt( *rPam.GetPoint() ); } diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx index b86bdad692ac..52fe406e459b 100644 --- a/sw/source/core/undo/unbkmk.cxx +++ b/sw/source/core/undo/unbkmk.cxx @@ -28,22 +28,20 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoBookmark.hxx> #include "doc.hxx" #include "docary.hxx" #include "swundo.hxx" // fuer die UndoIds #include "pam.hxx" -#include "undobj.hxx" +#include <UndoCore.hxx> #include "IMark.hxx" #include "rolbck.hxx" #include "SwRewriter.hxx" -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - - SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId, const ::sw::mark::IMark& rBkmk ) : SwUndo( nUndoId ) @@ -60,7 +58,6 @@ void SwUndoBookmark::SetInDoc( SwDoc* pDoc ) m_pHistoryBookmark->SetInDoc( pDoc, false ); } - void SwUndoBookmark::ResetInDoc( SwDoc* pDoc ) { IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); @@ -95,15 +92,13 @@ SwUndoInsBookmark::SwUndoInsBookmark( const ::sw::mark::IMark& rBkmk ) } -void SwUndoInsBookmark::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsBookmark::UndoImpl(::sw::UndoRedoContext & rContext) { - ResetInDoc( &rUndoIter.GetDoc() ); + ResetInDoc( &rContext.GetDoc() ); } - -void SwUndoInsBookmark::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsBookmark::RedoImpl(::sw::UndoRedoContext & rContext) { - SetInDoc( &rUndoIter.GetDoc() ); + SetInDoc( &rContext.GetDoc() ); } - diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index ef39a4e18950..3e1c0988b285 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoDelete.hxx> #include <hintids.hxx> #include <unotools/charclass.hxx> @@ -36,11 +37,12 @@ #include <frmfmt.hxx> #include <fmtanchr.hxx> #include <doc.hxx> +#include <UndoManager.hxx> #include <swtable.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> #include <poolfmt.hxx> #include <mvsave.hxx> @@ -60,8 +62,6 @@ // using namespace comphelper; -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - // DELETE /* lcl_MakeAutoFrms has to call MakeFrms for objects bounded "AtChar" ( == AUTO ), @@ -147,10 +147,8 @@ SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy ) DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint(), DelCntntType(nsDelCntntType::DELCNT_ALL | nsDelCntntType::DELCNT_CHKNOCNTNT) ); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); _DelBookmarks(pStt->nNode, pEnd->nNode); - pDoc->DoUndo( bDoesUndo ); } else DelCntntIndex( *rPam.GetMark(), *rPam.GetPoint() ); @@ -220,7 +218,7 @@ SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy ) if( bMoveNds ) // sind noch Nodes zu verschieben ? { - SwNodes& rNds = (SwNodes&)*pDoc->GetUndoNds(); + SwNodes& rNds = pDoc->GetUndoManager().GetUndoNodes(); SwNodes& rDocNds = pDoc->GetNodes(); SwNodeRange aRg( rDocNds, nSttNode - nNdDiff, rDocNds, nEndNode - nNdDiff ); @@ -253,11 +251,9 @@ SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy ) ++nReplaceDummy; SwNodeRange aMvRg( *pEndTxtNd, 0, *pEndTxtNd, 1 ); SwPosition aSplitPos( *pEndTxtNd ); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); pDoc->SplitNode( aSplitPos, false ); rDocNds._MoveNodes( aMvRg, rDocNds, aRg.aEnd, TRUE ); - pDoc->DoUndo( bDoesUndo ); aRg.aEnd--; } else @@ -279,11 +275,9 @@ SwUndoDelete::SwUndoDelete( SwPaM& rPam, BOOL bFullPara, BOOL bCalledByTblCpy ) { SwNodeRange aMvRg( *pSttTxtNd, 0, *pSttTxtNd, 1 ); SwPosition aSplitPos( *pSttTxtNd ); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); pDoc->SplitNode( aSplitPos, false ); rDocNds._MoveNodes( aMvRg, rDocNds, aRg.aStart, TRUE ); - pDoc->DoUndo( bDoesUndo ); aRg.aStart--; } } @@ -648,11 +642,9 @@ void lcl_ReAnchorAtCntntFlyFrames( const SwSpzFrmFmts& rSpzArr, SwPosition &rPos } } -void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) +void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rUndoIter.GetDoc(); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + SwDoc *const pDoc = & rContext.GetDoc(); ULONG nCalcStt = nSttNode - nNdDiff; @@ -686,7 +678,6 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) else pInsNd = 0; // Node nicht loeschen !! - SwNodes* pUNds = (SwNodes*)pDoc->GetUndoNds(); BOOL bNodeMove = 0 != nNode; if( pEndStr ) @@ -763,7 +754,7 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) { SwNodeRange aRange( *pMvStt, 0, *pMvStt, nNode ); SwNodeIndex aCopyIndex( aPos.nNode, -1 ); - pUNds->_Copy( aRange, aPos.nNode ); + pDoc->GetUndoManager().GetUndoNodes()._Copy( aRange, aPos.nNode ); if( nReplaceDummy ) { @@ -854,19 +845,14 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) if( pRedlSaveData ) SetSaveData( *pDoc, *pRedlSaveData ); - pDoc->DoUndo( bUndo ); // Undo wieder einschalten - SetPaM( rUndoIter, TRUE ); + AddUndoRedoPaM(rContext, true); } -void SwUndoDelete::Redo( SwUndoIter& rUndoIter ) +void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext) { - rUndoIter.SetUpdateAttr( TRUE ); - - SwPaM& rPam = *rUndoIter.pAktPam; + SwPaM & rPam = AddUndoRedoPaM(rContext); SwDoc& rDoc = *rPam.GetDoc(); - SetPaM( rPam ); - if( pRedlSaveData ) { bool bSuccess = FillSaveData(rPam, *pRedlSaveData, TRUE); @@ -981,15 +967,16 @@ void SwUndoDelete::Redo( SwUndoIter& rUndoIter ) rDoc.DeleteAndJoin( rPam ); } -void SwUndoDelete::Repeat( SwUndoIter& rUndoIter ) +void SwUndoDelete::RepeatImpl(::sw::RepeatContext & rContext) { - if( UNDO_DELETE == rUndoIter.GetLastUndoId() ) + // this action does not seem idempotent, + // so make sure it is only executed once on repeat + if (rContext.m_bDeleteRepeated) return; - SwPaM& rPam = *rUndoIter.pAktPam; + SwPaM & rPam = rContext.GetRepeatPaM(); SwDoc& rDoc = *rPam.GetDoc(); - BOOL bGroupUndo = rDoc.DoesGroupUndo(); - rDoc.DoGroupUndo( FALSE ); + ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); if( !rPam.HasMark() ) { rPam.SetMark(); @@ -999,8 +986,7 @@ void SwUndoDelete::Repeat( SwUndoIter& rUndoIter ) rDoc.DelFullPara( rPam ); else rDoc.DeleteAndJoin( rPam ); - rDoc.DoGroupUndo( bGroupUndo ); - rUndoIter.pLastUndoObj = this; + rContext.m_bDeleteRepeated = true; } diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 1a71a705b2fb..0bca86a04d70 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -29,28 +29,26 @@ #include "precompiled_sw.hxx" +#include <IShellCursorSupplier.hxx> #include <txtftn.hxx> #include <fmtanchr.hxx> #include <ftnidx.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <UndoManager.hxx> #include <docary.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> #include <ndnotxt.hxx> #include <IMark.hxx> #include <mvsave.hxx> #include <redline.hxx> #include <crossrefbookmark.hxx> -#ifndef _UNDO_HRC #include <undo.hrc> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <docsh.hxx> class SwRedlineSaveData : public SwUndRng, public SwRedlineData, @@ -70,20 +68,8 @@ public: #endif }; -SV_IMPL_PTRARR( SwUndos, SwUndo*) SV_IMPL_PTRARR( SwRedlineSaveDatas, SwRedlineSaveDataPtr ) -SwUndoIter::SwUndoIter( SwPaM* pPam, SwUndoId nId ) -{ - nUndoId = nId; - bWeiter = nId ? TRUE : FALSE; - bUpdateAttr = FALSE; - pAktPam = pPam; - nEndCnt = 0; - pSelFmt = 0; - pMarkList = 0; -} -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } //------------------------------------------------------------ @@ -147,12 +133,15 @@ void SwUndRng::SetPaM( SwPaM & rPam, BOOL bCorrToCntnt ) const rPam.GetPoint()->nContent.Assign( 0, 0 ); } -void SwUndRng::SetPaM( SwUndoIter& rIter, BOOL bCorrToCntnt ) const +SwPaM & SwUndRng::AddUndoRedoPaM( + ::sw::UndoRedoContext & rContext, bool bCorrToCntnt) const { - if( rIter.pAktPam ) - SetPaM( *rIter.pAktPam, bCorrToCntnt ); + SwPaM & rPaM( rContext.GetCursorSupplier().CreateNewShellCursor() ); + SetPaM( rPaM, bCorrToCntnt ); + return rPaM; } + //------------------------------------------------------------ @@ -201,8 +190,8 @@ void SwUndo::RemoveIdxRel( ULONG nIdx, const SwPosition& rPos ) ::PaMCorrRel( aIdx, rPos ); } -SwUndo::SwUndo( SwUndoId nI ) - : nId(nI), nOrigRedlineMode(nsRedlineMode_t::REDLINE_NONE), +SwUndo::SwUndo(SwUndoId const nId) + : m_nId(nId), nOrigRedlineMode(nsRedlineMode_t::REDLINE_NONE), bCacheComment(true), pComment(NULL) { } @@ -218,9 +207,89 @@ SwUndo::~SwUndo() delete pComment; } -void SwUndo::Repeat( SwUndoIter& rIter ) + +class UndoRedoRedlineGuard +{ +public: + UndoRedoRedlineGuard(::sw::UndoRedoContext & rContext, SwUndo & rUndo) + : m_rRedlineAccess(rContext.GetDoc()) + , m_eMode(m_rRedlineAccess.GetRedlineMode()) + { + RedlineMode_t const eTmpMode = + static_cast<RedlineMode_t>(rUndo.GetRedlineMode()); + if ((nsRedlineMode_t::REDLINE_SHOW_MASK & eTmpMode) != + (nsRedlineMode_t::REDLINE_SHOW_MASK & m_eMode)) + { + m_rRedlineAccess.SetRedlineMode( eTmpMode ); + } + m_rRedlineAccess.SetRedlineMode_intern( static_cast<RedlineMode_t>( + eTmpMode | nsRedlineMode_t::REDLINE_IGNORE) ); + } + ~UndoRedoRedlineGuard() + { + m_rRedlineAccess.SetRedlineMode(m_eMode); + } +private: + IDocumentRedlineAccess & m_rRedlineAccess; + RedlineMode_t const m_eMode; +}; + +void SwUndo::Undo() +{ + OSL_ENSURE(false, "SwUndo::Undo(): ERROR: must call Undo(context) instead"); +} + +void SwUndo::Redo() +{ + OSL_ENSURE(false, "SwUndo::Redo(): ERROR: must call Redo(context) instead"); +} + +void SwUndo::UndoWithContext(SfxUndoContext & rContext) +{ + ::sw::UndoRedoContext *const pContext( + dynamic_cast< ::sw::UndoRedoContext * >(& rContext)); + OSL_ASSERT(pContext); + if (!pContext) { return; } + UndoRedoRedlineGuard(*pContext, *this); + UndoImpl(*pContext); +} + +void SwUndo::RedoWithContext(SfxUndoContext & rContext) +{ + ::sw::UndoRedoContext *const pContext( + dynamic_cast< ::sw::UndoRedoContext * >(& rContext)); + OSL_ASSERT(pContext); + if (!pContext) { return; } + UndoRedoRedlineGuard(*pContext, *this); + RedoImpl(*pContext); +} + +void SwUndo::Repeat(SfxRepeatTarget & rContext) +{ + ::sw::RepeatContext *const pRepeatContext( + dynamic_cast< ::sw::RepeatContext * >(& rContext)); + OSL_ASSERT(pRepeatContext); + if (!pRepeatContext) { return; } + RepeatImpl(*pRepeatContext); +} + +BOOL SwUndo::CanRepeat(SfxRepeatTarget & rContext) const +{ + ::sw::RepeatContext *const pRepeatContext( + dynamic_cast< ::sw::RepeatContext * >(& rContext)); + OSL_ASSERT(pRepeatContext); + if (!pRepeatContext) { return false; } + return CanRepeatImpl(*pRepeatContext); +} + +void SwUndo::RepeatImpl( ::sw::RepeatContext & ) { - rIter.pLastUndoObj = this; +} + +bool SwUndo::CanRepeatImpl( ::sw::RepeatContext & ) const +{ +// return false; + return ((REPEAT_START <= GetId()) && (GetId() < REPEAT_END)); } String SwUndo::GetComment() const @@ -231,7 +300,7 @@ String SwUndo::GetComment() const { if (! pComment) { - pComment = new String(SW_RES(UNDO_BASE + nId)); + pComment = new String(SW_RES(UNDO_BASE + GetId())); SwRewriter aRewriter = GetRewriter(); @@ -242,7 +311,7 @@ String SwUndo::GetComment() const } else { - aResult = String(SW_RES(UNDO_BASE + nId)); + aResult = String(SW_RES(UNDO_BASE + GetId())); SwRewriter aRewriter = GetRewriter(); @@ -252,11 +321,6 @@ String SwUndo::GetComment() const return aResult; } -SwUndoId SwUndo::GetEffectiveId() const -{ - return GetId(); -} - SwRewriter SwUndo::GetRewriter() const { SwRewriter aResult; @@ -264,6 +328,7 @@ SwRewriter SwUndo::GetRewriter() const return aResult; } + //------------------------------------------------------------ SwUndoSaveCntnt::SwUndoSaveCntnt() @@ -289,13 +354,12 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, SwIndex* pCntIdx, ULONG* pEndNdIdx, xub_StrLen* pEndCntIdx ) { SwDoc& rDoc = *rPaM.GetDoc(); - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); SwNoTxtNode* pCpyNd = rPaM.GetNode()->GetNoTxtNode(); // jetzt kommt das eigentliche Loeschen(Verschieben) - SwNodes& rNds = (SwNodes&)*rDoc.GetUndoNds(); + SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes(); SwPosition aPos( pEndNdIdx ? rNds.GetEndOfPostIts() : rNds.GetEndOfExtras() ); aPos.nNode--; @@ -371,8 +435,6 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, else pCntIdx->Assign( 0, 0 ); } - - rDoc.DoUndo( bUndo ); } void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, @@ -380,12 +442,11 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, ULONG* pEndNdIdx, xub_StrLen* pEndCntIdx ) { // jetzt kommt das wiederherstellen - SwNodes& rNds = (SwNodes&)*rDoc.GetUndoNds(); + SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes(); if( nNodeIdx == rNds.GetEndOfPostIts().GetIndex() ) return; // nichts gespeichert - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); SwPaM aPaM( rInsPos ); if( pEndNdIdx ) // dann hole aus diesem den Bereich @@ -440,8 +501,6 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, else { ASSERT( FALSE, "was ist es denn nun?" ); } - - rDoc.DoUndo( bUndo ); } // diese beiden Methoden bewegen den Point vom Pam zurueck/vor. Damit @@ -501,8 +560,7 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwDoc* pDoc = rMark.nNode.GetNode().GetDoc(); - BOOL bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); // 1. Fussnoten if( nsDelCntntType::DELCNT_FTN & nDelCntntType ) @@ -599,7 +657,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, { if( !pHistory ) pHistory = new SwHistory; - SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); + SwTxtNode *const pTxtNd = + pAPos->nNode.GetNode().GetTxtNode(); SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt( pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); @@ -813,8 +872,6 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, } } } - - pDoc->DoUndo( bDoesUndo ); } @@ -882,8 +939,8 @@ void SwUndoSaveSection::RestoreSection( SwDoc* pDoc, SwNodeIndex* pIdx, { // ueberpruefe, ob der Inhalt an der alten Position steht SwNodeIndex aSttIdx( pDoc->GetNodes(), nStartPos ); - ASSERT( !pDoc->GetNodes()[ aSttIdx ]->GetCntntNode(), - "Position in irgendeiner Section" ); + OSL_ENSURE(!aSttIdx.GetNode().GetCntntNode(), + "RestoreSection(): Position on content node"); // move den Inhalt aus dem UndoNodes-Array in den Fly SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( aSttIdx, @@ -917,128 +974,6 @@ void SwUndoSaveSection::RestoreSection( SwDoc* pDoc, const SwNodeIndex& rInsPos } } -// START -SwUndoStart::SwUndoStart( SwUndoId nInitId ) - : SwUndo( UNDO_START ), nUserId( nInitId ), nEndOffset( 0 ) -{ -} - -void SwUndoStart::Undo( SwUndoIter& rUndoIter ) -{ - if( !( --rUndoIter.nEndCnt ) && rUndoIter.bWeiter && - ( rUndoIter.GetId() ? ( rUndoIter.GetId() == nUserId || - ( UNDO_END == rUndoIter.GetId() && UNDO_START == GetId() )) : TRUE )) - rUndoIter.bWeiter = FALSE; -} - -void SwUndoStart::Redo( SwUndoIter& rUndoIter ) -{ - rUndoIter.bWeiter = TRUE; - ++rUndoIter.nEndCnt; -} - -void SwUndoStart::Repeat( SwUndoIter& rUndoIter ) -{ - rUndoIter.bWeiter = FALSE; -} - -String SwUndoStart::GetComment() const -{ - String sResult; - - switch (nUserId) - { - case UNDO_START: - case UNDO_END: - sResult = String("??", RTL_TEXTENCODING_ASCII_US); - - break; - - default: - sResult = String(SW_RES(UNDO_BASE + nUserId)); - sResult = GetRewriter().Apply(sResult); - } - - return sResult; -} - -SwRewriter SwUndoStart::GetRewriter() const -{ - return mRewriter; -} - -SwUndoId SwUndoStart::GetEffectiveId() const -{ - return GetUserId(); -} - -void SwUndoStart::SetRewriter(const SwRewriter & rRewriter) -{ - mRewriter = rRewriter; -} - -// END -SwUndoEnd::SwUndoEnd( SwUndoId nInitId ) - : SwUndo( UNDO_END ), nUserId( nInitId ), nSttOffset( 0 ) -{ -} - -void SwUndoEnd::Undo( SwUndoIter& rUndoIter ) -{ - if( rUndoIter.GetId() == GetId() || !rUndoIter.GetId() ) - rUndoIter.bWeiter = TRUE; - if( rUndoIter.bWeiter ) - ++rUndoIter.nEndCnt; -} - -void SwUndoEnd::Redo( SwUndoIter& rUndoIter ) -{ - if( !( --rUndoIter.nEndCnt ) && rUndoIter.bWeiter && - ( rUndoIter.GetId() ? ( rUndoIter.GetId() == nUserId || - ( UNDO_END == rUndoIter.GetId() && UNDO_START == GetId() )) : TRUE )) - rUndoIter.bWeiter = FALSE; -} - -void SwUndoEnd::Repeat( SwUndoIter& rUndoIter ) -{ - rUndoIter.bWeiter = FALSE; -} - -String SwUndoEnd::GetComment() const -{ - String sResult; - - switch (nUserId) - { - case UNDO_START: - case UNDO_END: - sResult = String("??", RTL_TEXTENCODING_ASCII_US); - - break; - default: - sResult = SW_RES(UNDO_BASE + nUserId); - sResult = GetRewriter().Apply(sResult); - } - - return sResult; -} - -void SwUndoEnd::SetRewriter(const SwRewriter & rRewriter) -{ - mRewriter = rRewriter; -} - -SwUndoId SwUndoEnd::GetEffectiveId() const -{ - return GetUserId(); -} - -SwRewriter SwUndoEnd::GetRewriter() const -{ - return mRewriter; -} - -/* */ // sicher und setze die RedlineDaten SwRedlineSaveData::SwRedlineSaveData( SwComparePosition eCmpPos, diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index a0ba635549ac..fe57a900fabf 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -28,16 +28,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <svl/itemiter.hxx> #include <hintids.hxx> -#include <svl/itemiter.hxx> +#include <hints.hxx> #include <fmtflcnt.hxx> #include <fmtanchr.hxx> #include <fmtcntnt.hxx> #include <txtflcnt.hxx> #include <frmfmt.hxx> #include <flyfrm.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoDraw.hxx> #include <rolbck.hxx> // fuer die Attribut History #include <doc.hxx> #include <docary.hxx> @@ -49,10 +51,9 @@ #include <dcontact.hxx> #include <ndole.hxx> -// Inline Methode vom UndoIter -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } //--------------------------------------------------------------------- +// SwUndoLayBase ///////////////////////////////////////////////////////// SwUndoFlyBase::SwUndoFlyBase( SwFrmFmt* pFormat, SwUndoId nUndoId ) : SwUndo( nUndoId ), pFrmFmt( pFormat ) @@ -65,9 +66,9 @@ SwUndoFlyBase::~SwUndoFlyBase() delete pFrmFmt; } -void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) +void SwUndoFlyBase::InsFly(::sw::UndoRedoContext & rContext, bool bShowSelFrm) { - SwDoc* pDoc = &rUndoIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); // ins Array wieder eintragen SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); @@ -96,7 +97,7 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) } else { - SwPosition aNewPos( *rUndoIter.pAktPam->GetPoint() ); + SwPosition aNewPos(pDoc->GetNodes().GetEndOfContent()); aNewPos.nNode = nNdPgPos; if ((FLY_AS_CHAR == nRndId) || (FLY_AT_CHAR == nRndId)) { @@ -132,7 +133,9 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) pFrmFmt->MakeFrms(); if( bShowSelFrm ) - rUndoIter.pSelFmt = pFrmFmt; + { + rContext.SetSelections(pFrmFmt, 0); + } if( GetHistory() ) GetHistory()->Rollback( pDoc ); @@ -199,8 +202,8 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) { nNdPgPos = pPos->nNode.GetIndex(); nCntPos = pPos->nContent.GetIndex(); - SwTxtNode *pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode gefunden" ); + SwTxtNode *const pTxtNd = pPos->nNode.GetNode().GetTxtNode(); + OSL_ENSURE(pTxtNd, "no Textnode"); SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( pTxtNd->GetTxtAttrForCharAt( nCntPos, RES_TXTATR_FLYCNT ) ); // Attribut steht noch im TextNode, loeschen @@ -234,7 +237,7 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) rFlyFmts.Remove( rFlyFmts.GetPos( pFrmFmt )); } -// ----- Undo-InsertFly ------ +// SwUndoInsLayFmt /////////////////////////////////////////////////////// SwUndoInsLayFmt::SwUndoInsLayFmt( SwFrmFmt* pFormat, ULONG nNodeIdx, xub_StrLen nCntIdx ) : SwUndoFlyBase( pFormat, RES_DRAWFRMFMT == pFormat->Which() ? @@ -270,52 +273,52 @@ SwUndoInsLayFmt::~SwUndoInsLayFmt() { } -void SwUndoInsLayFmt::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsLayFmt::UndoImpl(::sw::UndoRedoContext & rContext) { + SwDoc & rDoc(rContext.GetDoc()); const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); if( rCntnt.GetCntntIdx() ) // kein Inhalt { bool bRemoveIdx = true; if( mnCrsrSaveIndexPara > 0 ) { - SwTxtNode *pNode = rUndoIter.GetDoc().GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode(); + SwTxtNode *const pNode = + rDoc.GetNodes()[mnCrsrSaveIndexPara]->GetTxtNode(); if( pNode ) { - SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), rCntnt.GetCntntIdx()->GetIndex() ); - SwNodeIndex aEndIdx( rUndoIter.GetDoc().GetNodes(), aIdx.GetNode().EndOfSectionIndex() ); + SwNodeIndex aIdx( rDoc.GetNodes(), + rCntnt.GetCntntIdx()->GetIndex() ); + SwNodeIndex aEndIdx( rDoc.GetNodes(), + aIdx.GetNode().EndOfSectionIndex() ); SwIndex aIndex( pNode, mnCrsrSaveIndexPos ); SwPosition aPos( *pNode, aIndex ); - rUndoIter.GetDoc().CorrAbs( aIdx, aEndIdx, aPos, TRUE ); + rDoc.CorrAbs( aIdx, aEndIdx, aPos, TRUE ); bRemoveIdx = false; } } if( bRemoveIdx ) - RemoveIdxFromSection( rUndoIter.GetDoc(), - rCntnt.GetCntntIdx()->GetIndex() ); + { + RemoveIdxFromSection( rDoc, rCntnt.GetCntntIdx()->GetIndex() ); + } } - DelFly( &rUndoIter.GetDoc() ); + DelFly(& rDoc); } -void SwUndoInsLayFmt::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsLayFmt::RedoImpl(::sw::UndoRedoContext & rContext) { - rUndoIter.pLastUndoObj = 0; - InsFly( rUndoIter ); + InsFly(rContext); } -void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInsLayFmt::RepeatImpl(::sw::RepeatContext & rContext) { - if( UNDO_INSLAYFMT == rUndoIter.GetLastUndoId() && - pFrmFmt == ((SwUndoInsLayFmt*)rUndoIter.pLastUndoObj)->pFrmFmt ) - return; - - SwDoc* pDoc = &rUndoIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); // erfrage und setze den Anker neu SwFmtAnchor aAnchor( pFrmFmt->GetAnchor() ); if ((FLY_AT_PARA == aAnchor.GetAnchorId()) || (FLY_AT_CHAR == aAnchor.GetAnchorId()) || (FLY_AS_CHAR == aAnchor.GetAnchorId())) { - SwPosition aPos( *rUndoIter.pAktPam->GetPoint() ); + SwPosition aPos( *rContext.GetRepeatPaM().GetPoint() ); if (FLY_AT_PARA == aAnchor.GetAnchorId()) { aPos.nContent.Assign( 0, 0 ); @@ -324,7 +327,8 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) } else if( FLY_AT_FLY == aAnchor.GetAnchorId() ) { - const SwStartNode* pSttNd = rUndoIter.pAktPam->GetNode()->FindFlyStartNode(); + SwStartNode const*const pSttNd = + rContext.GetRepeatPaM().GetNode()->FindFlyStartNode(); if( pSttNd ) { SwPosition aPos( *pSttNd ); @@ -332,23 +336,22 @@ void SwUndoInsLayFmt::Repeat( SwUndoIter& rUndoIter ) } else { - rUndoIter.pLastUndoObj = this; return ; } } else if (FLY_AT_PAGE == aAnchor.GetAnchorId()) { - aAnchor.SetPageNum( pDoc->GetRootFrm()->GetCurrPage( - rUndoIter.pAktPam )); + aAnchor.SetPageNum( + pDoc->GetRootFrm()->GetCurrPage(& rContext.GetRepeatPaM()) ); } else { ASSERT( FALSE, "was fuer ein Anker ist es denn nun?" ); } SwFrmFmt* pFlyFmt = pDoc->CopyLayoutFmt( *pFrmFmt, aAnchor, true, true ); - rUndoIter.pSelFmt = pFlyFmt; - - rUndoIter.pLastUndoObj = this; + (void) pFlyFmt; +//FIXME nobody ever did anything with this selection: +// rContext.SetSelections(pFlyFmt, 0); } // #111827# @@ -356,7 +359,12 @@ String SwUndoInsLayFmt::GetComment() const { String aResult; - if (! pComment) + // HACK: disable caching: + // the SfxUndoManager calls GetComment() too early: the pFrmFmt does not + // have a SwDrawContact yet, so it will fall back to SwUndo::GetComment(), + // which sets pComment to a wrong value. +// if (! pComment) + if (true) { /* If frame format is present and has an SdrObject use the undo @@ -383,28 +391,37 @@ String SwUndoInsLayFmt::GetComment() const return aResult; } -// ----- Undo-DeleteFly ------ +// SwUndoDelLayFmt /////////////////////////////////////////////////////// -SwUndoDelLayFmt::SwUndoDelLayFmt( SwFrmFmt* pFormat ) - : SwUndoFlyBase( pFormat, UNDO_DELLAYFMT ), bShowSelFrm( TRUE ) +static SwUndoId +lcl_GetSwUndoId(SwFrmFmt *const pFrmFmt) { - SwDoc* pDoc = pFormat->GetDoc(); - DelFly( pDoc ); - - SwNodeIndex* pIdx = GetMvSttIdx(); - SwNode* pNd; - if( 1 == GetMvNodeCnt() && pIdx && - ( pNd = (*pDoc->GetUndoNds())[ *pIdx ] )->IsNoTxtNode() ) + if (RES_DRAWFRMFMT != pFrmFmt->Which()) { - // dann setze eine andere Undo-ID; Grafik oder OLE - if( pNd->IsGrfNode() ) - SetId( UNDO_DELGRF ); - else if( pNd->IsOLENode() ) - { - SetId( UNDO_DELETE ); + const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); + OSL_ENSURE( rCntnt.GetCntntIdx(), "Fly without content" ); + SwNodeIndex firstNode(*rCntnt.GetCntntIdx(), 1); + SwNoTxtNode *const pNoTxtNode(firstNode.GetNode().GetNoTxtNode()); + if (pNoTxtNode && pNoTxtNode->IsGrfNode()) + { + return UNDO_DELGRF; + } + else if (pNoTxtNode && pNoTxtNode->IsOLENode()) + { + // surprisingly not UNDO_DELOLE, which does not seem to work + return UNDO_DELETE; } } + return UNDO_DELLAYFMT; +} + +SwUndoDelLayFmt::SwUndoDelLayFmt( SwFrmFmt* pFormat ) + : SwUndoFlyBase( pFormat, lcl_GetSwUndoId(pFormat) ) + , bShowSelFrm( TRUE ) +{ + SwDoc* pDoc = pFormat->GetDoc(); + DelFly( pDoc ); } SwRewriter SwUndoDelLayFmt::GetRewriter() const @@ -418,7 +435,7 @@ SwRewriter SwUndoDelLayFmt::GetRewriter() const SwNodeIndex* pIdx = GetMvSttIdx(); if( 1 == GetMvNodeCnt() && pIdx) { - SwNode * pNd = (*pDoc->GetUndoNds())[ *pIdx ]; + SwNode *const pNd = & pIdx->GetNode(); if ( pNd->IsNoTxtNode() && pNd->IsOLENode()) { @@ -432,22 +449,24 @@ SwRewriter SwUndoDelLayFmt::GetRewriter() const return aRewriter; } -void SwUndoDelLayFmt::Undo( SwUndoIter& rUndoIter ) +void SwUndoDelLayFmt::UndoImpl(::sw::UndoRedoContext & rContext) { - InsFly( rUndoIter, bShowSelFrm ); + InsFly( rContext, bShowSelFrm ); } -void SwUndoDelLayFmt::Redo( SwUndoIter& rUndoIter ) +void SwUndoDelLayFmt::RedoImpl(::sw::UndoRedoContext & rContext) { + SwDoc & rDoc(rContext.GetDoc()); const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); if( rCntnt.GetCntntIdx() ) // kein Inhalt - RemoveIdxFromSection( rUndoIter.GetDoc(), - rCntnt.GetCntntIdx()->GetIndex() ); + { + RemoveIdxFromSection(rDoc, rCntnt.GetCntntIdx()->GetIndex()); + } - DelFly( &rUndoIter.GetDoc() ); + DelFly(& rDoc); } -void SwUndoDelLayFmt::Redo() +void SwUndoDelLayFmt::RedoForRollback() { const SwFmtCntnt& rCntnt = pFrmFmt->GetCntnt(); if( rCntnt.GetCntntIdx() ) // kein Inhalt @@ -457,7 +476,7 @@ void SwUndoDelLayFmt::Redo() DelFly( pFrmFmt->GetDoc() ); } -/* */ +// SwUndoSetFlyFmt /////////////////////////////////////////////////////// SwUndoSetFlyFmt::SwUndoSetFlyFmt( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFrmFmt ) : SwUndo( UNDO_SETFLYFRMFMT ), SwClient( &rFlyFmt ), pFrmFmt( &rFlyFmt ), @@ -533,9 +552,9 @@ void SwUndoSetFlyFmt::GetAnchor( SwFmtAnchor& rAnchor, rAnchor.SetPageNum( nCntnt ); } -void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) +void SwUndoSetFlyFmt::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); // ist das neue Format noch vorhanden ?? if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pOldFmt ) ) @@ -603,13 +622,13 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) pFrmFmt->MakeFrms(); } - rIter.pSelFmt = pFrmFmt; + rContext.SetSelections(pFrmFmt, 0); } } -void SwUndoSetFlyFmt::Redo( SwUndoIter& rIter ) +void SwUndoSetFlyFmt::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); // ist das neue Format noch vorhanden ?? if( USHRT_MAX != rDoc.GetFrmFmts()->GetPos( (const SwFrmFmtPtr)pNewFmt ) ) @@ -626,7 +645,7 @@ void SwUndoSetFlyFmt::Redo( SwUndoIter& rIter ) else rDoc.SetFrmFmtToFly( *pFrmFmt, *pNewFmt, 0 ); - rIter.pSelFmt = pFrmFmt; + rContext.SetSelections(pFrmFmt, 0); } } diff --git a/sw/source/core/undo/undoflystrattr.cxx b/sw/source/core/undo/undoflystrattr.cxx index 23113d6b0d1b..fad07654f6f8 100644 --- a/sw/source/core/undo/undoflystrattr.cxx +++ b/sw/source/core/undo/undoflystrattr.cxx @@ -49,7 +49,7 @@ SwUndoFlyStrAttr::~SwUndoFlyStrAttr() { } -void SwUndoFlyStrAttr::Undo( SwUndoIter& ) +void SwUndoFlyStrAttr::UndoImpl(::sw::UndoRedoContext &) { switch ( GetId() ) { @@ -69,7 +69,7 @@ void SwUndoFlyStrAttr::Undo( SwUndoIter& ) } } -void SwUndoFlyStrAttr::Redo( SwUndoIter& ) +void SwUndoFlyStrAttr::RedoImpl(::sw::UndoRedoContext &) { switch ( GetId() ) { @@ -89,11 +89,6 @@ void SwUndoFlyStrAttr::Redo( SwUndoIter& ) } } -void SwUndoFlyStrAttr::Repeat( SwUndoIter& ) -{ - // no repeat -} - SwRewriter SwUndoFlyStrAttr::GetRewriter() const { SwRewriter aResult; diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index 980496cfd518..3e20e9e8aef0 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -28,25 +28,30 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoDraw.hxx> + #include <rtl/string.h> #include <rtl/memory.h> -#include <hintids.hxx> #include <svx/svdogrp.hxx> #include <svx/svdundo.hxx> #include <svx/svdpage.hxx> #include <svx/svdmark.hxx> + +#include <hintids.hxx> +#include <hints.hxx> #include <fmtanchr.hxx> #include <fmtflcnt.hxx> #include <txtflcnt.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <frame.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <dcontact.hxx> #include <dview.hxx> #include <rootfrm.hxx> @@ -64,8 +69,6 @@ struct SwUndoGroupObjImpl }; -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - // Draw-Objecte IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo ) @@ -76,15 +79,15 @@ IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo ) String sComment( pUndo->GetComment() ); #endif - if( DoesUndo() && !IsNoDrawUndoObj() ) + if (GetIDocumentUndoRedo().DoesUndo() && + GetIDocumentUndoRedo().DoesDrawUndo()) { - ClearRedo(); const SdrMarkList* pMarkList = 0; ViewShell* pSh = GetRootFrm() ? GetRootFrm()->GetCurrShell() : 0; if( pSh && pSh->HasDrawView() ) pMarkList = &pSh->GetDrawView()->GetMarkedObjectList(); - AppendUndo( new SwSdrUndo( pUndo, pMarkList ) ); + GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(pUndo, pMarkList) ); } else delete pUndo; @@ -106,16 +109,16 @@ SwSdrUndo::~SwSdrUndo() delete pMarkList; } -void SwSdrUndo::Undo( SwUndoIter& rUndoIter ) +void SwSdrUndo::UndoImpl(::sw::UndoRedoContext & rContext) { pSdrUndo->Undo(); - rUndoIter.pMarkList = pMarkList; + rContext.SetSelections(0, pMarkList); } -void SwSdrUndo::Redo( SwUndoIter& rUndoIter ) +void SwSdrUndo::RedoImpl(::sw::UndoRedoContext & rContext) { pSdrUndo->Redo(); - rUndoIter.pMarkList = pMarkList; + rContext.SetSelections(0, pMarkList); } String SwSdrUndo::GetComment() const @@ -222,7 +225,7 @@ SwUndoDrawGroup::~SwUndoDrawGroup() delete [] pObjArr; } -void SwUndoDrawGroup::Undo( SwUndoIter& ) +void SwUndoDrawGroup::UndoImpl(::sw::UndoRedoContext &) { bDelFmt = FALSE; @@ -273,7 +276,7 @@ void SwUndoDrawGroup::Undo( SwUndoIter& ) } } -void SwUndoDrawGroup::Redo( SwUndoIter& ) +void SwUndoDrawGroup::RedoImpl(::sw::UndoRedoContext &) { bDelFmt = TRUE; @@ -387,14 +390,14 @@ SwUndoDrawUnGroup::~SwUndoDrawUnGroup() delete [] pObjArr; } -void SwUndoDrawUnGroup::Undo( SwUndoIter& rIter ) +void SwUndoDrawUnGroup::UndoImpl(::sw::UndoRedoContext & rContext) { bDelFmt = TRUE; - // aus dem Array austragen - SwDoc* pDoc = &rIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); SwSpzFrmFmts& rFlyFmts = *(SwSpzFrmFmts*)pDoc->GetSpzFrmFmts(); + // remove from array for( USHORT n = 1; n < nSize; ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); @@ -439,7 +442,7 @@ void SwUndoDrawUnGroup::Undo( SwUndoIter& rIter ) // <-- } -void SwUndoDrawUnGroup::Redo( SwUndoIter& ) +void SwUndoDrawUnGroup::RedoImpl(::sw::UndoRedoContext &) { bDelFmt = FALSE; @@ -509,7 +512,8 @@ SwUndoDrawUnGroupConnectToLayout::~SwUndoDrawUnGroupConnectToLayout() { } -void SwUndoDrawUnGroupConnectToLayout::Undo( SwUndoIter& ) +void +SwUndoDrawUnGroupConnectToLayout::UndoImpl(::sw::UndoRedoContext &) { for ( std::vector< SdrObject >::size_type i = 0; i < aDrawFmtsAndObjs.size(); ++i ) @@ -528,7 +532,8 @@ void SwUndoDrawUnGroupConnectToLayout::Undo( SwUndoIter& ) } } -void SwUndoDrawUnGroupConnectToLayout::Redo( SwUndoIter& ) +void +SwUndoDrawUnGroupConnectToLayout::RedoImpl(::sw::UndoRedoContext &) { for ( std::vector< std::pair< SwDrawFrmFmt*, SdrObject* > >::size_type i = 0; i < aDrawFmtsAndObjs.size(); ++i ) @@ -570,10 +575,10 @@ SwUndoDrawDelete::~SwUndoDrawDelete() delete pMarkLst; } -void SwUndoDrawDelete::Undo( SwUndoIter &rIter ) +void SwUndoDrawDelete::UndoImpl(::sw::UndoRedoContext & rContext) { bDelFmt = FALSE; - SwSpzFrmFmts& rFlyFmts = *rIter.GetDoc().GetSpzFrmFmts(); + SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); for( USHORT n = 0; n < pMarkLst->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); @@ -596,13 +601,13 @@ void SwUndoDrawDelete::Undo( SwUndoIter &rIter ) } // <-- } - rIter.pMarkList = pMarkLst; + rContext.SetSelections(0, pMarkLst); } -void SwUndoDrawDelete::Redo( SwUndoIter &rIter ) +void SwUndoDrawDelete::RedoImpl(::sw::UndoRedoContext & rContext) { bDelFmt = TRUE; - SwSpzFrmFmts& rFlyFmts = *rIter.GetDoc().GetSpzFrmFmts(); + SwSpzFrmFmts & rFlyFmts = *rContext.GetDoc().GetSpzFrmFmts(); for( USHORT n = 0; n < pMarkLst->GetMarkCount(); ++n ) { SwUndoGroupObjImpl& rSave = *( pObjArr + n ); diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx index e67ec2e9d8c2..29eadf62d572 100644 --- a/sw/source/core/undo/unfmco.cxx +++ b/sw/source/core/undo/unfmco.cxx @@ -35,12 +35,10 @@ #include "pam.hxx" #include "ndtxt.hxx" -#include "undobj.hxx" +#include <UndoCore.hxx> #include "rolbck.hxx" -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - //-------------------------------------------------- @@ -70,51 +68,45 @@ SwUndoFmtColl::~SwUndoFmtColl() } -void SwUndoFmtColl::Undo( SwUndoIter& rUndoIter ) +void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext & rContext) { - // die alten Werte wieder zurueck - pHistory->TmpRollback( &rUndoIter.GetDoc(), 0 ); + // restore old values + pHistory->TmpRollback(& rContext.GetDoc(), 0); pHistory->SetTmpEnd( pHistory->Count() ); - // setze noch den Cursor auf den Undo-Bereich - SetPaM( rUndoIter ); + // create cursor for undo range + AddUndoRedoPaM(rContext); } -void SwUndoFmtColl::Redo( SwUndoIter& rUndoIter ) +void SwUndoFmtColl::RedoImpl(::sw::UndoRedoContext & rContext) { - // setze Attribut in dem Bereich: - SetPaM( rUndoIter ); - rUndoIter.pLastUndoObj = 0; - - Repeat( rUndoIter ); // Collection setzen + SwPaM & rPam = AddUndoRedoPaM(rContext); - rUndoIter.pLastUndoObj = 0; + DoSetFmtColl(rContext.GetDoc(), rPam); } - -void SwUndoFmtColl::Repeat( SwUndoIter& rUndoIter ) +void SwUndoFmtColl::RepeatImpl(::sw::RepeatContext & rContext) { - if( UNDO_SETFMTCOLL == rUndoIter.GetLastUndoId() && - pFmtColl == ((SwUndoFmtColl*)rUndoIter.pLastUndoObj)->pFmtColl ) - return; + DoSetFmtColl(rContext.GetDoc(), rContext.GetRepeatPaM()); +} +void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM) +{ // es kann nur eine TextFmtColl auf einen Bereich angewendet werden, // also erfrage auch nur in dem Array - USHORT nPos = rUndoIter.GetDoc().GetTxtFmtColls()->GetPos( + USHORT const nPos = rDoc.GetTxtFmtColls()->GetPos( (SwTxtFmtColl*)pFmtColl ); - // ist das Format ueberhaupt noch vorhanden? + // does the format still exist? if( USHRT_MAX != nPos ) { // --> OD 2008-04-15 #refactorlists# - rUndoIter.GetDoc().SetTxtFmtColl( *rUndoIter.pAktPam, + rDoc.SetTxtFmtColl(rPaM, (SwTxtFmtColl*)pFmtColl, mbReset, mbResetListAttrs ); // <-- } - - rUndoIter.pLastUndoObj = this; } SwRewriter SwUndoFmtColl::GetRewriter() const @@ -129,3 +121,4 @@ SwRewriter SwUndoFmtColl::GetRewriter() const return aResult; } + diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index dd95d06a34b1..c210bad3212e 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -27,6 +27,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include <UndoInsert.hxx> + #include <hintids.hxx> #include <unotools/charclass.hxx> #include <sot/storage.hxx> @@ -38,10 +41,13 @@ #include <fmtanchr.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoDelete.hxx> +#include <UndoAttribute.hxx> #include <rolbck.hxx> #include <ndgrf.hxx> #include <ndole.hxx> @@ -61,42 +67,6 @@ using namespace ::com::sun::star; -class _UnReplaceData : private SwUndoSaveCntnt -{ - String m_sOld, m_sIns; - ULONG m_nSttNd, m_nEndNd, m_nOffset; - xub_StrLen m_nSttCnt, m_nEndCnt, m_nSetPos, m_nSelEnd; - BOOL m_bSplitNext : 1; - BOOL m_bRegExp : 1; - // metadata references for paragraph and following para (if m_bSplitNext) - ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; - ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; - -public: - _UnReplaceData( const SwPaM& rPam, const String& rIns, BOOL bRegExp ); - ~_UnReplaceData(); - - void Undo( SwUndoIter& rIter ); - void Redo( SwUndoIter& rIter ); - void SetEnd( const SwPaM& rPam ); - - const String & GetOld() const { return m_sOld; } - const String & GetIns() const { return m_sIns; } -}; - - -SV_IMPL_PTRARR( _UnReplaceDatas, _UnReplaceData* ) - -//------------------------------------------------------------------ - -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - -// zwei Zugriffs-Funktionen -inline SwPosition* IterPt( SwUndoIter& rUIter ) -{ return rUIter.pAktPam->GetPoint(); } -inline SwPosition* IterMk( SwUndoIter& rUIter ) -{ return rUIter.pAktPam->GetMark(); } - //------------------------------------------------------------ // INSERT @@ -248,13 +218,13 @@ SwUndoInsert::~SwUndoInsert() -void SwUndoInsert::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pTmpDoc = &rUndoIter.GetDoc(); + SwDoc *const pTmpDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); if( bIsAppend ) { - SwPaM* pPam = rUndoIter.pAktPam; pPam->GetPoint()->nNode = nNode; if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) @@ -311,24 +281,22 @@ void SwUndoInsert::Undo( SwUndoIter& rUndoIter ) nCntnt = aPaM.GetPoint()->nContent.GetIndex(); } - // setze noch den Cursor auf den Undo-Bereich - rUndoIter.pAktPam->DeleteMark(); + // set cursor to Undo range + pPam->DeleteMark(); - IterPt(rUndoIter)->nNode = nNd; - IterPt(rUndoIter)->nContent.Assign( pTmpDoc->GetNodes()[ - IterPt(rUndoIter)->nNode ]->GetCntntNode(), nCnt ); - // SPoint und GetMark auf der gleichen Position + pPam->GetPoint()->nNode = nNd; + pPam->GetPoint()->nContent.Assign( + pPam->GetPoint()->nNode.GetNode().GetCntntNode(), nCnt ); } DELETEZ(pUndoTxt); } -void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) { - // setze noch den Cursor auf den Redo-Bereich - SwPaM* pPam = rUndoIter.pAktPam; - SwDoc* pTmpDoc = pPam->GetDoc(); + SwDoc *const pTmpDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); if( bIsAppend ) @@ -356,7 +324,8 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) else { pPam->GetPoint()->nNode = nNode; - SwCntntNode* pCNd = pTmpDoc->GetNodes()[ pPam->GetPoint()->nNode ]->GetCntntNode(); + SwCntntNode *const pCNd = + pPam->GetPoint()->nNode.GetNode().GetCntntNode(); pPam->GetPoint()->nContent.Assign( pCNd, nCntnt ); if( nLen ) @@ -383,18 +352,18 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) nCntnt = pPam->GetMark()->nContent.GetIndex(); MovePtForward( *pPam, bMvBkwrd ); - rUndoIter.pAktPam->Exchange(); + pPam->Exchange(); if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) { RedlineMode_t eOld = pTmpDoc->GetRedlineMode(); pTmpDoc->SetRedlineMode_intern((RedlineMode_t)(eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); pTmpDoc->AppendRedline( new SwRedline( *pRedlData, - *rUndoIter.pAktPam ), true); + *pPam ), true); pTmpDoc->SetRedlineMode_intern( eOld ); } else if( !( nsRedlineMode_t::REDLINE_IGNORE & GetRedlineMode() ) && pTmpDoc->GetRedlineTbl().Count() ) - pTmpDoc->SplitRedline( *rUndoIter.pAktPam ); + pTmpDoc->SplitRedline(*pPam); } } @@ -402,13 +371,12 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) } -void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext) { - rUndoIter.pLastUndoObj = this; if( !nLen ) return; - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwNodeIndex aNd( rDoc.GetNodes(), nNode ); SwCntntNode* pCNd = aNd.GetNode().GetCntntNode();; @@ -426,15 +394,15 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) { case ND_TEXTNODE: if( bIsAppend ) - rDoc.AppendTxtNode( *rUndoIter.pAktPam->GetPoint() ); + { + rDoc.AppendTxtNode( *rContext.GetRepeatPaM().GetPoint() ); + } else { String aTxt( ((SwTxtNode*)pCNd)->GetTxt() ); - BOOL bGroupUndo = rDoc.DoesGroupUndo(); - rDoc.DoGroupUndo( FALSE ); - rDoc.InsertString( *rUndoIter.pAktPam, + ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); + rDoc.InsertString( rContext.GetRepeatPaM(), aTxt.Copy( nCntnt - nLen, nLen ) ); - rDoc.DoGroupUndo( bGroupUndo ); } break; case ND_GRFNODE: @@ -444,7 +412,7 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) if( pGrfNd->IsGrfLink() ) pGrfNd->GetFileFilterNms( &sFile, &sFilter ); - rDoc.Insert( *rUndoIter.pAktPam, sFile, sFilter, + rDoc.Insert( rContext.GetRepeatPaM(), sFile, sFilter, &pGrfNd->GetGrf(), 0/* Grafik-Collection*/, NULL, NULL ); } @@ -464,7 +432,10 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) if ( aCnt.StoreEmbeddedObject( rSwOLE.GetOleRef(), aName, sal_True ) ) { uno::Reference < embed::XEmbeddedObject > aNew = aCnt.GetEmbeddedObject( aName ); - rDoc.Insert( *rUndoIter.pAktPam, svt::EmbeddedObjectRef( aNew, ((SwOLENode*)pCNd)->GetAspect() ), NULL, NULL, NULL ); + rDoc.Insert( rContext.GetRepeatPaM(), + svt::EmbeddedObjectRef( aNew, + static_cast<SwOLENode*>(pCNd)->GetAspect() ), + NULL, NULL, NULL ); } break; @@ -504,82 +475,85 @@ SwRewriter SwUndoInsert::GetRewriter() const } -/* */ +// SwUndoReplace ///////////////////////////////////////////////////////// -SwUndoReplace::SwUndoReplace() - : SwUndo( UNDO_REPLACE ), nAktPos( USHRT_MAX ) -{ -} -SwUndoReplace::~SwUndoReplace() +class SwUndoReplace::Impl + : private SwUndoSaveCntnt { -} + ::rtl::OUString m_sOld; + ::rtl::OUString m_sIns; + ULONG m_nSttNd, m_nEndNd, m_nOffset; + xub_StrLen m_nSttCnt, m_nEndCnt, m_nSetPos, m_nSelEnd; + bool m_bSplitNext : 1; + bool m_bRegExp : 1; + // metadata references for paragraph and following para (if m_bSplitNext) + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; -void SwUndoReplace::Undo( SwUndoIter& rUndoIter ) -{ - // war dieses nicht die letze Undo-Aktion, dann setze den - // Count neu - if( rUndoIter.pLastUndoObj != this ) +public: + Impl(SwPaM const& rPam, ::rtl::OUString const& rIns, bool const bRegExp); + virtual ~Impl() { - nAktPos = aArr.Count(); - rUndoIter.pLastUndoObj = this; - bOldIterFlag = rUndoIter.bWeiter; - rUndoIter.bWeiter = TRUE; } - aArr[ --nAktPos ]->Undo( rUndoIter ); + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); - if( !nAktPos ) // alten Status wieder zurueck - rUndoIter.bWeiter = bOldIterFlag; -} + void SetEnd(SwPaM const& rPam); + + ::rtl::OUString const& GetOld() const { return m_sOld; } + ::rtl::OUString const& GetIns() const { return m_sIns; } +}; -void SwUndoReplace::Redo( SwUndoIter& rUndoIter ) +SwUndoReplace::SwUndoReplace(SwPaM const& rPam, + ::rtl::OUString const& rIns, bool const bRegExp) + : SwUndo( UNDO_REPLACE ) + , m_pImpl(new Impl(rPam, rIns, bRegExp)) { - // war dieses nicht die letze Undo-Aktion, dann setze den - // Count neu - if( rUndoIter.pLastUndoObj != this ) - { - ASSERT( !nAktPos, "Redo ohne vorheriges Undo??" ); - rUndoIter.pLastUndoObj = this; - bOldIterFlag = rUndoIter.bWeiter; - rUndoIter.bWeiter = TRUE; - } +} - aArr[ nAktPos ]->Redo( rUndoIter ); +SwUndoReplace::~SwUndoReplace() +{ +} - if( ++nAktPos >= aArr.Count() ) // alten Status wieder zurueck - { - nAktPos = USHRT_MAX; - rUndoIter.bWeiter = bOldIterFlag; - } +void SwUndoReplace::UndoImpl(::sw::UndoRedoContext & rContext) +{ + m_pImpl->UndoImpl(rContext); } -// #111827# -SwRewriter SwUndoReplace::GetRewriter() const +void SwUndoReplace::RedoImpl(::sw::UndoRedoContext & rContext) +{ + m_pImpl->RedoImpl(rContext); +} + +SwRewriter +MakeUndoReplaceRewriter(ULONG const occurrences, + ::rtl::OUString const& sOld, ::rtl::OUString const& sNew) { SwRewriter aResult; - if (aArr.Count() > 1) + if (1 < occurrences) { - aResult.AddRule(UNDO_ARG1, String::CreateFromInt32(aArr.Count())); + aResult.AddRule(UNDO_ARG1, String::CreateFromInt32(occurrences)); aResult.AddRule(UNDO_ARG2, String(SW_RES(STR_OCCURRENCES_OF))); String aTmpStr; aTmpStr += String(SW_RES(STR_START_QUOTE)); - aTmpStr += ShortenString(aArr[0]->GetOld(), nUndoStringLength, + aTmpStr += ShortenString(sOld, nUndoStringLength, SW_RES(STR_LDOTS)); aTmpStr += String(SW_RES(STR_END_QUOTE)); aResult.AddRule(UNDO_ARG3, aTmpStr); } - else if (aArr.Count() == 1) + else if (1 == occurrences) { { String aTmpStr; aTmpStr += String(SW_RES(STR_START_QUOTE)); // #i33488 # - aTmpStr += ShortenString(aArr[0]->GetOld(), nUndoStringLength, + aTmpStr += ShortenString(sOld, nUndoStringLength, SW_RES(STR_LDOTS)); aTmpStr += String(SW_RES(STR_END_QUOTE)); aResult.AddRule(UNDO_ARG1, aTmpStr); @@ -592,7 +566,7 @@ SwRewriter SwUndoReplace::GetRewriter() const aTmpStr += String(SW_RES(STR_START_QUOTE)); // #i33488 # - aTmpStr += ShortenString(aArr[0]->GetIns(), nUndoStringLength, + aTmpStr += ShortenString(sNew, nUndoStringLength, SW_RES(STR_LDOTS)); aTmpStr += String(SW_RES(STR_END_QUOTE)); aResult.AddRule(UNDO_ARG3, aTmpStr); @@ -602,24 +576,23 @@ SwRewriter SwUndoReplace::GetRewriter() const return aResult; } -void SwUndoReplace::AddEntry( const SwPaM& rPam, const String& rInsert, - BOOL bRegExp ) +// #111827# +SwRewriter SwUndoReplace::GetRewriter() const { - _UnReplaceData* pNew = new _UnReplaceData( rPam, rInsert, bRegExp ); - aArr.C40_INSERT(_UnReplaceData, pNew, aArr.Count() ); + return MakeUndoReplaceRewriter(1, m_pImpl->GetOld(), m_pImpl->GetIns()); } -void SwUndoReplace::SetEntryEnd( const SwPaM& rPam ) +void SwUndoReplace::SetEnd(SwPaM const& rPam) { - _UnReplaceData* pEntry = aArr[ aArr.Count()-1 ]; - pEntry->SetEnd( rPam ); + m_pImpl->SetEnd(rPam); } -_UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, - BOOL bRgExp ) - : m_sIns( rIns ), m_nOffset( 0 ) +SwUndoReplace::Impl::Impl( + SwPaM const& rPam, ::rtl::OUString const& rIns, bool const bRegExp) + : m_sIns( rIns ) + , m_nOffset( 0 ) + , m_bRegExp(bRegExp) { - m_bRegExp = bRgExp; const SwPosition * pStt( rPam.Start() ); const SwPosition * pEnd( rPam.End() ); @@ -673,14 +646,10 @@ _UnReplaceData::_UnReplaceData( const SwPaM& rPam, const String& rIns, m_sOld = pNd->GetTxt().Copy( m_nSttCnt, nECnt - m_nSttCnt ); } -_UnReplaceData::~_UnReplaceData() -{ -} - -void _UnReplaceData::Undo( SwUndoIter& rIter ) +void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); - SwPaM& rPam = *rIter.pAktPam; + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor()); rPam.DeleteMark(); SwTxtNode* pNd = pDoc->GetNodes()[ m_nSttNd - m_nOffset ]->GetTxtNode(); @@ -689,18 +658,18 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwAutoCorrExceptWord* pACEWord = pDoc->GetAutoCorrExceptWord(); if( pACEWord ) { - if( 1 == m_sIns.Len() && 1 == m_sOld.Len() ) + if ((1 == m_sIns.getLength()) && (1 == m_sOld.getLength())) { SwPosition aPos( *pNd ); aPos.nContent.Assign( pNd, m_nSttCnt ); - pACEWord->CheckChar( aPos, m_sOld.GetChar( 0 ) ); + pACEWord->CheckChar( aPos, m_sOld[ 0 ] ); } pDoc->SetAutoCorrExceptWord( 0 ); } - SwIndex aIdx( pNd, m_nSttCnt ); + SwIndex aIdx( pNd, USHORT( m_nSttCnt ) ); if( m_nSttNd == m_nEndNd ) { - pNd->EraseText( aIdx, m_sIns.Len() ); + pNd->EraseText( aIdx, USHORT( m_sIns.getLength() ) ); } else { @@ -728,7 +697,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) pNd->RestoreMetadata(m_pMetadataUndoStart); } - if( m_sOld.Len() ) + if (m_sOld.getLength()) { pNd->InsertText( m_sOld, aIdx ); } @@ -762,13 +731,10 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) rPam.GetPoint()->nContent = aIdx; } -void _UnReplaceData::Redo( SwUndoIter& rIter ) +void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); - - SwPaM& rPam = *rIter.pAktPam; + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam(rContext.GetCursorSupplier().CreateNewShellCursor()); rPam.DeleteMark(); rPam.GetPoint()->nNode = m_nSttNd; @@ -805,21 +771,21 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) rDoc.ReplaceRange( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); - rDoc.DoUndo( bUndo ); } -void _UnReplaceData::SetEnd( const SwPaM& rPam ) +void SwUndoReplace::Impl::SetEnd(SwPaM const& rPam) { if( rPam.GetPoint()->nNode != rPam.GetMark()->nNode ) { - // es wurden mehrere Absaetze eingefuegt + // multiple paragraphs were inserted const SwPosition* pEnd = rPam.End(); m_nEndNd = m_nOffset + pEnd->nNode.GetIndex(); m_nEndCnt = pEnd->nContent.GetIndex(); } } -/* */ + +// SwUndoReRead ////////////////////////////////////////////////////////// SwUndoReRead::SwUndoReRead( const SwPaM& rPam, const SwGrfNode& rGrfNd ) @@ -837,9 +803,9 @@ SwUndoReRead::~SwUndoReRead() } -void SwUndoReRead::SetAndSave( SwUndoIter& rIter ) +void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwGrfNode* pGrfNd = rDoc.GetNodes()[ nPos ]->GetGrfNode(); if( !pGrfNd ) @@ -867,19 +833,19 @@ void SwUndoReRead::SetAndSave( SwUndoIter& rIter ) if( RES_MIRROR_GRAPH_DONT != nOldMirr ) pGrfNd->SetAttr( SwMirrorGrf() ); - rIter.pSelFmt = pGrfNd->GetFlyFmt(); + rContext.SetSelections(pGrfNd->GetFlyFmt(), 0); } -void SwUndoReRead::Undo( SwUndoIter& rIter ) +void SwUndoReRead::UndoImpl(::sw::UndoRedoContext & rContext) { - SetAndSave( rIter ); + SetAndSave(rContext); } -void SwUndoReRead::Redo( SwUndoIter& rIter ) +void SwUndoReRead::RedoImpl(::sw::UndoRedoContext & rContext) { - SetAndSave( rIter ); + SetAndSave(rContext); } @@ -938,9 +904,9 @@ SwUndoInsertLabel::~SwUndoInsertLabel() delete NODE.pUndoInsNd; } -void SwUndoInsertLabel::Undo( SwUndoIter& rIter ) +void SwUndoInsertLabel::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType ) { @@ -952,8 +918,8 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter ) ( LTYPE_DRAW != eType || 0 != (pSdrObj = pFmt->FindSdrObject()) ) ) { - OBJECT.pUndoAttr->Undo( rIter ); - OBJECT.pUndoFly->Undo( rIter ); + OBJECT.pUndoAttr->UndoImpl(rContext); + OBJECT.pUndoFly->UndoImpl(rContext); if( LTYPE_DRAW == eType ) { pSdrObj->SetLayer( nLayerId ); @@ -969,7 +935,7 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter ) if ( pNd ) pNd->GetTable().GetFrmFmt()->ResetFmtAttr( RES_KEEP ); } - SwPaM aPam( *rIter.pAktPam->GetPoint() ); + SwPaM aPam( rDoc.GetNodes().GetEndOfContent() ); aPam.GetPoint()->nNode = NODE.nNode; aPam.SetMark(); aPam.GetPoint()->nNode = NODE.nNode + 1; @@ -978,9 +944,9 @@ void SwUndoInsertLabel::Undo( SwUndoIter& rIter ) } -void SwUndoInsertLabel::Redo( SwUndoIter& rIter ) +void SwUndoInsertLabel::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if( LTYPE_OBJECT == eType || LTYPE_DRAW == eType ) { @@ -992,8 +958,8 @@ void SwUndoInsertLabel::Redo( SwUndoIter& rIter ) ( LTYPE_DRAW != eType || 0 != (pSdrObj = pFmt->FindSdrObject()) ) ) { - OBJECT.pUndoFly->Redo( rIter ); - OBJECT.pUndoAttr->Redo( rIter ); + OBJECT.pUndoFly->RedoImpl(rContext); + OBJECT.pUndoAttr->RedoImpl(rContext); if( LTYPE_DRAW == eType ) { pSdrObj->SetLayer( nLayerId ); @@ -1014,15 +980,15 @@ void SwUndoInsertLabel::Redo( SwUndoIter& rIter ) if ( pNd ) pNd->GetTable().GetFrmFmt()->SetFmtAttr( SvxFmtKeepItem(TRUE, RES_KEEP) ); } - NODE.pUndoInsNd->Undo( rIter ); + NODE.pUndoInsNd->UndoImpl(rContext); delete NODE.pUndoInsNd, NODE.pUndoInsNd = 0; } } -void SwUndoInsertLabel::Repeat( SwUndoIter& rIter ) +void SwUndoInsertLabel::RepeatImpl(::sw::RepeatContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); - const SwPosition& rPos = *rIter.pAktPam->GetPoint(); + SwDoc & rDoc = rContext.GetDoc(); + const SwPosition& rPos = *rContext.GetRepeatPaM().GetPoint(); ULONG nIdx = 0; diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 4c5fbca4085c..49155827b473 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -28,17 +28,17 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoSplitMove.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <swundo.hxx> // fuer die UndoIds #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - // MOVE SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) @@ -79,7 +79,8 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos ) pHistory->CopyFmtAttr( *pEndTxtNd->GetpSwAttrSet(), nEndNode ); } - if( 0 != (pTxtNd = rRange.GetDoc()->GetNodes()[ rMvPos.nNode ]->GetTxtNode() )) + pTxtNd = rMvPos.nNode.GetNode().GetTxtNode(); + if (0 != pTxtNd) { pHistory->Add( pTxtNd->GetTxtColl(), nMvDestNode, ND_TEXTNODE ); if ( pTxtNd->GetpSwpHints() ) @@ -187,11 +188,9 @@ void SwUndoMove::SetDestRange( const SwNodeIndex& rStt, } -void SwUndoMove::Undo( SwUndoIter& rUndoIter ) +void SwUndoMove::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rUndoIter.GetDoc(); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + SwDoc *const pDoc = & rContext.GetDoc(); // Block, damit aus diesem gesprungen werden kann do { @@ -276,18 +275,18 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) pHistory->SetTmpEnd( pHistory->Count() ); } - pDoc->DoUndo( bUndo ); - // setze noch den Cursor auf den Undo-Bereich if( !bMoveRange ) - SetPaM( rUndoIter ); + { + AddUndoRedoPaM(rContext); + } } -void SwUndoMove::Redo( SwUndoIter& rUndoIter ) +void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rUndoIter.pAktPam; - SwDoc& rDoc = *pPam->GetDoc(); + SwPaM *const pPam = & AddUndoRedoPaM(rContext); + SwDoc & rDoc = rContext.GetDoc(); SwNodes& rNds = rDoc.GetNodes(); SwNodeIndex aIdx( rNds, nMvDestNode ); diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx index 8cf782e85b53..121f4e5b9210 100644 --- a/sw/source/core/undo/unnum.cxx +++ b/sw/source/core/undo/unnum.cxx @@ -28,21 +28,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoNumbering.hxx> #include <hintids.hxx> #include <editeng/lrspitem.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> SV_DECL_PTRARR_DEL( _SfxPoolItems, SfxPoolItem*, 16, 16 ) SV_IMPL_PTRARR( _SfxPoolItems, SfxPoolItem* ); -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } SwUndoInsNum::SwUndoInsNum( const SwNumRule& rOldRule, const SwNumRule& rNewRule, @@ -87,14 +88,9 @@ SwRewriter SwUndoInsNum::GetRewriter() const return aResult; } -void SwUndoInsNum::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsNum::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - if( nSttNode ) - SetPaM( rUndoIter ); - - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + SwDoc & rDoc = rContext.GetDoc(); if( pOldNumRule ) rDoc.ChgNumRuleFmts( *pOldNumRule ); @@ -134,29 +130,31 @@ void SwUndoInsNum::Undo( SwUndoIter& rUndoIter ) pHistory->SetTmpEnd( pHistory->Count() ); } - if( nSttNode ) - SetPaM( rUndoIter ); - rDoc.DoUndo( bUndo ); + if (nSttNode) + { + AddUndoRedoPaM(rContext); + } } - -void SwUndoInsNum::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsNum::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if( pOldNumRule ) rDoc.ChgNumRuleFmts( aNumRule ); else if( pHistory ) { - SetPaM( rUndoIter ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); if( sReplaceRule.Len() ) - rDoc.ReplaceNumRule( *rUndoIter.pAktPam->GetPoint(), + { + rDoc.ReplaceNumRule(*rPam.GetPoint(), sReplaceRule, aNumRule.GetName() ); + } else { // --> OD 2005-02-25 #i42921# - adapt to changed signature // --> OD 2008-03-18 #refactorlists# - rDoc.SetNumRule( *rUndoIter.pAktPam, aNumRule, false ); + rDoc.SetNumRule(rPam, aNumRule, false); // <-- } } @@ -168,20 +166,23 @@ void SwUndoInsNum::SetLRSpaceEndPos() nLRSavePos = pHistory->Count(); } -void SwUndoInsNum::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInsNum::RepeatImpl(::sw::RepeatContext & rContext) { + SwDoc & rDoc(rContext.GetDoc()); if( nSttNode ) { if( !sReplaceRule.Len() ) { // --> OD 2005-02-25 #i42921# - adapt to changed signature // --> OD 2008-03-18 #refactorlists# - rUndoIter.GetDoc().SetNumRule( *rUndoIter.pAktPam, aNumRule, false ); + rDoc.SetNumRule(rContext.GetRepeatPaM(), aNumRule, false); // <-- } } else - rUndoIter.GetDoc().ChgNumRuleFmts( aNumRule ); + { + rDoc.ChgNumRuleFmts( aNumRule ); + } } SwHistory* SwUndoInsNum::GetHistory() @@ -207,20 +208,14 @@ SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam ) pHistory = new SwHistory; } - SwUndoDelNum::~SwUndoDelNum() { delete pHistory; } - -void SwUndoDelNum::Undo( SwUndoIter& rUndoIter ) +void SwUndoDelNum::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - SetPaM( rUndoIter ); - - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + SwDoc & rDoc = rContext.GetDoc(); pHistory->TmpRollback( &rDoc, 0 ); pHistory->SetTmpEnd( pHistory->Count() ); @@ -235,22 +230,18 @@ void SwUndoDelNum::Undo( SwUndoIter& rUndoIter ) pNd->ChkCondColl(); } - SetPaM( rUndoIter ); - rDoc.DoUndo( bUndo ); + AddUndoRedoPaM(rContext); } - -void SwUndoDelNum::Redo( SwUndoIter& rUndoIter ) +void SwUndoDelNum::RedoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().DelNumRules( *rUndoIter.pAktPam ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().DelNumRules(rPam); } - -void SwUndoDelNum::Repeat( SwUndoIter& rUndoIter ) +void SwUndoDelNum::RepeatImpl(::sw::RepeatContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().DelNumRules( *rUndoIter.pAktPam ); + rContext.GetDoc().DelNumRules(rContext.GetRepeatPaM()); } void SwUndoDelNum::AddNode( const SwTxtNode& rNd, BOOL ) @@ -277,8 +268,7 @@ SwUndoMoveNum::SwUndoMoveNum( const SwPaM& rPam, long nOff, BOOL bIsOutlMv ) // nach oben => -1 } - -void SwUndoMoveNum::Undo( SwUndoIter& rUndoIter ) +void SwUndoMoveNum::UndoImpl(::sw::UndoRedoContext & rContext) { ULONG nTmpStt = nSttNode, nTmpEnd = nEndNode; @@ -295,33 +285,35 @@ void SwUndoMoveNum::Undo( SwUndoIter& rUndoIter ) // SetPaM( rUndoIter ); // RemoveIdxFromRange( *rUndoIter.pAktPam, TRUE ); - SetPaM( rUndoIter ); - rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, -nOffset, + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().MoveParagraph( rPam, -nOffset, UNDO_OUTLINE_UD == GetId() ); nSttNode = nTmpStt; nEndNode = nTmpEnd; } - -void SwUndoMoveNum::Redo( SwUndoIter& rUndoIter ) +void SwUndoMoveNum::RedoImpl(::sw::UndoRedoContext & rContext) { //JP 22.06.95: wird wollen die Bookmarks/Verzeichnisse behalten, oder? // SetPaM( rUndoIter ); // RemoveIdxFromRange( *rUndoIter.pAktPam, TRUE ); - SetPaM( rUndoIter ); - rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, nOffset, - UNDO_OUTLINE_UD == GetId() ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().MoveParagraph(rPam, nOffset, UNDO_OUTLINE_UD == GetId()); } - -void SwUndoMoveNum::Repeat( SwUndoIter& rUndoIter ) +void SwUndoMoveNum::RepeatImpl(::sw::RepeatContext & rContext) { + SwDoc & rDoc = rContext.GetDoc(); if( UNDO_OUTLINE_UD == GetId() ) - rUndoIter.GetDoc().MoveOutlinePara( *rUndoIter.pAktPam, + { + rDoc.MoveOutlinePara(rContext.GetRepeatPaM(), 0 < nOffset ? 1 : -1 ); + } else - rUndoIter.GetDoc().MoveParagraph( *rUndoIter.pAktPam, nOffset, FALSE ); + { + rDoc.MoveParagraph(rContext.GetRepeatPaM(), nOffset, FALSE); + } } /* */ @@ -335,24 +327,21 @@ SwUndoNumUpDown::SwUndoNumUpDown( const SwPaM& rPam, short nOff ) // Up => -1 } - -void SwUndoNumUpDown::Undo( SwUndoIter& rUndoIter ) +void SwUndoNumUpDown::UndoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 != nOffset ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().NumUpDown(rPam, 1 != nOffset ); } - -void SwUndoNumUpDown::Redo( SwUndoIter& rUndoIter ) +void SwUndoNumUpDown::RedoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 == nOffset ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().NumUpDown(rPam, 1 == nOffset); } - -void SwUndoNumUpDown::Repeat( SwUndoIter& rUndoIter ) +void SwUndoNumUpDown::RepeatImpl(::sw::RepeatContext & rContext) { - rUndoIter.GetDoc().NumUpDown( *rUndoIter.pAktPam, 1 == nOffset ); + rContext.GetDoc().NumUpDown(rContext.GetRepeatPaM(), 1 == nOffset); } /* */ @@ -366,9 +355,9 @@ SwUndoNumOrNoNum::SwUndoNumOrNoNum( const SwNodeIndex& rIdx, BOOL bOldNum, } // #115901#, #i40034# -void SwUndoNumOrNoNum::Undo( SwUndoIter& rUndoIter ) +void SwUndoNumOrNoNum::UndoImpl(::sw::UndoRedoContext & rContext) { - SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), nIdx ); + SwNodeIndex aIdx( rContext.GetDoc().GetNodes(), nIdx ); SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode(); if (NULL != pTxtNd) @@ -378,9 +367,9 @@ void SwUndoNumOrNoNum::Undo( SwUndoIter& rUndoIter ) } // #115901#, #i40034# -void SwUndoNumOrNoNum::Redo( SwUndoIter& rUndoIter ) +void SwUndoNumOrNoNum::RedoImpl(::sw::UndoRedoContext & rContext) { - SwNodeIndex aIdx( rUndoIter.GetDoc().GetNodes(), nIdx ); + SwNodeIndex aIdx( rContext.GetDoc().GetNodes(), nIdx ); SwTxtNode * pTxtNd = aIdx.GetNode().GetTxtNode(); if (NULL != pTxtNd) @@ -390,15 +379,17 @@ void SwUndoNumOrNoNum::Redo( SwUndoIter& rUndoIter ) } // #115901# -void SwUndoNumOrNoNum::Repeat( SwUndoIter& rUndoIter ) +void SwUndoNumOrNoNum::RepeatImpl(::sw::RepeatContext & rContext) { - + SwDoc & rDoc = rContext.GetDoc(); if (mbOldNum && ! mbNewNum) - rUndoIter.GetDoc().NumOrNoNum( rUndoIter.pAktPam->GetPoint()->nNode, - FALSE); + { + rDoc.NumOrNoNum(rContext.GetRepeatPaM().GetPoint()->nNode, FALSE); + } else if ( ! mbOldNum && mbNewNum ) - rUndoIter.GetDoc().NumOrNoNum( rUndoIter.pAktPam->GetPoint()->nNode, - TRUE); + { + rDoc.NumOrNoNum(rContext.GetRepeatPaM().GetPoint()->nNode, TRUE); + } } /* */ @@ -432,34 +423,47 @@ SwUndoNumRuleStart::SwUndoNumRuleStart( const SwPosition& rPos, USHORT nStt ) } -void SwUndoNumRuleStart::Undo( SwUndoIter& rUndoIter ) +void SwUndoNumRuleStart::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPosition aPos( *rUndoIter.GetDoc().GetNodes()[ nIdx ] ); + SwDoc & rDoc = rContext.GetDoc(); + SwPosition const aPos( *rDoc.GetNodes()[ nIdx ] ); if( bSetSttValue ) - rUndoIter.GetDoc().SetNodeNumStart( aPos, nOldStt ); + { + rDoc.SetNodeNumStart( aPos, nOldStt ); + } else - rUndoIter.GetDoc().SetNumRuleStart( aPos, !bFlag ); + { + rDoc.SetNumRuleStart( aPos, !bFlag ); + } } -void SwUndoNumRuleStart::Redo( SwUndoIter& rUndoIter ) +void SwUndoNumRuleStart::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - - SwPosition aPos( *rDoc.GetNodes()[ nIdx ] ); + SwDoc & rDoc = rContext.GetDoc(); + SwPosition const aPos( *rDoc.GetNodes()[ nIdx ] ); if( bSetSttValue ) + { rDoc.SetNodeNumStart( aPos, nNewStt ); + } else + { rDoc.SetNumRuleStart( aPos, bFlag ); + } } -void SwUndoNumRuleStart::Repeat( SwUndoIter& rUndoIter ) +void SwUndoNumRuleStart::RepeatImpl(::sw::RepeatContext & rContext) { + SwDoc & rDoc = rContext.GetDoc(); if( bSetSttValue ) - rUndoIter.GetDoc().SetNodeNumStart( *rUndoIter.pAktPam->GetPoint(), nNewStt ); + { + rDoc.SetNodeNumStart(*rContext.GetRepeatPaM().GetPoint(), nNewStt); + } else - rUndoIter.GetDoc().SetNumRuleStart( *rUndoIter.pAktPam->GetPoint(), bFlag ); + { + rDoc.SetNumRuleStart(*rContext.GetRepeatPaM().GetPoint(), bFlag); + } } diff --git a/sw/source/core/undo/unoutl.cxx b/sw/source/core/undo/unoutl.cxx index 2a92097221b6..bbe80824d44a 100644 --- a/sw/source/core/undo/unoutl.cxx +++ b/sw/source/core/undo/unoutl.cxx @@ -28,43 +28,34 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "doc.hxx" #include "swundo.hxx" // fuer die UndoIds #include "pam.hxx" #include "ndtxt.hxx" -#include "undobj.hxx" +#include <UndoCore.hxx> -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - SwUndoOutlineLeftRight::SwUndoOutlineLeftRight( const SwPaM& rPam, short nOff ) : SwUndo( UNDO_OUTLINE_LR ), SwUndRng( rPam ), nOffset( nOff ) { } - -void SwUndoOutlineLeftRight::Undo( SwUndoIter& rUndoIter ) +void SwUndoOutlineLeftRight::UndoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, -nOffset ); + SwPaM & rPaM( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().OutlineUpDown(rPaM, -nOffset); } - -void SwUndoOutlineLeftRight::Redo( SwUndoIter& rUndoIter ) +void SwUndoOutlineLeftRight::RedoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, nOffset ); + SwPaM & rPaM( AddUndoRedoPaM(rContext) ); + rContext.GetDoc().OutlineUpDown(rPaM, nOffset); } - -void SwUndoOutlineLeftRight::Repeat( SwUndoIter& rUndoIter ) +void SwUndoOutlineLeftRight::RepeatImpl(::sw::RepeatContext & rContext) { - rUndoIter.GetDoc().OutlineUpDown( *rUndoIter.pAktPam, nOffset ); + rContext.GetDoc().OutlineUpDown(rContext.GetRepeatPaM(), nOffset); } - - diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index 91549c84a57e..0cd1711ffcd0 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -28,20 +28,26 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoOverwrite.hxx> + +#include <tools/resid.hxx> #include <unotools/charclass.hxx> #include <unotools/transliterationwrapper.hxx> + #include <comphelper/processfactory.hxx> + #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> +#include <IShellCursorSupplier.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> #include <acorrect.hxx> #include <docary.hxx> -#include <tools/resid.hxx> #include <comcore.hrc> // #111827# #include <undo.hrc> @@ -49,19 +55,9 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::uno; -//------------------------------------------------------------------ - -// zwei Zugriffs-Funktionen -inline SwPosition* IterPt( SwUndoIter& rUIter ) -{ return rUIter.pAktPam->GetPoint(); } -inline SwPosition* IterMk( SwUndoIter& rUIter ) -{ return rUIter.pAktPam->GetMark(); } - -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } //------------------------------------------------------------ - // OVERWRITE @@ -200,10 +196,11 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, -void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) +void SwUndoOverwrite::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pAktPam = rUndoIter.pAktPam; - SwDoc* pDoc = pAktPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pAktPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); + pAktPam->DeleteMark(); pAktPam->GetPoint()->nNode = nSttNode; SwTxtNode* pTxtNd = pAktPam->GetNode()->GetTxtNode(); @@ -266,29 +263,27 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) SetSaveData( *pDoc, *pRedlSaveData ); } -void SwUndoOverwrite::Repeat( SwUndoIter& rUndoIter ) +void SwUndoOverwrite::RepeatImpl(::sw::RepeatContext & rContext) { - rUndoIter.pLastUndoObj = this; - SwPaM* pAktPam = rUndoIter.pAktPam; + SwPaM *const pAktPam = & rContext.GetRepeatPaM(); if( !aInsStr.Len() || pAktPam->HasMark() ) return; - SwDoc& rDoc = *pAktPam->GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); - BOOL bGroupUndo = rDoc.DoesGroupUndo(); - rDoc.DoGroupUndo( FALSE ); - rDoc.Overwrite( *pAktPam, aInsStr.GetChar( 0 )); - rDoc.DoGroupUndo( bGroupUndo ); + { + ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); + rDoc.Overwrite(*pAktPam, aInsStr.GetChar(0)); + } for( xub_StrLen n = 1; n < aInsStr.Len(); ++n ) rDoc.Overwrite( *pAktPam, aInsStr.GetChar( n ) ); } - - -void SwUndoOverwrite::Redo( SwUndoIter& rUndoIter ) +void SwUndoOverwrite::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pAktPam = rUndoIter.pAktPam; - SwDoc* pDoc = pAktPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pAktPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); + pAktPam->DeleteMark(); pAktPam->GetPoint()->nNode = nSttNode; SwTxtNode* pTxtNd = pAktPam->GetNode()->GetTxtNode(); @@ -380,11 +375,9 @@ SwUndoTransliterate::~SwUndoTransliterate() delete aChanges[i]; } -void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter ) +void SwUndoTransliterate::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - BOOL bUndo = rDoc.DoesUndo(); - rDoc.DoUndo( FALSE ); + SwDoc & rDoc = rContext.GetDoc(); // since the changes were added to the vector from the end of the string/node towards // the start, we need to revert them from the start towards the end now to keep the @@ -393,27 +386,24 @@ void SwUndoTransliterate::Undo( SwUndoIter& rUndoIter ) for (sal_Int32 i = aChanges.size() - 1; i >= 0; --i) aChanges[i]->SetChangeAtNode( rDoc ); - rDoc.DoUndo( bUndo ); - SetPaM( rUndoIter, TRUE ); + AddUndoRedoPaM(rContext, true); } -void SwUndoTransliterate::Redo( SwUndoIter& rUndoIter ) +void SwUndoTransliterate::RedoImpl(::sw::UndoRedoContext & rContext) { -/* ??? */ rUndoIter.SetUpdateAttr( TRUE ); - - SetPaM( *rUndoIter.pAktPam ); - Repeat( rUndoIter ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + DoTransliterate(rContext.GetDoc(), rPam); } -void SwUndoTransliterate::Repeat( SwUndoIter& rUndoIter ) +void SwUndoTransliterate::RepeatImpl(::sw::RepeatContext & rContext) { - SwPaM& rPam = *rUndoIter.pAktPam; - SwDoc& rDoc = rUndoIter.GetDoc(); + DoTransliterate(rContext.GetDoc(), rContext.GetRepeatPaM()); +} +void SwUndoTransliterate::DoTransliterate(SwDoc & rDoc, SwPaM & rPam) +{ utl::TransliterationWrapper aTrans( ::comphelper::getProcessServiceFactory(), nType ); rDoc.TransliterateText( rPam, aTrans ); - - rUndoIter.pLastUndoObj = this; } void SwUndoTransliterate::AddChanges( SwTxtNode& rTNd, diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx index 7f76697c80a3..a3508cf5d568 100644 --- a/sw/source/core/undo/unredln.cxx +++ b/sw/source/core/undo/unredln.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoRedline.hxx> #include <hintids.hxx> #include <unotools/charclass.hxx> @@ -35,7 +36,8 @@ #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoDelete.hxx> #include <rolbck.hxx> #include <redline.hxx> #include <docary.hxx> @@ -46,9 +48,6 @@ extern void lcl_GetJoinFlags( SwPaM& rPam, BOOL& rJoinTxt, BOOL& rJoinPrev ); //------------------------------------------------------------------ -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - - SwUndoRedline::SwUndoRedline( SwUndoId nUsrId, const SwPaM& rRange ) : SwUndo( UNDO_REDLINE ), SwUndRng( rRange ), pRedlData( 0 ), pRedlSaveData( 0 ), nUserId( nUsrId ), @@ -94,13 +93,18 @@ SwUndoRedline::~SwUndoRedline() delete pRedlSaveData; } -void SwUndoRedline::Undo( SwUndoIter& rIter ) +USHORT SwUndoRedline::GetRedlSaveCount() const { - SwDoc* pDoc = &rIter.GetDoc(); - SetPaM( *rIter.pAktPam ); + return pRedlSaveData ? pRedlSaveData->Count() : 0; +} -// RedlineMode setzen? - _Undo( rIter ); + +void SwUndoRedline::UndoImpl(::sw::UndoRedoContext & rContext) +{ + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + + UndoRedlineImpl(*pDoc, rPam); if( pRedlSaveData ) { @@ -114,47 +118,47 @@ void SwUndoRedline::Undo( SwUndoIter& rIter ) nSttNode += nEndExtra; nEndNode += nEndExtra; } - SetPaM( *rIter.pAktPam, TRUE ); + SetPaM(rPam, true); } } -void SwUndoRedline::Redo( SwUndoIter& rIter ) +void SwUndoRedline::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rIter.GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(( eOld & ~nsRedlineMode_t::REDLINE_IGNORE) | nsRedlineMode_t::REDLINE_ON )); - SetPaM( *rIter.pAktPam ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); if( pRedlSaveData && bHiddenRedlines ) { ULONG nEndExtra = pDoc->GetNodes().GetEndOfExtras().GetIndex(); - FillSaveData( *rIter.pAktPam, *pRedlSaveData, FALSE, + FillSaveData(rPam, *pRedlSaveData, FALSE, UNDO_REJECT_REDLINE != nUserId ); nEndExtra -= pDoc->GetNodes().GetEndOfExtras().GetIndex(); nSttNode -= nEndExtra; nEndNode -= nEndExtra; } - _Redo( rIter ); - SetPaM( *rIter.pAktPam, TRUE ); + RedoRedlineImpl(*pDoc, rPam); + + SetPaM(rPam, true); pDoc->SetRedlineMode_intern( eOld ); } -// default ist leer -void SwUndoRedline::_Undo( SwUndoIter& ) +void SwUndoRedline::UndoRedlineImpl(SwDoc &, SwPaM &) { } -// default ist Redlines entfernen -void SwUndoRedline::_Redo( SwUndoIter& rIter ) +// default: remove redlines +void SwUndoRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - rIter.GetDoc().DeleteRedline( *rIter.pAktPam, true, USHRT_MAX ); + rDoc.DeleteRedline(rPam, true, USHRT_MAX); } -/* */ +// SwUndoRedlineDelete /////////////////////////////////////////////////// SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId ) : SwUndoRedline( nUsrId = (nUsrId ? nUsrId : UNDO_DELETE), rRange ), @@ -178,15 +182,17 @@ SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId ) bCacheComment = false; } -void SwUndoRedlineDelete::_Undo( SwUndoIter& rIter ) +void SwUndoRedlineDelete::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - rIter.GetDoc().DeleteRedline( *rIter.pAktPam, true, USHRT_MAX ); + rDoc.DeleteRedline(rPam, true, USHRT_MAX); } -void SwUndoRedlineDelete::_Redo( SwUndoIter& rIter ) +void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - if( *rIter.pAktPam->GetPoint() != *rIter.pAktPam->GetMark() ) - rIter.GetDoc().AppendRedline( new SwRedline( *pRedlData, *rIter.pAktPam ), FALSE ); + if (rPam.GetPoint() != rPam.GetMark()) + { + rDoc.AppendRedline( new SwRedline(*pRedlData, rPam), FALSE ); + } } BOOL SwUndoRedlineDelete::CanGrouping( const SwUndoRedlineDelete& rNext ) @@ -238,14 +244,13 @@ SwUndoRedlineSort::~SwUndoRedlineSort() delete pOpt; } -void SwUndoRedlineSort::_Undo( SwUndoIter& rIter ) +void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - // im rIter.pAktPam ist der sortiete Bereich, - // im aSaveRange steht der kopierte, sprich der originale. - SwDoc& rDoc = rIter.GetDoc(); + // rPam contains the sorted range + // aSaveRange contains copied (i.e. original) range - SwPosition* pStart = rIter.pAktPam->Start(); - SwPosition* pEnd = rIter.pAktPam->End(); + SwPosition *const pStart = rPam.Start(); + SwPosition *const pEnd = rPam.End(); SwNodeIndex aPrevIdx( pStart->nNode, -1 ); ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); @@ -266,7 +271,7 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter ) } { - SwPaM aTmp( *rIter.pAktPam->GetMark() ); + SwPaM aTmp( *rPam.GetMark() ); aTmp.GetMark()->nContent = 0; aTmp.SetMark(); aTmp.GetPoint()->nNode = nSaveEndNode; @@ -274,9 +279,9 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter ) rDoc.DeleteRedline( aTmp, true, USHRT_MAX ); } - rDoc.DelFullPara( *rIter.pAktPam ); + rDoc.DelFullPara(rPam); - SwPaM* pPam = rIter.pAktPam; + SwPaM *const pPam = & rPam; pPam->DeleteMark(); pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); SwCntntNode* pCNd = pPam->GetCntntNode(); @@ -289,13 +294,11 @@ void SwUndoRedlineSort::_Undo( SwUndoIter& rIter ) SetValues( *pPam ); - SetPaM( *rIter.pAktPam ); + SetPaM(rPam); } -void SwUndoRedlineSort::_Redo( SwUndoIter& rIter ) +void SwUndoRedlineSort::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - SwPaM& rPam = *rIter.pAktPam; - SwPaM* pPam = &rPam; SwPosition* pStart = pPam->Start(); SwPosition* pEnd = pPam->End(); @@ -304,7 +307,7 @@ void SwUndoRedlineSort::_Redo( SwUndoIter& rIter ) ULONG nOffsetTemp = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex(); xub_StrLen nCntStt = pStart->nContent.GetIndex(); - rIter.GetDoc().SortText( rPam, *pOpt ); + rDoc.SortText(rPam, *pOpt); pPam->DeleteMark(); pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 ); @@ -326,9 +329,9 @@ void SwUndoRedlineSort::_Redo( SwUndoIter& rIter ) rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nSaveEndCntnt ); } -void SwUndoRedlineSort::Repeat( SwUndoIter& rIter ) +void SwUndoRedlineSort::RepeatImpl(::sw::RepeatContext & rContext) { - rIter.GetDoc().SortText( *rIter.pAktPam, *pOpt ); + rContext.GetDoc().SortText( rContext.GetRepeatPaM(), *pOpt ); } void SwUndoRedlineSort::SetSaveRange( const SwPaM& rRange ) @@ -343,21 +346,21 @@ void SwUndoRedlineSort::SetOffset( const SwNodeIndex& rIdx ) nOffset = rIdx.GetIndex() - nSttNode; } -/* */ +// SwUndoAcceptRedline /////////////////////////////////////////////////// SwUndoAcceptRedline::SwUndoAcceptRedline( const SwPaM& rRange ) : SwUndoRedline( UNDO_ACCEPT_REDLINE, rRange ) { } -void SwUndoAcceptRedline::_Redo( SwUndoIter& rIter ) +void SwUndoAcceptRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - rIter.GetDoc().AcceptRedline( *rIter.pAktPam, false ); + rDoc.AcceptRedline(rPam, false); } -void SwUndoAcceptRedline::Repeat( SwUndoIter& rIter ) +void SwUndoAcceptRedline::RepeatImpl(::sw::RepeatContext & rContext) { - rIter.GetDoc().AcceptRedline( *rIter.pAktPam, true ); + rContext.GetDoc().AcceptRedline(rContext.GetRepeatPaM(), true); } SwUndoRejectRedline::SwUndoRejectRedline( const SwPaM& rRange ) @@ -365,17 +368,17 @@ SwUndoRejectRedline::SwUndoRejectRedline( const SwPaM& rRange ) { } -void SwUndoRejectRedline::_Redo( SwUndoIter& rIter ) +void SwUndoRejectRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) { - rIter.GetDoc().RejectRedline( *rIter.pAktPam, false ); + rDoc.RejectRedline(rPam, false); } -void SwUndoRejectRedline::Repeat( SwUndoIter& rIter ) +void SwUndoRejectRedline::RepeatImpl(::sw::RepeatContext & rContext) { - rIter.GetDoc().RejectRedline( *rIter.pAktPam, true ); + rContext.GetDoc().RejectRedline(rContext.GetRepeatPaM(), true); } -/* */ +// SwUndoCompDoc ///////////////////////////////////////////////////////// SwUndoCompDoc::SwUndoCompDoc( const SwPaM& rRg, BOOL bIns ) : SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRg ), pRedlData( 0 ), @@ -416,12 +419,10 @@ SwUndoCompDoc::~SwUndoCompDoc() delete pRedlSaveData; } -void SwUndoCompDoc::Undo( SwUndoIter& rIter ) +void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); - - SetPaM( *pPam ); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam( & AddUndoRedoPaM(rContext) ); if( !bInsert ) { @@ -481,22 +482,17 @@ void SwUndoCompDoc::Undo( SwUndoIter& rIter ) if( pRedlSaveData ) SetSaveData( *pDoc, *pRedlSaveData ); } - SetPaM( rIter, TRUE ); + SetPaM(*pPam, true); } } -void SwUndoCompDoc::Redo( SwUndoIter& rIter ) +void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext) { - // setze noch den Cursor auf den Redo-Bereich - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); - - rIter.pLastUndoObj = 0; + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam( & AddUndoRedoPaM(rContext) ); if( bInsert ) { - SetPaM( *pPam ); - if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) { SwRedline* pTmp = new SwRedline( *pRedlData, *pPam ); @@ -521,10 +517,10 @@ void SwUndoCompDoc::Redo( SwUndoIter& rIter ) if( pUnDel2 ) { - pUnDel2->Undo( rIter ); + pUnDel2->UndoImpl(rContext); delete pUnDel2, pUnDel2 = 0; } - pUnDel->Undo( rIter ); + pUnDel->UndoImpl(rContext); delete pUnDel, pUnDel = 0; SetPaM( *pPam ); @@ -537,7 +533,6 @@ void SwUndoCompDoc::Redo( SwUndoIter& rIter ) // pDoc->SetRedlineMode_intern( eOld ); } - SetPaM( rIter, TRUE ); + SetPaM(*pPam, true); } - diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index 98d0e41d4616..80e918670f7a 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoSection.hxx> #include <sfx2/linkmgr.hxx> #include <fmtcntnt.hxx> @@ -36,7 +37,7 @@ #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <section.hxx> #include <rolbck.hxx> #include <redline.hxx> @@ -48,8 +49,6 @@ #include <calc.hxx> -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } - SfxItemSet* lcl_GetAttrSet( const SwSection& rSect ) { // Attribute des Formate sichern (Spalten, Farbe, ... ) @@ -122,9 +121,9 @@ SwUndoInsSection::~SwUndoInsSection() { } -void SwUndoInsSection::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsSection::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); RemoveIdxFromSection( rDoc, m_nSectionNodePos ); @@ -167,25 +166,23 @@ void SwUndoInsSection::Undo( SwUndoIter& rUndoIter ) rDoc.GetFtnIdxs().UpdateFtn( aIdx ); } - SetPaM( rUndoIter ); + AddUndoRedoPaM(rContext); } - -void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - SetPaM( rUndoIter ); + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); const SwTOXBaseSection* pUpdateTOX = 0; if (m_pTOXBase.get()) { - pUpdateTOX = rDoc.InsertTableOf( *rUndoIter.pAktPam->GetPoint(), + pUpdateTOX = rDoc.InsertTableOf( *rPam.GetPoint(), *m_pTOXBase, m_pAttrSet.get(), true); } else { - rDoc.InsertSwSection(*rUndoIter.pAktPam, - *m_pSectionData, 0, m_pAttrSet.get(), true); + rDoc.InsertSwSection(rPam, *m_pSectionData, 0, m_pAttrSet.get(), true); } if (m_pHistory.get()) @@ -224,22 +221,21 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) } } - -void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInsSection::RepeatImpl(::sw::RepeatContext & rContext) { + SwDoc & rDoc = rContext.GetDoc(); if (m_pTOXBase.get()) { - rUndoIter.GetDoc().InsertTableOf( *rUndoIter.pAktPam->GetPoint(), + rDoc.InsertTableOf(*rContext.GetRepeatPaM().GetPoint(), *m_pTOXBase, m_pAttrSet.get(), true); } else { - rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam, + rDoc.InsertSwSection(rContext.GetRepeatPaM(), *m_pSectionData, 0, m_pAttrSet.get()); } } - void SwUndoInsSection::Join( SwDoc& rDoc, ULONG nNode ) { SwNodeIndex aIdx( rDoc.GetNodes(), nNode ); @@ -300,9 +296,11 @@ private: public: SwUndoDelSection( SwSectionFmt const&, SwSection const&, SwNodeIndex const*const); + virtual ~SwUndoDelSection(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); }; SW_DLLPRIVATE SwUndo * MakeUndoDelSection(SwSectionFmt const& rFormat) @@ -330,9 +328,9 @@ SwUndoDelSection::~SwUndoDelSection() { } -void SwUndoDelSection::Undo( SwUndoIter& rUndoIter ) +void SwUndoDelSection::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if (m_pTOXBase.get()) { @@ -383,13 +381,13 @@ void SwUndoDelSection::Undo( SwUndoIter& rUndoIter ) } } -void SwUndoDelSection::Redo( SwUndoIter& rUndoIter ) +void SwUndoDelSection::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwSectionNode *const pNd = rDoc.GetNodes()[ m_nStartNode ]->GetSectionNode(); - ASSERT( pNd, "wo ist mein SectionNode?" ); + OSL_ENSURE(pNd, "SwUndoDelSection::RedoImpl(): no SectionNode?"); // einfach das Format loeschen, der Rest erfolgt automatisch rDoc.DelSectionFmt( pNd->GetSection().GetFmt() ); } @@ -409,9 +407,11 @@ private: public: SwUndoUpdateSection( SwSection const&, SwNodeIndex const*const, bool const bOnlyAttr); + virtual ~SwUndoUpdateSection(); - virtual void Undo( SwUndoIter& ); - virtual void Redo( SwUndoIter& ); + + virtual void UndoImpl( ::sw::UndoRedoContext & ); + virtual void RedoImpl( ::sw::UndoRedoContext & ); }; SW_DLLPRIVATE SwUndo * @@ -436,9 +436,9 @@ SwUndoUpdateSection::~SwUndoUpdateSection() { } -void SwUndoUpdateSection::Undo( SwUndoIter& rUndoIter ) +void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwSectionNode *const pSectNd = rDoc.GetNodes()[ m_nStartNode ]->GetSectionNode(); ASSERT( pSectNd, "wo ist mein SectionNode?" ); @@ -492,8 +492,8 @@ void SwUndoUpdateSection::Undo( SwUndoIter& rUndoIter ) } } -void SwUndoUpdateSection::Redo( SwUndoIter& rUndoIter ) +void SwUndoUpdateSection::RedoImpl(::sw::UndoRedoContext & rContext) { - Undo( rUndoIter ); + UndoImpl(rContext); } diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx index 44b73736e458..d786a7c06e9e 100644 --- a/sw/source/core/undo/unsort.cxx +++ b/sw/source/core/undo/unsort.cxx @@ -27,20 +27,21 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + +#include <UndoSort.hxx> + #include <doc.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <swtable.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> +#include <UndoTable.hxx> #include <sortopt.hxx> -#ifndef _DOCSORT_HXX #include <docsort.hxx> -#endif #include <redline.hxx> #include <node2lay.hxx> -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } /*-------------------------------------------------------------------- Beschreibung: Undo fuers Sorting @@ -69,7 +70,6 @@ SwUndoSort::SwUndoSort(const SwPaM& rRg, const SwSortOptions& rOpt) pSortOpt = new SwSortOptions(rOpt); } - SwUndoSort::SwUndoSort( ULONG nStt, ULONG nEnd, const SwTableNode& rTblNd, const SwSortOptions& rOpt, BOOL bSaveTable ) : SwUndo(UNDO_SORT_TBL), pUndoTblAttr( 0 ), pRedlData( 0 ) @@ -83,8 +83,6 @@ SwUndoSort::SwUndoSort( ULONG nStt, ULONG nEnd, const SwTableNode& rTblNd, pUndoTblAttr = new SwUndoAttrTbl( rTblNd ); } - - SwUndoSort::~SwUndoSort() { delete pSortOpt; @@ -92,18 +90,18 @@ SwUndoSort::~SwUndoSort() delete pRedlData; } - - -void SwUndoSort::Undo( SwUndoIter& rIter) +void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if(pSortOpt->bTable) { // Undo Tabelle RemoveIdxFromSection( rDoc, nSttNode, &nEndNode ); if( pUndoTblAttr ) - pUndoTblAttr->Undo( rIter ); + { + pUndoTblAttr->UndoImpl(rContext); + } SwTableNode* pTblNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode(); @@ -141,7 +139,8 @@ void SwUndoSort::Undo( SwUndoIter& rIter) else { // Undo Text - RemoveIdx( *rIter.pAktPam ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + RemoveIdxFromRange(rPam, true); // fuer die sorted Positions einen Index anlegen. // JP 25.11.97: Die IndexList muss aber nach SourcePosition @@ -168,14 +167,13 @@ void SwUndoSort::Undo( SwUndoIter& rIter) } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); - SetPaM( rIter, TRUE ); + SetPaM(rPam, true); } } - -void SwUndoSort::Redo( SwUndoIter& rIter) +void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); if(pSortOpt->bTable) { @@ -208,7 +206,9 @@ void SwUndoSort::Redo( SwUndoIter& rIter) } if( pUndoTblAttr ) - pUndoTblAttr->Redo( rIter ); + { + pUndoTblAttr->RedoImpl(rContext); + } // Restore table frames: // --> FME 2004-11-26 #i37739# A simple 'MakeFrms' after the node sorting @@ -219,8 +219,10 @@ void SwUndoSort::Redo( SwUndoIter& rIter) } else { - // Redo bei Text - RemoveIdx( *rIter.pAktPam ); + // Redo for Text + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + SetPaM(rPam); + RemoveIdxFromRange(rPam, true); SwUndoSortList aIdxList( (BYTE)aSortList.Count() ); USHORT i; @@ -241,62 +243,37 @@ void SwUndoSort::Redo( SwUndoIter& rIter) } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); - SetPaM( rIter, TRUE ); - const SwTxtNode* pTNd = rIter.pAktPam->GetNode()->GetTxtNode(); + SetPaM(rPam, true); + SwTxtNode const*const pTNd = rPam.GetNode()->GetTxtNode(); if( pTNd ) - rIter.pAktPam->GetPoint()->nContent = pTNd->GetTxt().Len(); + { + rPam.GetPoint()->nContent = pTNd->GetTxt().Len(); + } } } - -void SwUndoSort::Repeat(SwUndoIter& rIter) +void SwUndoSort::RepeatImpl(::sw::RepeatContext & rContext) { + // table not repeat capable if(!pSortOpt->bTable) { - SwPaM* pPam = rIter.pAktPam; + SwPaM *const pPam = & rContext.GetRepeatPaM(); SwDoc& rDoc = *pPam->GetDoc(); if( !rDoc.IsIdxInTbl( pPam->Start()->nNode ) ) rDoc.SortText(*pPam, *pSortOpt); } - // Tabelle ist nicht Repeat-Faehig - rIter.pLastUndoObj = this; } - -void SwUndoSort::RemoveIdx( SwPaM& rPam ) -{ - rPam.DeleteMark(); - rPam.GetPoint()->nNode = nSttNode; - - SwCntntNode* pCNd = rPam.GetCntntNode(); - xub_StrLen nLen = pCNd->Len(); - if( nLen >= nSttCntnt ) - nLen = nSttCntnt; - rPam.GetPoint()->nContent.Assign(pCNd, nLen ); - rPam.SetMark(); - - rPam.GetPoint()->nNode = nEndNode; - pCNd = rPam.GetCntntNode(); - nLen = pCNd->Len(); - if( nLen >= nEndCntnt ) - nLen = nEndCntnt; - rPam.GetPoint()->nContent.Assign(pCNd, nLen ); - RemoveIdxFromRange( rPam, TRUE ); -} - - void SwUndoSort::Insert( const String& rOrgPos, const String& rNewPos) { SwSortUndoElement* pEle = new SwSortUndoElement(rOrgPos, rNewPos); aSortList.C40_INSERT( SwSortUndoElement, pEle, aSortList.Count() ); } - void SwUndoSort::Insert( ULONG nOrgPos, ULONG nNewPos) { SwSortUndoElement* pEle = new SwSortUndoElement(nOrgPos, nNewPos); aSortList.C40_INSERT( SwSortUndoElement, pEle, aSortList.Count() ); } - diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx index 14aa18ed6e07..a96e860dfe04 100644 --- a/sw/source/core/undo/unspnd.cxx +++ b/sw/source/core/undo/unspnd.cxx @@ -28,6 +28,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoSplitMove.hxx> #include "doc.hxx" #include "pam.hxx" @@ -37,13 +38,11 @@ #include <editeng/brkitem.hxx> #include <fmtpdsc.hxx> #include <frmfmt.hxx> -#include "undobj.hxx" +#include <UndoCore.hxx> #include "rolbck.hxx" #include "redline.hxx" #include "docary.hxx" - - -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } +#include <IShellCursorSupplier.hxx> //------------------------------------------------------------------ @@ -57,8 +56,8 @@ SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, nCntnt( rPos.nContent.GetIndex() ), bTblFlag( FALSE ), bChkTblStt( bChkTable ) { - SwTxtNode* pTxtNd = pDoc->GetNodes()[ rPos.nNode ]->GetTxtNode(); - ASSERT( pTxtNd, "nur beim TextNode rufen!" ); + SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode(); + OSL_ENSURE(pTxtNd, "SwUndoSplitNode: TextNode expected!"); if( pTxtNd->GetpSwpHints() ) { pHistory = new SwHistory; @@ -75,21 +74,16 @@ SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos, } } - - - SwUndoSplitNode::~SwUndoSplitNode() { delete pHistory; delete pRedlData; } - - -void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter ) +void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc* pDoc = &rUndoIter.GetDoc(); - SwPaM& rPam = *rUndoIter.pAktPam; + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() ); rPam.DeleteMark(); if( bTblFlag ) { @@ -163,23 +157,13 @@ void SwUndoSplitNode::Undo( SwUndoIter& rUndoIter ) rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), nCntnt ); } - -void SwUndoSplitNode::Repeat( SwUndoIter& rUndoIter ) -{ - if( UNDO_SPLITNODE == rUndoIter.GetLastUndoId() ) - return; - rUndoIter.GetDoc().SplitNode( *rUndoIter.pAktPam->GetPoint(), bChkTblStt ); - rUndoIter.pLastUndoObj = this; -} - - -void SwUndoSplitNode::Redo( SwUndoIter& rUndoIter ) +void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM& rPam = *rUndoIter.pAktPam; - ULONG nOldNode = rPam.GetPoint()->nNode.GetIndex(); + SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() ); rPam.GetPoint()->nNode = nNode; SwTxtNode * pTNd = rPam.GetNode()->GetTxtNode(); - if( pTNd ) // sollte eigentlich immer ein TextNode sein !! + OSL_ENSURE(pTNd, "SwUndoSplitNode::RedoImpl(): SwTxtNode expected"); + if (pTNd) { rPam.GetPoint()->nContent.Assign( pTNd, nCntnt ); @@ -210,7 +194,11 @@ void SwUndoSplitNode::Redo( SwUndoIter& rUndoIter ) rPam.DeleteMark(); } } - else - rPam.GetPoint()->nNode = nOldNode; +} + +void SwUndoSplitNode::RepeatImpl(::sw::RepeatContext & rContext) +{ + rContext.GetDoc().SplitNode( + *rContext.GetRepeatPaM().GetPoint(), bChkTblStt ); } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 9a654170187a..929fa647b455 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -28,12 +28,19 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <UndoTable.hxx> +#include <UndoRedline.hxx> +#include <UndoDelete.hxx> +#include <UndoSplitMove.hxx> +#include <UndoCore.hxx> #include <hintids.hxx> +#include <hints.hxx> #include <editeng/brkitem.hxx> #include <fmtornt.hxx> #include <fmtpdsc.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <editsh.hxx> #include <docary.hxx> #include <ndtxt.hxx> @@ -42,7 +49,6 @@ #include <cntfrm.hxx> #include <tblsel.hxx> #include <swundo.hxx> // fuer die UndoIds -#include <undobj.hxx> #include <rolbck.hxx> #include <ddefld.hxx> #include <tabcol.hxx> @@ -80,7 +86,6 @@ #define _DEBUG_REDLINE( pDoc ) lcl_DebugRedline( pDoc ); #endif -inline SwDoc& SwUndoIter::GetDoc() const { return *pAktPam->GetDoc(); } extern void ClearFEShellTabCols(); typedef SfxItemSet* SfxItemSetPtr; @@ -275,9 +280,9 @@ SwUndoInsTbl::~SwUndoInsTbl() delete pAutoFmt; } -void SwUndoInsTbl::Undo( SwUndoIter& rUndoIter ) +void SwUndoInsTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode ); SwTableNode* pTblNd = aIdx.GetNode().GetTableNode(); @@ -313,19 +318,18 @@ void SwUndoInsTbl::Undo( SwUndoIter& rUndoIter ) rDoc.GetNodes().Delete( aIdx, pTblNd->EndOfSectionIndex() - aIdx.GetIndex() + 1 ); - rUndoIter.pAktPam->DeleteMark(); - rUndoIter.pAktPam->GetPoint()->nNode = aIdx; - rUndoIter.pAktPam->GetPoint()->nContent.Assign( - rUndoIter.pAktPam->GetCntntNode(), 0 ); + SwPaM & rPam( rContext.GetCursorSupplier().CreateNewShellCursor() ); + rPam.DeleteMark(); + rPam.GetPoint()->nNode = aIdx; + rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 ); } -void SwUndoInsTbl::Redo( SwUndoIter& rUndoIter ) +void SwUndoInsTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); - SwPosition aPos( *rUndoIter.pAktPam->GetPoint() ); - aPos.nNode = nSttNode; + SwPosition const aPos(SwNodeIndex(rDoc.GetNodes(), nSttNode)); const SwTable* pTbl = rDoc.InsertTable( aInsTblOpts, aPos, nRows, nCols, nAdjust, pAutoFmt, pColWidth ); @@ -364,11 +368,11 @@ void SwUndoInsTbl::Redo( SwUndoIter& rUndoIter ) } -void SwUndoInsTbl::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInsTbl::RepeatImpl(::sw::RepeatContext & rContext) { - rUndoIter.GetDoc().InsertTable( aInsTblOpts, *rUndoIter.pAktPam->GetPoint(), - nRows, nCols, nAdjust, - pAutoFmt, pColWidth ); + rContext.GetDoc().InsertTable( + aInsTblOpts, *rContext.GetRepeatPaM().GetPoint(), + nRows, nCols, nAdjust, pAutoFmt, pColWidth ); } SwRewriter SwUndoInsTbl::GetRewriter() const @@ -473,10 +477,10 @@ SwUndoTblToTxt::~SwUndoTblToTxt() -void SwUndoTblToTxt::Undo( SwUndoIter& rUndoIter ) +void SwUndoTblToTxt::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - SwPaM* pPam = rUndoIter.pAktPam; + SwDoc & rDoc = rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); SwNodeIndex aFrmIdx( rDoc.GetNodes(), nSttNd ); SwNodeIndex aEndIdx( rDoc.GetNodes(), nEndNd ); @@ -653,11 +657,10 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, } -void SwUndoTblToTxt::Redo( SwUndoIter& rUndoIter ) +void SwUndoTblToTxt::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); - SwPaM* pPam = rUndoIter.pAktPam; - + SwDoc & rDoc = rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->GetPoint()->nNode = nSttNd; pPam->GetPoint()->nContent.Assign( 0, 0 ); @@ -691,19 +694,19 @@ void SwUndoTblToTxt::Redo( SwUndoIter& rUndoIter ) } -void SwUndoTblToTxt::Repeat( SwUndoIter& rUndoIter ) +void SwUndoTblToTxt::RepeatImpl(::sw::RepeatContext & rContext) { - SwTableNode* pTblNd = rUndoIter.pAktPam->GetNode()->FindTableNode(); + SwPaM *const pPam = & rContext.GetRepeatPaM(); + SwTableNode *const pTblNd = pPam->GetNode()->FindTableNode(); if( pTblNd ) { - // bewege den Cursor aus der Tabelle - SwPaM* pPam = rUndoIter.pAktPam; + // move cursor out of table pPam->GetPoint()->nNode = *pTblNd->EndOfSectionNode(); pPam->Move( fnMoveForward, fnGoCntnt ); pPam->SetMark(); pPam->DeleteMark(); - rUndoIter.GetDoc().TableToText( pTblNd, cTrenner ); + rContext.GetDoc().TableToText( pTblNd, cTrenner ); } } @@ -745,16 +748,16 @@ SwUndoTxtToTbl::~SwUndoTxtToTbl() delete pAutoFmt; } -void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter ) +void SwUndoTxtToTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); ULONG nTblNd = nSttNode; if( nSttCntnt ) ++nTblNd; // Node wurde vorher gesplittet SwNodeIndex aIdx( rDoc.GetNodes(), nTblNd ); - SwTableNode* pTNd = rDoc.GetNodes()[ aIdx ]->GetTableNode(); - ASSERT( pTNd, "keinen Tabellen-Node gefunden" ); + SwTableNode *const pTNd = aIdx.GetNode().GetTableNode(); + OSL_ENSURE( pTNd, "SwUndoTxtToTbl: no TableNode" ); RemoveIdxFromSection( rDoc, nTblNd ); @@ -783,15 +786,16 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter ) SwNodeIndex aEndIdx( *pTNd->EndOfSectionNode() ); rDoc.TableToText( pTNd, 0x0b == cTrenner ? 0x09 : cTrenner ); - // am Start wieder zusammenfuegen ? - SwPosition* pPos = rUndoIter.pAktPam->GetPoint(); + // join again at start? + SwPaM aPam(rDoc.GetNodes().GetEndOfContent()); + SwPosition *const pPos = aPam.GetPoint(); if( nSttCntnt ) { pPos->nNode = nTblNd; - pPos->nContent.Assign( rDoc.GetNodes()[ pPos->nNode ]->GetCntntNode(), 0 ); - if( rUndoIter.pAktPam->Move( fnMoveBackward, fnGoCntnt)) + pPos->nContent.Assign(pPos->nNode.GetNode().GetCntntNode(), 0); + if (aPam.Move(fnMoveBackward, fnGoCntnt)) { - SwNodeIndex& rIdx = rUndoIter.pAktPam->GetPoint()->nNode; + SwNodeIndex & rIdx = aPam.GetPoint()->nNode; // dann die Crsr/etc. nochmal relativ verschieben RemoveIdxRel( rIdx.GetIndex()+1, *pPos ); @@ -800,7 +804,7 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter ) } } - // am Ende wieder zusammenfuegen ? + // join again at end? if( bSplitEnd ) { SwNodeIndex& rIdx = pPos->nNode; @@ -808,8 +812,8 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter ) SwTxtNode* pTxtNd = rIdx.GetNode().GetTxtNode(); if( pTxtNd && pTxtNd->CanJoinNext() ) { - rUndoIter.pAktPam->GetMark()->nContent.Assign( 0, 0 ); - rUndoIter.pAktPam->GetPoint()->nContent.Assign( 0, 0 ); + aPam.GetMark()->nContent.Assign( 0, 0 ); + aPam.GetPoint()->nContent.Assign( 0, 0 ); // dann die Crsr/etc. nochmal relativ verschieben pPos->nContent.Assign( pTxtNd, pTxtNd->GetTxt().Len() ); @@ -819,30 +823,31 @@ void SwUndoTxtToTbl::Undo( SwUndoIter& rUndoIter ) } } - SetPaM( rUndoIter ); // manipulierten Bereich selectieren + AddUndoRedoPaM(rContext); } -void SwUndoTxtToTbl::Redo( SwUndoIter& rUndoIter ) +void SwUndoTxtToTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - SetPaM( rUndoIter ); - RemoveIdxFromRange( *rUndoIter.pAktPam, FALSE ); - SetPaM( rUndoIter ); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + RemoveIdxFromRange(rPam, false); + SetPaM(rPam); - const SwTable* pTable = rUndoIter.GetDoc().TextToTable( - aInsTblOpts, *rUndoIter.pAktPam, cTrenner, - nAdjust, pAutoFmt ); + SwTable const*const pTable = rContext.GetDoc().TextToTable( + aInsTblOpts, rPam, cTrenner, nAdjust, pAutoFmt ); ((SwFrmFmt*)pTable->GetFrmFmt())->SetName( sTblNm ); } -void SwUndoTxtToTbl::Repeat( SwUndoIter& rUndoIter ) +void SwUndoTxtToTbl::RepeatImpl(::sw::RepeatContext & rContext) { - // keine TABLE IN TABLE - if( !rUndoIter.pAktPam->GetNode()->FindTableNode() ) - rUndoIter.GetDoc().TextToTable( aInsTblOpts, *rUndoIter.pAktPam, + // no Table In Table + if (!rContext.GetRepeatPaM().GetNode()->FindTableNode()) + { + rContext.GetDoc().TextToTable( aInsTblOpts, rContext.GetRepeatPaM(), cTrenner, nAdjust, pAutoFmt ); + } } void SwUndoTxtToTbl::AddFillBox( const SwTableBox& rBox ) @@ -874,20 +879,18 @@ SwUndoTblHeadline::SwUndoTblHeadline( const SwTable& rTbl, USHORT nOldHdl, nTblNd = pSttNd->StartOfSectionIndex(); } - -void SwUndoTblHeadline::Undo( SwUndoIter& rUndoIter ) +void SwUndoTblHeadline::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode(); ASSERT( pTNd, "keinen Tabellen-Node gefunden" ); rDoc.SetRowsToRepeat( pTNd->GetTable(), nOldHeadline ); } - -void SwUndoTblHeadline::Redo( SwUndoIter& rUndoIter ) +void SwUndoTblHeadline::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTNd = rDoc.GetNodes()[ nTblNd ]->GetTableNode(); ASSERT( pTNd, "keinen Tabellen-Node gefunden" ); @@ -895,17 +898,18 @@ void SwUndoTblHeadline::Redo( SwUndoIter& rUndoIter ) rDoc.SetRowsToRepeat( pTNd->GetTable(), nNewHeadline ); } - -void SwUndoTblHeadline::Repeat( SwUndoIter& rUndoIter ) +void SwUndoTblHeadline::RepeatImpl(::sw::RepeatContext & rContext) { - SwTableNode* pTblNd = rUndoIter.pAktPam->GetNode()->FindTableNode(); + SwTableNode *const pTblNd = + rContext.GetRepeatPaM().GetNode()->FindTableNode(); if( pTblNd ) - rUndoIter.GetDoc().SetRowsToRepeat( pTblNd->GetTable(), nNewHeadline ); + { + rContext.GetDoc().SetRowsToRepeat( pTblNd->GetTable(), nNewHeadline ); + } } -/* */ - +////////////////////////////////////////////////////////////////////////// _SaveTable::_SaveTable( const SwTable& rTbl, USHORT nLnCnt, BOOL bSaveFml ) @@ -1424,7 +1428,7 @@ void _SaveBox::CreateNew( SwTable& rTbl, SwTableLine& rParent, _SaveTable& rSTbl } -/* */ +////////////////////////////////////////////////////////////////////////// // UndoObject fuer Attribut Aenderung an der Tabelle @@ -1437,17 +1441,14 @@ SwUndoAttrTbl::SwUndoAttrTbl( const SwTableNode& rTblNd, BOOL bClearTabCols ) pSaveTbl = new _SaveTable( rTblNd.GetTable() ); } - SwUndoAttrTbl::~SwUndoAttrTbl() { delete pSaveTbl; } - - -void SwUndoAttrTbl::Undo( SwUndoIter& rUndoIter ) +void SwUndoAttrTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode(); ASSERT( pTblNd, "kein TabellenNode" ); @@ -1463,14 +1464,13 @@ void SwUndoAttrTbl::Undo( SwUndoIter& rUndoIter ) ClearFEShellTabCols(); } - -void SwUndoAttrTbl::Redo( SwUndoIter& rUndoIter ) +void SwUndoAttrTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - Undo( rUndoIter ); + UndoImpl(rContext); } -/* */ +////////////////////////////////////////////////////////////////////////// // UndoObject fuer AutoFormat an der Tabelle @@ -1478,7 +1478,7 @@ void SwUndoAttrTbl::Redo( SwUndoIter& rUndoIter ) SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd, const SwTableAutoFmt& rAFmt ) : SwUndo( UNDO_TABLE_AUTOFMT ), - nSttNode( rTblNd.GetIndex() ), pUndos( 0 ), + nSttNode( rTblNd.GetIndex() ), bSaveCntntAttr( FALSE ) { pSaveTbl = new _SaveTable( rTblNd.GetTable() ); @@ -1492,25 +1492,22 @@ SwUndoTblAutoFmt::SwUndoTblAutoFmt( const SwTableNode& rTblNd, } } - SwUndoTblAutoFmt::~SwUndoTblAutoFmt() { - delete pUndos; delete pSaveTbl; } void SwUndoTblAutoFmt::SaveBoxCntnt( const SwTableBox& rBox ) { - SwUndoTblNumFmt* p = new SwUndoTblNumFmt( rBox ); - if( !pUndos ) - pUndos = new SwUndos( 8, 8 ); - pUndos->Insert( p, pUndos->Count() ); + ::boost::shared_ptr<SwUndoTblNumFmt> const p(new SwUndoTblNumFmt(rBox)); + m_Undos.push_back(p); } -void SwUndoTblAutoFmt::UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter ) +void +SwUndoTblAutoFmt::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode(); ASSERT( pTblNd, "kein TabellenNode" ); @@ -1520,29 +1517,31 @@ void SwUndoTblAutoFmt::UndoRedo( BOOL bUndo, SwUndoIter& rUndoIter ) if( bSaveCntntAttr ) pOrig->SaveCntntAttrs( &rDoc ); - if( pUndos && bUndo ) - for( USHORT n = pUndos->Count(); n; ) - pUndos->GetObject( --n )->Undo( rUndoIter ); + if (bUndo) + { + for (size_t n = m_Undos.size(); 0 < n; --n) + { + m_Undos.at(n-1)->UndoImpl(rContext); + } + } pSaveTbl->RestoreAttr( pTblNd->GetTable(), !bUndo ); delete pSaveTbl; pSaveTbl = pOrig; } -void SwUndoTblAutoFmt::Undo( SwUndoIter& rUndoIter ) +void SwUndoTblAutoFmt::UndoImpl(::sw::UndoRedoContext & rContext) { - UndoRedo( TRUE, rUndoIter ); + UndoRedo(true, rContext); } - -void SwUndoTblAutoFmt::Redo( SwUndoIter& rUndoIter ) +void SwUndoTblAutoFmt::RedoImpl(::sw::UndoRedoContext & rContext) { - UndoRedo( FALSE, rUndoIter ); + UndoRedo(false, rContext); } -/* */ - +////////////////////////////////////////////////////////////////////////// SwUndoTblNdsChg::SwUndoTblNdsChg( SwUndoId nAction, const SwSelBoxes& rBoxes, @@ -1766,13 +1765,13 @@ void SwUndoTblNdsChg::SaveSection( SwStartNode* pSttNd ) } -void SwUndoTblNdsChg::Undo( SwUndoIter& rUndoIter ) +void SwUndoTblNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode ); - SwTableNode* pTblNd = rDoc.GetNodes()[ aIdx ]->GetTableNode(); - ASSERT( pTblNd, "kein TabellenNode" ); + SwTableNode *const pTblNd = aIdx.GetNode().GetTableNode(); + OSL_ENSURE( pTblNd, "SwUndoTblNdsChg: no TableNode" ); SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() ); aMsgHnt.eFlags = TBL_BOXPTR; @@ -1885,9 +1884,9 @@ void SwUndoTblNdsChg::Undo( SwUndoIter& rUndoIter ) } -void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter ) +void SwUndoTblNdsChg::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTblNd = rDoc.GetNodes()[ nSttNode ]->GetTableNode(); ASSERT( pTblNd, "kein TabellenNode" ); @@ -1956,7 +1955,8 @@ void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter ) TblChgMode eOldMode = rTbl.GetTblChgMode(); rTbl.SetTblChgMode( (TblChgMode)nCount ); - rDoc.DoUndo( TRUE ); // wir brauchen die SaveSections! + // need the SaveSections! + rDoc.GetIDocumentUndoRedo().DoUndo( true ); SwUndoTblNdsChg* pUndo = 0; switch( nSetColType & 0xff ) @@ -1984,7 +1984,7 @@ void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter ) delete pUndo; } - rDoc.DoUndo( FALSE ); + rDoc.GetIDocumentUndoRedo().DoUndo( false ); rTbl.SetTblChgMode( eOldMode ); } @@ -1998,8 +1998,7 @@ void SwUndoTblNdsChg::Redo( SwUndoIter& rUndoIter ) } -/* */ - +////////////////////////////////////////////////////////////////////////// SwUndoTblMerge::SwUndoTblMerge( const SwPaM& rTblSel ) : SwUndo( UNDO_TABLE_MERGE ), SwUndRng( rTblSel ), pHistory( 0 ) @@ -2011,7 +2010,6 @@ SwUndoTblMerge::SwUndoTblMerge( const SwPaM& rTblSel ) nTblNode = pTblNd->GetIndex(); } - SwUndoTblMerge::~SwUndoTblMerge() { delete pSaveTbl; @@ -2019,14 +2017,13 @@ SwUndoTblMerge::~SwUndoTblMerge() delete pHistory; } - -void SwUndoTblMerge::Undo( SwUndoIter& rUndoIter ) +void SwUndoTblMerge::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rUndoIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwNodeIndex aIdx( rDoc.GetNodes(), nTblNode ); - SwTableNode* pTblNd = rDoc.GetNodes()[ aIdx ]->GetTableNode(); - ASSERT( pTblNd, "kein TabellenNode" ); + SwTableNode *const pTblNd = aIdx.GetNode().GetTableNode(); + OSL_ENSURE( pTblNd, "SwUndoTblMerge: no TableNode" ); SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() ); aMsgHnt.eFlags = TBL_BOXPTR; @@ -2094,7 +2091,7 @@ CHECKTABLE(pTblNd->GetTable()) pTxtNd = rDoc.GetNodes()[ pUndo->GetDestSttNode() ]->GetTxtNode(); nDelPos = pUndo->GetDestSttCntnt() - 1; } - pUndo->Undo( rUndoIter ); + pUndo->UndoImpl(rContext); if( pUndo->IsMoveRange() ) { // den ueberfluessigen Node loeschen @@ -2167,7 +2164,7 @@ CHECKTABLE(pTblNd->GetTable()) } // nTblNode = pTblNd->GetIndex(); - SwPaM* pPam = rUndoIter.pAktPam; + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); pPam->GetPoint()->nNode = nSttNode; pPam->GetPoint()->nContent.Assign( pPam->GetCntntNode(), nSttCntnt ); @@ -2178,27 +2175,21 @@ CHECKTABLE(pTblNd->GetTable()) ClearFEShellTabCols(); } - -void SwUndoTblMerge::Redo( SwUndoIter& rUndoIter ) +void SwUndoTblMerge::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rUndoIter.pAktPam; - SwDoc& rDoc = *pPam->GetDoc(); - - SetPaM( *pPam ); - rDoc.MergeTbl( *pPam ); + SwDoc & rDoc = rContext.GetDoc(); + SwPaM & rPam( AddUndoRedoPaM(rContext) ); + rDoc.MergeTbl(rPam); } void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& rPos ) { SwNodeIndex aTmp( rRg.aStart, -1 ), aTmp2( rPos, -1 ); SwUndoMove* pUndo = new SwUndoMove( pDoc, rRg, rPos ); - sal_Bool bDoesUndo = pDoc->DoesUndo(); - pDoc->DoUndo( sal_False ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); pDoc->MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ? IDocumentContentOperations::DOC_NO_DELFRMS : IDocumentContentOperations::DOC_MOVEDEFAULT ); - if( bDoesUndo ) - pDoc->DoUndo( sal_True ); aTmp++; aTmp2++; pUndo->SetDestRange( aTmp2, rPos, aTmp ); @@ -2206,7 +2197,6 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r pMoves->Insert( pUndo, pMoves->Count() ); } - void SwUndoTblMerge::SetSelBoxes( const SwSelBoxes& rBoxes ) { // die Selektion merken @@ -2237,8 +2227,8 @@ void SwUndoTblMerge::SaveCollection( const SwTableBox& rBox ) pHistory->CopyFmtAttr( *pCNd->GetpSwAttrSet(), aIdx.GetIndex() ); } -/* */ +////////////////////////////////////////////////////////////////////////// SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox, const SfxItemSet* pNewSet ) @@ -2301,18 +2291,17 @@ SwUndoTblNumFmt::SwUndoTblNumFmt( const SwTableBox& rBox, DELETEZ( pHistory ); } - SwUndoTblNumFmt::~SwUndoTblNumFmt() { delete pHistory; delete pBoxSet; } -void SwUndoTblNumFmt::Undo( SwUndoIter& rIter ) +void SwUndoTblNumFmt::UndoImpl(::sw::UndoRedoContext & rContext) { ASSERT( pBoxSet, "Where's the stored item set?" ) - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwStartNode* pSttNd = rDoc.GetNodes()[ nNode ]-> FindSttNodeByType( SwTableBoxStartNode ); ASSERT( pSttNd, "ohne StartNode kein TabellenBox" ); @@ -2358,7 +2347,7 @@ void SwUndoTblNumFmt::Undo( SwUndoIter& rIter ) pHistory->SetTmpEnd( nTmpEnd ); } - SwPaM* pPam = rIter.pAktPam; + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); pPam->GetPoint()->nNode = nNode + 1; pPam->GetPoint()->nContent.Assign( pTxtNd, 0 ); @@ -2401,19 +2390,19 @@ RedlineModeInternGuard::~RedlineModeInternGuard() -void SwUndoTblNumFmt::Redo( SwUndoIter& rIter ) +void SwUndoTblNumFmt::RedoImpl(::sw::UndoRedoContext & rContext) { // konnte die Box veraendert werden ? if( !pBoxSet ) return ; - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); - SwPaM* pPam = rIter.pAktPam; pPam->DeleteMark(); pPam->GetPoint()->nNode = nNode; - SwNode* pNd = rDoc.GetNodes()[ pPam->GetPoint()->nNode ]; + SwNode * pNd = & pPam->GetPoint()->nNode.GetNode(); SwStartNode* pSttNd = pNd->FindSttNodeByType( SwTableBoxStartNode ); ASSERT( pSttNd, "ohne StartNode kein TabellenBox" ); SwTableBox* pBox = pSttNd->FindTableNode()->GetTable().GetTblBox( @@ -2501,7 +2490,8 @@ void SwUndoTblNumFmt::SetBox( const SwTableBox& rBox ) nNode = rBox.GetSttIdx(); } -/* */ + +////////////////////////////////////////////////////////////////////////// _UndoTblCpyTbl_Entry::_UndoTblCpyTbl_Entry( const SwTableBox& rBox ) : nBoxIdx( rBox.GetSttIdx() ), nOffset( 0 ), @@ -2528,9 +2518,9 @@ SwUndoTblCpyTbl::~SwUndoTblCpyTbl() delete pInsRowUndo; } -void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) +void SwUndoTblCpyTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); _DEBUG_REDLINE( &rDoc ) SwTableNode* pTblNd = 0; @@ -2559,23 +2549,29 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) // There are a couple of different situations to consider during redlining if( pEntry->pUndo ) { - SwUndoDelete *pUnDel = (SwUndoDelete*)pEntry->pUndo; - if( UNDO_REDLINE == pUnDel->GetId() ) + SwUndoDelete *const pUndoDelete = + dynamic_cast<SwUndoDelete*>(pEntry->pUndo); + SwUndoRedlineDelete *const pUndoRedlineDelete = + dynamic_cast<SwUndoRedlineDelete*>(pEntry->pUndo); + OSL_ASSERT(pUndoDelete || pUndoRedlineDelete); + if (pUndoRedlineDelete) { // The old content was not empty or he has been merged with the new content bDeleteCompleteParagraph = !pEntry->bJoin; // bJoin is set when merged // Set aTmpIdx to the beginning fo the old content - SwNodeIndex aTmpIdx( *pEndNode, pUnDel->NodeDiff()-1 ); + SwNodeIndex aTmpIdx( *pEndNode, + pUndoRedlineDelete->NodeDiff()-1 ); SwTxtNode *pTxt = aTmpIdx.GetNode().GetTxtNode(); if( pTxt ) { aPam.GetPoint()->nNode = *pTxt; - aPam.GetPoint()->nContent.Assign( pTxt, pUnDel->ContentStart() ); + aPam.GetPoint()->nContent.Assign( pTxt, + pUndoRedlineDelete->ContentStart() ); } else *aPam.GetPoint() = SwPosition( aTmpIdx ); } - else if( pUnDel->IsDelFullPara() ) + else if (pUndoDelete && pUndoDelete->IsDelFullPara()) { // When the old content was an empty paragraph, but could not be joined // with the new content (e.g. because of a section or table) @@ -2599,8 +2595,9 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) if( pEntry->pUndo ) { - pEntry->pUndo->Undo( rIter ); + pEntry->pUndo->UndoImpl(rContext); delete pEntry->pUndo; + pEntry->pUndo = 0; } if( bShiftPam ) { @@ -2623,8 +2620,9 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) pUndo = new SwUndoDelete( aPam, true ); if( pEntry->pUndo ) { - pEntry->pUndo->Undo( rIter ); + pEntry->pUndo->UndoImpl(rContext); delete pEntry->pUndo; + pEntry->pUndo = 0; } } pEntry->pUndo = pUndo; @@ -2660,17 +2658,21 @@ void SwUndoTblCpyTbl::Undo( SwUndoIter& rIter ) } if( pInsRowUndo ) - pInsRowUndo->Undo( rIter ); + { + pInsRowUndo->UndoImpl(rContext); + } _DEBUG_REDLINE( &rDoc ) } -void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter ) +void SwUndoTblCpyTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); _DEBUG_REDLINE( &rDoc ) if( pInsRowUndo ) - pInsRowUndo->Redo( rIter ); + { + pInsRowUndo->RedoImpl(rContext); + } SwTableNode* pTblNd = 0; for( USHORT n = 0; n < pArr->Count(); ++n ) @@ -2691,7 +2693,7 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter ) SwUndo* pUndo = IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ? 0 : new SwUndoDelete( aPam, TRUE ); if( pEntry->pUndo ) { - pEntry->pUndo->Undo( rIter ); + pEntry->pUndo->UndoImpl(rContext); if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() ) ) { // PrepareRedline has to be called with the beginning of the old content @@ -2699,8 +2701,12 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter ) // by the Undo operation to this point. // Otherwise aInsIdx has been moved during the Undo operation if( pEntry->bJoin ) - pUndo = PrepareRedline( &rDoc, rBox, *rIter.pAktPam->GetPoint(), + { + SwPaM const& rLastPam = + rContext.GetCursorSupplier().GetCurrentShellCursor(); + pUndo = PrepareRedline( &rDoc, rBox, *rLastPam.GetPoint(), pEntry->bJoin, true ); + } else { SwPosition aTmpPos( aInsIdx ); @@ -2708,6 +2714,7 @@ void SwUndoTblCpyTbl::Redo( SwUndoIter& rIter ) } } delete pEntry->pUndo; + pEntry->pUndo = 0; } pEntry->pUndo = pUndo; // b62341295: Redline for copying tables - End. @@ -2899,7 +2906,8 @@ BOOL SwUndoTblCpyTbl::IsEmpty() const return !pInsRowUndo && !pArr->Count(); } -/* */ + +////////////////////////////////////////////////////////////////////////// SwUndoCpyTbl::SwUndoCpyTbl() : SwUndo( UNDO_CPYTBL ), pDel( 0 ), nTblNode( 0 ) @@ -2911,9 +2919,9 @@ SwUndoCpyTbl::~SwUndoCpyTbl() delete pDel; } -void SwUndoCpyTbl::Undo( SwUndoIter& rIter ) +void SwUndoCpyTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwDoc& rDoc = rIter.GetDoc(); + SwDoc & rDoc = rContext.GetDoc(); SwTableNode* pTNd = rDoc.GetNodes()[ nTblNode ]->GetTableNode(); // harte SeitenUmbrueche am nachfolgenden Node verschieben @@ -2936,14 +2944,14 @@ void SwUndoCpyTbl::Undo( SwUndoIter& rIter ) pDel = new SwUndoDelete( aPam, TRUE ); } -void SwUndoCpyTbl::Redo( SwUndoIter& rIter ) +void SwUndoCpyTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - pDel->Undo( rIter ); + pDel->UndoImpl(rContext); delete pDel, pDel = 0; } -/* */ +////////////////////////////////////////////////////////////////////////// SwUndoSplitTbl::SwUndoSplitTbl( const SwTableNode& rTblNd, SwSaveRowSpan* pRowSp, USHORT eMode, BOOL bNewSize ) @@ -2970,10 +2978,10 @@ SwUndoSplitTbl::~SwUndoSplitTbl() delete mpSaveRowSpan; } -void SwUndoSplitTbl::Undo( SwUndoIter& rIter ) +void SwUndoSplitTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); SwNodeIndex& rIdx = pPam->GetPoint()->nNode; @@ -3035,10 +3043,10 @@ void SwUndoSplitTbl::Undo( SwUndoIter& rIter ) ClearFEShellTabCols(); } -void SwUndoSplitTbl::Redo( SwUndoIter& rIter ) +void SwUndoSplitTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); pPam->GetPoint()->nNode = nTblNode; @@ -3047,10 +3055,10 @@ void SwUndoSplitTbl::Redo( SwUndoIter& rIter ) ClearFEShellTabCols(); } -void SwUndoSplitTbl::Repeat( SwUndoIter& rIter ) +void SwUndoSplitTbl::RepeatImpl(::sw::RepeatContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwPaM *const pPam = & rContext.GetRepeatPaM(); + SwDoc *const pDoc = & rContext.GetDoc(); pDoc->SplitTable( *pPam->GetPoint(), nMode, bCalcNewSize ); ClearFEShellTabCols(); @@ -3065,7 +3073,8 @@ void SwUndoSplitTbl::SaveFormula( SwHistory& rHistory ) pHistory->Move( 0, &rHistory ); } -/* */ + +////////////////////////////////////////////////////////////////////////// SwUndoMergeTbl::SwUndoMergeTbl( const SwTableNode& rTblNd, const SwTableNode& rDelTblNd, @@ -3092,10 +3101,10 @@ SwUndoMergeTbl::~SwUndoMergeTbl() delete pHistory; } -void SwUndoMergeTbl::Undo( SwUndoIter& rIter ) +void SwUndoMergeTbl::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); SwNodeIndex& rIdx = pPam->GetPoint()->nNode; @@ -3159,10 +3168,10 @@ void SwUndoMergeTbl::Undo( SwUndoIter& rIter ) } } -void SwUndoMergeTbl::Redo( SwUndoIter& rIter ) +void SwUndoMergeTbl::RedoImpl(::sw::UndoRedoContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); pPam->GetPoint()->nNode = nTblNode; @@ -3176,10 +3185,10 @@ void SwUndoMergeTbl::Redo( SwUndoIter& rIter ) ClearFEShellTabCols(); } -void SwUndoMergeTbl::Repeat( SwUndoIter& rIter ) +void SwUndoMergeTbl::RepeatImpl(::sw::RepeatContext & rContext) { - SwPaM* pPam = rIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam = & rContext.GetRepeatPaM(); pDoc->MergeTable( *pPam->GetPoint(), bWithPrev, nMode ); ClearFEShellTabCols(); @@ -3192,8 +3201,8 @@ void SwUndoMergeTbl::SaveFormula( SwHistory& rHistory ) pHistory->Move( 0, &rHistory ); } -/* */ +////////////////////////////////////////////////////////////////////////// void InsertSort( SvUShorts& rArr, USHORT nIdx, USHORT* pInsPos ) { diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index e9e7ce1e0e02..cf410a04032d 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -28,16 +28,16 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include <hintids.hxx> #include <fmtanchr.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <swundo.hxx> // fuer die UndoIds #include <pam.hxx> #include <ndtxt.hxx> -#include <undobj.hxx> +#include <UndoCore.hxx> #include <rolbck.hxx> #include <redline.hxx> @@ -45,7 +45,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam ) : SwUndo( nUndoId ), SwUndRng( rPam ), - pTxtFmtColl( 0 ), pLastNdColl(0), pFrmFmts( 0 ), pFlyUndos(0), pRedlData( 0 ), + pTxtFmtColl( 0 ), pLastNdColl(0), pFrmFmts( 0 ), pRedlData( 0 ), bSttWasTxtNd( TRUE ), nNdDiff( 0 ), pPos( 0 ), nSetPos( 0 ) { pHistory = new SwHistory; @@ -116,7 +116,6 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, { // dann alle neuen Flys zusammen sammeln !! SwDoc* pDoc = (SwDoc*)rPam.GetDoc(); - pFlyUndos = new SwUndos(); USHORT nFndPos, nArrLen = pDoc->GetSpzFrmFmts()->Count(); for( USHORT n = 0; n < nArrLen; ++n ) { @@ -130,16 +129,15 @@ void SwUndoInserts::SetInsertRange( const SwPaM& rPam, BOOL bScanFlys, if( !pFrmFmts || USHRT_MAX == ( nFndPos = pFrmFmts->GetPos( pFmt ) ) ) { - SwUndoInsLayFmt* pFlyUndo = new SwUndoInsLayFmt( pFmt,0,0 ); - pFlyUndos->Insert( pFlyUndo, pFlyUndos->Count() ); + ::boost::shared_ptr<SwUndoInsLayFmt> const pFlyUndo( + new SwUndoInsLayFmt(pFmt, 0, 0)); + m_FlyUndos.push_back(pFlyUndo); } else pFrmFmts->Remove( nFndPos ); } } delete pFrmFmts, pFrmFmts = 0; - if( !pFlyUndos->Count() ) - delete pFlyUndos, pFlyUndos = 0; } } @@ -166,18 +164,14 @@ SwUndoInserts::~SwUndoInserts() delete pPos; } delete pFrmFmts; - delete pFlyUndos; delete pRedlData; } -void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) +void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext) { - SwPaM * pPam = rUndoIter.pAktPam; - SwDoc* pDoc = pPam->GetDoc(); - SetPaM( rUndoIter ); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + SwDoc *const pDoc = & rContext.GetDoc(); + SwPaM *const pPam = & AddUndoRedoPaM(rContext); if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) pDoc->DeleteRedline( *pPam, true, USHRT_MAX ); @@ -200,7 +194,7 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } RemoveIdxFromRange( *pPam, FALSE ); - SetPaM( rUndoIter ); + SetPaM(*pPam); // sind Fussnoten oder CntntFlyFrames im Text ?? nSetPos = pHistory->Count(); @@ -218,11 +212,13 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } } - if( pFlyUndos ) + if (m_FlyUndos.size()) { ULONG nTmp = pPam->GetPoint()->nNode.GetIndex(); - for( USHORT n = pFlyUndos->Count(); n; ) - (*pFlyUndos)[ --n ]->Undo( rUndoIter ); + for (size_t n = m_FlyUndos.size(); 0 < n; --n) + { + m_FlyUndos[ n-1 ]->UndoImpl(rContext); + } nNdDiff += nTmp - pPam->GetPoint()->nNode.GetIndex(); } @@ -268,16 +264,12 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) pHistory->TmpRollback( pDoc, 0, false ); } } - - pDoc->DoUndo( bUndo ); - if( pPam != rUndoIter.pAktPam ) - delete pPam; } -void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) +void SwUndoInserts::RedoImpl(::sw::UndoRedoContext & rContext) { // setze noch den Cursor auf den Redo-Bereich - SwPaM* pPam = rUndoIter.pAktPam; + SwPaM *const pPam = & AddUndoRedoPaM(rContext); SwDoc* pDoc = pPam->GetDoc(); pPam->DeleteMark(); pPam->GetPoint()->nNode = nSttNode - nNdDiff; @@ -321,9 +313,10 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pTxtNd->ChgFmtColl( pLastNdColl ); } - if( pFlyUndos ) - for( USHORT n = pFlyUndos->Count(); n; ) - (*pFlyUndos)[ --n ]->Redo( rUndoIter ); + for (size_t n = m_FlyUndos.size(); 0 < n; --n) + { + m_FlyUndos[ n-1 ]->RedoImpl(rContext); + } pHistory->Rollback( pDoc, nSetPos ); @@ -339,21 +332,16 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pDoc->SplitRedline( *pPam ); } -void SwUndoInserts::Repeat( SwUndoIter& rUndoIter ) +void SwUndoInserts::RepeatImpl(::sw::RepeatContext & rContext) { - if( GetId() == rUndoIter.GetLastUndoId() ) - return; - - SwPaM aPam( *rUndoIter.pAktPam->GetPoint() ); + SwPaM aPam( rContext.GetDoc().GetNodes().GetEndOfContent() ); SetPaM( aPam ); - aPam.GetDoc()->CopyRange( aPam, *rUndoIter.pAktPam->GetPoint(), false ); - - rUndoIter.pLastUndoObj = this; + SwPaM & rRepeatPaM( rContext.GetRepeatPaM() ); + aPam.GetDoc()->CopyRange( aPam, *rRepeatPaM.GetPoint(), false ); } -/* */ - +////////////////////////////////////////////////////////////////////////// SwUndoInsDoc::SwUndoInsDoc( const SwPaM& rPam ) : SwUndoInserts( UNDO_INSDOKUMENT, rPam ) diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index 590ddb6e803e..7a67b7748c97 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -40,12 +40,11 @@ #include <IMark.hxx> #include <crossrefbookmark.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <swundo.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#include <undobj.hxx> +#include <SwRewriter.hxx> #include <docsh.hxx> @@ -376,9 +375,11 @@ throw (uno::RuntimeException) aRewriter.AddRule(UNDO_ARG2, SW_RES(STR_YIELDS)); aRewriter.AddRule(UNDO_ARG3, lcl_QuoteName(rName)); - m_pImpl->m_pDoc->StartUndo(UNDO_BOOKMARK_RENAME, &aRewriter); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( + UNDO_BOOKMARK_RENAME, &aRewriter); pMarkAccess->renameMark(m_pImpl->m_pRegisteredBookmark, rName); - m_pImpl->m_pDoc->EndUndo(UNDO_BOOKMARK_RENAME, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo( + UNDO_BOOKMARK_RENAME, &aRewriter); } OUString SAL_CALL diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 92a33da130fe..5c8669691aba 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -43,6 +43,7 @@ #include <unoframe.hxx> #include <unocrsr.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <IDocumentRedlineAccess.hxx> #include <fmtftn.hxx> #include <fmtpdsc.hxx> @@ -708,7 +709,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) if( rPam.GetNext() != &rPam ) // Mehrfachselektion ? { - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( rPam ); SwPaM aPam( *rPam.GetPoint() ); for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) @@ -718,7 +719,7 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) pDoc->SetNumRule( aRangeArr.SetPam( n, aPam ), aRule, false ); // <-- } - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else { @@ -805,12 +806,12 @@ void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPa if( rPam.GetNext() != &rPam ) // Mehrfachselektion ? { - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( rPam ); SwPaM aPam( *rPam.GetPoint() ); for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) pDoc->SetNodeNumStart( *aRangeArr.SetPam( n, aPam ).GetPoint(), 1 ); - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else pDoc->SetNodeNumStart( *rPam.GetPoint(), 0 ); @@ -935,6 +936,7 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, if( !pMed ) return; + // this sourcecode is not responsible for the lifetime of the shell, SfxObjectShellLock should not be used SfxObjectShellRef aRef( pDocSh ); pDocSh->RegisterTransfer( *pMed ); @@ -1007,6 +1009,8 @@ sal_Bool DocInsertStringSplitCR( IDocumentContentOperations::INS_EMPTYEXPAND) : IDocumentContentOperations::INS_EMPTYEXPAND; + // grouping done in InsertString is intended for typing, not API calls + ::sw::GroupUndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo()); OUString aTxt; xub_StrLen nStartIdx = 0; SwTxtNode* const pTxtNd = diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index ab5d68910769..005ead8cddd1 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -42,6 +42,7 @@ #include <svx/svditer.hxx> #include <swunohelper.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <fmtcntnt.hxx> #include <fmtflcnt.hxx> #include <txtatr.hxx> @@ -866,7 +867,7 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< if( !bFlyInCnt ) { UnoActionContext aContext(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwDrawContact* pContact = pDoc->GroupSelection( *pPage->GetDrawView() ); pDoc->ChgAnchor( @@ -880,7 +881,7 @@ uno::Reference< drawing::XShapeGroup > SwXDrawPage::group(const uno::Reference< uno::Reference< uno::XInterface > xInt = pPage->GetInterface( pContact->GetMaster() ); xRet = uno::Reference< drawing::XShapeGroup >(xInt, uno::UNO_QUERY); } - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } } pPage->RemovePageView(); @@ -903,13 +904,13 @@ void SwXDrawPage::ungroup(const uno::Reference< drawing::XShapeGroup > & xShapeG { pPage->PreUnGroup(xShapeGroup); UnoActionContext aContext(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); pDoc->UnGroupSelection( *pPage->GetDrawView() ); pDoc->ChgAnchor( pPage->GetDrawView()->GetMarkedObjectList(), FLY_AT_PARA/*int eAnchorId*/, sal_True, sal_False ); - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } pPage->RemovePageView(); } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 3a3df506b457..40b5afa67367 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -45,6 +45,7 @@ #include <memory> #include <hints.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docsh.hxx> #include <editsh.hxx> #include <swcli.hxx> @@ -1656,7 +1657,8 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) } } else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID|| - FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID) + FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID|| + FN_EMBEDDED_OBJECT == pEntry->nWID) { SwDoc* pDoc = pFmt->GetDoc(); const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); @@ -1677,7 +1679,15 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) { uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY ); uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY ); - if ( xModel.is() ) + if ( FN_EMBEDDED_OBJECT == pEntry->nWID ) + { + // ensure the + ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" ); + if ( pDoc->GetDocShell() ) + pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) ); + aAny <<= xIP; + } + else if ( xModel.is() ) aAny <<= xModel; else if ( FN_UNO_COMPONENT == pEntry->nWID ) aAny <<= xComp; @@ -2311,7 +2321,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan // xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) ); UnoActionContext aAction(pDoc); - pDoc->StartUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); if(!bSizeFound) { //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode? @@ -2358,7 +2368,7 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL ); ASSERT( pFmt2, "Doc->Insert(notxt) failed." ); - pDoc->EndUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); pFmt2->Add(this); if(sName.Len()) pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName); @@ -2368,11 +2378,11 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan { ::rtl::OUString sStreamName; (*pStreamName) >>= sStreamName; - pDoc->StartUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); SwFlyFrmFmt* pFrmFmt = 0; pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL ); - pDoc->EndUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); pFrmFmt->Add(this); if(sName.Len()) pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName); diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 765b1ae37485..a52b6325535a 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -1150,6 +1150,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { SW_PROP_NMID(UNO_NAME_GRAPHIC_URL), FN_UNO_REPLACEMENT_GRAPHIC_URL, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::MAYBEVOID, 0 }, { SW_PROP_NMID(UNO_NAME_GRAPHIC), FN_UNO_REPLACEMENT_GRAPHIC, CPPU_E2T(CPPUTYPE_REFXGRAPHIC), PropertyAttribute::MAYBEVOID, 0 }, { SW_PROP_NMID(UNO_NAME_COMPONENT),FN_UNO_COMPONENT, CPPU_E2T(CPPUTYPE_REFCOMPONENT), PropertyAttribute::READONLY, 0}, + { SW_PROP_NMID(UNO_NAME_EMBEDDED_OBJECT),FN_EMBEDDED_OBJECT, CPPU_E2T(CPPUTPYE_REFEMBEDDEDOBJECT), PropertyAttribute::READONLY, 0}, // { SW_PROP_NMID(UNO_NAME_ALTERNATIVE_TEXT), FN_UNO_ALTERNATIVE_TEXT,CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE , 0 }, {0,0,0,0,0,0} }; diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index f572b5f3e91c..73f5c9736018 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -40,6 +40,7 @@ #include <IMark.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <istyleaccess.hxx> #include <ndtxt.hxx> #include <ndnotxt.hxx> @@ -66,9 +67,7 @@ #include <fmtfld.hxx> #include <fmtpdsc.hxx> #include <pagedesc.hxx> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif #include <poolfmt.hxx> #include <edimp.hxx> #include <fchrfmt.hxx> @@ -350,13 +349,13 @@ throw (lang::IllegalArgumentException) SwTxtFmtColl *const pLocal = pStyle->GetCollection(); UnoActionContext aAction(pDoc); - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPaM *pTmpCrsr = &rPaM; do { pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); } while ( pTmpCrsr != &rPaM ); - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } /* -----------------06.07.98 07:38------------------- @@ -427,7 +426,7 @@ lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue) if( rCrsr.GetNext() != &rCrsr ) // Mehrfachselektion ? { - pDoc->StartUndo( UNDO_START, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); SwPamRanges aRangeArr( rCrsr ); SwPaM aPam( *rCrsr.GetPoint() ); for( sal_uInt16 n = 0; n < aRangeArr.Count(); ++n ) @@ -436,7 +435,7 @@ lcl_SetNodeNumStart(SwPaM & rCrsr, uno::Any const& rValue) pDoc->SetNodeNumStart(*aRangeArr.SetPam( n, aPam ).GetPoint(), nStt ); } - pDoc->EndUndo( UNDO_END, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } else { @@ -457,7 +456,7 @@ lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue) for (sal_Int32 nStyle = 0; nStyle < aCharStyles.getLength(); nStyle++) { uno::Any aStyle; - rPam.GetDoc()->StartUndo(UNDO_START, NULL); + rPam.GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL); aStyle <<= aCharStyles.getConstArray()[nStyle]; // create a local set and apply each format directly SfxItemSet aSet(rPam.GetDoc()->GetAttrPool(), @@ -468,7 +467,7 @@ lcl_setCharFmtSequence(SwPaM & rPam, uno::Any const& rValue) SwUnoCursorHelper::SetCrsrAttr(rPam, aSet, (nStyle) ? nsSetAttrMode::SETATTR_DONTREPLACE : nsSetAttrMode::SETATTR_DEFAULT); - rPam.GetDoc()->EndUndo(UNDO_START, NULL); + rPam.GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_START, NULL); } return true; } @@ -931,7 +930,7 @@ void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText, SwDoc* pDoc = pUnoCrsr->GetDoc(); UnoActionContext aAction(pDoc); const xub_StrLen nTxtLen = rText.getLength(); - pDoc->StartUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); SwCursor * pCurrent = pUnoCrsr; do { @@ -953,7 +952,7 @@ void SwXTextCursor::DeleteAndInsert(const ::rtl::OUString& rText, } pCurrent = static_cast<SwCursor *>(pCurrent->GetNext()); } while (pCurrent != pUnoCrsr); - pDoc->EndUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); } } diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index d9334e97c841..0a6b5d1cfce4 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -37,6 +37,7 @@ #include <bookmrk.hxx> #include <frmfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <ndtxt.hxx> #include <ndnotxt.hxx> #include <unocrsr.hxx> @@ -357,7 +358,7 @@ void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam, UnoActionContext aAction(pDoc); if (rPam.GetNext() != &rPam) // Ring of Cursors { - pDoc->StartUndo(UNDO_INSATTR, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSATTR, NULL); SwPaM *pCurrent = &rPam; do @@ -371,7 +372,7 @@ void SwUnoCursorHelper::SetCrsrAttr(SwPaM & rPam, pCurrent= static_cast<SwPaM *>(pCurrent->GetNext()); } while (pCurrent != &rPam); - pDoc->EndUndo(UNDO_INSATTR, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSATTR, NULL); } else { @@ -923,7 +924,7 @@ throw (uno::RuntimeException) if (GetPositions(aCursor)) { UnoActionContext aAction(& m_pImpl->m_rDoc); - m_pImpl->m_rDoc.StartUndo(UNDO_INSERT, NULL); + m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); if (aCursor.HasMark()) { m_pImpl->m_rDoc.DeleteAndJoin(aCursor); @@ -938,7 +939,7 @@ throw (uno::RuntimeException) aCursor.Left(rText.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } SetPositions(aCursor); - m_pImpl->m_rDoc.EndUndo(UNDO_INSERT, NULL); + m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); } } @@ -1794,7 +1795,7 @@ void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString) // Start/EndAction SwDoc *const pDoc = rCursor.GetDoc(); UnoActionContext aAction(pDoc); - pDoc->StartUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); if (rCursor.HasMark()) { pDoc->DeleteAndJoin(rCursor); @@ -1809,7 +1810,7 @@ void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString) SwUnoCursorHelper::SelectPam(rCursor, true); rCursor.Left(rString.getLength(), CRSR_SKIP_CHARS, FALSE, FALSE); } - pDoc->EndUndo(UNDO_INSERT, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); } /****************************************************************** diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index 049ccfe42ed7..e4351ce1e571 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -779,6 +779,7 @@ const SwPropNameTab aPropNameTab = { /* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")}, /* 0738 UNO_NAME_META */ {MAP_CHAR_LEN("InContentMetadata")}, /* 0739 UNO_NAME_NESTED_TEXT_CONTENT */ {MAP_CHAR_LEN("NestedTextContent")}, +/* 0740 UNO_NAME_EMBEDDED_OBJECT */ {MAP_CHAR_LEN("EmbeddedObject")}, }; const SwPropNameLen& SwGetPropName( USHORT nId ) diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index 2810b500ea4b..b8d1e3318ddf 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -50,6 +50,7 @@ #include <unocrsr.hxx> #include <section.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docsh.hxx> #include <sfx2/docfile.hxx> #include <docary.hxx> @@ -327,7 +328,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) //das muss jetzt sal_True liefern ::sw::XTextRangeToSwPaM(aPam, xTextRange); UnoActionContext aCont(pDoc); - pDoc->StartUndo( UNDO_INSSECTION, NULL ); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSSECTION, NULL ); if (!m_pImpl->m_sName.getLength()) { @@ -456,7 +457,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } // Undo-Klammerung hier beenden - pDoc->EndUndo( UNDO_INSSECTION, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSSECTION, NULL ); m_pImpl->m_pProps.reset(); m_pImpl->m_bIsDescriptor = false; } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 252be1efa9ba..49030c7e8eeb 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -47,6 +47,7 @@ #include <editeng/paperinf.hxx> #include <pagedesc.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docary.hxx> #include <charfmt.hxx> #include <cmdid.h> @@ -3397,15 +3398,13 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( } if(aBaseImpl.HasItemSet()) { - BOOL bDoesUndo = GetDoc()->DoesUndo(); - if( bDoesUndo ) + ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); + if (undoGuard.UndoWasEnabled()) { // Fix i64460: as long as Undo of page styles with header/footer causes trouble... - GetDoc()->DelAllUndoObj(); - GetDoc()->DoUndo( FALSE ); + GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); } aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet()); - GetDoc()->DoUndo( bDoesUndo ); } } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 856d5e0b44bb..225896af5349 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -45,6 +45,7 @@ #include <hints.hxx> #include <swtblfmt.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <shellres.hxx> #include <docary.hxx> #include <ndole.hxx> @@ -2505,7 +2506,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex { UnoActionContext aCont( pDoc ); - pDoc->StartUndo(UNDO_EMPTY, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); const SwTable *pTable = 0; if( 0 != aPam.Start()->nContent.GetIndex() ) { @@ -2564,9 +2565,8 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex bIsDescriptor = sal_False; DELETEZ(pTableProps); } - pDoc->EndUndo( UNDO_END, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } - } else throw lang::IllegalArgumentException(); @@ -3417,7 +3417,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, SwDoc* pDoc = pFmt->GetDoc(); SwTable* pTable = SwTable::FindTable( pFmt ); SwTableLines &rLines = pTable->GetTabLines(); - pDoc->StartUndo(UNDO_START, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL); for(sal_uInt16 i = 0; i < rLines.Count(); i++) { SwTableLine* pLine = rLines.GetObject(i); @@ -3447,7 +3447,7 @@ void SwXTextTable::setPropertyValue(const OUString& rPropertyName, } } } - pDoc->EndUndo(UNDO_END, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); } break; case FN_UNO_TABLE_COLUMN_SEPARATORS: @@ -3777,7 +3777,7 @@ void SwXTextTable::setName(const OUString& rName) throw( uno::RuntimeException ) while ( 0 != (pStNd = aIdx.GetNode().GetStartNode()) ) { aIdx++; - SwNode *pNd = pFmt->GetDoc()->GetNodes()[aIdx]; + SwNode *const pNd = & aIdx.GetNode(); if ( pNd->IsOLENode() && aOldName == ((SwOLENode*)pNd)->GetChartTblName() ) { diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 3ddcfc1d2ed7..9caf8e5f5d1e 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -28,6 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" +#include <stdlib.h> + +#include <memory> +#include <iostream> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/text/ControlCharacter.hpp> @@ -57,12 +61,12 @@ #include <unoredline.hxx> #include <unomap.hxx> #include <unoprnms.hxx> -#include <undobj.hxx> #include <unoparagraph.hxx> #include <unocrsrhelper.hxx> #include <docsh.hxx> #include <docary.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <redline.hxx> #include <swundo.hxx> #include <section.hxx> @@ -72,10 +76,7 @@ #include <crsskip.hxx> #include <ndtxt.hxx> -#include <memory> -#include <stdlib.h> -#include <iostream> using namespace ::com::sun::star; using ::rtl::OUString; @@ -404,12 +405,9 @@ throw (uno::RuntimeException) // so the text is inserted before UnoActionContext aContext(GetDoc()); SwPaM aInsertPam(*pPam->Start()); - const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); - GetDoc()->DoGroupUndo(sal_False); - + ::sw::GroupUndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); SwUnoCursorHelper::DocInsertStringSplitCR( *GetDoc(), aInsertPam, rString, bForceExpandHints ); - GetDoc()->DoGroupUndo(bGroupUndo); } } @@ -991,7 +989,7 @@ SwXText::setString(const OUString& rString) throw (uno::RuntimeException) throw uno::RuntimeException(); } - GetDoc()->StartUndo(UNDO_START, NULL); + GetDoc()->GetIDocumentUndoRedo().StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor if (CURSOR_META != m_pImpl->m_eType) @@ -1029,14 +1027,14 @@ SwXText::setString(const OUString& rString) throw (uno::RuntimeException) const uno::Reference< text::XTextCursor > xRet = CreateCursor(); if(!xRet.is()) { - GetDoc()->EndUndo(UNDO_END, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); uno::RuntimeException aRuntime; aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } xRet->gotoEnd(sal_True); xRet->setString(rString); - GetDoc()->EndUndo(UNDO_END, NULL); + GetDoc()->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); } //FIXME why is CheckForOwnMember duplicated in some insert methods? @@ -1373,7 +1371,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) bool bIllegalException = false; bool bRuntimeException = false; ::rtl::OUString sMessage; - m_pDoc->StartUndo(UNDO_START , NULL); + m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_START , NULL); // find end node, go backward - don't skip tables because the new // paragraph has to be the last node //aPam.Move( fnMoveBackward, fnGoNode ); @@ -1425,11 +1423,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } } } - m_pDoc->EndUndo(UNDO_END, NULL); + m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); if (bIllegalException || bRuntimeException) { - SwUndoIter aUndoIter( &aPam, UNDO_EMPTY ); - m_pDoc->Undo(aUndoIter); + m_pDoc->GetIDocumentUndoRedo().Undo(); if (bIllegalException) { lang::IllegalArgumentException aEx; @@ -1483,7 +1480,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) bool bIllegalException = false; bool bRuntimeException = false; ::rtl::OUString sMessage; - m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); // SwPaM aPam(*pStartNode->EndOfSectionNode()); //aPam.Move( fnMoveBackward, fnGoNode ); @@ -1538,11 +1535,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } } } - m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); if (bIllegalException || bRuntimeException) { - SwUndoIter aUndoIter( pCursor, UNDO_EMPTY ); - m_pImpl->m_pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(); if (bIllegalException) { lang::IllegalArgumentException aEx; @@ -1584,7 +1580,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } uno::Reference< text::XTextRange > xRet; - m_pImpl->m_pDoc->StartUndo(UNDO_INSERT, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); // find end node, go backward - don't skip tables because the // new paragraph has to be the last node SwPaM aPam(*pStartNode->EndOfSectionNode()); @@ -1619,7 +1615,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) throw uno::RuntimeException(); } } - m_pImpl->m_pDoc->EndUndo(UNDO_INSERT, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); return xRet; } @@ -1666,7 +1662,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) pEndRange->Invalidate(); } - m_pImpl->m_pDoc->StartUndo( UNDO_START, NULL ); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL ); bool bIllegalException = false; bool bRuntimeException = false; ::rtl::OUString sMessage; @@ -1817,11 +1813,10 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) } } - m_pImpl->m_pDoc->EndUndo(UNDO_END, NULL); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_END, NULL); if (bIllegalException || bRuntimeException) { - SwUndoIter aUndoIter( &aStartPam, UNDO_EMPTY ); - m_pImpl->m_pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(); if (bIllegalException) { lang::IllegalArgumentException aEx; @@ -2301,8 +2296,7 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) if(bExcept) { - SwUndoIter aUndoIter( &aLastPaM, UNDO_EMPTY ); - m_pImpl->m_pDoc->Undo(aUndoIter); + m_pImpl->m_pDoc->GetIDocumentUndoRedo().Undo(); throw lang::IllegalArgumentException(); } diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 6897e6065db0..764a71b76b69 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -71,8 +71,7 @@ SwPagePreviewLayout::SwPagePreviewLayout( ViewShell& _rParentViewShell, mbBookPreview = false; mbBookPreviewModeToggled = false; - const SwPrintData* pPrintData = mrParentViewShell.getIDocumentDeviceAccess()->getPrintData(); - mbPrintEmptyPages = pPrintData ? pPrintData->IsPrintEmptyPages() : true; + mbPrintEmptyPages = mrParentViewShell.getIDocumentDeviceAccess()->getPrintData().IsPrintEmptyPages(); } void SwPagePreviewLayout::_Clear() diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx index b54922a1b8e7..bc16348abaee 100644 --- a/sw/source/core/view/printdata.cxx +++ b/sw/source/core/view/printdata.cxx @@ -198,8 +198,8 @@ SwPrintUIOptions::SwPrintUIOptions( { ResStringArray aLocalizedStrings( SW_RES( STR_PRINTOPTUI ) ); - DBG_ASSERT( aLocalizedStrings.Count() >= 44, "resource incomplete" ); - if( aLocalizedStrings.Count() < 44 ) // bad resource ? + DBG_ASSERT( aLocalizedStrings.Count() >= 30, "resource incomplete" ); + if( aLocalizedStrings.Count() < 30 ) // bad resource ? return; // printing HTML sources does not have any valid UI options. @@ -226,7 +226,7 @@ SwPrintUIOptions::SwPrintUIOptions( String aAppGroupname( aLocalizedStrings.GetString( 0 ) ); aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ), aModOpt.GetModuleName( SvtModuleOptions::E_SWRITER ) ); - m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getGroupControlOpt( aAppGroupname, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) ) ); // create sub section for Contents m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 1 ), rtl::OUString() ); @@ -234,79 +234,79 @@ SwPrintUIOptions::SwPrintUIOptions( // create a bool option for background bool bDefaultVal = rDefaultPrintData.IsPrintPageBackground(); m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 2 ), - aLocalizedStrings.GetString( 3 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPageBackground" ) ), - bDefaultVal ); + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintPageBackground:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPageBackground" ) ), + bDefaultVal ); // create a bool option for pictures/graphics AND OLE and drawing objects as well bDefaultVal = rDefaultPrintData.IsPrintGraphic() || rDefaultPrintData.IsPrintDraw(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), - aLocalizedStrings.GetString( 5 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPicturesAndObjects" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 3 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintPicturesAndObjects:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPicturesAndObjects" ) ), + bDefaultVal ); if (!bWeb) { // create a bool option for hidden text bDefaultVal = rDefaultPrintData.IsPrintHiddenText(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), - aLocalizedStrings.GetString( 7 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 4 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintHiddenText:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintHiddenText" ) ), + bDefaultVal ); // create a bool option for place holder bDefaultVal = rDefaultPrintData.IsPrintTextPlaceholder(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), - aLocalizedStrings.GetString( 9 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTextPlaceholder" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 5 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintTextPlaceholder:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintTextPlaceholder" ) ), + bDefaultVal ); } // create a bool option for controls bDefaultVal = rDefaultPrintData.IsPrintControl(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), - aLocalizedStrings.GetString( 11 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 6 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintControls:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintControls" ) ), + bDefaultVal ); // create sub section for Color - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 12 ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( aLocalizedStrings.GetString( 7 ), rtl::OUString() ); // create a bool option for printing text with black font color bDefaultVal = rDefaultPrintData.IsPrintBlackFont(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 13 ), - aLocalizedStrings.GetString( 14 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 8 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintBlackFonts:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintBlackFonts" ) ), + bDefaultVal ); if (!bWeb) { // create subgroup for misc options - m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 15 ) ), rtl::OUString() ); + m_aUIProperties[ nIdx++ ].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 9 ) ), rtl::OUString() ); // create a bool option for printing automatically inserted blank pages bDefaultVal = rDefaultPrintData.IsPrintEmptyPages(); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 16 ), - aLocalizedStrings.GetString( 17 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), - bDefaultVal ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 10 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintEmptyPages:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintEmptyPages" ) ), + bDefaultVal ); } // create a bool option for paper tray bDefaultVal = rDefaultPrintData.IsPaperFromSetup(); vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt; aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 18 ), - aLocalizedStrings.GetString( 19 ), - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ), - bDefaultVal, - aPaperTrayOpt - ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 11 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintPaperFromSetup:CheckBox" ) ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ), + bDefaultVal, + aPaperTrayOpt + ); // print range selection vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt; aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) ); aPrintRangeOpt.mbInternalOnly = sal_True; - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 37 ) ), + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 26 ) ), rtl::OUString(), aPrintRangeOpt ); @@ -315,18 +315,18 @@ SwPrintUIOptions::SwPrintUIOptions( rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ); uno::Sequence< rtl::OUString > aChoices( 3 ); uno::Sequence< sal_Bool > aChoicesDisabled( 3 ); - uno::Sequence< rtl::OUString > aHelpText( 3 ); - aChoices[0] = aLocalizedStrings.GetString( 38 ); + uno::Sequence< rtl::OUString > aHelpIds( 3 ); + aChoices[0] = aLocalizedStrings.GetString( 27 ); aChoicesDisabled[0] = sal_False; - aHelpText[0] = aLocalizedStrings.GetString( 39 ); - aChoices[1] = aLocalizedStrings.GetString( 40 ); + aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) ); + aChoices[1] = aLocalizedStrings.GetString( 28 ); aChoicesDisabled[1] = sal_False; - aHelpText[1] = aLocalizedStrings.GetString( 41 ); - aChoices[2] = aLocalizedStrings.GetString( 42 ); + aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) ); + aChoices[2] = aLocalizedStrings.GetString( 29 ); aChoicesDisabled[2] = sal_Bool(! bHasSelection); - aHelpText[2] = aLocalizedStrings.GetString( 43 ); + aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) ); m_aUIProperties[nIdx++].Value = getChoiceControlOpt( rtl::OUString(), - aHelpText, + aHelpIds, aPrintRangeName, aChoices, bHasSelection ? 2 /*enable 'Selection' radio button*/ : 0 /* enable 'All pages' */, @@ -336,7 +336,7 @@ SwPrintUIOptions::SwPrintUIOptions( // create a an Edit dependent on "Pages" selected vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True ); m_aUIProperties[nIdx++].Value = getEditControlOpt( rtl::OUString(), - rtl::OUString(), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageRange:Edit" ) ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ), rtl::OUString(), aPageRangeOpt @@ -344,31 +344,31 @@ SwPrintUIOptions::SwPrintUIOptions( // print content selection vcl::PrinterOptionsHelper::UIControlOptions aContentsOpt; aContentsOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) ); - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 20 ) ), + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 12 ) ), rtl::OUString(), aContentsOpt ); // create a list box for notes content const sal_Int16 nPrintPostIts = rDefaultPrintData.GetPrintPostIts(); aChoices.realloc( 4 ); - aChoices[0] = aLocalizedStrings.GetString( 21 ); - aChoices[1] = aLocalizedStrings.GetString( 22 ); - aChoices[2] = aLocalizedStrings.GetString( 23 ); - aChoices[3] = aLocalizedStrings.GetString( 24 ); - aHelpText.realloc( 2 ); - aHelpText[0] = aLocalizedStrings.GetString( 25 ); - aHelpText[1] = aLocalizedStrings.GetString( 25 ); + aChoices[0] = aLocalizedStrings.GetString( 13 ); + aChoices[1] = aLocalizedStrings.GetString( 14 ); + aChoices[2] = aLocalizedStrings.GetString( 15 ); + aChoices[3] = aLocalizedStrings.GetString( 16 ); + aHelpIds.realloc( 2 ); + aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintAnnotationMode:FixedText" ) ); + aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintAnnotationMode:ListBox" ) ); vcl::PrinterOptionsHelper::UIControlOptions aAnnotOpt( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), 0, sal_False ); aAnnotOpt.mbEnabled = bHasPostIts; - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 26 ), - aHelpText, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), - aChoices, - nPrintPostIts, - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), - uno::Sequence< sal_Bool >(), - aAnnotOpt - ); + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 17 ), + aHelpIds, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintAnnotationMode" ) ), + aChoices, + nPrintPostIts, + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ), + uno::Sequence< sal_Bool >(), + aAnnotOpt + ); // create subsection for Page settings vcl::PrinterOptionsHelper::UIControlOptions aPageSetOpt; @@ -376,16 +376,16 @@ SwPrintUIOptions::SwPrintUIOptions( if (!bWeb) { - m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 27 ) ), + m_aUIProperties[nIdx++].Value = getSubgroupControlOpt( rtl::OUString( aLocalizedStrings.GetString( 18 ) ), rtl::OUString(), aPageSetOpt ); uno::Sequence< rtl::OUString > aRLChoices( 3 ); - aRLChoices[0] = aLocalizedStrings.GetString( 28 ); - aRLChoices[1] = aLocalizedStrings.GetString( 29 ); - aRLChoices[2] = aLocalizedStrings.GetString( 30 ); + aRLChoices[0] = aLocalizedStrings.GetString( 19 ); + aRLChoices[1] = aLocalizedStrings.GetString( 20 ); + aRLChoices[2] = aLocalizedStrings.GetString( 21 ); uno::Sequence< rtl::OUString > aRLHelp( 1 ); - aRLHelp[0] = aLocalizedStrings.GetString( 31 ); + aRLHelp[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintLeftRightPages:ListBox" ) ); // create a choice option for all/left/right pages // 0 : all pages (left & right) // 1 : left pages @@ -397,7 +397,7 @@ SwPrintUIOptions::SwPrintUIOptions( nPagesChoice = 1; else if (!rDefaultPrintData.IsPrintLeftPage() && rDefaultPrintData.IsPrintRightPage()) nPagesChoice = 2; - m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 32 ), + m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( aLocalizedStrings.GetString( 22 ), aRLHelp, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintLeftRightPages" ) ), aRLChoices, @@ -409,27 +409,29 @@ SwPrintUIOptions::SwPrintUIOptions( // create a bool option for brochure bDefaultVal = rDefaultPrintData.IsPrintProspect(); rtl::OUString aBrochurePropertyName( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ); - m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 33 ), - aLocalizedStrings.GetString( 34 ), - aBrochurePropertyName, - bDefaultVal, - aPageSetOpt - ); + m_aUIProperties[ nIdx++ ].Value = getBoolControlOpt( aLocalizedStrings.GetString( 23 ), + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintProspect:CheckBox" ) ), + aBrochurePropertyName, + bDefaultVal, + aPageSetOpt + ); if (bCTL) { // create a bool option for brochure RTL dependent on brochure uno::Sequence< rtl::OUString > aBRTLChoices( 2 ); - aBRTLChoices[0] = aLocalizedStrings.GetString( 35 ); - aBRTLChoices[1] = aLocalizedStrings.GetString( 36 ); + aBRTLChoices[0] = aLocalizedStrings.GetString( 24 ); + aBRTLChoices[1] = aLocalizedStrings.GetString( 25 ); vcl::PrinterOptionsHelper::UIControlOptions aBrochureRTLOpt( aBrochurePropertyName, -1, sal_True ); + uno::Sequence< rtl::OUString > aBRTLHelpIds( 1 ); + aBRTLHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintProspectRTL:ListBox" ) ); aBrochureRTLOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) ); // RTL brochure choices // 0 : left-to-right // 1 : right-to-left const sal_Int16 nBRTLChoice = rDefaultPrintData.IsPrintProspectRTL() ? 1 : 0; m_aUIProperties[ nIdx++ ].Value = getChoiceControlOpt( rtl::OUString(), - uno::Sequence< rtl::OUString >(), + aBRTLHelpIds, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectRTL" ) ), aBRTLChoices, nBRTLChoice, diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 0bbfc70d5a22..e7addbff63e0 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2731,7 +2731,12 @@ const IDocumentFieldsAccess* ViewShell::getIDocumentFieldsAccess() const { retur IDocumentContentOperations* ViewShell::getIDocumentContentOperations() { return pDoc; } IDocumentStylePoolAccess* ViewShell::getIDocumentStylePoolAccess() { return pDoc; } const IDocumentStatistics* ViewShell::getIDocumentStatistics() const { return pDoc; } -IDocumentUndoRedo* ViewShell::getIDocumentUndoRedoAccess() { return pDoc; } + +IDocumentUndoRedo & ViewShell::GetIDocumentUndoRedo() +{ return pDoc->GetIDocumentUndoRedo(); } +IDocumentUndoRedo const& ViewShell::GetIDocumentUndoRedo() const +{ return pDoc->GetIDocumentUndoRedo(); } + // --> OD 2007-11-14 #i83479# const IDocumentListItems* ViewShell::getIDocumentListItemsAccess() const { diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx index adf37dd11f22..209730ff59dd 100644 --- a/sw/source/core/view/vnew.cxx +++ b/sw/source/core/view/vnew.cxx @@ -32,9 +32,8 @@ #include <sfx2/printer.hxx> #include <rtl/logfile.hxx> #include <doc.hxx> -#ifndef _DOCSH_HXX +#include <IDocumentUndoRedo.hxx> #include <docsh.hxx> -#endif #include <viewsh.hxx> #include <rootfrm.hxx> #include <viewimp.hxx> @@ -220,7 +219,8 @@ ViewShell::ViewShell( SwDoc& rDocument, Window *pWindow, //In Init wird ein Standard-FrmFmt angelegt. // --> OD 2005-02-11 #i38810# - if ( !pDoc->IsUndoNoResetModified() && !bIsDocModified ) + if ( !pDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() + && !bIsDocModified ) // <-- { pDoc->ResetModified(); @@ -293,8 +293,10 @@ ViewShell::ViewShell( ViewShell& rShell, Window *pWindow, SetHiddenFlag( !pOpt->IsShowHiddenField() ); // in Init wird ein Standard-FrmFmt angelegt - if( !bModified && !pDoc->IsUndoNoResetModified() ) + if( !bModified && !pDoc->GetIDocumentUndoRedo().IsUndoNoResetModified() ) + { pDoc->ResetModified(); + } //Format-Cache erweitern. if ( SwTxtFrm::GetTxtCache()->GetCurMax() < 2550 ) diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 83e0289e6082..271ca4e4c463 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -60,6 +60,7 @@ #include <pagefrm.hxx> #include <cntfrm.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <wdocsh.hxx> #include <fesh.hxx> #include <pam.hxx> @@ -270,10 +271,10 @@ void ViewShell::ChgAllPageOrientation( USHORT eOri ) if( rOld.GetLandscape() != bNewOri ) { SwPageDesc aNew( rOld ); - const sal_Bool bDoesUndo( GetDoc()->DoesUndo() ); - GetDoc()->DoUndo( sal_False ); - GetDoc()->CopyPageDesc(rOld, aNew); - GetDoc()->DoUndo( bDoesUndo ); + { + ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo()); + GetDoc()->CopyPageDesc(rOld, aNew); + } aNew.SetLandscape( bNewOri ); SwFrmFmt& rFmt = aNew.GetMaster(); SwFmtFrmSize aSz( rFmt.GetFrmSize() ); @@ -313,10 +314,10 @@ void ViewShell::ChgAllPageSize( Size &rSz ) { const SwPageDesc &rOld = const_cast<const SwDoc *>(pMyDoc)->GetPageDesc( i ); SwPageDesc aNew( rOld ); - const sal_Bool bDoesUndo( GetDoc()->DoesUndo() ); - GetDoc()->DoUndo( sal_False ); - GetDoc()->CopyPageDesc( rOld, aNew ); - GetDoc()->DoUndo( bDoesUndo ); + { + ::sw::UndoGuard const ug(GetDoc()->GetIDocumentUndoRedo()); + GetDoc()->CopyPageDesc( rOld, aNew ); + } SwFrmFmt& rPgFmt = aNew.GetMaster(); Size aSz( rSz ); const BOOL bOri = aNew.GetLandscape(); @@ -443,8 +444,8 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) } // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!) -// if( aDocShellRef.Is() ) -// SwDataExchange::InitOle( aDocShellRef, pPrtDoc ); +//REMOVE // if( aDocShellRef.Is() ) +//REMOVE // SwDataExchange::InitOle( aDocShellRef, pPrtDoc ); // und fuellen es mit dem selektierten Bereich pFESh->Copy( pPrtDoc ); @@ -503,10 +504,6 @@ sal_Bool ViewShell::PrintOrPDFExport( ViewShell *pShell; SwDoc *pOutDevDoc; - //!! muss warum auch immer hier in diesem scope existieren !! - //!! (h?ngt mit OLE Objekten im Dokument zusammen.) - SfxObjectShellRef aDocShellRef; - // Print/PDF export for (multi-)selection has already generated a // temporary document with the selected text. // (see XRenderable implementation in unotxdoc.cxx) diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 282551474e36..64a261fc8ba0 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -54,6 +54,8 @@ #include <mdiexp.hxx> // ...Percent() #include <poolfmt.hxx> +#include "vcl/metric.hxx" + #define ASC_BUFFLEN 4096 class SwASCIIParser @@ -129,24 +131,14 @@ SwASCIIParser::SwASCIIParser(SwDoc* pD, const SwPaM& rCrsr, SvStream& rIn, } if( rOpt.GetFontName().Len() ) { - bool bDelete = false; - const SfxFont* pFnt = 0; + Font aTextFont( rOpt.GetFontName(), Size( 0, 10 ) ); if( pDoc->getPrinter( false ) ) - pFnt = pDoc->getPrinter( false )->GetFontByName( rOpt.GetFontName() ); - - if( !pFnt ) - { - pFnt = new SfxFont( FAMILY_DONTKNOW, rOpt.GetFontName() ); - bDelete = true; - } - SvxFontItem aFont( pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), RES_CHRATR_FONT ); + aTextFont = pDoc->getPrinter( false )->GetFontMetric( aTextFont ); + SvxFontItem aFont( aTextFont.GetFamily(), aTextFont.GetName(), + aEmptyStr, aTextFont.GetPitch(), aTextFont.GetCharSet(), RES_CHRATR_FONT ); pItemSet->Put( aFont ); pItemSet->Put( aFont, RES_CHRATR_CJK_FONT ); pItemSet->Put( aFont, RES_CHRATR_CTL_FONT ); - - if( bDelete ) - delete (SfxFont*)pFnt; } } diff --git a/sw/source/filter/basflt/shellio.cxx b/sw/source/filter/basflt/shellio.cxx index 963c5c847500..80ed9630318c 100644 --- a/sw/source/filter/basflt/shellio.cxx +++ b/sw/source/filter/basflt/shellio.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <tools/date.hxx> #include <tools/time.hxx> @@ -46,6 +47,7 @@ #include <swtypes.hxx> #include <shellio.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <editsh.hxx> #include <undobj.hxx> // fuer Undo Insert-Dokument @@ -131,7 +133,7 @@ ULONG SwReader::Read( const Reader& rOptions ) SwUndoInsDoc* pUndo = 0; BOOL bReadPageDescs = FALSE; - BOOL bDocUndo = pDoc->DoesUndo(); + bool const bDocUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); BOOL bSaveUndo = bDocUndo && pCrsr; if( bSaveUndo ) { @@ -139,15 +141,15 @@ ULONG SwReader::Read( const Reader& rOptions ) if( 0 != ( bReadPageDescs = po->aOpt.IsPageDescs() ) ) { bSaveUndo = FALSE; - pDoc->DelAllUndoObj(); + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); } else { - pDoc->ClearRedo(); - pDoc->StartUndo( UNDO_INSDOKUMENT, NULL ); + pDoc->GetIDocumentUndoRedo().ClearRedo(); + pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSDOKUMENT, NULL ); } } - pDoc->DoUndo( FALSE ); + pDoc->GetIDocumentUndoRedo().DoUndo(false); SwNodeIndex aSplitIdx( pDoc->GetNodes() ); @@ -270,7 +272,11 @@ ULONG SwReader::Read( const Reader& rOptions ) if( bSaveUndo ) { pDoc->SetRedlineMode_intern( eOld ); - pDoc->AppendUndo( new SwUndoInsLayFmt( pFrmFmt,0,0 ) ); + // UGLY: temp. enable undo + pDoc->GetIDocumentUndoRedo().DoUndo(true); + pDoc->GetIDocumentUndoRedo().AppendUndo( + new SwUndoInsLayFmt( pFrmFmt,0,0 ) ); + pDoc->GetIDocumentUndoRedo().DoUndo(false); pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE ); } if( pFrmFmt->GetDepends() ) @@ -314,7 +320,10 @@ ULONG SwReader::Read( const Reader& rOptions ) { pDoc->SetRedlineMode_intern( eOld ); pUndo->SetInsertRange( *pUndoPam, FALSE ); - pDoc->AppendUndo( pUndo ); + // UGLY: temp. enable undo + pDoc->GetIDocumentUndoRedo().DoUndo(true); + pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo ); + pDoc->GetIDocumentUndoRedo().DoUndo(false); pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE ); } @@ -348,15 +357,13 @@ ULONG SwReader::Read( const Reader& rOptions ) pDoc->ChkCondColls(); pDoc->SetAllUniqueFlyNames(); - if( bReadPageDescs ) - pDoc->DoUndo( TRUE ); - else + pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo); + if (!bReadPageDescs) { - pDoc->DoUndo( bDocUndo ); if( bSaveUndo ) { pDoc->SetRedlineMode_intern( eOld ); - pDoc->EndUndo( UNDO_INSDOKUMENT, NULL ); + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSDOKUMENT, NULL ); pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE ); } } @@ -530,12 +537,13 @@ SwDoc* Reader::GetTemplateDoc() { SwDocShell *pDocSh = new SwDocShell ( SFX_CREATE_MODE_INTERNAL ); - SfxObjectShellRef xDocSh = pDocSh; + SfxObjectShellLock xDocSh = pDocSh; if( pDocSh->DoInitNew( 0 ) ) { pTemplate = pDocSh->GetDoc(); pTemplate->SetOle2Link( Link() ); - pTemplate->DoUndo( FALSE ); // always FALSE + // always FALSE + pTemplate->GetIDocumentUndoRedo().DoUndo( false ); pTemplate->set(IDocumentSettingAccess::BROWSE_MODE, bTmplBrowseMode ); pTemplate->RemoveAllFmtLanguageDependencies(); @@ -805,15 +813,12 @@ ULONG SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) SwPaM * pPam; SwDoc *pDoc = 0; - SfxObjectShellRef* pRefForDocSh = 0; if ( pShell && !bWriteAll && pShell->IsTableMode() ) { bWriteAll = TRUE; pDoc = new SwDoc; pDoc->acquire(); - pRefForDocSh = new SfxObjectShellRef(); - pDoc->SetRefForDocShell( pRefForDocSh ); // kopiere Teile aus einer Tabelle: lege eine Tabelle mit der Breite // von der Originalen an und kopiere die selectierten Boxen. @@ -971,7 +976,6 @@ ULONG SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName ) if ( pDoc ) { - delete pRefForDocSh; if ( !pDoc->release() ) delete pDoc; bWriteAll = FALSE; diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx index 6a6bcc04b34c..c81547e66213 100644 --- a/sw/source/filter/html/htmlbas.cxx +++ b/sw/source/filter/html/htmlbas.cxx @@ -271,8 +271,7 @@ void SwHTMLParser::InsertBasicDocEvent( rtl::OUString aEvent, const String& rNam rtl::OUString aEventName; - SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig(); - pECfg->ConfigureEvent( aEvent, SvxMacro( sEvent, sScriptType, eScrType ), + SfxEventConfiguration::ConfigureEvent( aEvent, SvxMacro( sEvent, sScriptType, eScrType ), pDocSh ); } @@ -281,14 +280,11 @@ void SwHTMLWriter::OutBasic() if( !bCfgStarBasic ) return; - SFX_APP()->EnterBasicCall(); - BasicManager *pBasicMan = pDoc->GetDocShell()->GetBasicManager(); ASSERT( pBasicMan, "Wo ist der Basic-Manager?" ); //JP 17.07.96: Bug 29538 - nur das DocumentBasic schreiben if( !pBasicMan || pBasicMan == SFX_APP()->GetBasicManager() ) { - SFX_APP()->LeaveBasicCall(); return; } @@ -335,8 +331,6 @@ void SwHTMLWriter::OutBasic() eDestEnc, &aNonConvertableCharacters ); } } - - SFX_APP()->LeaveBasicCall(); } static const char* aEventNames[] = diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx index 9d05d833c2d2..fdc5f5f90452 100644 --- a/sw/source/filter/html/htmlcss1.cxx +++ b/sw/source/filter/html/htmlcss1.cxx @@ -2077,7 +2077,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( const SfxItemSet & /*rItemSet*/, // sie nicht schon in einem Rahmen stehen und sonst // Rahmengebunden. const SwStartNode *pFlySttNd = - pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode(); + pPam->GetPoint()->nNode.GetNode().FindFlyStartNode(); if( pFlySttNd ) { aAnchor.SetType( FLY_AT_FLY ); diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx index e0f8be92c93e..e973ad3df26d 100644 --- a/sw/source/filter/html/htmldraw.cxx +++ b/sw/source/filter/html/htmldraw.cxx @@ -183,7 +183,7 @@ void SwHTMLParser::InsertDrawObject( SdrObject* pNewDrawObj, SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType ) { const SwStartNode *pFlySttNd = - pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode(); + pPam->GetPoint()->nNode.GetNode().FindFlyStartNode(); if( pFlySttNd ) { @@ -446,8 +446,8 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable ) RES_CHRATR_CTL_POSTURE, RES_CHRATR_CTL_WEIGHT, 0 }; - const SwTxtNode *pTxtNd = pDoc->GetNodes()[pPam->GetPoint()->nNode] - ->GetTxtNode(); + SwTxtNode const*const pTxtNd = + pPam->GetPoint()->nNode.GetNode().GetTxtNode(); if( pTxtNd ) { const SfxItemSet& rItemSet = pTxtNd->GetAnyFmtColl().GetAttrSet(); diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx index a8c0aedc388f..d45202d88c48 100644 --- a/sw/source/filter/html/htmlform.cxx +++ b/sw/source/filter/html/htmlform.cxx @@ -544,7 +544,7 @@ void SwHTMLImageWatcher::init( sal_Int32 Width, sal_Int32 Height ) SwNode *pANd; SwTableNode *pTblNd; if( pAPos && - 0 != (pANd = pDoc->GetNodes()[pAPos->nNode]) && + 0 != (pANd = & pAPos->nNode.GetNode()) && 0 != (pTblNd = pANd->FindTableNode()) ) { const sal_Bool bLastGrf = !pTblNd->GetTable().DecGrfsThatResize(); @@ -1171,7 +1171,7 @@ uno::Reference< drawing::XShape > SwHTMLParser::InsertControl( SVX_CSS1_LTYPE_TWIP == rCSS1PropInfo.eTopType ) { const SwStartNode *pFlySttNd = - pDoc->GetNodes()[pPam->GetPoint()->nNode]->FindFlyStartNode(); + pPam->GetPoint()->nNode.GetNode().FindFlyStartNode(); if( pFlySttNd ) { diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index ac2f348532e8..6494e07f15ad 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -204,7 +204,7 @@ void SwHTMLParser::NewDivision( int nToken ) aDelPam.SetMark(); const SwStartNode *pStNd = - (const SwStartNode *)pDoc->GetNodes()[rCntntStIdx]; + (const SwStartNode *) &rCntntStIdx.GetNode(); aDelPam.GetPoint()->nNode = pStNd->EndOfSectionIndex() - 1; pDoc->DelFullPara( aDelPam ); @@ -261,7 +261,7 @@ void SwHTMLParser::NewDivision( int nToken ) if( !bAppended ) { SwNodeIndex aPrvNdIdx( pPam->GetPoint()->nNode, -1 ); - if( (pDoc->GetNodes()[aPrvNdIdx])->IsSectionNode() ) + if (aPrvNdIdx.GetNode().IsSectionNode()) { AppendTxtNode(); bAppended = sal_True; @@ -350,8 +350,7 @@ void SwHTMLParser::NewDivision( int nToken ) } SwTxtNode* pOldTxtNd = - bAppended ? 0 : pDoc->GetNodes()[pPam->GetPoint()->nNode] - ->GetTxtNode(); + (bAppended) ? 0 : pPam->GetPoint()->nNode.GetNode().GetTxtNode(); pPam->Move( fnMoveBackward ); @@ -438,7 +437,7 @@ void SwHTMLParser::FixHeaderFooterDistance( sal_Bool bHeader, ULONG nPrvNxtIdx; if( bHeader ) { - nPrvNxtIdx = pDoc->GetNodes()[rCntntStIdx]->EndOfSectionIndex()-1; + nPrvNxtIdx = rCntntStIdx.GetNode().EndOfSectionIndex()-1; } else { @@ -689,7 +688,7 @@ void SwHTMLParser::NewMultiCol() // node must be inserted. Otherwise, the new section will be // inserted in front of the old one. SwNodeIndex aPrvNdIdx( pPam->GetPoint()->nNode, -1 ); - if( (pDoc->GetNodes()[aPrvNdIdx])->IsSectionNode() ) + if (aPrvNdIdx.GetNode().IsSectionNode()) { AppendTxtNode(); bAppended = sal_True; @@ -745,8 +744,7 @@ void SwHTMLParser::NewMultiCol() } SwTxtNode* pOldTxtNd = - bAppended ? 0 : pDoc->GetNodes()[pPam->GetPoint()->nNode] - ->GetTxtNode(); + (bAppended) ? 0 : pPam->GetPoint()->nNode.GetNode().GetTxtNode(); pPam->Move( fnMoveBackward ); diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index df9f43fafa41..111fce4863dc 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -2894,7 +2894,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection const SwStartNode *pStNd; if( pTable && pTable->bFirstCell ) { - SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]; + SwNode *const pNd = & pPam->GetPoint()->nNode.GetNode(); pNd->GetTxtNode()->ChgFmtColl( pColl ); pStNd = pNd->FindTableBoxStartNode(); pTable->bFirstCell = sal_False; @@ -2937,7 +2937,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId ) SwTxtFmtColl *pColl = pCSS1Parser->GetTxtCollFromPool( nPoolId ); - SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]; + SwNode *const pNd = & pPam->GetPoint()->nNode.GetNode(); const SwStartNode *pStNd; if( pTable && pTable->bFirstCell ) { @@ -3453,7 +3453,7 @@ void _CellSaveStruct::EndNoBreak( const SwPosition& rPos ) } } -void _CellSaveStruct::CheckNoBreak( const SwPosition& rPos, SwDoc *pDoc ) +void _CellSaveStruct::CheckNoBreak( const SwPosition& rPos, SwDoc * /*pDoc*/ ) { if( pCnts && pCurrCnts==pCnts ) { @@ -3472,8 +3472,7 @@ void _CellSaveStruct::CheckNoBreak( const SwPosition& rPos, SwDoc *pDoc ) } else if( nNoBreakEndCntntPos + 1 == rPos.nContent.GetIndex() ) { - const SwTxtNode *pTxtNd = - pDoc->GetNodes()[rPos.nNode]->GetTxtNode(); + SwTxtNode const*const pTxtNd(rPos.nNode.GetNode().GetTxtNode()); if( pTxtNd ) { sal_Unicode cLast = @@ -3866,11 +3865,11 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions, pPam->Move( fnMoveBackward ); } - const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]; + SwNode const*const pNd = & pPam->GetPoint()->nNode.GetNode(); if( !bAppended && !bForceFrame ) { - SwTxtNode* pOldTxtNd = - pDoc->GetNodes()[pSavePos->nNode]->GetTxtNode(); + SwTxtNode *const pOldTxtNd = + pSavePos->nNode.GetNode().GetTxtNode(); ASSERT( pOldTxtNd, "Wieso stehen wir in keinem Txt-Node?" ); SwFrmFmt *pFrmFmt = pSwTable->GetFrmFmt(); @@ -3939,7 +3938,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions, } } - const SwNode *pNd = pDoc->GetNodes()[pPam->GetPoint()->nNode]; + SwNode const*const pNd = & pPam->GetPoint()->nNode.GetNode(); const SwStartNode *pStNd = (pTable->bFirstCell ? pNd->FindTableNode() : pNd->FindTableBoxStartNode() ); @@ -4043,8 +4042,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, sal_Bool bReadOptions, // koennen wir erneut eine echte Tabelle aufmachen. // Wir erkennen das daran, dass wir keinen // Tabellen-Node mehr finden. - bTopTable = pDoc->GetNodes()[pPam->GetPoint()->nNode] - ->FindTableNode() == 0; + bTopTable = (0 == + pPam->GetPoint()->nNode.GetNode().FindTableNode()); // Wenn im aktuellen Absatz Flys verankert sind, // muss die neue Tabelle in einen Rahmen. diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 230da033d50c..2ba3388d767a 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -87,6 +87,7 @@ #include <docary.hxx> #include <docstat.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pam.hxx> #include <ndtxt.hxx> #include <mdiexp.hxx> // ...Percent() @@ -109,9 +110,7 @@ #include <sfx2/viewfrm.hxx> -#ifndef _STATSTR_HRC #include <statstr.hrc> // ResId fuer Statusleiste -#endif #include <swerror.h> #define FONTSIZE_MASK 7 @@ -631,8 +630,8 @@ void __EXPORT SwHTMLParser::Continue( int nToken ) pDoc->SetOle2Link( Link() ); BOOL bModified = pDoc->IsModified(); - BOOL bWasUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo(); + pDoc->GetIDocumentUndoRedo().DoUndo(false); // Wenn der Import abgebrochen wird, kein Continue mehr rufen. // Falls ein Pending-Stack existiert aber durch einen Aufruf @@ -889,8 +888,8 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) { if( bWasUndo ) { - pDoc->DelAllUndoObj(); - pDoc->DoUndo( TRUE ); + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + pDoc->GetIDocumentUndoRedo().DoUndo(true); } else if( !pInitVSh ) { @@ -900,7 +899,9 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) // wir muessen das Undo noch anschalten. ViewShell *pTmpVSh = CheckActionViewShell(); if( pTmpVSh ) - pDoc->DoUndo( TRUE ); + { + pDoc->GetIDocumentUndoRedo().DoUndo(true); + } } pDoc->SetOle2Link( aOLELink ); @@ -951,7 +952,7 @@ void SwHTMLParser::DocumentDetected() CallEndAction( TRUE, TRUE ); - pDoc->DoUndo( FALSE ); + pDoc->GetIDocumentUndoRedo().DoUndo(false); // Durch das DocumentDetected wurde im allgemeinen eine // ViewShell angelegt. Es kann aber auch sein, dass sie // erst spaeter angelegt wird, naemlich dann, wenn die UI @@ -1461,8 +1462,7 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) if( nPos ) { const String& rText = - pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->GetTxtNode() - ->GetTxt(); + pPam->GetPoint()->nNode.GetNode().GetTxtNode()->GetTxt(); sal_Unicode cLast = rText.GetChar(--nPos); if( ' ' == cLast || '\x0a' == cLast) aToken.Erase(0,1); @@ -2111,7 +2111,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) if( AM_SPACE==eMode || AM_NOSPACE==eMode ) { SwTxtNode *pTxtNode = - pDoc->GetNodes()[pPam->GetPoint()->nNode]->GetTxtNode(); + pPam->GetPoint()->nNode.GetNode().GetTxtNode(); const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)pTxtNode->SwCntntNode::GetAttr( RES_UL_SPACE ); @@ -2426,8 +2426,10 @@ void SwHTMLParser::Show() // ist der aktuelle Node nicht mehr sichtbar, dann benutzen wir // eine groessere Schrittweite if( pVSh ) - nParaCnt = pDoc->GetNodes()[pPam->GetPoint()->nNode] - ->IsInVisibleArea(pVSh) ? 5 : 50; + { + nParaCnt = (pPam->GetPoint()->nNode.GetNode().IsInVisibleArea(pVSh)) + ? 5 : 50; + } } void SwHTMLParser::ShowStatline() @@ -2656,7 +2658,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, } - pCNd = pDoc->GetNodes()[ pAttr->nSttPara ]->GetCntntNode(); + pCNd = pAttr->nSttPara.GetNode().GetCntntNode(); if( !pCNd ) { // durch die elende Loescherei von Nodes kann auch mal @@ -2696,7 +2698,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, if ( (pAttr->GetSttPara() != pAttr->GetEndPara()) && !isTXTATR_NOEND(nWhich) ) { - pCNd = pDoc->GetNodes()[ pAttr->nEndPara ]->GetCntntNode(); + pCNd = pAttr->nEndPara.GetNode().GetCntntNode(); if( !pCNd ) { pCNd = pDoc->GetNodes().GoPrevious( &(pAttr->nEndPara) ); @@ -2888,7 +2890,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, { pAttr = aFields[0]; - pCNd = pDoc->GetNodes()[ pAttr->nSttPara ]->GetCntntNode(); + pCNd = pAttr->nSttPara.GetNode().GetCntntNode(); pAttrPam->GetPoint()->nNode = pAttr->nSttPara; pAttrPam->GetPoint()->nContent.Assign( pCNd, pAttr->nSttCntnt ); diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index 5303ad26dcba..0309d85833ed 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -115,7 +115,7 @@ int SwFlySave::IsEqualFly( const SwPaM& rPos, SfxItemSet& rSet ) else { SwNodeIndex aIdx( nEndNd ); - SwCntntNode* pCNd = rPos.GetDoc()->GetNodes()[ aIdx ]->GetCntntNode(); + SwCntntNode *const pCNd = aIdx.GetNode().GetCntntNode(); if( !GoNextNds( &aIdx, TRUE ) || aIdx.GetIndex() != rPos.GetPoint()->nNode.GetIndex() || ( pCNd && pCNd->Len() != nEndCnt )) @@ -287,7 +287,7 @@ void SwRTFParser::SetFlysInDoc() if( n + 1 < aFlyArr.Count() && pFlySave->nEndCnt && pFlySave->nEndNd == aFlyArr[ n + 1 ]->nSttNd ) { - SwCntntNode* pCNd = rNds[ pFlySave->nEndNd ]->GetCntntNode(); + SwCntntNode *const pCNd = pFlySave->nEndNd.GetNode().GetCntntNode(); if( pCNd ) { SwPosition aPos( pFlySave->nEndNd, @@ -1375,7 +1375,7 @@ void SwRTFParser::_SetPictureSize( const SwNoTxtNode& rNd, } //steht der Fly etwa in einer Tabelle ? - const SwNode* pAnchorNd = pDoc->GetNodes()[ rAnchor ]; + const SwNode* pAnchorNd = & rAnchor.GetNode(); const SwTableNode* pTblNd = pAnchorNd->FindTableNode(); if( pTblNd ) { diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx index 6737ebce596e..8a7f38044ecb 100644 --- a/sw/source/filter/rtf/rtftbl.cxx +++ b/sw/source/filter/rtf/rtftbl.cxx @@ -181,7 +181,7 @@ void SwRTFParser::ReadTable( int nToken ) // wenn schon in einer Tabellen, dann splitte oder benutze // die bisherigen Boxen weiter - bChkExistTbl = 0 != pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->FindTableNode(); + bChkExistTbl = 0 != pPam->GetPoint()->nNode.GetNode().FindTableNode(); } else { @@ -919,7 +919,7 @@ void SwRTFParser::GotoNextBox() // dann hinter die Tabelle pPam->Move( fnMoveForward, fnGoNode ); } - else if( !pDoc->GetNodes()[ pPam->GetPoint()->nNode ]->IsCntntNode() ) + else if (pPam->GetPoint()->nNode.GetNode().IsCntntNode()) // dann in die vorherige ans Ende pPam->Move( fnMoveBackward, fnGoCntnt ); } diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 0c23218092d5..629c7f068dc9 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -1015,8 +1015,7 @@ void rtfSections::InsertSegments(bool bNewDoc) } const SwPosition* pPos = aSectPaM.GetPoint(); - const SwTxtNode* pSttNd = - mrReader.pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); + SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode(); const SwTableNode* pTableNd = pSttNd ? pSttNd->FindTableNode() : 0; if (pTableNd) { diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 2a77d47dd65b..f11cbd751c8e 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -223,10 +223,10 @@ sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const } -SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray ) +SwPaM * +Writer::NewSwPaM(SwDoc & rDoc, ULONG const nStartIdx, ULONG const nEndIdx) { - SwNodes* pNds = bNodesArray ? &rDoc.GetNodes() : (SwNodes*)rDoc.GetUndoNds(); + SwNodes *const pNds = &rDoc.GetNodes(); SwNodeIndex aStt( *pNds, nStartIdx ); SwCntntNode* pCNode = aStt.GetNode().GetCntntNode(); diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 2cf1ca325a5b..a110e4003263 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -79,7 +79,7 @@ using namespace com::sun::star; static SwCntntNode* GetCntntNode(SwDoc* pDoc, SwNodeIndex& rIdx, BOOL bNext) { - SwCntntNode* pCNd = pDoc->GetNodes()[ rIdx ]->GetCntntNode(); + SwCntntNode * pCNd = rIdx.GetNode().GetCntntNode(); if(!pCNd && 0 == (pCNd = bNext ? pDoc->GetNodes().GoNext(&rIdx) : pDoc->GetNodes().GoPrevious(&rIdx))) { @@ -368,12 +368,12 @@ static void MakeBookRegionOrPoint(SwFltStackEntry* pEntry, SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ) { if (pEntry->MakeRegion(pDoc, rRegion, bCheck )){ - const SwNodes& rNds = pDoc->GetNodes(); // BOOL b1 = rNds[rRegion.GetPoint()->nNode]->FindTableNode() != 0; // const SwStartNode* p1 = rNds[rRegion.GetPoint()->nNode]->FindTableBoxStartNode(); // const SwStartNode* p2 = rNds[rRegion.GetMark()->nNode]->FindTableBoxStartNode(); - if( rNds[rRegion.GetPoint()->nNode]->FindTableBoxStartNode() - != rNds[rRegion.GetMark()->nNode]->FindTableBoxStartNode() ){ + if (rRegion.GetPoint()->nNode.GetNode().FindTableBoxStartNode() + != rRegion.GetMark()->nNode.GetNode().FindTableBoxStartNode()) + { rRegion.Exchange(); // Ungueltiger Bereich rRegion.DeleteMark(); // -> beide auf Mark } @@ -632,7 +632,7 @@ const SfxPoolItem* SwFltControlStack::GetFmtAttr(const SwPosition& rPos, USHORT // im Stack ist das Attribut nicht vorhanden, also befrage das Dokument // SwCntntNode * pNd = rPaM.GetCntntNode(); - SwCntntNode * pNd = pDoc->GetNodes()[ rPos.nNode ]->GetCntntNode(); + SwCntntNode * pNd = rPos.nNode.GetNode().GetCntntNode(); if (!pNd) // kein ContentNode, dann das dflt. Attribut return &pDoc->GetAttrPool().GetDefaultItem(nWhich); @@ -1205,8 +1205,7 @@ const SfxPoolItem& SwFltFormatCollection::GetAttr(USHORT nWhich) const SfxPoolItem& SwFltOutDoc::GetNodeOrStyAttr(USHORT nWhich) { - SwCntntNode * pNd = GetDoc().GetNodes()[ pPaM->GetPoint()->nNode ] - ->GetCntntNode(); + SwCntntNode * pNd = pPaM->GetPoint()->nNode.GetNode().GetCntntNode(); if (pNd) // ContentNode: Attribut mit Parent return pNd->GetAttr(nWhich); else // kein ContentNode, dann das dflt. Attribut diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0a6151b98388..0ab613730948 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -32,7 +32,7 @@ #include "wrtww8.hxx" #include "ww8par.hxx" -#include <oox/core/tokens.hxx> +#include <oox/token/tokens.hxx> #include <oox/export/drawingml.hxx> #include <oox/export/utils.hxx> #include <oox/export/vmlexport.hxx> @@ -128,6 +128,7 @@ using rtl::OUString; using rtl::OUStringBuffer; using rtl::OUStringToOString; +using namespace oox; using namespace docx; using namespace sax_fastparser; using namespace nsSwDocInfoSubType; diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 35c126cd6571..a4b5fb3a9514 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -32,7 +32,7 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/i18n/ScriptType.hdl> -#include <oox/core/tokens.hxx> +#include <oox/token/tokens.hxx> #include <oox/export/drawingml.hxx> #include <oox/export/vmlexport.hxx> @@ -62,6 +62,7 @@ using namespace ::comphelper; using namespace ::com::sun::star; +using namespace ::oox; using oox::vml::VMLExport; diff --git a/sw/source/filter/ww8/docxfootnotes.hxx b/sw/source/filter/ww8/docxfootnotes.hxx index b9d49f78f560..ec91731bc6dd 100644 --- a/sw/source/filter/ww8/docxfootnotes.hxx +++ b/sw/source/filter/ww8/docxfootnotes.hxx @@ -30,7 +30,6 @@ #include <fmtftn.hxx> -#include <oox/core/tokens.hxx> #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <sax/fshelper.hxx> diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 7d8bc56272b7..9ae2cf4ce442 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -219,7 +219,7 @@ bool WW8Glossary::Load( SwTextBlocks &rBlocks, bool bSaveRelFile ) if ( 0 != (nStrings = static_cast< USHORT >(aStrings.size()))) { - SfxObjectShellRef xDocSh(new SwDocShell(SFX_CREATE_MODE_INTERNAL)); + SfxObjectShellLock xDocSh(new SwDocShell(SFX_CREATE_MODE_INTERNAL)); if (xDocSh->DoInitNew(0)) { SwDoc *pD = ((SwDocShell*)(&xDocSh))->GetDoc(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 21804b38dca9..e1a0fbc1f5b1 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1007,7 +1007,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetFmtAttr(const SwPosition& rPos, const SfxPoolItem *pItem = GetStackAttr(rPos, nWhich); if (!pItem) { - const SwCntntNode *pNd = pDoc->GetNodes()[ rPos.nNode ]->GetCntntNode(); + SwCntntNode const*const pNd = rPos.nNode.GetNode().GetCntntNode(); if (!pNd) pItem = &pDoc->GetAttrPool().GetDefaultItem(nWhich); else @@ -3609,8 +3609,7 @@ void wwSectionManager::InsertSegments() } const SwPosition* pPos = aSectPaM.GetPoint(); - const SwTxtNode* pSttNd = - mrReader.rDoc.GetNodes()[ pPos->nNode ]->GetTxtNode(); + SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode(); const SwTableNode* pTableNd = pSttNd ? pSttNd->FindTableNode() : 0; if (pTableNd) { @@ -4025,8 +4024,7 @@ ULONG SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) // evtl. Zeilen eingefuegt / aufgebrochen werden // const SwPosition* pPos = pPaM->GetPoint(); - const SwTxtNode* pSttNd = - rDoc.GetNodes()[ pPos->nNode ]->GetTxtNode(); + SwTxtNode const*const pSttNd = pPos->nNode.GetNode().GetTxtNode(); USHORT nCntPos = pPos->nContent.GetIndex(); diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index f848b6332c38..059f33634424 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -2505,7 +2505,7 @@ void WW8TabDesc::CreateSwTable() // ein Pagedesc steht. Dann wuerde der PageDesc in die naechste Zeile // hinter der Tabelle rutschen, wo er nichts zu suchen hat. -> loeschen // und spaeter an das Tabellenformat setzen - if (SwTxtNode* pNd = pIo->rDoc.GetNodes()[pTmpPos->nNode]->GetTxtNode()) + if (SwTxtNode *const pNd = pTmpPos->nNode.GetNode().GetTxtNode()) { if (const SfxItemSet* pSet = pNd->GetpSwAttrSet()) { diff --git a/sw/source/filter/xml/xmliteme.cxx b/sw/source/filter/xml/xmliteme.cxx index 5645891c5b3c..05c30ce7b496 100644 --- a/sw/source/filter/xml/xmliteme.cxx +++ b/sw/source/filter/xml/xmliteme.cxx @@ -40,7 +40,7 @@ #include "xmlbrshe.hxx" #include <editeng/tstpitem.hxx> #include <editeng/brshitem.hxx> -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> #include <swmodule.hxx> #include <doc.hxx> #include "fmtornt.hxx" diff --git a/sw/source/ui/app/appenv.cxx b/sw/source/ui/app/appenv.cxx index ce06c22cfc88..ee2e686a8400 100644 --- a/sw/source/ui/app/appenv.cxx +++ b/sw/source/ui/app/appenv.cxx @@ -189,7 +189,7 @@ static USHORT nTitleNo = 0; pOldSh = pMyDocSh ? pMyDocSh->GetWrtShell() : 0; // Neues Dokument erzeugen (kein Show!) - SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); + SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); xDocSh->DoInitNew( 0 ); pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); pNewView = (SwView*) pFrame->GetViewShell(); diff --git a/sw/source/ui/app/apphdl.cxx b/sw/source/ui/app/apphdl.cxx index 653208aaf250..8e939c88fd37 100644 --- a/sw/source/ui/app/apphdl.cxx +++ b/sw/source/ui/app/apphdl.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <tools/urlobj.hxx> @@ -71,9 +72,7 @@ #include <srcview.hxx> #include <wrtsh.hxx> #include <docsh.hxx> -#ifndef _CMDID_H #include <cmdid.h> // Funktion-Ids -#endif #include <initui.hxx> #include <uitool.hxx> #include <swmodule.hxx> @@ -83,13 +82,12 @@ #include <gloslst.hxx> // SwGlossaryList #include <glosdoc.hxx> // SwGlossaryList #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <cfgitems.hxx> #include <prtopt.hxx> #include <modcfg.hxx> #include <globals.h> // globale Konstanten z.B. -#ifndef _APP_HRC #include <app.hrc> -#endif #include <fontcfg.hxx> #include <barcfg.hxx> #include <uinums.hxx> @@ -802,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()->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 ) { @@ -968,7 +962,7 @@ void NewXForms( SfxRequest& rReq ) // copied & excerpted from SwModule::InsertLab(..) // create new document - SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD) ); + SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD) ); xDocSh->DoInitNew( 0 ); // initialize XForms diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx index 41f055f86050..1bbdfc71eeb4 100644 --- a/sw/source/ui/app/applab.cxx +++ b/sw/source/ui/app/applab.cxx @@ -209,7 +209,7 @@ static sal_uInt16 nBCTitleNo = 0; aLabCfg.Commit(); // Neues Dokument erzeugen. - SfxObjectShellRef xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD)); + SfxObjectShellLock xDocSh( new SwDocShell( SFX_CREATE_MODE_STANDARD)); xDocSh->DoInitNew( 0 ); // Drucker diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index a1e6cef80cd1..0b6b728f18f7 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -246,8 +246,8 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) /*-----------------01.02.97 13.02------------------- Optionen fuer PrintTabPage --------------------------------------------------*/ - SwPrintData* pOpt = pAppView ? - pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() : + const SwPrintData* pOpt = pAppView ? + &pAppView->GetWrtShell().getIDocumentDeviceAccess()->getPrintData() : 0; if(!pOpt) diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index c839b5c03f52..c1704f21d0f0 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -81,6 +81,7 @@ #include <shellio.hxx> // I/O #include <docstyle.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <docstat.hxx> #include <pagedesc.hxx> #include <pview.hxx> @@ -468,7 +469,9 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) // will set the wrong class id. SvGlobalName aClassName; String aAppName, aLongUserName, aUserName; - SfxObjectShellRef xDocSh = + + // The document is closed explicitly, but using SfxObjectShellLock is still more correct here + SfxObjectShellLock xDocSh = new SwGlobalDocShell( SFX_CREATE_MODE_INTERNAL ); // the global document can not be a template xDocSh->SetupStorage( xStor, SotStorage::GetVersion( xStor ), sal_False ); @@ -492,7 +495,7 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) // Modified-Flag merken und erhalten ohne den Link zu Callen // (fuer OLE; nach Anweisung von MM) BOOL bIsModified = pDoc->IsModified(); - SwUndoNoModifiedPosition aOldPos = pDoc->getUndoNoModifiedPosition(); + pDoc->GetIDocumentUndoRedo().LockUndoNoModifiedPosition(); Link aOldOLELnk( pDoc->GetOle2Link() ); pDoc->SetOle2Link( Link() ); @@ -519,7 +522,7 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) if( bIsModified ) { pDoc->SetModified(); - pDoc->setUndoNoModifiedPosition( aOldPos ); + pDoc->GetIDocumentUndoRedo().UnLockUndoNoModifiedPosition(); } pDoc->SetOle2Link( aOldOLELnk ); @@ -701,25 +704,6 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) GetDoc()->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bIsGlblDocSaveLinksSave); } - if( bRet && nMyType != nSaveType ) - { - SvGlobalName aClassName; - String aAppName, aLongUserName, aUserName; - SfxObjectShellRef xDocSh; - switch( nSaveType ) - { - case 0: - xDocSh = new SwDocShell( SFX_CREATE_MODE_INTERNAL ); - break; - case 1: - xDocSh = new SwWebDocShell( SFX_CREATE_MODE_INTERNAL ); - break; - case 2: - xDocSh = new SwGlobalDocShell( SFX_CREATE_MODE_INTERNAL ); - break; - } - } - return bRet; } diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 5bbc29aab2ee..263e3274972b 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -44,9 +44,7 @@ #include <svl/zformat.hxx> #include <unotools/pathoptions.hxx> #include <svtools/transfer.hxx> -#ifndef _SFXSIDS_HRC //autogen #include <sfx2/dialogs.hrc> -#endif #include <sfx2/dinfdlg.hxx> #include <sfx2/request.hxx> #include <sfx2/dispatch.hxx> @@ -57,9 +55,7 @@ #include <svtools/sfxecode.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> -#ifndef _SVX_SVXIDS_HRC //autogen #include <svx/svxids.hrc> -#endif #include <svx/drawitem.hxx> #include <editeng/svxacorr.hxx> #include <editeng/langitem.hxx> @@ -86,6 +82,7 @@ #include <redlndlg.hxx> #include <docstyle.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagedesc.hxx> #include <shellio.hxx> #include <pview.hxx> @@ -103,15 +100,9 @@ #include <cmdid.h> #include <globals.h> #include <helpid.h> -#ifndef _APP_HRC #include <app.hrc> -#endif -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> @@ -342,8 +333,7 @@ BOOL SwDocShell::Insert( SfxObjectShell &rSource, // --> OD 2005-05-10 #i48949# - actions aren't undoable. Thus, allow no undo // actions // Note: The undo action stack is cleared at the end of this method. - bool bDoesUndo( GetDoc()->DoesUndo() ); - GetDoc()->DoUndo( sal_False ); + ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo()); // <-- BOOL bRet = FALSE; @@ -542,11 +532,10 @@ BOOL SwDocShell::Insert( SfxObjectShell &rSource, // --> OD 2005-05-10 #i48949# - actions aren't undoable and could have change // the document node array. Thus, clear the undo action stack. - if ( bDoesUndo ) + if (undoGuard.UndoWasEnabled()) { - GetDoc()->DelAllUndoObj(); + GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); } - GetDoc()->DoUndo( bDoesUndo ); // <-- return bRet; @@ -947,12 +936,11 @@ void SwDocShell::Execute(SfxRequest& rReq) aTempFile.EnableKillingFile(); pSrcView->SaveContent(aTempFile.GetURL()); bDone = TRUE; - SfxEventConfiguration* pEvent = SFX_APP()->GetEventConfig(); SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC); - pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); - pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); - pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); - pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); + SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); + SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); + SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); + SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); ReloadFromHtml(aTempFile.GetURL(), pSrcView); nSlot = 0; } @@ -1013,7 +1001,7 @@ void SwDocShell::Execute(SfxRequest& rReq) BYTE nLevel = pDlg->GetLevel(); BYTE nPara = pDlg->GetPara(); SwDoc* pSmryDoc = new SwDoc(); - SfxObjectShellRef xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD)); + SfxObjectShellLock xDocSh( new SwDocShell( pSmryDoc, SFX_CREATE_MODE_STANDARD)); xDocSh->DoInitNew( 0 ); BOOL bImpress = FN_ABSTRACT_STARIMPRESS == nWhich; @@ -1637,7 +1625,9 @@ void SwDocShell::SetModified( BOOL bSet ) BOOL bOld = pDoc->IsModified(); pDoc->SetModified(); if( !bOld ) - pDoc->SetUndoNoResetModified(); + { + pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } } else pDoc->ResetModified(); @@ -1697,9 +1687,6 @@ void SwDocShell::ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView ClearHeaderAttributesForSourceViewHack(); // MIB 24.07.97: Das Dokument-Basic muss auch noch d'ran glauben ... - // Ein EnterBasicCall braucht man hier nicht, weil man nichts ruft und - // in HTML-Dokument kein Dok-Basic vorhanden sein kann, das noch nicht - // geladen wurde. SvxHtmlOptions* pHtmlOptions = SvxHtmlOptions::Get(); //#59620# HasBasic() zeigt an, dass es schon einen BasicManager an der DocShell // gibt. Der wurde im HTML-Import immer angelegt, wenn Macros im Quelltext diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index 98fe7316ecd5..d4b15b7febd0 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -210,21 +210,15 @@ sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) if(!pStdFont->IsFontDefault(nFontId)) { sEntry = pStdFont->GetFontFor(nFontId); - sal_Bool bDelete = sal_False; - const SfxFont* pFnt = pPrt ? pPrt->GetFontByName(sEntry): 0; - if(!pFnt) - { - pFnt = new SfxFont( FAMILY_DONTKNOW, sEntry, PITCH_DONTKNOW, - ::gsl_getSystemTextEncoding() ); - bDelete = sal_True; - } - pFontItem = new SvxFontItem(pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), nFontWhich); - if(bDelete) + + Font aFont( sEntry, Size( 0, 10 ) ); + if( pPrt ) { - delete (SfxFont*) pFnt; - bDelete = sal_False; + aFont = pPrt->GetFontMetric( aFont ); } + + pFontItem = new SvxFontItem(aFont.GetFamily(), aFont.GetName(), + aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich); } else { @@ -303,25 +297,18 @@ sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) if(!pStdFont->IsFontDefault(aFontIdPoolId[nIdx])) { sEntry = pStdFont->GetFontFor(aFontIdPoolId[nIdx]); - sal_Bool bDelete = sal_False; - const SfxFont* pFnt = pPrt ? pPrt->GetFontByName(sEntry): 0; - if(!pFnt) - { - pFnt = new SfxFont( FAMILY_DONTKNOW, sEntry, PITCH_DONTKNOW, - ::gsl_getSystemTextEncoding() ); - bDelete = sal_True; - } + + Font aFont( sEntry, Size( 0, 10 ) ); + if( pPrt ) + aFont = pPrt->GetFontMetric( aFont ); + pColl = pDoc->GetTxtCollFromPool(aFontIdPoolId[nIdx + 1]); if( !bHTMLTemplSet || SFX_ITEM_SET != pColl->GetAttrSet().GetItemState( nFontWhich, sal_False ) ) { - pColl->SetFmtAttr(SvxFontItem(pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), nFontWhich)); - } - if(bDelete) - { - delete (SfxFont*) pFnt; + pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(), + aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich)); } } sal_Int32 nFontHeight = pStdFont->GetFontHeight( static_cast< sal_Int8 >(aFontIdPoolId[nIdx]), 0, eLanguage ); diff --git a/sw/source/ui/app/docst.cxx b/sw/source/ui/app/docst.cxx index d06ab31b7478..60206f764663 100644 --- a/sw/source/ui/app/docst.cxx +++ b/sw/source/ui/app/docst.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameAccess.hpp> @@ -52,7 +53,8 @@ #include <fchrfmt.hxx> #include <svtools/htmlcfg.hxx> #include <SwStyleNameMapper.hxx> -#include <undobj.hxx> +#include <SwRewriter.hxx> +#include <numrule.hxx> #include <swundo.hxx> #include "view.hxx" @@ -62,7 +64,8 @@ #include "cmdid.h" #include "globals.hrc" #include "viewopt.hxx" -#include "doc.hxx" +#include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include "swstyle.h" #include "frmfmt.hxx" #include "charfmt.hxx" @@ -751,7 +754,9 @@ USHORT SwDocShell::Edit( const String &rName, const String &rParent, USHORT nFam pDoc->SetModified(); if( !bModified ) // Bug 57028 - pDoc->SetUndoNoResetModified(); + { + pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } GetWrtShell()->EndAllAction(); } @@ -761,8 +766,8 @@ USHORT SwDocShell::Edit( const String &rName, const String &rParent, USHORT nFam { // #116530# //pBasePool->Erase( &aTmp ); - GetWrtShell()->Undo(UNDO_EMPTY, 1); - pDoc->ClearRedo(); + GetWrtShell()->Undo(1); + pDoc->GetIDocumentUndoRedo().ClearRedo(); } if( !bModified ) @@ -814,7 +819,9 @@ USHORT SwDocShell::Edit( const String &rName, const String &rParent, USHORT nFam pDoc->SetModified(); if( !bModified ) // Bug 57028 - pDoc->SetUndoNoResetModified(); + { + pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); + } GetWrtShell()->EndAllAction(); } @@ -1003,7 +1010,7 @@ USHORT SwDocShell::UpdateStyle(const String &rName, USHORT nFamily, SwWrtShell* // Vorlage auch anwenden, um harte Attributierung // zu entfernen GetWrtShell()->SetTxtFmtColl( pColl ); - GetWrtShell()->EndUndo(UNDO_INSFMTATTR, NULL); + GetWrtShell()->EndUndo(); GetWrtShell()->EndAllAction(); } break; @@ -1200,7 +1207,7 @@ USHORT SwDocShell::MakeByExample( const String &rName, USHORT nFamily, rDest.SetPoolHlpFileId( nHFId ); // werden Kopf-/Fusszeilen angelegt, so gibt es kein Undo mehr! - pCurrWrtShell->GetDoc()->DelAllUndoObj(); + pCurrWrtShell->GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj(); pCurrWrtShell->EndAllAction(); } @@ -1274,7 +1281,7 @@ void SwDocShell::_LoadStyles( SfxObjectShell& rSource, BOOL bPreserveCurrentDocu { // die View wird spaeter angelegt, ueberschreibt aber das // Modify-Flag. Per Undo ist sowieso nichts mehr zu machen - pDoc->SetUndoNoResetModified(); + pDoc->GetIDocumentUndoRedo().SetUndoNoResetModified(); } } } diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index b0b81c5df6e4..e3d47a82b38f 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -54,6 +54,7 @@ #include <docary.hxx> #include <ccoll.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <cmdid.h> #include <swstyle.h> #include <app.hrc> @@ -68,7 +69,6 @@ #include <svx/svxids.hrc> // --> OD 2008-02-12 #newlistlevelattrs# #include <SwRewriter.hxx> -#include <undobj.hxx> // <-- // MD 06.02.95: Die Formatnamen in der Liste aller Namen haben als @@ -844,11 +844,11 @@ BOOL SwDocStyleSheet::SetName( const String& rStr) String aOldName(aPageDesc.GetName()); aPageDesc.SetName( rStr ); - BOOL bDoesUndo = rDoc.DoesUndo(); + bool const bDoesUndo = rDoc.GetIDocumentUndoRedo().DoesUndo(); - rDoc.DoUndo(aOldName.Len() > 0); + rDoc.GetIDocumentUndoRedo().DoUndo(aOldName.Len() > 0); rDoc.ChgPageDesc(aOldName, aPageDesc); - rDoc.DoUndo(bDoesUndo); + rDoc.GetIDocumentUndoRedo().DoUndo(bDoesUndo); // <- #116530# rDoc.SetModified(); @@ -1140,11 +1140,11 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, ASSERT( &rSet != &aCoreSet, "SetItemSet mit eigenem Set ist nicht erlaubt" ); // --> OD 2008-02-12 #newlistlevelattrs# - if ( rDoc.DoesUndo() ) + if (rDoc.GetIDocumentUndoRedo().DoesUndo()) { SwRewriter aRewriter; aRewriter.AddRule( UNDO_ARG1, GetName() ); - rDoc.StartUndo( UNDO_INSFMTATTR, &aRewriter ); + rDoc.GetIDocumentUndoRedo().StartUndo( UNDO_INSFMTATTR, &aRewriter ); } // <-- @@ -1310,10 +1310,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, pNewDsc = new SwPageDesc( *pDesc ); // --> OD 2005-05-09 #i48949# - no undo actions for the // copy of the page style - const sal_Bool bDoesUndo( rDoc.DoesUndo() ); - rDoc.DoUndo( sal_False ); + ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo()); rDoc.CopyPageDesc(*pDesc, *pNewDsc); // #i7983# - rDoc.DoUndo( bDoesUndo ); // <-- pFmt = &pNewDsc->GetMaster(); @@ -1409,9 +1407,9 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet, } // --> OD 2008-02-12 #newlistlevelattrs# - if ( rDoc.DoesUndo() ) + if (rDoc.GetIDocumentUndoRedo().DoesUndo()) { - rDoc.EndUndo( UNDO_INSFMTATTR, NULL ); + rDoc.GetIDocumentUndoRedo().EndUndo(UNDO_END, 0); } // <-- } diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index 0f0eddc5d9ed..400b3439b795 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -1035,7 +1035,6 @@ TabPage TP_OPTSHDWCRSR }; }; - StringArray STR_PRINTOPTUI { ItemList [en-US] = @@ -1043,47 +1042,33 @@ StringArray STR_PRINTOPTUI < "%PRODUCTNAME %s"; >; < "Contents"; >; < "Page ba~ckground"; >; - < "Specifies whether to include colors and objects that are inserted to the background of the page (Format - Page - Background) in the printed document."; >; < "P~ictures and other graphic objects"; >; - < "Specifies whether the graphics and drawing or OLE objects of your text document are printed"; >; < "Hidden te~xt"; >; - < "Enable this option to print text that is marked as hidden."; >; < "~Text placeholders"; >; - < "Enable this option to print text placeholders. Disable this option to leave the text placeholders blank in the printout."; >; < "Form control~s"; >; - < "Specifies whether the form control fields of the text document are printed"; >; < "Color"; >; < "Print text in blac~k"; >; - < "Specifies whether to always print text in black."; >; < "Pages"; >; < "Print ~automatically inserted blank pages"; >; - < "If this option is enabled automatically inserted blank pages are printed. This is best if you are printing double-sided. For example, in a book, a \"chapter\" paragraph style has been set to always start with an odd numbered page. If the previous chapter ends on an odd page, %PRODUCTNAME inserts an even numbered blank page. This option controls whether to print that even numbered page or not"; >; < "~Use only paper tray from printer preferences"; >; - < "For printers with multiple trays this option specifies whether the paper tray used is specified by the system settings of the printer."; >; < "Print"; >; < "None (document only)"; >; < "Comments only"; >; < "Place at end of document"; >; < "Place at end of page"; >; - < "Specify where to print comments (if any)."; >; < "~Comments"; >; < "Page sides";>; < "All pages"; >; < "Back sides / left pages"; >; < "Front sides / right pages"; >; - < "Specify which pages to include in the output"; >; < "Include"; >; < "Broch~ure"; >; - < "Select the Brochure option to print the document in brochure format."; >; < "Left-to-right script"; >; < "Right-to-left script"; >; < "Range and copies"; >; < "~All pages"; >; - < "Print the whole document."; >; < "Pa~ges"; >; - < "Print a range of pages of the document."; >; < "~Selection"; >; - < "Print only the selected parts of the document"; >; }; }; diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index 4a0c9c2a6b25..b1f3bd899018 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -34,13 +34,9 @@ #include <tools/shl.hxx> #include <swtypes.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif #include <uiitems.hxx> -#ifndef _MODCFG_HXX #include <modcfg.hxx> -#endif #include "swmodule.hxx" #include "usrpref.hxx" #include "wrtsh.hxx" @@ -65,9 +61,7 @@ #include <sot/clsids.hxx> #include <unotools/configmgr.hxx> #include <docsh.hxx> -#ifndef _CONFIG_HRC #include <config.hrc> -#endif #include <SwStyleNameMapper.hxx> #include <numrule.hxx> #include <SwNodeNum.hxx> diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx index 6e6ed773a33d..01ef0a4f7500 100644 --- a/sw/source/ui/config/optpage.cxx +++ b/sw/source/ui/config/optpage.cxx @@ -726,20 +726,12 @@ void lcl_SetColl(SwWrtShell* pWrtShell, USHORT nType, SfxPrinter* pPrt, const String& rStyle, USHORT nFontWhich) { - BOOL bDelete = FALSE; - const SfxFont* pFnt = pPrt ? pPrt->GetFontByName(rStyle): 0; - if(!pFnt) - { - pFnt = new SfxFont(FAMILY_DONTKNOW, rStyle); - bDelete = TRUE; - } + Font aFont( rStyle, Size( 0, 10 ) ); + if( pPrt ) + aFont = pPrt->GetFontMetric( aFont ); SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(nType); - pColl->SetFmtAttr(SvxFontItem(pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), nFontWhich)); - if(bDelete) - { - delete (SfxFont*) pFnt; - } + pColl->SetFmtAttr(SvxFontItem(aFont.GetFamily(), aFont.GetName(), + aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich)); } /*-- 11.10.2005 15:47:52--------------------------------------------------- @@ -822,22 +814,13 @@ BOOL SwStdFontTabPage::FillItemSet( SfxItemSet& ) FONT_GROUP_CJK == nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE); if(sStandard != sShellStd) { - BOOL bDelete = FALSE; - const SfxFont* pFnt = pPrinter ? pPrinter->GetFontByName(sStandard): 0; - if(!pFnt) - { - pFnt = new SfxFont(FAMILY_DONTKNOW, sStandard); - bDelete = TRUE; - } - pWrtShell->SetDefault(SvxFontItem(pFnt->GetFamily(), pFnt->GetName(), - aEmptyStr, pFnt->GetPitch(), pFnt->GetCharSet(), nFontWhich)); + Font aFont( sStandard, Size( 0, 10 ) ); + if( pPrinter ) + aFont = pPrinter->GetFontMetric( aFont ); + pWrtShell->SetDefault(SvxFontItem(aFont.GetFamily(), aFont.GetName(), + aEmptyStr, aFont.GetPitch(), aFont.GetCharSet(), nFontWhich)); SwTxtFmtColl *pColl = pWrtShell->GetTxtCollFromPool(RES_POOLCOLL_STANDARD); pColl->ResetFmtAttr(nFontWhich); - if(bDelete) - { - delete (SfxFont*) pFnt; - bDelete = FALSE; - } // lcl_SetColl(pWrtShell, RES_POOLCOLL_STANDARD, pPrinter, sStandard); bMod = TRUE; } @@ -943,15 +926,24 @@ void SwStdFontTabPage::Reset( const SfxItemSet& rSet) // #i94536# prevent duplication of font entries when 'reset' button is pressed if( !aStandardBox.GetEntryCount() ) { - const USHORT nCount = pPrt->GetFontCount(); - for (USHORT i = 0; i < nCount; ++i) + // get the set of disctinct available family names + std::set< String > aFontNames; + int nFontNames = pPrt->GetDevFontCount(); + for( int i = 0; i < nFontNames; i++ ) + { + FontInfo aInf( pPrt->GetDevFont( i ) ); + aFontNames.insert( aInf.GetName() ); + } + + // insert to listboxes + for( std::set< String >::const_iterator it = aFontNames.begin(); + it != aFontNames.end(); ++it ) { - const String &rString = pPrt->GetFont(i)->GetName(); - aStandardBox.InsertEntry( rString ); - aTitleBox .InsertEntry( rString ); - aListBox .InsertEntry( rString ); - aLabelBox .InsertEntry( rString ); - aIdxBox .InsertEntry( rString ); + aStandardBox.InsertEntry( *it ); + aTitleBox .InsertEntry( *it ); + aListBox .InsertEntry( *it ); + aLabelBox .InsertEntry( *it ); + aIdxBox .InsertEntry( *it ); } } if(SFX_ITEM_SET == rSet.GetItemState(FN_PARAM_STDFONTS, FALSE, &pItem)) diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 005be763b71a..c3119dc14876 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -939,7 +939,11 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, // in case of creating a single resulting file this has to be created here SwWrtShell* pTargetShell = 0; - SfxObjectShellRef xTargetDocShell; + + // the shell will be explicitly closed at the end of the method, but it is + // still more safe to use SfxObjectShellLock here + SfxObjectShellLock xTargetDocShell; + SwView* pTargetView = 0; std::auto_ptr< utl::TempFile > aTempFile; String sModifiedStartingPageDesc; @@ -1063,8 +1067,9 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, for (USHORT i = 0; i < 10; i++) Application::Reschedule(); - // Neues Dokument erzeugen und speichern - SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); + // Create and save new document + // The SfxObjectShell will be closed explicitly later but it is more safe to use SfxObjectShellLock here + SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); SfxMedium* pWorkMed = new SfxMedium( sSourceDocumentURL, STREAM_STD_READ, TRUE ); pWorkMed->SetFilter( pSfxFlt ); @@ -1504,7 +1509,8 @@ ULONG SwNewDBMgr::GetColumnFmt( uno::Reference< XDataSource> xSource, if(!xSource.is()) { uno::Reference<XChild> xChild(xConnection, UNO_QUERY); - xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); + if ( xChild.is() ) + xSource = uno::Reference<XDataSource>(xChild->getParent(), UNO_QUERY); } if(xSource.is() && xConnection.is() && xColumn.is() && pNFmtr) { @@ -2544,6 +2550,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, if(xResSet.is()) aDescriptor[daCursor] <<= xResSet; + // SfxObjectShellRef is ok, since there should be no control over the document lifetime here SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell(); SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell)); { @@ -2574,7 +2581,9 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, } else { - SfxObjectShellRef xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); + // the shell will be explicitly closed, but it is more safe to use SfxObjectShellLock here + // especially for the case that the loading has failed + SfxObjectShellLock xWorkDocSh( new SwDocShell( SFX_CREATE_MODE_INTERNAL )); SfxMedium* pWorkMed = new SfxMedium( sTempURL, STREAM_STD_READ, TRUE ); pWorkMed->SetFilter( pSfxFlt ); if( xWorkDocSh->DoLoad(pWorkMed) ) @@ -2917,7 +2926,8 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, } // copy the source document - SfxObjectShellRef xWorkDocSh; + // the copy will be closed later, but it is more safe to use SfxObjectShellLock here + SfxObjectShellLock xWorkDocSh; if(nDocNo == 1 ) { uno::Reference< util::XCloneable > xClone( rSourceView.GetDocShell()->GetModel(), uno::UNO_QUERY); @@ -2939,8 +2949,14 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); pWorkDoc->EmbedAllLinks(); - if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) - rWorkShell.Undo(); + SwUndoId nLastUndoId(UNDO_EMPTY); + if (rWorkShell.GetLastUndoInfo(0, & nLastUndoId)) + { + if (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId) + { + rWorkShell.Undo(); + } + } // #i69485# lock fields to prevent access to the result set while calculating layout rWorkShell.LockExpFlds(); // create a layout diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index ee2803e73aad..943e21adee34 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -853,7 +853,8 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton) aSaveMonitor.aPrintInfo.SetText(sStat); //now extract a document from the target document - SfxObjectShellRef xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); + // the shell will be closed at the end, but it is more safe to use SfxObjectShellLock here + SfxObjectShellLock xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); xTempDocShell->DoInitNew( 0 ); SfxViewFrame* pTempFrame = SfxViewFrame::LoadHiddenDocument( *xTempDocShell, 0 ); // pTempFrame->GetFrame().Appear(); @@ -1271,7 +1272,8 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc); //now extract a document from the target document - SfxObjectShellRef xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); + // the shell will be closed at the end, but it is more safe to use SfxObjectShellLock here + SfxObjectShellLock xTempDocShell( new SwDocShell( SFX_CREATE_MODE_STANDARD ) ); xTempDocShell->DoInitNew( 0 ); SfxViewFrame* pTempFrame = SfxViewFrame::LoadHiddenDocument( *xTempDocShell, 0 ); // pTempFrame->GetFrame().Appear(); diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 355e68bd5c58..4cab48e79d8a 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -58,6 +58,8 @@ #include <ascfldlg.hrc> #endif +#include "vcl/metric.hxx" + using namespace ::com::sun::star; @@ -180,11 +182,21 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, bDelPrinter = TRUE; } - const USHORT nCount = pPrt->GetFontCount(); - for (USHORT i = 0; i < nCount; ++i) + + // get the set of disctinct available family names + std::set< String > aFontNames; + int nFontNames = pPrt->GetDevFontCount(); + for( int i = 0; i < nFontNames; i++ ) + { + FontInfo aInf( pPrt->GetDevFont( i ) ); + aFontNames.insert( aInf.GetName() ); + } + + // insert to listbox + for( std::set< String >::const_iterator it = aFontNames.begin(); + it != aFontNames.end(); ++it ) { - const String &rStr = pPrt->GetFont(i)->GetName(); - aFontLB.InsertEntry( rStr ); + aFontLB.InsertEntry( *it ); } if( !aOpt.GetFontName().Len() ) diff --git a/sw/source/ui/dialog/macassgn.cxx b/sw/source/ui/dialog/macassgn.cxx index 2d2b7c357720..fe19a7310135 100644 --- a/sw/source/ui/dialog/macassgn.cxx +++ b/sw/source/ui/dialog/macassgn.cxx @@ -61,8 +61,6 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::frame::XFrame; -// SvStringsDtor* __EXPORT _GetRangeHdl( _SfxMacroTabPage*, const String& ); - SfxEventNamesItem SwMacroAssignDlg::AddEvents( DlgEventType eType ) { // const SfxItemSet& rSet = rPg.GetItemSet(); @@ -163,34 +161,3 @@ BOOL SwMacroAssignDlg::INetFmtDlg( Window* pParent, SwWrtShell& rSh, } return bRet; } - -/* -SvStringsDtor* __EXPORT _GetRangeHdl( _SfxMacroTabPage* , const String& rLanguage ) -{ - SvStringsDtor* pNew = new SvStringsDtor; - - SfxApplication* pSfxApp = SFX_APP(); - if ( !rLanguage.EqualsAscii(SVX_MACRO_LANGUAGE_JAVASCRIPT) ) - { - pSfxApp->EnterBasicCall(); - - String* pNewEntry = new String( pSfxApp->GetName() ); - pNew->Insert( pNewEntry, pNew->Count() ); - - TypeId aType( TYPE( SwDocShell )); - SfxObjectShell* pDoc = SfxObjectShell::GetFirst( &aType ); - while( pDoc ) - { - pNewEntry = new String( pDoc->GetTitle() ); - pNew->Insert( pNewEntry, pNew->Count() ); - pDoc = SfxObjectShell::GetNext( *pDoc, &aType ); - } - pSfxApp->LeaveBasicCall(); - } - - return pNew; -} -*/ - - - diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 8220c7ee2c8d..23f7741969ce 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -88,6 +88,7 @@ #include <shellio.hxx> #include <ddefld.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <pagedesc.hxx> #include <IMark.hxx> #include <docary.hxx> @@ -132,7 +133,6 @@ // #109590# #include <swcrsr.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> #include <globals.hrc> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> @@ -228,7 +228,7 @@ public: } ~SwTrnsfrActionAndUndo() { - pSh->EndUndo( eUndoId ); + pSh->EndUndo(); pSh->EndAllAction(); } }; @@ -454,14 +454,14 @@ sal_Bool SwTransferable::GetData( const DATA_FLAVOR& rFlavor ) pClpDocFac = new SwDocFac; SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac); - pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pWrtShell->Copy( pTmpDoc ); // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!) + aDocShellRef = pTmpDoc->GetTmpDocShell(); if( aDocShellRef.Is() ) SwTransferable::InitOle( aDocShellRef, *pTmpDoc ); - pTmpDoc->SetRefForDocShell( 0 ); + pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL ); if( nSelectionType & nsSelectionType::SEL_TXT && !pWrtShell->HasMark() ) { @@ -869,7 +869,6 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) SwDoc *const pTmpDoc = lcl_GetDoc(*pClpDocFac); - pTmpDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pTmpDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pWrtShell->Copy( pTmpDoc ); @@ -892,9 +891,10 @@ int SwTransferable::PrepareForCopy( BOOL bIsCut ) } // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!) + aDocShellRef = pTmpDoc->GetTmpDocShell(); if( aDocShellRef.Is() ) SwTransferable::InitOle( aDocShellRef, *pTmpDoc ); - pTmpDoc->SetRefForDocShell( 0 ); + pTmpDoc->SetTmpDocShell( (SfxObjectShell*)NULL ); if( pWrtShell->IsObjSelected() ) eBufferType = TRNSFR_DRAWING; @@ -1052,15 +1052,15 @@ int SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, SwCntntNode* pCNd = rNds.GoNext( &aNodeIdx ); // gehe zum 1. ContentNode SwPaM aPam( *pCNd ); - pCDoc->SetRefForDocShell( boost::addressof(aDocShellRef) ); pCDoc->LockExpFlds(); // nie die Felder updaten - Text so belassen pCDoc->InsertGlossary( rGlossary, rStr, aPam, 0 ); // es wurde in der CORE eine neu angelegt (OLE-Objekte kopiert!) + aDocShellRef = pCDoc->GetTmpDocShell(); if( aDocShellRef.Is() ) SwTransferable::InitOle( aDocShellRef, *pCDoc ); - pCDoc->SetRefForDocShell( 0 ); + pCDoc->SetTmpDocShell( (SfxObjectShell*)NULL ); eBufferType = TRNSFR_DOCUMENT; @@ -3434,7 +3434,7 @@ int SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, { // nicht in sich selbst kopieren/verschieben rSh.DestroyCrsr(); - rSh.EndUndo( eUndoId ); + rSh.EndUndo(); rSh.EndAction(); rSh.EndAction(); return 0; @@ -3542,8 +3542,8 @@ int SwTransferable::PrivateDrop( SwWrtShell& rSh, const Point& rDragPt, rSrcSh.LeaveSelFrmMode(); if( rSrcSh.GetDoc() != rSh.GetDoc() ) - rSrcSh.EndUndo( eUndoId ); - rSh.EndUndo( eUndoId ); + rSrcSh.EndUndo(); + rSh.EndUndo(); // Shell in den richtigen Status versetzen if( &rSrcSh != &rSh && ( rSh.IsFrmSelected() || rSh.IsObjSelected() )) @@ -3797,8 +3797,7 @@ void SwTrnsfrDdeLink::Disconnect( BOOL bRemoveDataAdvise ) if( bDelBookmrk && refObj.Is() && FindDocShell() ) { SwDoc* pDoc = pDocShell->GetDoc(); - BOOL bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( FALSE ); + ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo()); // --> OD, CD, OS 2005-11-25 #i58448# Link aSavedOle2Link( pDoc->GetOle2Link() ); @@ -3815,7 +3814,6 @@ void SwTrnsfrDdeLink::Disconnect( BOOL bRemoveDataAdvise ) pDoc->SetOle2Link( aSavedOle2Link ); // <-- - pDoc->DoUndo( bUndo ); bDelBookmrk = FALSE; } diff --git a/sw/source/ui/docvw/AnnotationWin.cxx b/sw/source/ui/docvw/AnnotationWin.cxx index 08fb91dcc3c6..52b1821d5a8b 100644 --- a/sw/source/ui/docvw/AnnotationWin.cxx +++ b/sw/source/ui/docvw/AnnotationWin.cxx @@ -28,7 +28,6 @@ * ************************************************************************/ - #include "precompiled_sw.hxx" #include <AnnotationWin.hxx> @@ -62,8 +61,10 @@ #include <wrtsh.hxx> #include <docsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <SwUndoField.hxx> + namespace sw { namespace annotation { SwAnnotationWin::SwAnnotationWin( SwEditWin& rEditWin, @@ -116,7 +117,8 @@ void SwAnnotationWin::UpdateData() SwField* pOldField = mpFld->Copy(); mpFld->SetPar2(Engine()->GetEditEngine().GetText()); mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView().GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo( + new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); delete pOldField; // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one) Mgr().SetLayout(); @@ -246,7 +248,8 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText) SwField* pOldField = mpFld->Copy(); mpFld->SetPar2(Engine()->GetEditEngine().GetText()); mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView().GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo( + new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); delete pOldField; Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) ); Engine()->ClearModifyFlag(); diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 645d4773626a..f45d1ee1e78c 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -59,16 +59,12 @@ #include <redline.hxx> #include <docary.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> #include <tools/color.hxx> #include <swmodule.hxx> #include <annotation.hrc> #include "cmdid.h" -#include <SwRewriter.hxx> -#include <undobj.hxx> - #include <sfx2/request.hxx> #include <sfx2/event.hxx> #include <svl/srchitem.hxx> @@ -1251,7 +1247,7 @@ void SwPostItMgr::Delete(String aAuthor) mpWrtShell->GotoField( *(*i) ); mpWrtShell->DelRight(); } - mpWrtShell->EndUndo( UNDO_DELETE ); + mpWrtShell->EndUndo(); PrepareView(); mpWrtShell->EndAllAction(); mbLayout = true; @@ -1297,7 +1293,7 @@ void SwPostItMgr::Delete() mvPostItFlds.clear(); */ - mpWrtShell->EndUndo( UNDO_DELETE ); + mpWrtShell->EndUndo(); PrepareView(); mpWrtShell->EndAllAction(); mbLayout = true; diff --git a/sw/source/ui/docvw/SidebarTxtControl.cxx b/sw/source/ui/docvw/SidebarTxtControl.cxx index 829c79373a61..bd645324ee13 100644 --- a/sw/source/ui/docvw/SidebarTxtControl.cxx +++ b/sw/source/ui/docvw/SidebarTxtControl.cxx @@ -64,7 +64,6 @@ #include <wrtsh.hxx> #include <shellres.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> namespace css = ::com::sun::star; diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 5049220b1b5a..e3991352b0b3 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -4320,8 +4320,14 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) !GetConnectMetaFile() && rSh.VisArea().IsInside( aDocPt )) { - if( UNDO_INS_FROM_SHADOWCRSR == rSh.GetUndoIds() ) - rSh.Undo(); + SwUndoId nLastUndoId(UNDO_EMPTY); + if (rSh.GetLastUndoInfo(0, & nLastUndoId)) + { + if (UNDO_INS_FROM_SHADOWCRSR == nLastUndoId) + { + rSh.Undo(); + } + } SwFillMode eMode = (SwFillMode)rSh.GetViewOptions()->GetShdwCrsrFillMode(); rSh.SetShadowCrsrPos( aDocPt, eMode ); } diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx index 43ef58b11d7c..49932804d8ea 100644 --- a/sw/source/ui/envelp/mailmrge.cxx +++ b/sw/source/ui/envelp/mailmrge.cxx @@ -804,11 +804,8 @@ bool SwMailMergeDlg::ExecQryShell() } } } - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(FALSE); IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - if(pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData( pIDDA->getPrintData() ); aPrtData.SetPrintSingleJobs(aSingleJobsCB.IsChecked()); pIDDA->setPrintData(aPrtData); diff --git a/sw/source/ui/inc/annotsh.hxx b/sw/source/ui/inc/annotsh.hxx index 979e1374e004..ad91eb1b4f52 100755 --- a/sw/source/ui/inc/annotsh.hxx +++ b/sw/source/ui/inc/annotsh.hxx @@ -71,7 +71,8 @@ public: void StateSearch(SfxItemSet &); - virtual SfxUndoManager* GetUndoManager(); + virtual ::svl::IUndoManager* + GetUndoManager(); }; #endif diff --git a/sw/source/ui/inc/drwtxtsh.hxx b/sw/source/ui/inc/drwtxtsh.hxx index 79aebc4e016a..1bbec5daafcb 100644 --- a/sw/source/ui/inc/drwtxtsh.hxx +++ b/sw/source/ui/inc/drwtxtsh.hxx @@ -57,7 +57,8 @@ public: SwDrawTextShell(SwView &rView); virtual ~SwDrawTextShell(); - virtual SfxUndoManager* GetUndoManager(); + virtual ::svl::IUndoManager* + GetUndoManager(); void StateDisableItems(SfxItemSet &); 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/inc/pview.hxx b/sw/source/ui/inc/pview.hxx index d0d8f2cb804a..2b1c9366707e 100644 --- a/sw/source/ui/inc/pview.hxx +++ b/sw/source/ui/inc/pview.hxx @@ -223,7 +223,6 @@ class SW_DLLPUBLIC SwPagePreView: public SfxViewShell SW_DLLPRIVATE virtual USHORT SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false ); SW_DLLPRIVATE virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions ); - SW_DLLPRIVATE virtual PrintDialog* CreatePrintDialog( Window *pParent ); SW_DLLPRIVATE void CalcAndSetBorderPixel( SvBorder &rToFill, BOOL bInner ); diff --git a/sw/source/ui/inc/swdtflvr.hxx b/sw/source/ui/inc/swdtflvr.hxx index 041b55d9c6db..452637a3e7f8 100644 --- a/sw/source/ui/inc/swdtflvr.hxx +++ b/sw/source/ui/inc/swdtflvr.hxx @@ -65,7 +65,7 @@ namespace nsTransferBufferType class SwTransferable : public TransferableHelper { friend class SwView_Impl; - SfxObjectShellRef aDocShellRef; + SfxObjectShellLock aDocShellRef; TransferableDataHelper aOleData; TransferableObjectDescriptor aObjDesc; ::sfx2::SvBaseLinkRef refDdeLink; diff --git a/sw/source/ui/inc/uitool.hxx b/sw/source/ui/inc/uitool.hxx index e48f78f9aa96..c3dfd0f07b2a 100644 --- a/sw/source/ui/inc/uitool.hxx +++ b/sw/source/ui/inc/uitool.hxx @@ -27,7 +27,7 @@ #ifndef _UITOOL_HXX #define _UITOOL_HXX -#include <vcl/wintypes.hxx> +#include <tools/wintypes.hxx> #include <vcl/field.hxx> #include <swtypes.hxx> #include "swdllapi.h" diff --git a/sw/source/ui/inc/uivwimp.hxx b/sw/source/ui/inc/uivwimp.hxx index 9c22b44ad868..509610500a3f 100644 --- a/sw/source/ui/inc/uivwimp.hxx +++ b/sw/source/ui/inc/uivwimp.hxx @@ -111,8 +111,7 @@ class SwView_Impl // temporary document for printing text of selection / multi selection // in PDF export. - SfxObjectShellRef xTmpSelDocSh; - SfxObjectShellRef aEmbeddedObjRef; + SfxObjectShellLock xTmpSelDocSh; SwView* pView; SwScannerEventListener* pScanEvtLstnr; @@ -148,9 +147,7 @@ public: void AddClipboardListener(); - SfxObjectShellRef & GetTmpSelectionDoc() { return xTmpSelDocSh; } - - SfxObjectShellRef& GetEmbeddedObjRef() { return *boost::addressof(aEmbeddedObjRef); } + SfxObjectShellLock& GetTmpSelectionDoc() { return xTmpSelDocSh; } void AddTransferable(SwTransferable& rTransferable); diff --git a/sw/source/ui/inc/unotxvw.hxx b/sw/source/ui/inc/unotxvw.hxx index 4990df84f43b..1c8ad77e2054 100644 --- a/sw/source/ui/inc/unotxvw.hxx +++ b/sw/source/ui/inc/unotxvw.hxx @@ -156,7 +156,7 @@ public: void Invalidate(); // temporary document used for PDF export of selections/multi-selections - SfxObjectShellRef BuildTmpSelectionDoc(); + SfxObjectShellLock BuildTmpSelectionDoc(); }; /* -----------------17.09.98 12:52------------------- diff --git a/sw/source/ui/inc/usrpref.hxx b/sw/source/ui/inc/usrpref.hxx index 0758f89af8bf..854b12d4f40e 100644 --- a/sw/source/ui/inc/usrpref.hxx +++ b/sw/source/ui/inc/usrpref.hxx @@ -32,7 +32,7 @@ #include <unotools/configitem.hxx> #include <fldupde.hxx> #include "viewopt.hxx" -#include <vcl/fldunit.hxx> +#include <tools/fldunit.hxx> /* -----------------------------28.09.00 09:45-------------------------------- diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index 78817eec874c..a462cd1deb6d 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -32,7 +32,7 @@ #include <svtools/htmlcfg.hxx> #include <sfx2/viewfac.hxx> #include <sfx2/viewsh.hxx> -#include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell) +#include <sfx2/objsh.hxx> #include <editeng/svxenum.hxx> #include <svx/zoomitem.hxx> #include <editeng/editstat.hxx> @@ -57,7 +57,6 @@ class SvxRuler; class SvxLRSpaceItem; class SwDocShell; class SwScrollbar; -class PrintDialog; class SvxVCBrowser; class SvBorder; class Ruler; @@ -355,7 +354,6 @@ class SW_DLLPUBLIC SwView: public SfxViewShell // Methoden fuers Printing SW_DLLPRIVATE virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE ); - SW_DLLPRIVATE virtual PrintDialog* CreatePrintDialog( Window* pParent ); SfxTabPage* CreatePrintOptionsPage( Window* pParent, const SfxItemSet& rSet); // fuer Readonly-Umschaltung @@ -643,8 +641,8 @@ public: void NotifyDBChanged(); - SfxObjectShellRef & GetTmpSelectionDoc(); - SfxObjectShellRef & GetOrCreateTmpSelectionDoc(); + SfxObjectShellLock & GetTmpSelectionDoc(); + SfxObjectShellLock & GetOrCreateTmpSelectionDoc(); void AddTransferable(SwTransferable& rTransferable); diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 54d1fab4cc0c..16ff3e4973d8 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -33,9 +33,7 @@ #include "swuiidxmrk.hxx" #include <hintids.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif #define _SVSTDARR_STRINGSSORT #include <svl/svstdarr.hxx> #include <comphelper/processfactory.hxx> @@ -46,9 +44,7 @@ #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> #include <svl/stritem.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <sfx2/dispatch.hxx> #include <svl/eitem.hxx> #include <svtools/txtcmp.hxx> @@ -60,20 +56,12 @@ #include <idxmrk.hxx> #include <txttxmrk.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <multmrk.hxx> #include <swundo.hxx> // fuer Undo-Ids -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _INDEX_HRC #include <index.hrc> -#endif -#ifndef _IDXMRK_HRC #include <idxmrk.hrc> -#endif #include <swmodule.hxx> #include <fldmgr.hxx> #include <fldbas.hxx> @@ -83,7 +71,6 @@ #include <ndtxt.hxx> #include <breakit.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> #include "swuiidxmrk.hxx" #include <unomid.h> diff --git a/sw/source/ui/index/toxmgr.cxx b/sw/source/ui/index/toxmgr.cxx index 8564000d26ac..e23073053e54 100644 --- a/sw/source/ui/index/toxmgr.cxx +++ b/sw/source/ui/index/toxmgr.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <wrtsh.hxx> #include <shellres.hxx> #include <swwait.hxx> @@ -34,10 +35,9 @@ #include <toxmgr.hxx> #include <crsskip.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <swundo.hxx> -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif /*-------------------------------------------------------------------- Beschreibung: Handhabung der Verzeichnisse durch TOXMgr @@ -450,12 +450,14 @@ BOOL SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc, { SwDoc * pDoc = pSh->GetDoc(); - if (pDoc->DoesUndo()) + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { if (pNewTOX != NULL) - pDoc->DelAllUndoObj(); + { + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + } - pDoc->StartUndo(UNDO_TOXCHANGE, NULL); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_TOXCHANGE, NULL); } if (pNewTOX != NULL) // => pTOX != NULL @@ -463,12 +465,14 @@ BOOL SwTOXMgr::UpdateOrInsertTOX(const SwTOXDescription& rDesc, bRet = pSh->UpdateTableOf(*pTOX, pSet); - if (pDoc->DoesUndo()) + if (pDoc->GetIDocumentUndoRedo().DoesUndo()) { - pDoc->EndUndo(UNDO_TOXCHANGE, NULL); + pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_TOXCHANGE, NULL); if (pNewTOX == NULL) - pDoc->DelAllUndoObj(); + { + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + } } } diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index e9bb702b3d66..352580707f74 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -47,7 +47,6 @@ #include "swtypes.hxx" #include "swundo.hxx" #include "uitool.hxx" -#include "undobj.hxx" #include "unomid.h" #include "view.hxx" #include "viewopt.hxx" @@ -789,7 +788,7 @@ void SwSpellPopup::Execute( USHORT nId ) of temporary auto correction is now undoable two and must reside in the same undo group.*/ pSh->EndAction(); - pSh->EndUndo(UNDO_UI_REPLACE); + pSh->EndUndo(); pSh->SetInsMode( bOldIns ); } diff --git a/sw/source/ui/misc/glshell.cxx b/sw/source/ui/misc/glshell.cxx index 4d93f8d7542f..9c70ef06e58a 100644 --- a/sw/source/ui/misc/glshell.cxx +++ b/sw/source/ui/misc/glshell.cxx @@ -49,18 +49,13 @@ #include <view.hxx> #include <glshell.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <glosdoc.hxx> #include <shellio.hxx> #include <initui.hxx> // fuer ::GetGlossaries() -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _SWERROR_H #include <swerror.h> -#endif -#ifndef _MISC_HRC #include <misc.hrc> -#endif #define SwWebGlosDocShell @@ -311,8 +306,9 @@ SwDocShellRef SwGlossaries::EditGroupDoc( const String& rGroup, const String& rS aDocTitle += ' '; aDocTitle += sLongName; - BOOL bDoesUndo = xDocSh->GetDoc()->DoesUndo(); - xDocSh->GetDoc()->DoUndo( FALSE ); + bool const bDoesUndo = + xDocSh->GetDoc()->GetIDocumentUndoRedo().DoesUndo(); + xDocSh->GetDoc()->GetIDocumentUndoRedo().DoUndo( false ); xDocSh->GetWrtShell()->InsertGlossary( *pGroup, rShortName ); if( !xDocSh->GetDoc()->getPrinter( false ) ) @@ -340,7 +336,7 @@ SwDocShellRef SwGlossaries::EditGroupDoc( const String& rGroup, const String& rS catch( uno::Exception& ) {} - xDocSh->GetDoc()->DoUndo( bDoesUndo ); + xDocSh->GetDoc()->GetIDocumentUndoRedo().DoUndo( bDoesUndo ); xDocSh->GetDoc()->ResetModified(); if ( bShow ) pFrame->GetFrame().Appear(); diff --git a/sw/source/ui/misc/redlndlg.cxx b/sw/source/ui/misc/redlndlg.cxx index 0101e92a0081..19decf172798 100644 --- a/sw/source/ui/misc/redlndlg.cxx +++ b/sw/source/ui/misc/redlndlg.cxx @@ -37,9 +37,7 @@ #include <redline.hxx> #include <tools/datetime.hxx> #include <vcl/msgbox.hxx> -#ifndef _SVSTDARR_HXX #include <svl/svstdarr.hxx> -#endif #include <svl/eitem.hxx> #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> @@ -47,9 +45,7 @@ #include <svx/postattr.hxx> #include <swtypes.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #ifndef _REDLNDLG_HXX #define _REDLNACCEPTDLG @@ -58,26 +54,15 @@ #include <swwait.hxx> #include <uitool.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _MISC_HRC #include <misc.hrc> -#endif -#ifndef _REDLNDLG_HRC #include <redlndlg.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif // -> #111827# #include <comcore.hrc> #include <swundo.hxx> -#include <undobj.hxx> #include <SwRewriter.hxx> // <- #111827# @@ -975,7 +960,9 @@ void SwRedlineAcceptDlg::CallAcceptReject( BOOL bSelect, BOOL bAccept ) // #111827# if (aRedlines.size() > 1) - pSh->EndUndo(bAccept? UNDO_ACCEPT_REDLINE : UNDO_REJECT_REDLINE); + { + pSh->EndUndo(); + } pSh->EndAction(); diff --git a/sw/source/ui/ribbar/drawbase.cxx b/sw/source/ui/ribbar/drawbase.cxx index 61dcd3f23505..fae2df9c0f4a 100644 --- a/sw/source/ui/ribbar/drawbase.cxx +++ b/sw/source/ui/ribbar/drawbase.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <tools/list.hxx> #include <svx/svdview.hxx> @@ -45,7 +46,7 @@ #include "edtwin.hxx" #include "caption.hxx" #include "swundo.hxx" -#include "undobj.hxx" +#include <SwRewriter.hxx> #include "comcore.hrc" using namespace ::com::sun::star; @@ -363,7 +364,9 @@ BOOL SwDrawBase::MouseButtonUp(const MouseEvent& rMEvt) } } if (m_pWin->GetSdrDrawMode() == OBJ_NONE) - m_pSh->EndUndo(UNDO_INSERT); + { + m_pSh->EndUndo(); + } } bReturn = TRUE; 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/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index 8115b4ec7438..f750447ed3fe 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -161,7 +161,7 @@ SwAnnotationShell::~SwAnnotationShell() { } -SfxUndoManager* SwAnnotationShell::GetUndoManager() +::svl::IUndoManager* SwAnnotationShell::GetUndoManager() { SwPostItMgr* pPostItMgr = rView.GetPostItMgr(); if ( !pPostItMgr || @@ -1358,7 +1358,7 @@ void SwAnnotationShell::ExecTransliteration(SfxRequest &rReq) void SwAnnotationShell::ExecUndo(SfxRequest &rReq) { const SfxItemSet* pArgs = rReq.GetArgs(); - SfxUndoManager* pUndoManager = GetUndoManager(); + ::svl::IUndoManager* pUndoManager = GetUndoManager(); SwWrtShell &rSh = rView.GetWrtShell(); long aOldHeight = rView.GetPostItMgr()->HasActiveSidebarWin() @@ -1387,7 +1387,7 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq) nCnt = 0; while( nSteps-- ) - pUndoManager->Undo(0); + pUndoManager->Undo(); } if ( nCnt ) @@ -1411,7 +1411,7 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq) nCnt = 0; while( nSteps-- ) - pUndoManager->Redo(0); + pUndoManager->Redo(); } if ( nCnt ) @@ -1435,7 +1435,7 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) SfxWhichIter aIter(rSet); USHORT nWhich = aIter.FirstWhich(); - SfxUndoManager* pUndoManager = GetUndoManager(); + ::svl::IUndoManager* pUndoManager = GetUndoManager(); SfxViewFrame *pSfxViewFrame = rView.GetViewFrame(); SwWrtShell &rSh = rView.GetWrtShell(); @@ -1448,8 +1448,10 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) sal_uInt16 nCount = pUndoManager->GetUndoActionCount(); if ( nCount ) pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); - else if( rSh.GetUndoIds() ) + else if (rSh.GetLastUndoInfo(0, 0)) + { rSet.Put( SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::UNDO)) ); + } else rSet.DisableItem(nWhich); break; @@ -1459,8 +1461,10 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) sal_uInt16 nCount = pUndoManager->GetRedoActionCount(); if ( nCount ) pSfxViewFrame->GetSlotState( nWhich, pSfxViewFrame->GetInterface(), &rSet ); - else if(rSh.GetRedoIds()) + else if (rSh.GetFirstRedoInfo(0)) + { rSet.Put(SfxStringItem( nWhich, rSh.GetDoString(SwWrtShell::REDO)) ); + } else rSet.DisableItem(nWhich); break; @@ -1470,34 +1474,36 @@ void SwAnnotationShell::StateUndo(SfxItemSet &rSet) { if( pUndoManager ) { - UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const; + UniString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const; sal_uInt16 nCount; if( SID_GETUNDOSTRINGS == nWhich ) { nCount = pUndoManager->GetUndoActionCount(); - fnGetComment = &SfxUndoManager::GetUndoActionComment; + fnGetComment = &::svl::IUndoManager::GetUndoActionComment; } else { nCount = pUndoManager->GetRedoActionCount(); - fnGetComment = &SfxUndoManager::GetRedoActionComment; + fnGetComment = &::svl::IUndoManager::GetRedoActionComment; } String sList; if( nCount ) { for( sal_uInt16 n = 0; n < nCount; ++n ) - ( sList += (pUndoManager->*fnGetComment)( n ) ) + ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) ) += '\n'; } SfxStringListItem aItem( nWhich ); - if( nWhich == SID_GETUNDOSTRINGS && rSh.GetUndoIds() ) + if ((nWhich == SID_GETUNDOSTRINGS) && + rSh.GetLastUndoInfo(0, 0)) { rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); } - else if( nWhich == SID_GETREDOSTRINGS && rSh.GetRedoIds() ) + else if ((nWhich == SID_GETREDOSTRINGS) && + (rSh.GetFirstRedoInfo(0))) { rSh.GetDoStrings( SwWrtShell::UNDO, aItem ); } diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 15c97f67c847..9b760ed1b596 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -27,14 +27,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <sot/factory.hxx> #include <hintids.hxx> #include <svl/urihelper.hxx> #include <svl/languageoptions.hxx> -#ifndef _SVX_SVXIDS_HRC #include <svx/svxids.hrc> -#endif #include <sfx2/linkmgr.hxx> #include <svx/htmlmode.hxx> #include <svx/imapdlg.hxx> @@ -97,15 +96,9 @@ #include <caption.hxx> #include <swwait.hxx> #include <cmdid.h> -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _STATSTR_HRC #include <statstr.hrc> -#endif #include <globals.h> #include <unotxdoc.hxx> #include <crsskip.hxx> @@ -120,10 +113,7 @@ #include <instable.hxx> #include <svx/fmshell.hxx> // for FN_XFORMS_DESIGN_MODE #include <SwRewriter.hxx> -#include <undobj.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <unomid.h> @@ -553,35 +543,41 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet) { case SID_UNDO: { - if( rSh.GetUndoIds() ) + if (rSh.GetLastUndoInfo(0, 0)) + { rSet.Put( SfxStringItem(nWhich, rSh.GetDoString(SwWrtShell::UNDO))); + } else rSet.DisableItem(nWhich); break; } case SID_REDO: { - if(rSh.GetRedoIds()) + if (rSh.GetFirstRedoInfo(0)) + { rSet.Put(SfxStringItem(nWhich, rSh.GetDoString(SwWrtShell::REDO))); + } else rSet.DisableItem(nWhich); break; } case SID_REPEAT: { // Repeat nur moeglich wenn kein REDO moeglich - UI-Restriktion - if(rSh.GetRedoIds() == UNDO_EMPTY && + if ((!rSh.GetFirstRedoInfo(0)) && !rSh.IsSelFrmMode() && - rSh.GetRepeatIds() ) + (UNDO_EMPTY != rSh.GetRepeatInfo(0))) + { rSet.Put(SfxStringItem(nWhich, rSh.GetRepeatString())); + } else rSet.DisableItem(nWhich); break; } case SID_GETUNDOSTRINGS: - if( rSh.GetUndoIds() ) + if (rSh.GetLastUndoInfo(0, 0)) { SfxStringListItem aStrLst( nWhich ); rSh.GetDoStrings( SwWrtShell::UNDO, aStrLst ); @@ -592,7 +588,7 @@ void SwBaseShell::StateUndo(SfxItemSet &rSet) break; case SID_GETREDOSTRINGS: - if( rSh.GetRedoIds() ) + if (rSh.GetFirstRedoInfo(0)) { SfxStringListItem aStrLst( nWhich ); rSh.GetDoStrings( SwWrtShell::REDO, aStrLst ); diff --git a/sw/source/ui/shells/drwbassh.cxx b/sw/source/ui/shells/drwbassh.cxx index 2bd3a59d0810..ba205e5fb313 100644 --- a/sw/source/ui/shells/drwbassh.cxx +++ b/sw/source/ui/shells/drwbassh.cxx @@ -294,7 +294,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq) pSh->StartAllAction(); // --> OD 2004-07-14 #i30451# - pSh->StartUndo(); + pSh->StartUndo(UNDO_INSFMTATTR); pSdrView->SetGeoAttrToMarked(*pOutSet); diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 78a9b05ce70b..afd69a492c71 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -623,15 +623,15 @@ void SwDrawTextShell::ExecUndo(SfxRequest &rReq) 1 < (nCnt = ((SfxUInt16Item*)pItem)->GetValue()) ) { // then we make by ourself. - SfxUndoManager* pUndoManager = GetUndoManager(); + ::svl::IUndoManager* pUndoManager = GetUndoManager(); if( pUndoManager ) { if( SID_UNDO == nId ) while( nCnt-- ) - pUndoManager->Undo(0); + pUndoManager->Undo(); else while( nCnt-- ) - pUndoManager->Redo(0); + pUndoManager->Redo(); } bCallBase = FALSE; GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); @@ -668,27 +668,27 @@ void SwDrawTextShell::StateUndo(SfxItemSet &rSet) case SID_GETUNDOSTRINGS: case SID_GETREDOSTRINGS: { - SfxUndoManager* pUndoManager = GetUndoManager(); + ::svl::IUndoManager* pUndoManager = GetUndoManager(); if( pUndoManager ) { - UniString (SfxUndoManager:: *fnGetComment)( USHORT ) const; + UniString (::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const; sal_uInt16 nCount; if( SID_GETUNDOSTRINGS == nWhich ) { nCount = pUndoManager->GetUndoActionCount(); - fnGetComment = &SfxUndoManager::GetUndoActionComment; + fnGetComment = &::svl::IUndoManager::GetUndoActionComment; } else { nCount = pUndoManager->GetRedoActionCount(); - fnGetComment = &SfxUndoManager::GetRedoActionComment; + fnGetComment = &::svl::IUndoManager::GetRedoActionComment; } if( nCount ) { String sList; for( sal_uInt16 n = 0; n < nCount; ++n ) - ( sList += (pUndoManager->*fnGetComment)( n ) ) + ( sList += (pUndoManager->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ) ) += '\n'; SfxStringListItem aItem( nWhich ); @@ -899,7 +899,7 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq) /*-- 22.10.2003 14:26:32--------------------------------------------------- -----------------------------------------------------------------------*/ -SfxUndoManager* SwDrawTextShell::GetUndoManager() +::svl::IUndoManager* SwDrawTextShell::GetUndoManager() { SwWrtShell &rSh = GetShell(); pSdrView = rSh.GetDrawView(); diff --git a/sw/source/ui/shells/grfshex.cxx b/sw/source/ui/shells/grfshex.cxx index fe2e7502a3df..8669c4e201c1 100644 --- a/sw/source/ui/shells/grfshex.cxx +++ b/sw/source/ui/shells/grfshex.cxx @@ -34,42 +34,28 @@ #include <wrtsh.hxx> #include <view.hxx> #include <docary.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif #include <viewopt.hxx> #include <swundo.hxx> -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif #include <caption.hxx> #define _SVSTDARR_STRINGSSORTDTOR #include <svl/svstdarr.hxx> #include <svtools/filter.hxx> #include <svx/htmlmode.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmfmt.hxx> #include <frmmgr.hxx> #include <vcl/msgbox.hxx> -#ifndef _SVX_SVDOMEDIA_HXX #include <svx/svdomedia.hxx> -#endif -#ifndef _SVX_SVDVIEW_HXX #include <svx/svdview.hxx> -#endif -#ifndef _SVX_SVDPAGV_HXX #include <svx/svdpagv.hxx> -#endif #include <SwStyleNameMapper.hxx> #include <sfx2/filedlghelper.hxx> #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> -#ifndef _POOLFMT_HRC #include <poolfmt.hrc> -#endif #include <sfx2/request.hxx> #include <sfx2/viewfrm.hxx> @@ -79,7 +65,6 @@ // -> #111827# #include <SwRewriter.hxx> -#include <undobj.hxx> #include <comcore.hrc> // <- #111827# diff --git a/sw/source/ui/shells/langhelper.cxx b/sw/source/ui/shells/langhelper.cxx index 37d5e1ed5d69..fbdcd264c5d5 100644..100755 --- a/sw/source/ui/shells/langhelper.cxx +++ b/sw/source/ui/shells/langhelper.cxx @@ -300,11 +300,9 @@ namespace SwLangHelper } rWrtSh.SetDefault( SvxLanguageItem( nLang, nLangWhichId ) ); - // set respective language attribute in text document to default + // #i102191: hard set respective language attribute in text document // (for all text in the document - which should be selected by now...) - SvUShortsSort aAttribs; - aAttribs.Insert( nLangWhichId ); - rWrtSh.ResetAttr( &aAttribs ); + rWrtSh.SetAttr( SvxLanguageItem( nLang, nLangWhichId ) ); } } } diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 0d217532e32a..b7795172e55f 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -79,9 +79,7 @@ #include <doc.hxx> #include <uitool.hxx> #include <cmdid.h> -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <frmmgr.hxx> #include <textsh.hxx> #include <frmfmt.hxx> @@ -100,12 +98,8 @@ #include <modcfg.hxx> #include <column.hxx> #include <edtwin.hxx> -#ifndef _SHELLS_HRC #include <shells.hrc> -#endif -#ifndef _POPUP_HRC #include <popup.hrc> -#endif #include <swerror.h> #include <SwAppletImpl.hxx> #include <unochart.hxx> @@ -120,10 +114,7 @@ #include <sfx2/msg.hxx> #include <swslots.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif using namespace ::com::sun::star; using ::rtl::OUString; @@ -1217,7 +1208,7 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq ) } rSh.EndAllAction(); - rSh.EndUndo( UNDO_INSERT ); + rSh.EndUndo(); if ( aChars.Len() ) { diff --git a/sw/source/ui/table/chartins.cxx b/sw/source/ui/table/chartins.cxx index a11f04d55656..50d22e2d7804 100644 --- a/sw/source/ui/table/chartins.cxx +++ b/sw/source/ui/table/chartins.cxx @@ -53,9 +53,7 @@ #include <edtwin.hxx> #include <cmdid.h> -#ifndef _CHARTINS_HRC #include <chartins.hrc> -#endif #include <anchoredobject.hxx> #include <sot/clsids.hxx> @@ -259,7 +257,7 @@ void SwInsertChart(Window* pParent, SfxBindings* pBindings ) if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) { rWrtShell.Undo(); - rWrtShell.getIDocumentUndoRedoAccess()->ClearRedo(); + rWrtShell.GetIDocumentUndoRedo().ClearRedo(); } else { diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index addf6f9db512..fd5d57ae35c0 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -35,7 +35,6 @@ #include <vcl/help.hxx> #include <vcl/cmdevt.hxx> #include <vcl/button.hxx> -#include <svtools/printdlg.hxx> #include <svl/whiter.hxx> #include <svl/stritem.hxx> #include <svl/eitem.hxx> @@ -1985,18 +1984,6 @@ SfxTabPage* SwPagePreView::CreatePrintOptionsPage( Window *pParent, --------------------------------------------------------------------*/ -PrintDialog* SwPagePreView::CreatePrintDialog( Window *pParent ) -{ - PrintDialog *pDlg = ::CreatePrintDialog( pParent, 1, 0 ); - pDlg->DisableRange( PRINTDIALOG_SELECTION ); - return pDlg; -} - -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - - // OD 18.12.2002 #103492# - no longer needed ?? Size SwPagePreView::GetOptimalSizePixel() const { diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index af7e12629a73..1f223350ed70 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -553,7 +553,7 @@ void SwSrcView::GetState(SfxItemSet& rSet) case SID_UNDO: case SID_REDO: { - SfxUndoManager& rMgr = pTextView->GetTextEngine()->GetUndoManager(); + ::svl::IUndoManager& rMgr = pTextView->GetTextEngine()->GetUndoManager(); USHORT nCount = 0; if(nWhich == SID_UNDO) { diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 5abe83c3a53d..2c4a556f6bca 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -39,7 +39,6 @@ #include <svl/eitem.hxx> #include <unotools/undoopt.hxx> #include <unotools/lingucfg.hxx> -#include <svtools/printdlg.hxx> #include <unotools/useroptions.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/request.hxx> @@ -75,12 +74,12 @@ #include <beziersh.hxx> #include <globdoc.hxx> #include <scroll.hxx> -#include <globdoc.hxx> #include <navipi.hxx> #include <gloshdl.hxx> #include <usrpref.hxx> #include <srcview.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <drawdoc.hxx> #include <wdocsh.hxx> #include <wview.hxx> @@ -183,7 +182,7 @@ void SwView::ImpSetVerb( int nSelType ) } if ( bResetVerbs ) { - SetVerbs( 0 ); + SetVerbs( Sequence< embed::VerbDescriptor >() ); bVerbsActive = sal_False; } } @@ -974,9 +973,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); @@ -1021,7 +1018,7 @@ SwView::SwView( SfxViewFrame *_pFrame, SfxViewShell* pOldSh ) // so setze das Modified NICHT zurueck. // --> OD 2005-02-11 #i38810# - no reset of modified state, if document // was already modified. - if ( !pWrtShell->GetDoc()->IsUndoNoResetModified() && + if (!pWrtShell->GetDoc()->GetIDocumentUndoRedo().IsUndoNoResetModified() && ( !pFirst || pFirst == pVFrame ) && !bIsDocModified ) // <-- @@ -1898,16 +1895,16 @@ void SwView::NotifyDBChanged() /* -----------------------------28.10.02 13:25-------------------------------- ---------------------------------------------------------------------------*/ -SfxObjectShellRef & SwView::GetTmpSelectionDoc() +SfxObjectShellLock & SwView::GetTmpSelectionDoc() { return GetViewImpl()->GetTmpSelectionDoc(); } /* -----------------------------31.10.02 13:25-------------------------------- ---------------------------------------------------------------------------*/ -SfxObjectShellRef & SwView::GetOrCreateTmpSelectionDoc() +SfxObjectShellLock & SwView::GetOrCreateTmpSelectionDoc() { - SfxObjectShellRef &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc(); + SfxObjectShellLock &rxTmpDoc = GetViewImpl()->GetTmpSelectionDoc(); if (!rxTmpDoc.Is()) { SwXTextView *pImpl = GetViewImpl()->GetUNOObject_Impl(); diff --git a/sw/source/ui/uiview/view.hrc b/sw/source/ui/uiview/view.hrc index d2aa60494801..d2aa60494801 100755..100644 --- a/sw/source/ui/uiview/view.hrc +++ b/sw/source/ui/uiview/view.hrc diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index eeab95b5bccd..960478c925dd 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <com/sun/star/util/SearchOptions.hpp> #include <com/sun/star/util/SearchFlags.hpp> #include <com/sun/star/i18n/TransliterationModules.hpp> @@ -43,7 +44,7 @@ #include <docary.hxx> #include <hintids.hxx> #include <SwRewriter.hxx> -#include <undobj.hxx> +#include <numrule.hxx> #include <swundo.hxx> #include <caption.hxx> #include <svl/PasswordHelper.hxx> @@ -86,6 +87,7 @@ #include <uivwimp.hxx> #include <docsh.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <wrtsh.hxx> #include <viewopt.hxx> #include <basesh.hxx> @@ -469,7 +471,7 @@ BOOL SwView::InsertGraphicDlg( SfxRequest& rReq ) rReq.Done(); } - rSh.EndUndo(UNDO_INSERT); // wegen moegl. Shellwechsel + rSh.EndUndo(); // due to possible change of Shell } delete pFileDlg; @@ -2105,10 +2107,8 @@ long SwView::InsertMedium( USHORT nSlotId, SfxMedium* pMedium, INT16 nVersion ) } else { - sal_Bool bUndo = pDoc->DoesUndo(); - pDoc->DoUndo( sal_False ); + ::sw::UndoGuard const ug(pDoc->GetIDocumentUndoRedo()); nErrno = pDocSh->InsertFrom( *pMedium ) ? 0 : ERR_SWG_READ_ERROR; - pDoc->DoUndo( bUndo ); } } @@ -2125,7 +2125,9 @@ long SwView::InsertMedium( USHORT nSlotId, SfxMedium* pMedium, INT16 nVersion ) { // Disable Undo for .sdw (136991) or // if the number of page styles with header/footer has changed (#i67305) if( !pRead || nUndoCheck != lcl_PageDescWithHeader( *pDoc ) ) - pDoc->DelAllUndoObj(); + { + pDoc->GetIDocumentUndoRedo().DelAllUndoObj(); + } } pWrtShell->EndAllAction(); @@ -2142,14 +2144,15 @@ long SwView::InsertMedium( USHORT nSlotId, SfxMedium* pMedium, INT16 nVersion ) else { SfxObjectShellRef xDocSh; + SfxObjectShellLock xLockRef; -extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh, +extern int lcl_FindDocShell( SfxObjectShellRef& xDocSh, SfxObjectShellLock& xLockRef, const String& rFileName, const String& rPasswd, String& rFilter, INT16 nVersion, SwDocShell* pDestSh ); String sFltNm; - int nRet = lcl_FindDocShell( xDocSh, pMedium->GetName(), aEmptyStr, + int nRet = lcl_FindDocShell( xDocSh, xLockRef, pMedium->GetName(), aEmptyStr, sFltNm, nVersion, pDocSh ); if( nRet ) { diff --git a/sw/source/ui/uiview/viewfunc.hxx b/sw/source/ui/uiview/viewfunc.hxx index f04db152ec2f..6da6c01bbda4 100644 --- a/sw/source/ui/uiview/viewfunc.hxx +++ b/sw/source/ui/uiview/viewfunc.hxx @@ -30,7 +30,6 @@ class ImageButton; class Point; -class PrintDialog; class SfxItemSet; class SfxPrinter; class SfxTabPage; @@ -42,7 +41,6 @@ class Window; class SwWrtShell; // folgende Funktionen stehen im viewprt.cxx -PrintDialog* CreatePrintDialog( Window* , USHORT, SwWrtShell* ); void SetPrinter( IDocumentDeviceAccess*, SfxPrinter*, BOOL bWeb ); SfxTabPage* CreatePrintOptionsPage( Window*, const SfxItemSet& ); void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb ); diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 7ddc594dd223..64e0d5142db7 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -49,7 +49,6 @@ #include <svl/flagitem.hxx> #include <vcl/msgbox.hxx> #include <vcl/oldprintadaptor.hxx> -#include <svtools/printdlg.hxx> #include <sfx2/printer.hxx> #include <sfx2/prnmon.hxx> #include <editeng/paperinf.hxx> @@ -183,42 +182,6 @@ SfxTabPage* __EXPORT SwView::CreatePrintOptionsPage(Window* pParent, } /*-------------------------------------------------------------------- - Beschreibung: Druckerdialog - --------------------------------------------------------------------*/ - -PrintDialog* CreatePrintDialog( Window* pParent, USHORT nPg, SwWrtShell* pSh ) -{ - PrintDialog *pDlg = new PrintDialog( pParent, false ); -// pDlg->ChangeFirstPage( 1 ); - - if ( !nPg ) - nPg = 1; -// pDlg->ChangeLastPage( nPg ); -// pDlg->ChangeMaxPage( 9999 ); - pDlg->EnableRange( PRINTDIALOG_FROMTO ); - - if (pSh && (pSh->IsSelection() || pSh->IsFrmSelected() || pSh->IsObjSelected())) - pDlg->EnableRange( PRINTDIALOG_SELECTION ); - - pDlg->SetRangeText( String::CreateFromInt32(nPg) ); - pDlg->EnableRange( PRINTDIALOG_RANGE ); - pDlg->EnableCollate(); - return pDlg; -} - -/*-------------------------------------------------------------------- - Beschreibung: - --------------------------------------------------------------------*/ - -PrintDialog* __EXPORT SwView::CreatePrintDialog( Window* pParent ) -{ - // AMA: Hier sollte vielleicht die virtuelle Seitennummer angezeigt werden, - // aber nur, wenn das Drucken virtuelle Seitennummern und nicht wie - // bisher (auch beim SWG 2.0) physikalische beachtet werden. - return ::CreatePrintDialog( pParent, GetWrtShell().GetPhyPageNum(), &GetWrtShell() ); -} - -/*-------------------------------------------------------------------- Beschreibung: Print-Dispatcher --------------------------------------------------------------------*/ @@ -338,12 +301,8 @@ SfxTabPage* CreatePrintOptionsPage( Window *pParent, void SetAppPrintOptions( ViewShell* pSh, BOOL bWeb ) { - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions(bWeb); const IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - - if(pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData = pIDDA->getPrintData(); if( pIDDA->getPrinter( false ) ) { diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index 57c7bd20623c..dd2db26a58e8 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -38,9 +38,7 @@ #include <svl/whiter.hxx> #include <sfx2/dispatch.hxx> #include <svl/stritem.hxx> -#ifndef _T2XTCMP_HXX //autogen #include <svtools/txtcmp.hxx> -#endif #include <svl/itempool.hxx> #include <svl/eitem.hxx> #include <svl/srchitem.hxx> @@ -52,27 +50,16 @@ #include <swmodule.hxx> #include <swwait.hxx> #include <workctrl.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> #include <swundo.hxx> // fuer Undo-Ids #include <uitool.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif -#ifndef _VIEW_HRC #include <view.hrc> -#endif #include <SwRewriter.hxx> -#include <undobj.hxx> -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include "PostItMgr.hxx" @@ -598,7 +585,7 @@ void SwView::Replace() pSrchItem->GetReplaceString(), SwWrtShell::GETSTYLE_CREATESOME )); - pWrtShell->EndUndo(UNDO_UI_REPLACE_STYLE); // #111827# + pWrtShell->EndUndo(); // #111827# } else { diff --git a/sw/source/ui/uiview/viewstat.cxx b/sw/source/ui/uiview/viewstat.cxx index 40ba6e3c6d2d..d0b9d2a06827 100644 --- a/sw/source/ui/uiview/viewstat.cxx +++ b/sw/source/ui/uiview/viewstat.cxx @@ -27,6 +27,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" + #include <hintids.hxx> #include <com/sun/star/linguistic2/XThesaurus.hpp> #include <com/sun/star/uno/Sequence.hxx> @@ -49,28 +50,20 @@ #include <tox.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/app.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <wrtsh.hxx> -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif #include <uitool.hxx> #include <viewopt.hxx> #include <tablemgr.hxx> #include <pagedesc.hxx> -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <globdoc.hxx> #include <svl/stritem.hxx> #include <unotools/moduleoptions.hxx> #include <svl/visitem.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <IDocumentRedlineAccess.hxx> @@ -163,7 +156,7 @@ void SwView::GetState(SfxItemSet &rSet) break; case SID_CLEARHISTORY: { - rSet.Put(SfxBoolItem(nWhich, pWrtShell->GetUndoIds() != UNDO_EMPTY)); + rSet.Put(SfxBoolItem(nWhich, pWrtShell->GetLastUndoInfo(0, 0))); } break; case SID_UNDO: diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx index 9b847644234f..64f904b61c87 100644 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ b/sw/source/ui/uno/SwXDocumentSettings.cxx @@ -708,11 +708,7 @@ void SwXDocumentSettings::_postSetValues () // #i86352# the printer is also used as container for options by sfx // when setting a printer it should have decent default options SfxItemSet aOptions( mpPrinter->GetOptions() ); - SwPrintData aPrtData; - if( mpDoc->getPrintData() ) - aPrtData = *mpDoc->getPrintData(); - else - aPrtData = *SW_MOD()->GetPrtOptions(false); + SwPrintData aPrtData( mpDoc->getPrintData() ); SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData); aOptions.Put(aAddPrinterItem); mpPrinter->SetOptions( aOptions ); diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index 06b9e62b4a94..7a9cc3bceaee 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -201,6 +201,7 @@ static BOOL LoadFromURL_impl( } else { + // SfxObjectShellRef is ok here, since the document will be explicitly closed SfxObjectShellRef xTmpDocSh = pTmpDocShell; CloseModelAndDocSh( xTmpModel, xTmpDocSh ); } @@ -711,11 +712,8 @@ uno::Any SAL_CALL SwXMailMerge::execute( uno::Reference< mail::XMailService > xInService; if (MailMergeType::PRINTER == nCurOutputType) { - SwPrintData aPrtData = *SW_MOD()->GetPrtOptions( FALSE ); IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); - SwPrintData* pShellPrintData = pIDDA->getPrintData(); - if (pShellPrintData) - aPrtData = *pShellPrintData; + SwPrintData aPrtData( pIDDA->getPrintData() ); aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs ); pIDDA->setPrintData( aPrtData ); // #i25686# printing should not be done asynchronously to prevent dangling offices diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 75b76b6de887..42ef04634f6c 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -340,13 +340,7 @@ void SwXPrintSettings::_preSetValues () { if (!mpDoc) throw IllegalArgumentException (); - if ( !mpDoc->getPrintData() ) - { - mpPrtOpt = new SwPrintData; - mpDoc->setPrintData ( *mpPrtOpt ); - delete mpPrtOpt; - } - mpPrtOpt = mpDoc->getPrintData(); + mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData()); } break; } @@ -502,13 +496,7 @@ void SwXPrintSettings::_preGetValues () { if (!mpDoc) throw IllegalArgumentException (); - if ( !mpDoc->getPrintData() ) - { - mpPrtOpt = new SwPrintData; - mpDoc->setPrintData ( *mpPrtOpt ); - delete mpPrtOpt; - } - mpPrtOpt = mpDoc->getPrintData(); + mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData()); } break; } diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index b0b95657600c..280ee131f958 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -198,10 +198,9 @@ SwPrintUIOptions * lcl_GetPrintUIOptions( const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 ); // get default values to use in dialog from documents SwPrintData - const SwPrintData *pPrintData = pDocShell->GetDoc()->getPrintData(); - DBG_ASSERT( pPrintData, "failed to get SwPrintData from document" ); + const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData(); - return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, *pPrintData ); + return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData ); } //////////////////////////////////////////////////////////// @@ -2591,7 +2590,7 @@ SwDoc * SwXTextDocument::GetRenderDoc( const TypeId aSwViewTypeId = TYPE(SwView); if (rpView && rpView->IsA(aSwViewTypeId)) { - SfxObjectShellRef xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc()); + SfxObjectShellLock xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc()); if (xDocSh.Is()) { pDoc = ((SwDocShell*)&xDocSh)->GetDoc(); @@ -2616,33 +2615,28 @@ static void lcl_SavePrintUIOptionsToDocumentPrintData( const SwPrintUIOptions &rPrintUIOptions, bool bIsPDFEXport ) { - if (!rDoc.getPrintData()) - { - SwPrintData *pTmpData = new SwPrintData; - rDoc.setPrintData ( *pTmpData ); - delete pTmpData; // setPrintData does make its own copy! - } + SwPrintData aDocPrintData( rDoc.getPrintData() ); - SwPrintData *pDocPrintData = rDoc.getPrintData(); - - pDocPrintData->SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); - pDocPrintData->SetPrintTable( rPrintUIOptions.IsPrintTables() ); - pDocPrintData->SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); - pDocPrintData->SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); - pDocPrintData->SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); - pDocPrintData->SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); - pDocPrintData->SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); - pDocPrintData->SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); - pDocPrintData->SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); - pDocPrintData->SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); - pDocPrintData->SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); - pDocPrintData->SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); - pDocPrintData->SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); - pDocPrintData->SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); - // pDocPrintData->SetPrintSingleJobs( b ); handled by File/Print dialog itself - // pDocPrintData->SetFaxName( s ); n/a in File/Print dialog - pDocPrintData->SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); - pDocPrintData->SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); + aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); + aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() ); + aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); + aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); + aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); + aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); + aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); + aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); + aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); + aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); + aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); + aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); + aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); + aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); + // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself + // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog + aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); + aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); + + rDoc.setPrintData( aDocPrintData ); } @@ -3170,8 +3164,12 @@ uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno:: ::vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw RuntimeException(); - //create a new document - hidden - copy the storage and return it - SfxObjectShell* pShell = pDocShell->GetDoc()->CreateCopy(false); + + // create a new document - hidden - copy the storage and return it + // SfxObjectShellRef is used here, since the model should control object lifetime after creation + // and thus SfxObjectShellLock is not allowed here + // the model holds reference to the shell, so the shell will not destructed at the end of method + SfxObjectShellRef pShell = pDocShell->GetDoc()->CreateCopy(false); uno::Reference< frame::XModel > xNewModel = pShell->GetModel(); uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( ); uno::Sequence< beans::PropertyValue > aTempMediaDescriptor; diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx index c03935464abf..5f533bde3f22 100644 --- a/sw/source/ui/uno/unotxvw.cxx +++ b/sw/source/ui/uno/unotxvw.cxx @@ -903,12 +903,12 @@ void SAL_CALL SwXTextView::setRubyList( /*-- 29.12.02 15:45:29--------------------------------------------------- -----------------------------------------------------------------------*/ -SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc() +SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() { SwWrtShell& rOldSh = m_pView->GetWrtShell(); SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false ); SwDocShell* pDocSh; - SfxObjectShellRef xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); + SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); xDocSh->DoInitNew( 0 ); SwDoc *const pTempDoc( pDocSh->GetDoc() ); // #i103634#, #i112425#: do not expand numbering and fields on PDF export diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index 6eab64f68a60..e3777e6a8feb 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -36,9 +36,7 @@ #include <tools/urlobj.hxx> #include <sfx2/docfile.hxx> #include <sfx2/dispatch.hxx> -#ifndef _HELP_HXX #include <vcl/help.hxx> -#endif #include <sot/formats.hxx> #include <vcl/sound.hxx> #include <uiitems.hxx> @@ -47,13 +45,9 @@ #include <fmtfld.hxx> #include <swmodule.hxx> #include <wrtsh.hxx> -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <errhdl.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <content.hxx> #include <frmfmt.hxx> #include <fldbas.hxx> @@ -69,24 +63,12 @@ #include <doc.hxx> #include <unotools.hxx> #include <crsskip.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _NAVIPI_HRC #include <navipi.hrc> -#endif -#ifndef _UTLUI_HRC #include <utlui.hrc> -#endif -#ifndef _MISC_HRC #include <misc.hrc> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif #include <com/sun/star/text/XTextSectionsSupplier.hpp> #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> @@ -102,7 +84,9 @@ #include <svx/svdview.hxx> #include <vcl/scrbar.hxx> #include <comcore.hrc> -#include <undobj.hxx> +#include <SwRewriter.hxx> +#include <hints.hxx> +#include <numrule.hxx> #include <swundo.hxx> #include <ndtxt.hxx> #include <PostItMgr.hxx> @@ -2834,7 +2818,7 @@ void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) pActiveShell->StartUndo(UNDO_DELETE, &aRewriter); pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL); pActiveShell->DeleteRow(); - pActiveShell->EndUndo(UNDO_DELETE); + pActiveShell->EndUndo(); pActiveShell->EndAction(); } else if(nMode == EDIT_MODE_RENAME) diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index 9acf40160bc3..8deacd017970 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -210,7 +210,7 @@ ULONG SwWrtShell::SearchPattern( const SearchOptions& rSearchOpt, BOOL bSearchIn ULONG nRet = Find( rSearchOpt, bSearchInNotes, eStt, eEnd, bCancel, eFlags, bReplace ); if(bCancel) { - Undo(UNDO_EMPTY, 1); + Undo(1); nRet = ULONG_MAX; } return nRet; @@ -238,7 +238,7 @@ ULONG SwWrtShell::SearchTempl( const String &rTempl, eStt,eEnd, bCancel, eFlags, pReplaceColl); if(bCancel) { - Undo(UNDO_EMPTY, 1); + Undo(1); nRet = ULONG_MAX; } return nRet; @@ -263,7 +263,7 @@ ULONG SwWrtShell::SearchAttr( const SfxItemSet& rFindSet, BOOL bNoColls, if(bCancel) { - Undo(UNDO_EMPTY, 1); + Undo(1); nRet = ULONG_MAX; } return nRet; diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 919ebbe079ba..60b9821c15ba 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/util/XModifiable.hpp> #if STLPORT_VERSION>=321 #include <math.h> // prevent conflict between exception and std::exception @@ -101,7 +102,6 @@ // -> #111827# #include <SwRewriter.hxx> #include <comcore.hrc> -#include <undobj.hxx> // <- #111827# #include <toolkit/helper/vclunohelper.hxx> @@ -277,7 +277,7 @@ JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das if( bStarted ) { EndAllAction(); - EndUndo(UNDO_REPLACE); + EndUndo(); } // delete pChgFlg; } @@ -377,7 +377,7 @@ void SwWrtShell::Insert( const String &rPath, const String &rFilter, if ( bOwnMgr ) delete pFrmMgr; - EndUndo(UNDO_INSERT); + EndUndo(); EndAllAction(); } @@ -604,6 +604,31 @@ BOOL SwWrtShell::InsertOleObject( const svt::EmbeddedObjectRef& xRef, SwFlyFrmFm if (pFlyFrmFmt) *pFlyFrmFmt = pFmt; + if ( SotExchange::IsChart( aCLSID ) ) + { + uno::Reference< embed::XEmbeddedObject > xEmbeddedObj( xRef.GetObject(), uno::UNO_QUERY ); + if ( xEmbeddedObj.is() ) + { + bool bDisableDataTableDialog = false; + svt::EmbeddedObjectRef::TryRunningState( xEmbeddedObj ); + uno::Reference< beans::XPropertySet > xProps( xEmbeddedObj->getComponent(), uno::UNO_QUERY ); + if ( xProps.is() && + ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) && + bDisableDataTableDialog ) + { + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ), + uno::makeAny( sal_False ) ); + xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ), + uno::makeAny( sal_False ) ); + uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY ); + if ( xModifiable.is() ) + { + xModifiable->setModified( sal_True ); + } + } + } + } + EndAllAction(); GetView().AutoCaption(OLE_CAP, &aCLSID); diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 0e51cd4c756c..7aa0c49087d2 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -51,6 +51,7 @@ #include <reffld.hxx> #include <swundo.hxx> #include <doc.hxx> +#include <IDocumentUndoRedo.hxx> #include <viewopt.hxx> // SwViewOptions #include <frmfmt.hxx> // fuer UpdateTable #include <swtable.hxx> // fuer UpdateTable @@ -67,8 +68,7 @@ #include <wrtsh.hrc> #include "swabstdlg.hxx" #include "fldui.hrc" - -#include <undobj.hxx> +#include <SwRewriter.hxx> #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -97,7 +97,7 @@ void SwWrtShell::Insert(SwField &rFld) } SwEditShell::Insert2(rFld, bDeleted); - EndUndo(UNDO_INSERT); + EndUndo(); EndAllAction(); } @@ -229,10 +229,11 @@ BOOL SwWrtShell::UpdateTableOf(const SwTOXBase& rTOX, const SfxItemSet* pSet) if (pSet == NULL) { - SwDoc * _pDoc = GetDoc(); - - if (_pDoc != NULL) - _pDoc->DelAllUndoObj(); + SwDoc *const pDoc_ = GetDoc(); + if (pDoc_) + { + pDoc_->GetIDocumentUndoRedo().DelAllUndoObj(); + } } } @@ -480,8 +481,14 @@ 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 != GetUndoIds() ) - DoUndo( FALSE ); + SwUndoId nLastUndoId(UNDO_EMPTY); + if (GetLastUndoInfo(0, & nLastUndoId)) + { + 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 8a20a03be0f0..b721b0500a29 100644 --- a/sw/source/ui/wrtsh/wrtundo.cxx +++ b/sw/source/ui/wrtsh/wrtundo.cxx @@ -36,6 +36,7 @@ #include <svl/slstitm.hxx> #include <wrtsh.hxx> #include <swundo.hxx> // fuer Undo-Ids +#include <IDocumentUndoRedo.hxx> #include <swdtflvr.hxx> #include <svtools/svtdata.hxx> #include <svtools/svtools.hrc> @@ -60,7 +61,7 @@ void SwWrtShell::Do( DoType eDoType, USHORT nCnt ) DoUndo(sal_False); // #i21739# // Modi zuruecksetzen EnterStdMode(); - SwEditShell::Undo(UNDO_EMPTY, nCnt ); + SwEditShell::Undo(nCnt); break; case REDO: DoUndo(sal_False); // #i21739# @@ -113,70 +114,66 @@ void SwWrtShell::Do( DoType eDoType, USHORT nCnt ) String SwWrtShell::GetDoString( DoType eDoType ) const { - String aStr, aUndoStr; + ::rtl::OUString aUndoStr; USHORT nResStr = STR_UNDO; switch( eDoType ) { case UNDO: nResStr = STR_UNDO; - aUndoStr = GetUndoIdsStr(); + GetLastUndoInfo(& aUndoStr, 0); break; case REDO: nResStr = STR_REDO; - aUndoStr = GetRedoIdsStr(); + GetFirstRedoInfo(& aUndoStr); break; default:;//prevent warning } - aStr.Insert( String( SvtResId( nResStr)), 0 ); - aStr += aUndoStr; + ::rtl::OUStringBuffer buf = ::rtl::OUStringBuffer( String( SvtResId( nResStr ) ) ); + buf.append(aUndoStr); - return aStr; + return buf.makeStringAndClear(); } USHORT SwWrtShell::GetDoStrings( DoType eDoType, SfxStringListItem& rStrs ) const { - SwUndoIds aIds; + SwUndoComments_t comments; switch( eDoType ) { case UNDO: - GetUndoIds( NULL, &aIds ); + comments = GetIDocumentUndoRedo().GetUndoComments(); break; case REDO: - GetRedoIds( NULL, &aIds ); + comments = GetIDocumentUndoRedo().GetRedoComments(); break; default:;//prevent warning } - String sList; - for( USHORT n = 0, nEnd = aIds.Count(); n < nEnd; ++n ) + ::rtl::OUStringBuffer buf; + for (size_t i = 0; i < comments.size(); ++i) { - const SwUndoIdAndName& rIdNm = *aIds[ n ]; - if( rIdNm.GetUndoStr() ) - sList += *rIdNm.GetUndoStr(); - else - { - ASSERT( !this, "no Undo/Redo Test set" ); - } - sList += '\n'; + OSL_ENSURE(comments[i].getLength(), "no Undo/Redo Text set"); + buf.append(comments[i]); + buf.append(sal_Unicode('\n')); } - rStrs.SetString( sList ); - return aIds.Count(); + rStrs.SetString(buf.makeStringAndClear()); + return static_cast<sal_uInt16>(comments.size()); } String SwWrtShell::GetRepeatString() const { - String aStr; - String aUndoStr = GetRepeatIdsStr(); + ::rtl::OUString str; + GetRepeatInfo(& str); - if (aUndoStr.Len() > 0) + if (str.getLength() == 0) { - aStr.Insert( SvtResId( STR_REPEAT ), 0 ); - aStr += aUndoStr; + return str; } - return aStr; + ::rtl::OUStringBuffer buf( String(SvtResId(STR_REPEAT)) ); + buf.append(str); + return buf.makeStringAndClear(); } |