sw/source/filter/xml/xmlimp.cxx |   43 +++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 22 deletions(-)

New commits:
commit 70dcd1135743eb4dae6f881201140b57c1daddd3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Sep 12 15:12:08 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Sep 12 17:00:55 2022 +0200

    tdf#150753: always do the final steps, including unlocking draw model
    
    Otherwise, it's impossible to select objects added to the document
    created from a template without content.xml, until save-and-reload,
    because they never recalculate their bounds.
    
    Change-Id: Id97f0ff14be33196703b6f0ade713203ff10df74
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139796
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 61bbf47aa11d..352d658a24d8 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -821,29 +821,31 @@ void SwXMLImport::endDocument()
 
     m_oSttNdIdx.reset();
 
+    // tdf#150753: pDoc may be null e.g. when the package lacks content.xml;
+    // we should not forget to tidy up here, including unlocking draw model
+    if (!pDoc)
+        pDoc = SwImport::GetDocFromXMLImport(*this);
+    assert(pDoc);
     // SJ: #i49801# -> now permitting repaints
-    if ( pDoc )
+    if (getImportFlags() == SvXMLImportFlags::ALL)
     {
-        if( getImportFlags() == SvXMLImportFlags::ALL )
-        {
-            // Notify math objects. If we are in the package filter this will
-            // be done by the filter object itself
-            if( IsInsertMode() )
-                pDoc->PrtOLENotify( false );
-            else if ( pDoc->IsOLEPrtNotifyPending() )
-                pDoc->PrtOLENotify( true );
-
-            assert(pDoc->IsInReading());
-            assert(pDoc->IsInXMLImport());
-            pDoc->SetInReading(false);
-            pDoc->SetInXMLImport(false);
-        }
-
-        SwDrawModel* pDrawModel = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel();
-        if ( pDrawModel )
-            pDrawModel->setLock(false);
+        // Notify math objects. If we are in the package filter this will
+        // be done by the filter object itself
+        if (IsInsertMode())
+            pDoc->PrtOLENotify(false);
+        else if (pDoc->IsOLEPrtNotifyPending())
+            pDoc->PrtOLENotify(true);
+
+        assert(pDoc->IsInReading());
+        assert(pDoc->IsInXMLImport());
+        pDoc->SetInReading(false);
+        pDoc->SetInXMLImport(false);
     }
 
+    SwDrawModel* pDrawModel = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel();
+    if (pDrawModel)
+        pDrawModel->setLock(false);
+
     // #i90243#
     if ( m_bInititedXForms )
     {
@@ -871,8 +873,6 @@ void SwXMLImport::endDocument()
         }
     }
 
-#if 1
-    if (!pDoc) { pDoc = SwImport::GetDocFromXMLImport(*this); }
     for (SwNodeOffset i(0); i < pDoc->GetNodes().Count(); ++i)
     {
         if (SwTableNode *const pTableNode = 
pDoc->GetNodes()[i]->GetTableNode())
@@ -885,7 +885,6 @@ void SwXMLImport::endDocument()
         }
         // don't skip to the end; nested tables could have subtables too...
     }
-#endif
 
     // delegate to parent: takes care of error handling
     SvXMLImport::endDocument();

Reply via email to