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 +++++++++++++++++ 5 files changed, 36 insertions(+), 20 deletions(-)
New commits: commit b1170251fbca5b6b243902cf10695ab4c4c5642b 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:05:14 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 dbc115356cca..e4303419a599 100644 --- a/sw/qa/extras/uiwriter/uiwriter6.cxx +++ b/sw/qa/extras/uiwriter/uiwriter6.cxx @@ -742,10 +742,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", {}); @@ -764,10 +760,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 ff06611b46fd..ab820a9dfc79 100644 --- a/sw/qa/extras/uiwriter/uiwriter8.cxx +++ b/sw/qa/extras/uiwriter/uiwriter8.cxx @@ -856,15 +856,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 8b8c85753e96..e1727bfc9fdf 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -239,6 +239,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 ); } @@ -590,6 +592,7 @@ private: bool NxtWrdForDelete(); bool PrvWrdForDelete(); bool FwdSentence_(); + bool EndSentence_(); bool BwdSentence_(); SW_DLLPUBLIC bool FwdPara_(); bool BwdPara_(); diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx index 1b1fb47fd1f3..93020de3bad2 100644 --- a/sw/source/uibase/shells/textsh.cxx +++ b/sw/source/uibase/shells/textsh.cxx @@ -878,20 +878,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();