diff options
author | Jim Raykowski <raykowj@gmail.com> | 2019-07-24 14:14:12 -0800 |
---|---|---|
committer | Michael Stahl <Michael.Stahl@cib.de> | 2019-08-14 17:40:36 +0200 |
commit | bd4f9c7c77a28db3a927faa6cc63e02015b65e76 (patch) | |
tree | d6db112083a0540c246bab6327b252edbc1a9868 /sw | |
parent | afe2e8d7323d2be6388056400ee053d401d36888 (diff) |
tdf#118384 Fix paragraph, character, and frame style undo redo
In order for the inherited (parent) style to be restored after create
style undo redo it must be included in the create style undo append.
This patch prevents create style undo append during style make and
provides for it after style dialog return ok when the parent of the new
style is known.
Change-Id: Ie9d7fb7989a5e669db18a1f263632ff208b0e718
Reviewed-on: https://gerrit.libreoffice.org/76279
Tested-by: Jenkins
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
(cherry picked from commit c4d82fc21c5e155472f6a30244b3fce806ada85c)
Reviewed-on: https://gerrit.libreoffice.org/77433
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/app/docst.cxx | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx index 292095ae2544..dbf79bc31180 100644 --- a/sw/source/uibase/app/docst.cxx +++ b/sw/source/uibase/app/docst.cxx @@ -88,6 +88,7 @@ #include <paratr.hxx> #include <tblafmt.hxx> #include <sfx2/watermarkitem.hxx> +#include <SwUndoFmt.hxx> using namespace ::com::sun::star; @@ -678,7 +679,19 @@ void SwDocShell::Edit( else nMask = SfxStyleSearchBits::UserDefined; - pStyle = &m_xBasePool->Make( rName, nFamily, nMask ); + if ( nFamily == SfxStyleFamily::Para || nFamily == SfxStyleFamily::Char || nFamily == SfxStyleFamily::Frame ) + { + // Prevent undo append from being done during paragraph, character, and frame style Make + // Do it after ok return from style dialog when derived from style is known + const bool bDoesUndo = GetDoc()->GetIDocumentUndoRedo().DoesUndo(); + GetDoc()->GetIDocumentUndoRedo().DoUndo( false ); + pStyle = &m_xBasePool->Make( rName, nFamily, nMask ); + GetDoc()->GetIDocumentUndoRedo().DoUndo( bDoesUndo ); + } + else + { + pStyle = &m_xBasePool->Make( rName, nFamily, nMask ); + } // set the current one as Parent SwDocStyleSheet* pDStyle = static_cast<SwDocStyleSheet*>(pStyle); @@ -840,6 +853,50 @@ void SwDocShell::Edit( if (bNew) { + switch( nFamily ) + { + case SfxStyleFamily::Para: + { + if(!xTmp->GetParent().isEmpty()) + { + SwTextFormatColl* pColl = m_pWrtShell->FindTextFormatCollByName(xTmp->GetParent()); + if (GetDoc()->GetIDocumentUndoRedo().DoesUndo()) + { + GetDoc()->GetIDocumentUndoRedo().AppendUndo( + std::make_unique<SwUndoTextFormatCollCreate>(xTmp->GetCollection(), pColl, GetDoc())); + } + } + } + break; + case SfxStyleFamily::Char: + { + if(!xTmp->GetParent().isEmpty()) + { + SwCharFormat* pCFormat = m_pWrtShell->FindCharFormatByName(xTmp->GetParent()); + if (GetDoc()->GetIDocumentUndoRedo().DoesUndo()) + { + GetDoc()->GetIDocumentUndoRedo().AppendUndo( + std::make_unique<SwUndoCharFormatCreate>(xTmp->GetCharFormat(), pCFormat, GetDoc())); + } + } + } + break; + case SfxStyleFamily::Frame: + { + if(!xTmp->GetParent().isEmpty()) + { + SwFrameFormat* pFFormat = m_pWrtShell->GetDoc()->FindFrameFormatByName(xTmp->GetParent()); + if (GetDoc()->GetIDocumentUndoRedo().DoesUndo()) + { + GetDoc()->GetIDocumentUndoRedo().AppendUndo( + std::make_unique<SwUndoFrameFormatCreate>(xTmp->GetFrameFormat(), pFFormat, GetDoc())); + } + } + } + break; + default: break; + } + SwRewriter aRewriter; aRewriter.AddRule(UndoArg1, xTmp->GetName()); //Group the create style and change style operations together under the |