[Libreoffice-commits] core.git: sw/qa sw/source
Mike Kaganski
mike.kaganski at collabora.com
Mon Nov 21 08:51:39 UTC 2016
sw/qa/extras/uiwriter/data/tdf95699.odt |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 20 ++++++++++++++++
sw/source/core/doc/DocumentContentOperationsManager.cxx | 6 +++-
3 files changed, 24 insertions(+), 2 deletions(-)
New commits:
commit de524d2051abd700f93da4e0e9f273504b12515a
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Fri Nov 18 11:17:40 2016 +0300
tdf#95699: allow copy FORMCHECKBOX and FORMDROPDOWN ...
... when they are selected alone (no adjacent text selected).
Unit test included.
Change-Id: Ia278ae2ea86a3e6d83e1a628880f770f1eb11cd7
Reviewed-on: https://gerrit.libreoffice.org/30954
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sw/qa/extras/uiwriter/data/tdf95699.odt b/sw/qa/extras/uiwriter/data/tdf95699.odt
new file mode 100644
index 0000000..79cf858
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf95699.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index f001fc6..4c12fc3 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -213,6 +213,7 @@ public:
void testRedlineTimestamp();
void testCursorWindows();
void testLandscape();
+ void testTdf95699();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -323,6 +324,7 @@ public:
CPPUNIT_TEST(testRedlineTimestamp);
CPPUNIT_TEST(testCursorWindows);
CPPUNIT_TEST(testLandscape);
+ CPPUNIT_TEST(testTdf95699);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4049,6 +4051,24 @@ void SwUiWriterTest::testLandscape()
CPPUNIT_ASSERT(pWrtShell->GetPageDesc(nPageDesc).GetLandscape());
}
+void SwUiWriterTest::testTdf95699()
+{
+ // Open the document with single FORMCHECKBOX field, select all and copy to clipboard
+ // then check that clipboard contains the FORMCHECKBOX in text body.
+ // Previously that failed.
+ SwDoc* pDoc = createDoc("tdf95699.odt");
+ IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ SwDoc aClipboard;
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->SelAll();
+ pWrtShell->Copy(&aClipboard);
+ pMarkAccess = aClipboard.getIDocumentMarkAccess();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ ::sw::mark::IFieldmark* pFieldMark = pMarkAccess->getFieldmarkAfter(SwPosition(pDoc->GetNodes().GetEndOfExtras()));
+ CPPUNIT_ASSERT_EQUAL(OUString("vnd.oasis.opendocument.field.FORMCHECKBOX"), pFieldMark->GetFieldname());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index bdf8038..9e64e0a 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -234,14 +234,16 @@ namespace
const SwPosition& rMarkStart = pMark->GetMarkStart();
const SwPosition& rMarkEnd = pMark->GetMarkEnd();
// only include marks that are in the range and not touching both start and end
- // - not for annotation marks.
+ // - not for annotation or checkbox marks.
const bool bIsNotOnBoundary =
pMark->IsExpanded()
? (rMarkStart != rStt || rMarkEnd != rEnd) // rMarkStart != rMarkEnd
: (rMarkStart != rStt && rMarkEnd != rEnd); // rMarkStart == rMarkEnd
+ const IDocumentMarkAccess::MarkType aMarkType = IDocumentMarkAccess::GetType(*pMark);
if ( rMarkStart >= rStt && rMarkEnd <= rEnd
&& ( bIsNotOnBoundary
- || IDocumentMarkAccess::GetType( *pMark ) == IDocumentMarkAccess::MarkType::ANNOTATIONMARK ) )
+ || aMarkType == IDocumentMarkAccess::MarkType::ANNOTATIONMARK
+ || aMarkType == IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK ) )
{
vMarksToCopy.push_back(pMark);
}
More information about the Libreoffice-commits
mailing list