[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa sw/source

Mike Kaganski mike.kaganski at collabora.com
Wed Mar 29 15:53:29 UTC 2017


 sw/qa/extras/uiwriter/data/tdf105625.fodt |    1 +
 sw/qa/extras/uiwriter/uiwriter.cxx        |   12 +++++++++---
 sw/source/core/crsr/callnk.cxx            |    4 ++--
 sw/source/core/crsr/pam.cxx               |    4 +++-
 4 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 9b2e5dcb402445d8ddb3e88509bfacd506d66497
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Feb 1 13:52:22 2017 +0300

    tdf#105625 related: also check selection across field boundaries
    
    The problem in callnk.cxx was that when selecting 1 char to the right
    using keyboard, and exiting field boundary, nCmp pointed to previous
    position (inside field), and then compared to position to the left
    (which also may be inside field), thus missing call change link (and
    read-only state change). Seems that this was a mistake in commit
    740efbb1daf26828f70dc785c1e107f67706286b.
    
    In pam.cxx, if cursor was to the left of field, and then selected
    1 char to the right to cross field's boundary, then both PaM's point
    and mark had same fieldmark, but point was outside, and mark inside,
    and as code didn't check this condition, so read-only state wasn't
    properly set.
    
    Unit test is augmented to check the second problem.
    
    Change-Id: I7323e53eeb261b4ccdc0f9e36cc0956b373f104d
    Reviewed-on: https://gerrit.libreoffice.org/33790
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit c34fc4520dfee4ca068f249ee0756dacaa7a60cf)
    Reviewed-on: https://gerrit.libreoffice.org/35858
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/uiwriter/data/tdf105625.fodt b/sw/qa/extras/uiwriter/data/tdf105625.fodt
index 44c0577d301b..9a1d573d033f 100644
--- a/sw/qa/extras/uiwriter/data/tdf105625.fodt
+++ b/sw/qa/extras/uiwriter/data/tdf105625.fodt
@@ -3,6 +3,7 @@
  <office:body>
   <office:text>
    <text:p><field:fieldmark field:type="vnd.oasis.opendocument.field.FORMCHECKBOX"/></text:p>
+   <text:p><field:fieldmark-start field:type="vnd.oasis.opendocument.field.FORMTEXT"/>Field<field:fieldmark-end/></text:p>
   </office:text>
  </office:body>
 </office:document>
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 158364927abe..f758d8a8f640 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4155,18 +4155,24 @@ void SwUiWriterTest::testTdf105417()
 
 void SwUiWriterTest::testTdf105625()
 {
-    // We should be able to edit at positions adjacent to fields.
-    // Check if the start and the end of the only paragraph are not protected
-    // (they are adjacent to FORMCHECKBOX)
     SwDoc* pDoc = createDoc("tdf105625.fodt");
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
     uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext());
     // Ensure correct initial setting
     comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, "org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+    // We should be able to edit at positions adjacent to fields.
+    // Check if the start and the end of the 1st paragraph are not protected
+    // (they are adjacent to FORMCHECKBOX)
     pWrtShell->SttPara();
     CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
     pWrtShell->EndPara();
     CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
+    // 2nd paragraph - FORMTEXT
+    pWrtShell->Down(/*bSelect=*/false);
+    // Check selection across FORMTEXT field boundary - must be read-only
+    pWrtShell->SttPara();
+    pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+    CPPUNIT_ASSERT_EQUAL(true, pWrtShell->HasReadonlySel());
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 6e97ba4f04ab..bf56e7a846d5 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -195,8 +195,8 @@ SwCallLink::~SwCallLink()
             {
                 const OUString rText = pCNd->GetTextNode()->GetText();
                 if( !nCmp ||
-                    g_pBreakIt->GetBreakIter()->getScriptType( rText, nCmp )
-                     != g_pBreakIt->GetBreakIter()->getScriptType( rText, nCmp - 1 ))
+                    g_pBreakIt->GetBreakIter()->getScriptType( rText, nContent )
+                    != g_pBreakIt->GetBreakIter()->getScriptType(rText, nAktContent))
                 {
                     rShell.CallChgLnk();
                     return;
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index ee5ad68010ed..7c58f1665391 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -691,7 +691,9 @@ bool SwPaM::HasReadonlySel( bool bFormView, bool /*bAnnotationMode*/ ) const
             bool bAtStartA = (pA != nullptr) && (pA->GetMarkStart() == *GetPoint());
             bool bAtStartB = (pB != nullptr) && (pB->GetMarkStart() == *GetMark());
 
-            if (pA != pB)
+            if ((pA == pB) && (bAtStartA != bAtStartB))
+                bRet = true;
+            else if (pA != pB)
             {
                 // If both points are either outside or at marks edges (i.e. selection either
                 // touches fields, or fully encloses it), then don't disable editing


More information about the Libreoffice-commits mailing list