summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-06-09 15:56:09 +0200
committerLászló Németh <nemeth@numbertext.org>2021-06-10 09:07:03 +0200
commit68b6004fe9df184bcbaf46dd53abfec228219df6 (patch)
treefd2cc53899adc395d0d5385f3c4d710abbdf2f6c /sw/qa
parent2693ef720d9aaabe4fca0183f0c91ab34cf47fb4 (diff)
tdf#141994 track changes: record insertion of images
by adding a SwRangeRedline to the anchoring point of the image inserted with Insert->Image... or "Insert Image" of the Standard toolbar. Note: Only images anchored as characters can be recorded this way, so change the default to-character anchoring at enabled change tracking. (In other office suites, as-character insertion is the default anchoring for inserted images with disabled change tracking, too.) Follow-up to commit d6322bcedc197a654abc7d64bfea8cf570f123bf "tdf#59463 track changes: record deletion of images". Change-Id: I593abbdb6f9f2b1a5265f112103479c1833166af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116924 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/data/ole2.pngbin0 -> 766 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx29
2 files changed, 29 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/ole2.png b/sw/qa/extras/uiwriter/data/ole2.png
new file mode 100644
index 000000000000..fdad35484e7c
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/ole2.png
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 736704b45d04..5e6cfb1fc0f4 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/table/XTableRows.hpp>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <comphelper/configuration.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <i18nlangtag/languagetag.hxx>
@@ -3533,6 +3534,34 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTrackImageDeletion)
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTrackImageInsertion)
+{
+ loadURL("private:factory/swriter", nullptr);
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+
+ // turn on red-lining and show changes
+ IDocumentRedlineAccess& rIDRA(pDoc->getIDocumentRedlineAccess());
+
+ rIDRA.SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // Insert an image with change tracking
+ OUString aImageURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "ole2.png";
+ uno::Sequence<beans::PropertyValue> aArgs = {
+ comphelper::makePropertyValue("FileName", aImageURL),
+ };
+ dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs);
+
+ const SwRedlineTable& rTable = rIDRA.GetRedlineTable();
+ // this was 0 (missing recording of insertion of images)
+ CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338)
{
load(DATA_DIRECTORY, "tdf120338.docx");