include/svx/ctredlin.hxx                      |    3 +
 svx/source/dialog/ctredlin.cxx                |   40 +++++++++++++++++++
 svx/uiconfig/ui/acceptrejectchangesdialog.ui  |    5 ++
 sw/qa/extras/uiwriter/data2/tdf52391.fodt     |   54 ++++++++++++++++++++++++++
 sw/qa/extras/uiwriter/uiwriter2.cxx           |   18 ++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |   14 ++++++
 sw/source/uibase/misc/redlndlg.cxx            |   21 ++++++----
 7 files changed, 147 insertions(+), 8 deletions(-)

New commits:
commit 9c4eef7d809ad7d283860c7b47b0f561aa240906
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Jan 29 14:53:43 2019 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jan 29 20:40:30 2019 +0100

    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 <nem...@numbertext.org>

diff --git a/include/svx/ctredlin.hxx b/include/svx/ctredlin.hxx
index e83b9eec7e0c..7e2260b4f1c4 100644
--- a/include/svx/ctredlin.hxx
+++ b/include/svx/ctredlin.hxx
@@ -329,6 +329,9 @@ public:
     void            EnableAcceptAll(bool bFlag);
     void            EnableReject(bool bFlag);
     void            EnableRejectAll(bool bFlag);
+    static void     EnableClearFormatButton(VclPtr<PushButton>, bool bFlag);
+    void            EnableClearFormat(bool bFlag);
+    void            EnableClearFormatAll(bool bFlag);
     void            EnableUndo(bool bFlag=true);
     void            DisableUndo()       {EnableUndo(false);}
     void            ShowUndo();
diff --git a/svx/source/dialog/ctredlin.cxx b/svx/source/dialog/ctredlin.cxx
index 188d7bc582e3..5e1aefc7f7c2 100644
--- a/svx/source/dialog/ctredlin.cxx
+++ b/svx/source/dialog/ctredlin.cxx
@@ -32,6 +32,8 @@
 
 #include <editeng/unolingu.hxx>
 #include <svx/ctredlin.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/strings.hrc>
 
 #define WRITER_DATE     2
 #define CALC_DATE       3
@@ -371,6 +373,11 @@ SvxTPView::SvxTPView(vcl::Window *pParent, 
VclBuilderContainer *pTopLevel)
     pTopLevel->get(m_pRejectAll, "rejectall");
     pTopLevel->get(m_pUndo, "undo");
 
+    // set wider window for the optional extending button labels
+    // eg. "Reject/Clear formatting" instead of "Reject"
+    EnableClearFormat(true);
+    EnableClearFormatAll(true);
+
     SvSimpleTableContainer* pTable = get<SvSimpleTableContainer>("changes");
     Size aControlSize(80, 65);
     aControlSize = LogicToPixel(aControlSize, MapMode(MapUnit::MapAppFont));
@@ -483,6 +490,39 @@ void SvxTPView::EnableRejectAll(bool bFlag)
     m_pRejectAll->Enable(bFlag);
 }
 
+void SvxTPView::EnableClearFormatButton(VclPtr<PushButton> pButton, bool bFlag)
+{
+    OUString sText = pButton->GetText();
+    OUString sClearFormat = SvxResId(RID_SVXSTR_CLEARFORM);
+    sal_Int32 nPos = sText.indexOf(sClearFormat);
+
+    // add or remove "Clear formatting" to get "Reject" or "Reject/Clear 
formatting"
+    if (bFlag)
+    {
+        if (nPos == -1)
+        {
+            pButton->SetText(sText + "/" + sClearFormat);
+        }
+    }
+    else
+    {
+        if (nPos > 0)
+        {
+            pButton->SetText(sText.copy(0, nPos - 1));
+        }
+    }
+}
+
+void SvxTPView::EnableClearFormat(bool bFlag)
+{
+    EnableClearFormatButton( m_pReject, bFlag );
+}
+
+void SvxTPView::EnableClearFormatAll(bool bFlag)
+{
+    EnableClearFormatButton( m_pRejectAll, bFlag );
+}
+
 void SvxTPView::ShowUndo()
 {
     m_pUndo->Show();
diff --git a/svx/uiconfig/ui/acceptrejectchangesdialog.ui 
b/svx/uiconfig/ui/acceptrejectchangesdialog.ui
index 0161bff86885..7e9817689a99 100644
--- a/svx/uiconfig/ui/acceptrejectchangesdialog.ui
+++ b/svx/uiconfig/ui/acceptrejectchangesdialog.ui
@@ -28,6 +28,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">0</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
@@ -42,6 +43,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">1</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
@@ -56,6 +58,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">2</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
@@ -70,6 +73,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">3</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
@@ -84,6 +88,7 @@
                 <property name="expand">False</property>
                 <property name="fill">True</property>
                 <property name="position">4</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
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:oas
 is: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)
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to