[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 21 11:12:30 UTC 2020


 sw/qa/extras/ooxmlimport/data/text-copy.docx            |binary
 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx               |    1 
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   19 ++++++++++++++--
 3 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 8d58d0ef72162bbfb92cd3a894387f57c62ee8ae
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Jan 10 16:03:43 2020 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Jan 21 12:12:01 2020 +0100

    DOCX import: fix lost objects anchored to an empty linked header
    
    This is really similar to commit
    04b2310aaa094794ceedaa1bb6ff1823a2d29d3e (DOCX import: fix lost objects
    anchored to the single para of a linked header, 2020-01-10), except here
    the header is not just a single-paragraph one, but has no text portions.
    
    Update text-copy.docx to have a header which is not only a single
    paragraph, but also has no character content. This keeps testing the
    original case, but now also tests the more strict case (single paragraph
    -> single empty paragraph).
    
    Change-Id: I11bb062e77af1a83f717225ea5b4daef39e5a672
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86552
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit c12358166a9bd88fe10feabca45a6ad3f65dff8e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87123
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>

diff --git a/sw/qa/extras/ooxmlimport/data/text-copy.docx b/sw/qa/extras/ooxmlimport/data/text-copy.docx
index 9c871e633517..03c0563b37fd 100644
Binary files a/sw/qa/extras/ooxmlimport/data/text-copy.docx and b/sw/qa/extras/ooxmlimport/data/text-copy.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 11243d14e33d..d75a8c0dc4fe 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -287,6 +287,7 @@ DECLARE_OOXMLIMPORT_TEST(testTextCopy, "text-copy.docx")
 {
     // The document has a header on the second page that is copied as part of the import process.
     // The header has a single paragraph: make sure shapes anchored to it are not lost.
+    // Note that the single paragraph itself has no text portions.
     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
                                                                   uno::UNO_QUERY);
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index aacb19945791..af698f237a5b 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -1828,6 +1828,21 @@ DocumentContentOperationsManager::DocumentContentOperationsManager( SwDoc& i_rSw
 {
 }
 
+/**
+ * Checks if rStart..rEnd mark a range that makes sense to copy.
+ *
+ * bCopyText means that an empty range is OK, since paragraph-anchored objects may present.
+ */
+static bool IsEmptyRange(const SwPosition& rStart, const SwPosition& rEnd, bool bCopyText)
+{
+    bool bEmptyRange = rStart >= rEnd;
+    if (bCopyText)
+    {
+        bEmptyRange = rStart > rEnd;
+    }
+    return bEmptyRange;
+}
+
 // Copy an area into this document or into another document
 bool
 DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll, bool bCheckPos, bool bCopyText ) const
@@ -1838,7 +1853,7 @@ DocumentContentOperationsManager::CopyRange( SwPaM& rPam, SwPosition& rPos, cons
     bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection();
 
     // Catch if there's no copy to do
-    if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) )
+    if (!rPam.HasMark() || (IsEmptyRange(*pStt, *pEnd, bCopyText) && !bColumnSel))
         return false;
 
     // Prevent copying in Flys that are anchored in the area
@@ -4526,7 +4541,7 @@ bool DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
     SwPosition *const pEnd = rPam.End();
 
     // Catch when there's no copy to do.
-    if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ||
+    if (!rPam.HasMark() || (IsEmptyRange(*pStt, *pEnd, bCopyText) && !bColumnSel) ||
         //JP 29.6.2001: 88963 - don't copy if inspos is in region of start to end
         //JP 15.11.2001: don't test inclusive the end, ever exclusive
         ( pDoc == &m_rDoc && *pStt <= rPos && rPos < *pEnd ))


More information about the Libreoffice-commits mailing list