[Libreoffice-commits] core.git: qadevOOo/runner sc/source

Stephan Bergmann sbergman at redhat.com
Wed Jan 14 03:10:28 PST 2015


 qadevOOo/runner/lib/MultiPropertyTest.java |    2 +-
 qadevOOo/runner/util/ValueChanger.java     |   10 ++++++++--
 sc/source/ui/unoobj/appluno.cxx            |   15 ++++++++++++++-
 sc/source/ui/unoobj/confuno.cxx            |   15 ++++++++++++++-
 4 files changed, 37 insertions(+), 5 deletions(-)

New commits:
commit 9ab76447cd7e1c61bc284c810734227438aa13c7
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 14 12:06:28 2015 +0100

    LinkUpdateMode property values must be in the range 0--2 or 0--3
    
    ...avoid setting bad values from generic qadevOOo property set tests, and throw
    an IllegalArgumentException if bad values do get set.  Found via
    -fsanitize=enum.  The TODO about ScLkUpdMode vs. LinkUpdateModes mismatch looks
    worrying.
    
    Change-Id: Ibc01845e7e3179dc693fe8c59c1f1ffad5282420

diff --git a/qadevOOo/runner/lib/MultiPropertyTest.java b/qadevOOo/runner/lib/MultiPropertyTest.java
index b314ccf..918d5e6 100644
--- a/qadevOOo/runner/lib/MultiPropertyTest.java
+++ b/qadevOOo/runner/lib/MultiPropertyTest.java
@@ -454,7 +454,7 @@ public class MultiPropertyTest extends MultiMethodTest
         protected Object getNewValue(String propName, Object oldValue)
                 throws java.lang.IllegalArgumentException
         {
-            return ValueChanger.changePValue(oldValue);
+            return ValueChanger.changePValue(oldValue, propName);
         }
 
         /**
diff --git a/qadevOOo/runner/util/ValueChanger.java b/qadevOOo/runner/util/ValueChanger.java
index 197de43..05b5232 100644
--- a/qadevOOo/runner/util/ValueChanger.java
+++ b/qadevOOo/runner/util/ValueChanger.java
@@ -58,9 +58,15 @@ public class ValueChanger {
             newValue = Long.valueOf(oldlong + 15);
         } else if (oldValue instanceof Short) {
             short n = ((Short) oldValue).shortValue();
-            // css.form.component.{CheckBox,RadioButton} DefaultState properties
-            // must have values in the range 0--2:
             if ("DefaultState".equals(name) && n == 2) {
+                // css.form.component.{CheckBox,RadioButton} DefaultState
+                // properties must have values in the range 0--2:
+                --n;
+            } else if ("LinkUpdateMode".equals(name) && n >= 2) {
+                // css.document.Settings LinkUpdateMode property must have
+                // values in the css.document.LinkUpdateModes range (0--3),
+                // while css.sheet.XGlobalSheetSettings LinkUpdateMode property
+                // must have values in the range 0--2:
                 --n;
             } else {
                 ++n;
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index fd7edfd..d814831 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -36,6 +36,7 @@
 #include "sc.hrc"
 #include "unonames.hxx"
 #include "funcdesc.hxx"
+#include <com/sun/star/document/LinkUpdateModes.hpp>
 #include <com/sun/star/sheet/FunctionArgument.hpp>
 #include "ScPanelFactory.hxx"
 #include <boost/scoped_array.hpp>
@@ -395,7 +396,19 @@ void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
     }
     else if (aString == SC_UNONAME_LINKUPD)
     {
-        aAppOpt.SetLinkMode( (ScLkUpdMode) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+        sal_Int16 n;
+        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 with a value in"
+                 " the range of the css.document.LinkUpdateModes constants"),
+                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;
     }
     else if (aString == SC_UNONAME_MARKHDR)
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index ed59eeb..6cd3204 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -156,7 +156,20 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
         else if ( aPropertyName == SC_UNO_SHOWPAGEBR )
             aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
         else if ( aPropertyName == SC_UNONAME_LINKUPD )
-            rDoc.SetLinkMode( static_cast<ScLkUpdMode> ( ScUnoHelpFunctions::GetInt16FromAny( aValue ) ) );
+        {
+            sal_Int16 n;
+            //TODO: css.sheet.XGlobalSheetSettings LinkUpdateMode property is
+            // documented to take values in the range 0--2 (always, never, on
+            // demaned), but appears to be routinely set to 3 here,
+            // corresponding to ScLkUpdMode LM_UNKNOWN:
+            if (!(aValue >>= n) || n < 0 || n > 3) {
+                throw css::lang::IllegalArgumentException(
+                    ("LinkUpdateMode property value must be a SHORT in the"
+                     " range 0--3"),
+                    css::uno::Reference<css::uno::XInterface>(), -1);
+            }
+            rDoc.SetLinkMode( static_cast<ScLkUpdMode>(n) );
+        }
         else if ( aPropertyName == SC_UNO_COLROWHDR )
             aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
         else if ( aPropertyName == SC_UNO_SHEETTABS )


More information about the Libreoffice-commits mailing list