summaryrefslogtreecommitdiff
path: root/sw/source/core/doc/docfmt.cxx
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-06-19 20:52:11 +0200
committerMichael Stahl <mstahl@redhat.com>2013-06-20 00:34:38 +0200
commite012f326c1c32c053304998a6826cb322f2c7728 (patch)
tree6738393ea746d4407a013d4e4feebe7ca8346edc /sw/source/core/doc/docfmt.cxx
parente3e2cf30373446e5511b12467e3b8008311c81c2 (diff)
sw: implement proper Undo for SwDoc::UpdateRsid
This is annoying because it's not possible to use StartUndo/EndUndo because that would break grouping via SwUndoInsert::CanGrouping(); also SwUndoAttr is somehow incapable of removing the inserted hints of a grouped insert (it seems to leave no-length hints behind); so add an explicit call to DeleteAttributes which should avoid the no-length hints. Change-Id: I1533daed9b2cf59886f380141b4eace4b22c15e0
Diffstat (limited to 'sw/source/core/doc/docfmt.cxx')
-rw-r--r--sw/source/core/doc/docfmt.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 49a36da82d3b..748b5b28ca5b 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -26,6 +26,7 @@
#include <editeng/langitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/formatbreakitem.hxx>
+#include <editeng/rsiditem.hxx>
#include <svl/whiter.hxx>
#include <svl/zforlist.hxx>
#include <comphelper/processfactory.hxx>
@@ -44,6 +45,7 @@
#include <pam.hxx>
#include <UndoCore.hxx>
#include <UndoAttribute.hxx>
+#include <UndoInsert.hxx>
#include <ndgrf.hxx>
#include <pagedesc.hxx> // For special treatment in InsFrmFmt
#include <rolbck.hxx> // Undo-Attr
@@ -63,6 +65,7 @@
#include <fmtautofmt.hxx>
#include <istyleaccess.hxx>
#include <SwUndoFmt.hxx>
+#include <UndoManager.hxx>
#include <docsh.hxx>
using namespace ::com::sun::star::i18n;
@@ -1098,6 +1101,47 @@ bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet,
return bRet;
}
+/// Set the rsid of the next nLen symbols of rRg to the current session number
+bool SwDoc::UpdateRsid( const SwPaM &rRg, const xub_StrLen nLen )
+{
+ SwTxtNode *pTxtNode = rRg.GetPoint()->nNode.GetNode().GetTxtNode();
+ if (!pTxtNode)
+ {
+ return false;
+ }
+ xub_StrLen const nStart(rRg.GetPoint()->nContent.GetIndex() - nLen);
+ SvxRsidItem aRsid( mnRsid, RES_CHRATR_RSID );
+
+ SfxItemSet aSet(GetAttrPool(), RES_CHRATR_RSID, RES_CHRATR_RSID);
+ aSet.Put(aRsid);
+ bool const bRet(pTxtNode->SetAttr(aSet, nStart,
+ rRg.GetPoint()->nContent.GetIndex(), nsSetAttrMode::SETATTR_DEFAULT));
+
+ if (bRet && GetIDocumentUndoRedo().DoesUndo())
+ {
+ SwUndo *const pLastUndo = GetUndoManager().GetLastUndo();
+ SwUndoInsert *const pUndoInsert(dynamic_cast<SwUndoInsert*>(pLastUndo));
+ // this function is called after Insert so expects to find SwUndoInsert
+ assert(pUndoInsert);
+ if (pUndoInsert)
+ {
+ pUndoInsert->SetWithRsid();
+ }
+ }
+ return bRet;
+}
+
+bool SwDoc::UpdateParRsid( SwTxtNode *pTxtNode, sal_uInt32 nVal )
+{
+ if (!pTxtNode)
+ {
+ return false;
+ }
+
+ SvxRsidItem aRsid( nVal ? nVal : mnRsid, RES_PARATR_RSID );
+ return pTxtNode->SetAttr( aRsid );
+}
+
/// Set the attribute according to the stated format.
/// If Undo is enabled, the old values is added to the Undo history.
void SwDoc::SetAttr( const SfxPoolItem& rAttr, SwFmt& rFmt )