[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 14 15:43:42 UTC 2019
sw/source/core/inc/UndoAttribute.hxx | 1 +
sw/source/core/undo/unattr.cxx | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
New commits:
commit f9c85a92fae87c4c6d12bb1eab091ceb24cf8ca6
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Fri Aug 2 12:02:07 2019 +0300
Commit: Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Wed Aug 14 17:42:52 2019 +0200
sw: avoid dangling references to style in undo/redo
if text style was created/deleted, reference contained
in SwUndoAttr is irrelevant and can't be used. Instead of this
style name is keept and reference to style is found during redo.
Change-Id: I688ae5e7d58149f9fe824c6b0945e72aba82abb1
Reviewed-on: https://gerrit.libreoffice.org/76842
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
(cherry picked from commit c8e64ea4fd0122dad9d4f06bacffd1c179e753f8)
Reviewed-on: https://gerrit.libreoffice.org/77424
diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx
index ab66b6d234c6..288eabe20765 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -42,6 +42,7 @@ class SwUndoAttr : public SwUndo, private SwUndRng
std::unique_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
sal_uLong m_nNodeIndex; // Offset: for Redlining
const SetAttrMode m_nInsertFlags; // insert flags
+ OUString m_aChrFormatName;
void RemoveIdx( SwDoc& rDoc );
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index e389d4341dab..a8245c7a45bc 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -678,6 +678,15 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
, m_nInsertFlags( nFlags )
{
m_AttrSet.Put( rAttr );
+
+ // Save character style as a style name, not as a reference
+ const SfxPoolItem* pItem = m_AttrSet.GetItem(RES_TXTATR_CHARFMT);
+ if (pItem)
+ {
+ uno::Any aValue;
+ pItem->QueryValue(aValue, RES_TXTATR_CHARFMT);
+ aValue >>= m_aChrFormatName;
+ }
}
SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet,
@@ -688,6 +697,14 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet,
, m_nNodeIndex( ULONG_MAX )
, m_nInsertFlags( nFlags )
{
+ // Save character style as a style name, not as a reference
+ const SfxPoolItem* pItem = m_AttrSet.GetItem(RES_TXTATR_CHARFMT);
+ if (pItem)
+ {
+ uno::Any aValue;
+ pItem->QueryValue(aValue, RES_TXTATR_CHARFMT);
+ aValue >>= m_aChrFormatName;
+ }
}
SwUndoAttr::~SwUndoAttr()
@@ -771,6 +788,17 @@ void SwUndoAttr::RedoImpl(::sw::UndoRedoContext & rContext)
SwDoc & rDoc = rContext.GetDoc();
SwPaM & rPam = AddUndoRedoPaM(rContext);
+ // Restore pointer to char format from name
+ if (!m_aChrFormatName.isEmpty())
+ {
+ SwCharFormat* pCharFormat = rDoc.FindCharFormatByName(m_aChrFormatName);
+ if (pCharFormat)
+ {
+ SwFormatCharFormat aFormat(pCharFormat);
+ m_AttrSet.Put(aFormat);
+ }
+ }
+
if ( m_pRedlineData.get() &&
IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() ) ) {
RedlineFlags eOld = rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
More information about the Libreoffice-commits
mailing list