diff options
-rw-r--r-- | sc/source/ui/unoobj/appluno.cxx | 14 | ||||
-rw-r--r-- | sc/source/ui/unoobj/confuno.cxx | 56 |
2 files changed, 53 insertions, 17 deletions
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 2845341982c1..989e45d64290 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 7377860b7a73..b7f0c32ff35f 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 ) |