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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jul 1 09:17:41 UTC 2020


 sw/qa/uibase/shells/data/ole-save-preview-update.odt |binary
 sw/qa/uibase/shells/shells.cxx                       |   33 +++++++++++++++++--
 sw/source/uibase/shells/basesh.cxx                   |    4 ++
 3 files changed, 34 insertions(+), 3 deletions(-)

New commits:
commit b7a465c9403cf198df3424e9893c323b9d305026
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jun 23 10:31:05 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jul 1 11:17:09 2020 +0200

    sw: fix missing OLE preview on updating links
    
    Regression from commit 74844277cc2194c9e43f5bd7a6f78a9603da32f3 (disable
    generation of ole previews in ODF format until after load, 2016-09-13),
    if the document has charts without previews, it's loaded, fields are
    updated and saved, we no longer generate those previews.
    
    Given that Tools -> Update -> Update all is always an explicit user
    action, restore the permission to update OLE previews / links before
    performing the actual update.
    
    With this, comphelper::EmbeddedObjectContainer::StoreAsChildren() will
    generate those missing previews inside the getUserAllowsLinkUpdate()
    conditional block.
    
    Change-Id: Ib54e06a2e2f2e1c65951fdec302e59e63c71d008
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96928
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 2aad85f84235f362604b5fd385bb77de839d2014)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97492

diff --git a/sw/qa/uibase/shells/data/ole-save-preview-update.odt b/sw/qa/uibase/shells/data/ole-save-preview-update.odt
new file mode 100644
index 000000000000..353ce7fa050c
Binary files /dev/null and b/sw/qa/uibase/shells/data/ole-save-preview-update.odt differ
diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx
index c1012d6af1d1..fbdf35758156 100644
--- a/sw/qa/uibase/shells/shells.cxx
+++ b/sw/qa/uibase/shells/shells.cxx
@@ -26,16 +26,21 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <drawdoc.hxx>
 
+static char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/";
+
 /// Covers sw/source/uibase/shells/ fixes.
 class SwUibaseShellsTest : public SwModelTestBase
 {
 public:
-    SwDoc* createDoc();
+    SwDoc* createDoc(const char* pName = nullptr);
 };
 
-SwDoc* SwUibaseShellsTest::createDoc()
+SwDoc* SwUibaseShellsTest::createDoc(const char* pName)
 {
-    loadURL("private:factory/swriter", nullptr);
+    if (!pName)
+        loadURL("private:factory/swriter", nullptr);
+    else
+        load(DATA_DIRECTORY, pName);
 
     SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
     CPPUNIT_ASSERT(pTextDoc);
@@ -112,6 +117,28 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testShapeTextAlignment)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testOleSavePreviewUpdate)
+{
+    // Load a document with 2 charts in it. The second is down enough that you have to scroll to
+    // trigger its rendering. Previews are missing for both.
+    createDoc("ole-save-preview-update.odt");
+
+    // Explicitly update OLE previews, etc.
+    dispatchCommand(mxComponent, ".uno:UpdateAll", {});
+
+    // Save the document and see if we get the previews.
+    uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+    xStorable->storeToURL(maTempFile.GetURL(), {});
+    uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
+        = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory),
+                                                      maTempFile.GetURL());
+
+    // Without the accompanying fix in place, this test would have failed, because the object
+    // replacements were not generated, even after UpdateAll.
+    CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Object 1"));
+    CPPUNIT_ASSERT(xNameAccess->hasByName("ObjectReplacements/Object 2"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 2265ea10bb2a..2253441310f0 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -717,6 +717,10 @@ void SwBaseShell::Execute(SfxRequest &rReq)
 
         case FN_UPDATE_ALL:
             {
+                comphelper::EmbeddedObjectContainer& rEmbeddedObjectContainer
+                    = GetObjectShell()->getEmbeddedObjectContainer();
+                rEmbeddedObjectContainer.setUserAllowsLinkUpdate(true);
+
                 SwView&  rTempView = GetView();
                 rSh.EnterStdMode();
                 if( !rSh.GetLinkManager().GetLinks().empty() )


More information about the Libreoffice-commits mailing list