diff options
author | László Németh <nemeth@numbertext.org> | 2019-01-29 14:53:43 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-01-29 20:40:30 +0100 |
commit | 9c4eef7d809ad7d283860c7b47b0f561aa240906 (patch) | |
tree | 72ee40f8545473ab8240082c9dc3b9a25994dde4 /sw | |
parent | 930ec0e6ab7bd5492fb4cf4a8f6860e3b728929d (diff) |
tdf#52391 reject/clear formatting of format-only changes
Format-only changes had 1) disabled (in Manage Changes
dialog window) or 2) bad rejection (Track Changes toolbar
icons and Edit->Track Changes menu item functions
"Reject"/"Reject All" resulted acception of the tracked
format-only changes instead of rejection).
Because format-only changes haven't had real rejection
support, yet, this commit 1) adds an often useful
reject-like function in the Manage Changes dialog window:
instead of disabling Reject/Reject All, now these buttons
clears direct text formatting in the area of the tracked
format-only changes. Because this may be not a rejection
(ie. the original text can contain direct text formatting),
the labels of the button warn about it: "Reject/Clear
formatting" and "Reject All/Clear formatting".
Note: "Reject All" still rejects only
insertions/deletions at (now first) pressing,
as from commit a8a3928bd3614e52edc0a4df6f67ce53e787905c.
2) Icons and menu items "Reject"/"Reject All" clear
direct text formatting in the areas of the tracked
format-only changes. Note: this is still not ideal,
but it can help to avoid of unintended direct
text formatting until implementing upcoming ODF 1.3
change tracking.
Change-Id: I87c3ac6165019cae9c49ed4591eaadef9e06beb5
Reviewed-on: https://gerrit.libreoffice.org/67080
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf52391.fodt | 54 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 18 | ||||
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 14 | ||||
-rw-r--r-- | sw/source/uibase/misc/redlndlg.cxx | 21 |
4 files changed, 99 insertions, 8 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf52391.fodt b/sw/qa/extras/uiwriter/data2/tdf52391.fodt new file mode 100644 index 000000000000..b61d76f716d9 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf52391.fodt @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="T2" style:family="text"> + <style:text-properties fo:background-color="#fff200"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:tracked-changes text:track-changes="false"> + <text:changed-region xml:id="ct94610104150512" text:id="ct94610104150512"> + <text:format-change> + <office:change-info> + <dc:creator>anonymous</dc:creator> + <dc:date>2019-01-29T12:09:20</dc:date> + </office:change-info> + </text:format-change> + </text:changed-region> + <text:changed-region xml:id="ct94610081735200" text:id="ct94610081735200"> + <text:deletion> + <office:change-info> + <dc:creator>anonymous</dc:creator> + <dc:date>2018-12-03T20:35:00</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + <text:changed-region xml:id="ct94610081779760" text:id="ct94610081779760"> + <text:deletion> + <office:change-info> + <dc:creator>anonymous</dc:creator> + <dc:date>2018-12-03T20:34:58</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + </text:tracked-changes> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="Standard"><text:change-start text:change-id="ct94610104150512"/><text:span text:style-name="T2">Portion1</text:span><text:change-end text:change-id="ct94610104150512"/><text:change-start text:change-id="ct94610081735200"/>Portion2<text:change-end text:change-id="ct94610081735200"/><text:change-start text:change-id="ct94610081779760"/></text:p> + <text:p text:style-name="Standard"/> + <text:p text:style-name="Standard"><text:change-end text:change-id="ct94610081779760"/>Format-only change in Portion1...</text:p> + <text:p text:style-name="Standard">...its rejection results also acception, but now rejection clears direct formatting in its text area.</text:p> + <text:p text:style-name="Standard"/> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 8a54f0a97910..93334ddc5027 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -59,6 +59,7 @@ public: void testTdf122893(); void testTdf122901(); void testTdf122942(); + void testTdf52391(); CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testRedlineMoveInsertInDelete); @@ -79,6 +80,7 @@ public: CPPUNIT_TEST(testTdf122893); CPPUNIT_TEST(testTdf122901); CPPUNIT_TEST(testTdf122942); + CPPUNIT_TEST(testTdf52391); CPPUNIT_TEST_SUITE_END(); private: @@ -823,6 +825,22 @@ void SwUiWriterTest2::testTdf122942() CPPUNIT_ASSERT_LESS(static_cast<SwTwips>(0), rVert.GetPos()); } +void SwUiWriterTest2::testTdf52391() +{ + load(DATA_DIRECTORY, "tdf52391.fodt"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {}); + + const uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 1); + // this was "Portion1", because the tracked background color of Portion1 was + // accepted for "Reject All". Now rejection clears formatting of the text + // in format-only changes, concatenating the text portions in the first paragraph. + CPPUNIT_ASSERT_EQUAL(OUString("Portion1Portion2"), xRun->getString()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 5eddd00f0ebf..39a083977b96 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -654,7 +654,19 @@ namespace { if( pRedl->GetExtraData() ) pRedl->GetExtraData()->Reject( *pRedl ); - rArr.DeleteAndDestroy( rPos-- ); + + // tdf#52391 instead of hidden acception at the requested + // rejection, remove direct text formatting to get the potential + // original state of the text (FIXME if the original text + // has already contained direct text formatting: unfortunately + // ODF 1.2 doesn't support rejection of format-only changes) + if ( pRedl->GetType() == nsRedlineType_t::REDLINE_FORMAT ) + { + SwPaM aPam( *(pRedl->Start()), *(pRedl->End()) ); + rArr.DeleteAndDestroy( rPos-- ); + rDoc.ResetAttrs(aPam); + } else + rArr.DeleteAndDestroy( rPos-- ); } break; diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 8d71eaafd69b..5c1b8156a864 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -316,10 +316,12 @@ void SwRedlineAcceptDlg::InitAuthors() } m_pTPView->EnableAccept( bEnable && bSel ); - m_pTPView->EnableReject( bEnable && bIsNotFormated && bSel ); + m_pTPView->EnableReject( bEnable && bSel ); + m_pTPView->EnableClearFormat( bEnable && !bIsNotFormated && bSel ); m_pTPView->EnableAcceptAll( bEnable ); - m_pTPView->EnableRejectAll( bEnable && - !m_bOnlyFormatedRedlines ); + m_pTPView->EnableRejectAll( bEnable ); + m_pTPView->EnableClearFormatAll( bEnable && + m_bOnlyFormatedRedlines ); } OUString SwRedlineAcceptDlg::GetRedlineText(const SwRangeRedline& rRedln, DateTime &rDateTime, sal_uInt16 nStack) @@ -793,8 +795,11 @@ void SwRedlineAcceptDlg::CallAcceptReject( bool bSelect, bool bAccept ) bool bIsNotFormatted = true; - // don't accept format-only changes secretly for Reject all - if ( !bSelect && !bAccept ) + // first remove only changes with insertion/deletion, if they exist + // (format-only changes haven't had real rejection yet, only an + // approximation: clear direct formatting, so try to warn + // with the extended button label "Reject All/Clear formatting") + if ( !bSelect && !bAccept && !m_bOnlyFormatedRedlines ) { SwRedlineTable::size_type nPosition = GetRedlinePos( *pEntry ); const SwRangeRedline& rRedln = pSh->GetRedline(nPosition); @@ -1002,8 +1007,10 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, GotoHdl, Timer *, void) } bool bEnable = !pSh->getIDocumentRedlineAccess().GetRedlinePassword().getLength(); m_pTPView->EnableAccept( bEnable && bSel /*&& !bReadonlySel*/ ); - m_pTPView->EnableReject( bEnable && bSel && bIsNotFormated /*&& !bReadonlySel*/ ); - m_pTPView->EnableRejectAll( bEnable && !m_bOnlyFormatedRedlines ); + m_pTPView->EnableReject( bEnable && bSel /*&& !bReadonlySel*/ ); + m_pTPView->EnableClearFormat( bEnable && bSel && !bIsNotFormated /*&& !bReadonlySel*/ ); + m_pTPView->EnableRejectAll( bEnable ); + m_pTPView->EnableClearFormatAll( bEnable && m_bOnlyFormatedRedlines ); } IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl, SvSimpleTable*, void) |