sd/source/ui/view/drviewse.cxx      |   10 ++++++++--
 sw/qa/extras/uiwriter/uiwriter6.cxx |    8 --------
 sw/qa/extras/uiwriter/uiwriter8.cxx |    9 ---------
 sw/source/uibase/inc/wrtsh.hxx      |    3 +++
 sw/source/uibase/shells/textsh.cxx  |   19 ++++++++++++++++---
 sw/source/uibase/wrtsh/wrtsh4.cxx   |   17 +++++++++++++++++
 6 files changed, 44 insertions(+), 22 deletions(-)

New commits:
commit 5de5a5bde5024b5cdf8cfc1aa342c387f0cb1565
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Thu Apr 11 08:56:17 2024 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Mon Apr 15 19:11:12 2024 +0200

    Improve case rotation in sentence case
    
    Rotating case (Shift+F3) applies sentence case only
    if multiple words are already selected or selects
    sentence if SENTENCE_CASE is going to be applied.
    
    Change-Id: I9e8536d7744a344d7ad54150783e91e843e0e81e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165986
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index bb51b96d8137..c0804bc91bac 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -721,10 +721,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
 
     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", {});
@@ -743,10 +739,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
 
     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", {});
diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index a928bea1695d..9caed95c578b 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -837,15 +837,6 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf116315)
         pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_F3);
         Scheduler::ProcessEventsToIdle();
 
-        // Sentence Case
-        // Without the fix in place, this test would have failed with
-        // - Expected: This is a Test
-        // - Actual  : This is a TEST
-        CPPUNIT_ASSERT_EQUAL(OUString("This is a Test"), 
getParagraph(1)->getString());
-
-        pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_F3);
-        Scheduler::ProcessEventsToIdle();
-
         // Upper Case
         CPPUNIT_ASSERT_EQUAL(OUString("This is a TEST"), 
getParagraph(1)->getString());
 
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
index a055c0cb4b8a..c1365979b5a6 100644
--- a/sw/source/uibase/inc/wrtsh.hxx
+++ b/sw/source/uibase/inc/wrtsh.hxx
@@ -237,6 +237,8 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
                 { SimpleMove( &SwWrtShell::BwdPara_, false/*bSelect*/ ); }
     void FwdSentence( bool bSelect = false )
                 { SimpleMove( &SwWrtShell::FwdSentence_, bSelect ); }
+    void EndSentence( bool bSelect = false )
+                { SimpleMove( &SwWrtShell::EndSentence_, bSelect ); }
     void BwdSentence( bool bSelect = false )
                 { SimpleMove( &SwWrtShell::BwdSentence_, bSelect ); }
 
@@ -588,6 +590,7 @@ private:
     SAL_DLLPRIVATE bool NxtWrdForDelete();
     SAL_DLLPRIVATE bool PrvWrdForDelete();
     SAL_DLLPRIVATE bool FwdSentence_();
+    SAL_DLLPRIVATE bool EndSentence_();
     SAL_DLLPRIVATE bool BwdSentence_();
     bool FwdPara_();
     SAL_DLLPRIVATE bool BwdPara_();
diff --git a/sw/source/uibase/shells/textsh.cxx 
b/sw/source/uibase/shells/textsh.cxx
index b3e32caab9d2..3e1b28fd5300 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -864,20 +864,33 @@ void SwTextShell::ExecRotateTransliteration( SfxRequest 
const & rReq )
 {
     if( rReq.GetSlot() == SID_TRANSLITERATE_ROTATE_CASE )
     {
+        TransliterationFlags transFlags = m_aRotateCase.getNextMode();
+        bool bSentenceCase = TransliterationFlags::SENTENCE_CASE == transFlags;
         SwWrtShell& rSh = GetShell();
         if (rSh.HasSelection())
         {
-            rSh.TransliterateText(m_aRotateCase.getNextMode());
+            if (bSentenceCase)
+            {
+                OUString aSelection = rSh.GetSelText().trim();
+                if (aSelection.getLength() <= 2 || (aSelection.indexOf(' ') < 
0 && aSelection.indexOf('        ') < 0))
+                    transFlags = m_aRotateCase.getNextMode();
+            }
+            rSh.TransliterateText(transFlags);
         }
         else
         {
+            if (bSentenceCase)
+            {
+                if (!rSh.IsEndSentence())
+                    rSh.EndSentence(false);
+            }
             if (rSh.IsEndSentence())
             {
                 rSh.BwdSentence(true);
-                rSh.TransliterateText(m_aRotateCase.getNextMode());
+                rSh.TransliterateText(transFlags);
             }
             else if ((rSh.IsEndWrd() || rSh.IsStartWord() || rSh.IsInWord()) 
&& rSh.SelWrd())
-                rSh.TransliterateText(m_aRotateCase.getNextMode());
+                rSh.TransliterateText(transFlags);
         }
     }
 }
diff --git a/sw/source/uibase/wrtsh/wrtsh4.cxx 
b/sw/source/uibase/wrtsh/wrtsh4.cxx
index 0442e3152bb6..0edf4a1780b1 100644
--- a/sw/source/uibase/wrtsh/wrtsh4.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh4.cxx
@@ -190,6 +190,23 @@ bool SwWrtShell::FwdSentence_()
     return true;
 }
 
+bool SwWrtShell::EndSentence_()
+{
+    Push();
+    ClearMark();
+    if(!SwCursorShell::Right(1,SwCursorSkipMode::Chars))
+    {
+        Pop(SwCursorShell::PopMode::DeleteCurrent);
+        return false;
+    }
+    if( !GoEndSentence() && !IsEndPara() )
+        SwCursorShell::MovePara(GoCurrPara, fnParaEnd);
+
+    ClearMark();
+    Combine();
+    return true;
+}
+
 bool SwWrtShell::BwdSentence_()
 {
     Push();
commit 4a9149b5383819203ef264a4047541722e35561e
Author:     Oliver Specht <oliver.spe...@cib.de>
AuthorDate: Mon Apr 15 11:40:12 2024 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Mon Apr 15 19:01:57 2024 +0200

    Case rotation in Impress: skip sentence case
    
    Sentence case does not make sense if a selection contains less than two 
words.
    Rotation then skkips to the next case mode.
    
    Change-Id: I79d6560c494b716a53bfed654027f6f37dc6c362
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166115
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index f1a11c90c866..32e999f858d6 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -1474,8 +1474,14 @@ void DrawViewShell::FuSupportRotate(SfxRequest const 
&rReq)
 
     if (!pOLV)
         return;
-
-    pOLV->TransliterateText( m_aRotateCase.getNextMode() );
+    TransliterationFlags transFlags = m_aRotateCase.getNextMode();
+    if (TransliterationFlags::SENTENCE_CASE == transFlags)
+    {
+        OUString SelectedText = pOLV->GetSelected().trim();
+        if (SelectedText.getLength() <= 2 || (SelectedText.indexOf(' ') < 0 && 
SelectedText.indexOf('  ') < 0))
+            transFlags = m_aRotateCase.getNextMode();
+    }
+    pOLV->TransliterateText( transFlags );
 }
 
 void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText,

Reply via email to