diff options
author | László Németh <nemeth@numbertext.org> | 2021-09-27 11:36:50 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-09-27 16:37:08 +0200 |
commit | c364532e6b06391a0584f58142c2366d28c803dd (patch) | |
tree | 78697e725bf80590f5d65e9eea418cb9996a01fb /sw/source/core/edit/edfcol.cxx | |
parent | bfd7730f4cf002a79dc9c02c23286850fee3f12a (diff) |
tdf#144272 sw: track change of paragraph style
Modifying style of a paragraph, e.g. from "Standard"
or "Text body" to "Heading n" styles wasn't recorded
by change tracking.
Now it's possible to track and reject these changes
also after DOCX export/import.
Note: ODF track changes doesn't support format-only
changes, so likely it will need to export the paragraph
content two times, with the old and with the new
paragraph styles, too).
Note: selecting multiple paragraphs to modify their
styles at once doesn't record the changes, yet, because
multi-paragraph ParagraphFormat redline range hasn't
supported by AppendRedline().
Change-Id: I2d81fa23c59b7b75b3101dc3f2bb8c9eed8ab165
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122707
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source/core/edit/edfcol.cxx')
-rw-r--r-- | sw/source/core/edit/edfcol.cxx | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 6b76f14623b9..dbed7a76db0f 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -68,6 +68,8 @@ #include <vcl/weld.hxx> #include <vcl/virdev.hxx> +#include <redline.hxx> +#include <poolfmt.hxx> #include <hintids.hxx> #include <doc.hxx> #include <IDocumentUndoRedo.hxx> @@ -2216,6 +2218,21 @@ void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat, GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eRedlMode ); } + // store previous paragraph style for track changes + OUString sParaStyleName; + sal_uInt16 nPoolId = USHRT_MAX; + SwContentNode * pCnt = rPaM.Start()->nNode.GetNode().GetContentNode(); + if ( pCnt && pCnt->GetTextNode() && GetDoc()->getIDocumentRedlineAccess().IsRedlineOn() ) + { + const SwTextFormatColl* pTextFormatColl = pCnt->GetTextNode()->GetTextColl(); + sal_uInt16 nStylePoolId = pTextFormatColl->GetPoolFormatId(); + // default paragraph style + if ( nStylePoolId == RES_POOLCOLL_STANDARD ) + nPoolId = nStylePoolId; + else + sParaStyleName = pTextFormatColl->GetName(); + } + // Change the paragraph style to pLocal and remove all direct paragraph formatting. GetDoc()->SetTextFormatColl(rPaM, pLocal, true, bResetListAttrs, GetLayout()); @@ -2227,6 +2244,27 @@ void SwEditShell::SetTextFormatColl(SwTextFormatColl *pFormat, aPaM.End()->nContent = pEndTextNode->GetText().getLength(); } GetDoc()->RstTextAttrs(aPaM, /*bInclRefToxMark=*/false, /*bExactRange=*/true, GetLayout()); + + // add redline tracking the previous paragraph style + if ( GetDoc()->getIDocumentRedlineAccess().IsRedlineOn() && + // multi-paragraph ParagraphFormat redline ranges + // haven't supported by AppendRedline(), yet + // TODO handle multi-paragraph selections, too, + // e.g. by breaking them to single paragraphs + aPaM.Start()->nNode == aPaM.End()->nNode ) + { + SwRangeRedline * pRedline = new SwRangeRedline( RedlineType::ParagraphFormat, aPaM ); + auto const result(GetDoc()->getIDocumentRedlineAccess().AppendRedline( pRedline, true)); + // store original paragraph style to reject formatting change + if ( IDocumentRedlineAccess::AppendResult::IGNORED != result && + ( nPoolId == RES_POOLCOLL_STANDARD || !sParaStyleName.isEmpty() ) ) + { + std::unique_ptr<SwRedlineExtraData_FormatColl> xExtra; + xExtra.reset(new SwRedlineExtraData_FormatColl(sParaStyleName, nPoolId, nullptr)); + if (xExtra) + pRedline->SetExtraData( xExtra.get() ); + } + } } } |