[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sc/source

Eike Rathke erack at redhat.com
Fri Jan 27 16:47:37 UTC 2017


 sc/source/ui/unoobj/appluno.cxx |   14 ++++------
 sc/source/ui/unoobj/confuno.cxx |   56 +++++++++++++++++++++++++++++++++-------
 2 files changed, 53 insertions(+), 17 deletions(-)

New commits:
commit 739353bcb420c18df6116cd645cc2226782e13cc
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Jan 26 17:51:17 2017 +0100

    dissolve LinkUpdateMode confusion, document::Settings vs XGlobalSheetSettings
    
    This is a combination of 3 commits.
    
    this is css::sheet::XGlobalSheetSettings attribute LinkUpdateMode
    
    ... and not css::document::Settings property LinkUpdateMode.
    It directly maps to ScLkUpdMode, LM_UNKNOWN isn't documented as a valid input value.
    
    (cherry picked from commit 109cff60a3a18b20b2e0efefd0d49f6eab9b52fd)
    
    remove now unused header file
    
    (cherry picked from commit d03cacfb7b9b126e375dfeaeed2fcd74d4fa48fb)
    
    this is the css::document::Settings property LinkUpdateMode
    
    ... not the css::sheet::XGlobalSheetSettings attribute LinkUpdateMode.
    
    (cherry picked from commit 32d90e643e4d9285366169301af4342d871c0d94)
    
    7a9696f07c1a6e1deec342f224343bd938078c2c
    039c8d39e89e693de1c5a1a4218c2fca70a6de9f
    
    Change-Id: I062a1fd32ad6a98db4f8e78de4724be1c8190407
    Reviewed-on: https://gerrit.libreoffice.org/33600
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index 2845341..989e45d 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -36,7 +36,6 @@
 #include "sc.hrc"
 #include "unonames.hxx"
 #include "funcdesc.hxx"
-#include <com/sun/star/document/LinkUpdateModes.hpp>
 #include <com/sun/star/sheet/FunctionArgument.hpp>
 #include <memory>
 
@@ -263,18 +262,17 @@ void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
     }
     else if (aPropertyName == SC_UNONAME_LINKUPD)
     {
+        // XXX NOTE: this is not css::document::Settings property
+        // LinkUpdateMode but css::sheet::XGlobalSheetSettings attribute
+        // LinkUpdateMode.
         sal_Int16 n;
-        if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER
-            || n > css::document::LinkUpdateModes::GLOBAL_SETTING)
+        if (!(aValue >>= n) || n < 0 || n >= ScLkUpdMode::LM_UNKNOWN)
         {
             throw css::lang::IllegalArgumentException(
-                ("LinkUpdateMode property value must be a SHORT with a value in"
-                 " the range of the css.document.LinkUpdateModes constants"),
+                ("LinkUpdateMode property value must be a SHORT with a value in the range of 0--2"
+                 " as documented for css::sheet::XGlobalSheetSettings attribute LinkUpdateMode"),
                 css::uno::Reference<css::uno::XInterface>(), -1);
         }
-        //TODO: ScLkUpdMode (LM_ALWAYS=0, LM_NEVER=1, LM_ON_DEMAND=2,
-        // LM_UNKNOWN=3) does not match css.document.LinkUpdateModes (NEVER=0,
-        // MANUAL=1, AUTO=2, GLOBAL_SETTINGS=3):
         aAppOpt.SetLinkMode( static_cast<ScLkUpdMode>(n) );
         bSaveApp = true;
     }
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index 7377860..b7f0c32 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -30,6 +30,7 @@
 #include "sc.hrc"
 
 #include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/document/LinkUpdateModes.hpp>
 #include <cppuhelper/supportsservice.hxx>
 #include <formula/grammar.hxx>
 #include <sfx2/printer.hxx>
@@ -158,18 +159,36 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
             aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
         else if ( aPropertyName == SC_UNONAME_LINKUPD )
         {
+            // XXX NOTE: this is the css::document::Settings property
+            // LinkUpdateMode, not the css::sheet::XGlobalSheetSettings
+            // attribute LinkUpdateMode.
             sal_Int16 n;
-            //TODO: css.sheet.XGlobalSheetSettings LinkUpdateMode property is
-            // documented to take values in the range 0--2 (always, never, on
-            // demand), but appears to be routinely set to 3 here,
-            // corresponding to ScLkUpdMode LM_UNKNOWN:
-            if (!(aValue >>= n) || n < 0 || n > 3) {
+            if (!(aValue >>= n) || n < css::document::LinkUpdateModes::NEVER ||
+                    n > css::document::LinkUpdateModes::GLOBAL_SETTING)
+            {
                 throw css::lang::IllegalArgumentException(
-                    ("LinkUpdateMode property value must be a SHORT in the"
-                     " range 0--3"),
+                    ("LinkUpdateMode property value must be a SHORT with a value in"
+                     " the range of the css::document::LinkUpdateModes constants"),
                     css::uno::Reference<css::uno::XInterface>(), -1);
             }
-            rDoc.SetLinkMode( static_cast<ScLkUpdMode>(n) );
+            ScLkUpdMode eMode;
+            switch (n)
+            {
+                case css::document::LinkUpdateModes::NEVER:
+                    eMode = LM_NEVER;
+                break;
+                case css::document::LinkUpdateModes::MANUAL:
+                    eMode = LM_ON_DEMAND;
+                break;
+                case css::document::LinkUpdateModes::AUTO:
+                    eMode = LM_ALWAYS;
+                break;
+                case css::document::LinkUpdateModes::GLOBAL_SETTING:
+                default:
+                    eMode = SC_MOD()->GetAppOptions().GetLinkMode();
+                break;
+            }
+            rDoc.SetLinkMode( eMode );
         }
         else if ( aPropertyName == SC_UNO_COLROWHDR )
             aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
@@ -391,7 +410,26 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPr
         else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
             aRet <<= aViewOpt.GetOption( VOPT_PAGEBREAKS );
         else if ( aPropertyName == SC_UNONAME_LINKUPD )
-            aRet <<= static_cast<sal_Int16> ( rDoc.GetLinkMode() );
+        {
+            sal_Int16 nLUM;
+            switch (rDoc.GetLinkMode())
+            {
+                case LM_ALWAYS:
+                    nLUM = css::document::LinkUpdateModes::AUTO;
+                break;
+                case LM_NEVER:
+                    nLUM = css::document::LinkUpdateModes::NEVER;
+                break;
+                case LM_ON_DEMAND:
+                    nLUM = css::document::LinkUpdateModes::MANUAL;
+                break;
+                case LM_UNKNOWN:
+                default:
+                    nLUM = css::document::LinkUpdateModes::GLOBAL_SETTING;
+                break;
+            }
+            aRet <<= nLUM;
+        }
         else if ( aPropertyName == SC_UNO_COLROWHDR )
             aRet <<= aViewOpt.GetOption( VOPT_HEADER );
         else if ( aPropertyName == SC_UNO_SHEETTABS )


More information about the Libreoffice-commits mailing list