sw/qa/extras/layout/data/tdf147666.odt |binary
 sw/qa/extras/layout/data/tdf147666.png |binary
 sw/qa/extras/layout/layout3.cxx        |   35 +++++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

New commits:
commit ab70d0faf602de7d9711d99bd285a25c05335e9a
Author:     Adam Seskunas <adamsesku...@gmail.com>
AuthorDate: Wed Nov 1 08:21:57 2023 -0700
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 10 09:22:48 2024 +0100

    tdf#147666 sw layout: add test case
    
    The test adds a large picture to the test document, and tests if the
    document correctly moves focus to the added picture.
    
    Change-Id: I10c6ac00510250c374391fe9a53d42b3df317bb0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158761
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/layout/data/tdf147666.odt 
b/sw/qa/extras/layout/data/tdf147666.odt
new file mode 100644
index 000000000000..23a09b50cabe
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf147666.odt differ
diff --git a/sw/qa/extras/layout/data/tdf147666.png 
b/sw/qa/extras/layout/data/tdf147666.png
new file mode 100644
index 000000000000..7e845d34dd24
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf147666.png differ
diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index e4bfc5195b4b..8dc7b61645c3 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -19,6 +19,7 @@
 #include <editeng/unolingu.hxx>
 #include <editeng/editobj.hxx>
 #include <comphelper/sequence.hxx>
+#include <comphelper/propertyvalue.hxx>
 
 #include <fmtfsize.hxx>
 #include <wrtsh.hxx>
@@ -2208,6 +2209,40 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, 
testTdf57187_Tdf158900)
 }
 
 } // end of anonymous namespace
+
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf147666)
+{
+    createSwDoc("tdf147666.odt");
+
+    // Move cursor into position to insert image
+    dispatchCommand(mxComponent, ".uno:GoToEndOfPara", {});
+    dispatchCommand(mxComponent, ".uno:GoDown", {});
+
+    save("writer8");
+    sal_Int32 nNonInsertedViewTop
+        = getXPathContent(parseExport("settings.xml"),
+                          "//config:config-item[@config:name='ViewTop']"_ostr)
+              .toInt32();
+
+    // Insert image below the end of the paragraph on page one
+    uno::Sequence<beans::PropertyValue> aArgs = {
+        comphelper::makePropertyValue("FileName", 
createFileURL(u"tdf147666.png")),
+    };
+    dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs);
+
+    save("writer8");
+    sal_Int32 nInsertedViewTop
+        = getXPathContent(parseExport("settings.xml"),
+                          "//config:config-item[@config:name='ViewTop']"_ostr)
+              .toInt32();
+
+    // Without the fix in place this will fail with
+    // nInsertedViewTop = nNonInsertedViewTop
+    // i.e. when the image is inserted, the view doesn't
+    // focus to the inserted graphic
+    CPPUNIT_ASSERT_LESS(nInsertedViewTop, nNonInsertedViewTop);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to