sw/source/core/doc/DocumentLinksAdministrationManager.cxx |   76 +++++++-------
 1 file changed, 40 insertions(+), 36 deletions(-)

New commits:
commit fad9786b06d188ba6e354620f57176f3d94a6637
Author: Caolán McNamara <caol...@redhat.com>
Date:   Tue Sep 13 12:32:04 2016 +0100

    detangle gadzillion checks into something readable
    
    no logic change intended
    
    Change-Id: Ib6af93afc1f80b7fc36239c96d5e0a71fcbcb789

diff --git a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx 
b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
index 39a8032..ea88e9a 100644
--- a/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
+++ b/sw/source/core/doc/DocumentLinksAdministrationManager.cxx
@@ -199,45 +199,49 @@ const sfx2::LinkManager& 
DocumentLinksAdministrationManager::GetLinkManager() co
 // to new SwDoc::UpdateLinks():
 void DocumentLinksAdministrationManager::UpdateLinks()
 {
-    SfxObjectCreateMode eMode;
-    sal_uInt16 nLinkMode = 
m_rDoc.GetDocumentSettingManager().getLinkUpdateMode( true );
-    if ( m_rDoc.GetDocShell()) {
-        sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
-        if( (nLinkMode != NEVER ||  document::UpdateDocMode::FULL_UPDATE == 
nUpdateDocMode) &&
-            !GetLinkManager().GetLinks().empty() &&
-            SfxObjectCreateMode::INTERNAL !=
-                        ( eMode = m_rDoc.GetDocShell()->GetCreateMode()) &&
-            SfxObjectCreateMode::ORGANIZER != eMode &&
-            SfxObjectCreateMode::PREVIEW != eMode &&
-            !m_rDoc.GetDocShell()->IsPreview() )
+    if (!m_rDoc.GetDocShell())
+        return;
+    sal_uInt16 nLinkMode = 
m_rDoc.GetDocumentSettingManager().getLinkUpdateMode(true);
+    sal_uInt16 nUpdateDocMode = m_rDoc.GetDocShell()->GetUpdateDocMode();
+    if (nLinkMode == NEVER && nUpdateDocMode != 
document::UpdateDocMode::FULL_UPDATE)
+        return;
+    if (GetLinkManager().GetLinks().empty())
+        return;
+    SfxObjectCreateMode eMode = m_rDoc.GetDocShell()->GetCreateMode();
+    if (eMode == SfxObjectCreateMode::INTERNAL)
+        return;
+    if (eMode == SfxObjectCreateMode::ORGANIZER)
+        return;
+    if (eMode == SfxObjectCreateMode::PREVIEW)
+        return;
+    if (m_rDoc.GetDocShell()->IsPreview())
+        return;
+
+    bool bAskUpdate = nLinkMode == MANUAL;
+    bool bUpdate = true;
+    switch(nUpdateDocMode)
+    {
+        case document::UpdateDocMode::NO_UPDATE:   bUpdate = false;break;
+        case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; break;
+        case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; break;
+    }
+    if (nLinkMode == AUTOMATIC && !bAskUpdate)
+    {
+        SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
+        if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
+                medium == nullptr ? OUString() : medium->GetName()))
         {
-            bool bAskUpdate = nLinkMode == MANUAL;
-            bool bUpdate = true;
-            switch(nUpdateDocMode)
-            {
-                case document::UpdateDocMode::NO_UPDATE:   bUpdate = 
false;break;
-                case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = false; 
break;
-                case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = true; 
break;
-            }
-            if (nLinkMode == AUTOMATIC && !bAskUpdate)
-            {
-                SfxMedium * medium = m_rDoc.GetDocShell()->GetMedium();
-                if (!SvtSecurityOptions().isTrustedLocationUriForUpdatingLinks(
-                        medium == nullptr ? OUString() : medium->GetName()))
-                {
-                    bAskUpdate = true;
-                }
-            }
-            if( bUpdate )
-            {
-                SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
-                SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : 
nullptr;
-                vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : 
nullptr;
-
-                GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, 
pDlgParent );
-            }
+            bAskUpdate = true;
         }
     }
+    if( bUpdate )
+    {
+        SfxMedium* pMedium = m_rDoc.GetDocShell()->GetMedium();
+        SfxFrame* pFrame = pMedium ? pMedium->GetLoadTargetFrame() : nullptr;
+        vcl::Window* pDlgParent = pFrame ? &pFrame->GetWindow() : nullptr;
+
+        GetLinkManager().UpdateAllLinks( bAskUpdate, true, false, pDlgParent );
+    }
 }
 
 bool DocumentLinksAdministrationManager::GetData( const OUString& rItem, const 
OUString& rMimeType,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to