[Libreoffice-commits] core.git: sw/source
Jim Raykowski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 6 18:44:44 UTC 2019
sw/source/uibase/app/docst.cxx | 59 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 58 insertions(+), 1 deletion(-)
New commits:
commit c4d82fc21c5e155472f6a30244b3fce806ada85c
Author: Jim Raykowski <raykowj at gmail.com>
AuthorDate: Wed Jul 24 14:14:12 2019 -0800
Commit: Jim Raykowski <raykowj at gmail.com>
CommitDate: Tue Aug 6 20:43:46 2019 +0200
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 at gmail.com>
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
More information about the Libreoffice-commits
mailing list