sw/qa/extras/uiwriter/uiwriter6.cxx                     |   69 ++++++++++++++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   38 ++++++++
 vcl/qa/cppunit/pdfexport/data/tdf157679.pptx            |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx                  |   28 ++++++
 4 files changed, 135 insertions(+)

New commits:
commit 6bf92349cab2a558a8160ad6ace409cd4b6f260e
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Oct 30 14:42:34 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Nov 2 09:29:56 2023 +0100

    tdf#157988 sw track changes: fix cycle case on a selected word
    
    Cycle case didn't work on a selected word, only on the
    word under the cursor without selection.
    
    Add unit test also for tdf#141198.
    
    Follow up to commit dc748d7dbd114fbf663752258dbaf003af2926c3
    "tdf#141198 sw: fix cycle case with change tracking".
    
    Change-Id: I0c1361c78d09e9b8743192a47dcdfa6f6da52e38
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158666
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158686

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index edfc5c153afc..316181c37cff 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -689,6 +689,75 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157937)
     dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
+{
+    createSwDoc("tdf130088.docx");
+    SwDoc* pDoc = getSwDoc();
+
+    // select the second word
+    dispatchCommand(mxComponent, ".uno:GoToNextWord", {});
+    dispatchCommand(mxComponent, ".uno:SelectWord", {});
+
+    // enable redlining
+    dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+                           pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+    // show changes
+    CPPUNIT_ASSERT_MESSAGE(
+        "redlines should be visible",
+        
IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+    // cycle case with change tracking
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    // This was false (missing revert of the tracked change)
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSODALES"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+    // tdf#141198 cycle case without selection: the word under the cursor
+
+    dispatchCommand(mxComponent, ".uno:Escape", {});
+
+    dispatchCommand(mxComponent, ".uno:GoRight", {});
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSODALES"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer 
sodalesSodales"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales 
tincidunt"));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108048)
 {
     createSwDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 47e5b818b2fb..bac73a325a5f 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3036,6 +3036,44 @@ void DocumentContentOperationsManager::TransliterateText(
             return;
         }
     }
+    else
+    {
+        bool bHasTrackedChange = false;
+        IDocumentRedlineAccess& rIDRA = m_rDoc.getIDocumentRedlineAccess();
+        if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) 
&&
+                        pEnd->GetContentIndex() > 0 )
+        {
+            SwPosition aPos(*pEnd->GetContentNode(), pEnd->GetContentIndex() - 
1);
+            SwRedlineTable::size_type n = 0;
+
+            const SwRangeRedline* pFnd =
+                                rIDRA.GetRedlineTable().FindAtPosition( aPos, 
n );
+            if ( pFnd && RedlineType::Insert == pFnd->GetType() && n > 0 )
+            {
+                const SwRangeRedline* pFnd2 = rIDRA.GetRedlineTable()[n-1];
+                if ( RedlineType::Delete == pFnd2->GetType() &&
+                      m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() 
&&
+                      *pFnd2->End() == *pFnd->Start() &&
+                      pFnd->GetAuthor() == pFnd2->GetAuthor() )
+                {
+                    bHasTrackedChange = true;
+                    SwPosition aPos2(*pFnd2->Start());
+                    rIDRA.RejectRedline(*pFnd, true);
+
+                    rIDRA.RejectRedline(*pFnd2, true);
+                    // positionate the text cursor before the changed word to 
select it
+                    if ( SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(
+                            
m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell()) )
+                    {
+                        pWrtShell->GetCursor()->GetPoint()->
+                                Assign(*aPos2.GetContentNode(), 
aPos2.GetContentIndex());
+                    }
+                }
+            }
+        }
+        if ( bHasTrackedChange )
+            return;
+    }
 
     bool bUseRedlining = m_rDoc.getIDocumentRedlineAccess().IsRedlineOn();
     // as a workaround for a known performance problem, switch off redlining
commit 0f3d1f346b5c4dfb4073e772df1ccd91e538cf3f
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Oct 31 13:43:32 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Nov 2 09:29:42 2023 +0100

    tdf#157679: vcl_pdfexport: Add unittest
    
    Change-Id: I31aa7f683e8d9f9a227ba88c58e7fdba94c83bb5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158725
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit d0f521132c43fea1ca18e18d3e31c6d868e4ebd6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158706

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx 
b/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx
new file mode 100644
index 000000000000..ca82491c21f3
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 8b06e41be74d..10c36a3f5906 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1676,6 +1676,34 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105954)
     CPPUNIT_ASSERT_LESS(static_cast<tools::Long>(250), aMeta.getWidth());
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157679)
+{
+    // Import the bugdoc and export as PDF.
+    aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export");
+    saveAsPDF(u"tdf157679.pptx");
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
+
+    // The document has one page.
+    CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+    std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+    CPPUNIT_ASSERT(pPdfPage);
+
+    // Without the fix in place, this test would have failed with
+    // - Expected: 3
+    // - Actual  : 5
+    CPPUNIT_ASSERT_EQUAL(3, pPdfPage->getObjectCount());
+
+    std::unique_ptr<vcl::pdf::PDFiumTextPage> pTextPage = 
pPdfPage->getTextPage();
+    int nPageObjectCount = pPdfPage->getObjectCount();
+    for (int i = 0; i < nPageObjectCount; ++i)
+    {
+        // Check there are not Text objects
+        std::unique_ptr<vcl::pdf::PDFiumPageObject> pPageObject = 
pPdfPage->getObject(i);
+        CPPUNIT_ASSERT(pPageObject->getType() != 
vcl::pdf::PDFPageObjectType::Text);
+    }
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128445)
 {
     // Import the bugdoc and export as PDF.

Reply via email to