From a39c96af53ec3364de70012ebfa7c09c4a55a7c3 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 9 May 2013 09:09:52 +0200 Subject: fdo#46808, Convert sheet::GlobalSheetSettings service to new style Change-Id: If5fc10e408427fe5d87968a0ad51a3142f895709 --- sc/source/ui/unoobj/appluno.cxx | 16 ++++++++++++++++ sc/source/ui/vba/excelvbahelper.cxx | 15 ++++++--------- sc/source/ui/vba/vbahelper.cxx | 23 ++++++++++------------- 3 files changed, 32 insertions(+), 22 deletions(-) (limited to 'sc/source/ui') diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx index 07eb1156c484..1862f9ddf62d 100644 --- a/sc/source/ui/unoobj/appluno.cxx +++ b/sc/source/ui/unoobj/appluno.cxx @@ -378,6 +378,22 @@ uno::Sequence ScSpreadsheetSettings::getSupportedServiceNames_Static() return aRet; } +sal_Bool ScSpreadsheetSettings::getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException) +{ + uno::Any any = getPropertyValue(aPropertyName); + sal_Bool b; + any >>= b; + return b; +} + +sal_Int16 ScSpreadsheetSettings::getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException) +{ + uno::Any any = getPropertyValue(aPropertyName); + sal_Int16 b; + any >>= b; + return b; +} + // XPropertySet uno::Reference SAL_CALL ScSpreadsheetSettings::getPropertySetInfo() diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index 86943a21d4ac..d8eb7f321e67 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -21,6 +21,8 @@ #include #include +#include + #include "docuno.hxx" #include "tabvwsh.hxx" #include "transobj.hxx" @@ -107,26 +109,21 @@ class PasteCellsWarningReseter { private: bool bInitialWarningState; - static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException ) + static uno::Reference< sheet::XGlobalSheetSettings > getGlobalSheetSettings() throw ( uno::RuntimeException ) { - static uno::Reference xContext( - comphelper::getProcessComponentContext() ); - static uno::Reference xServiceManager( - xContext->getServiceManager() ); - static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( OUString( "com.sun.star.sheet.GlobalSheetSettings" ) ,xContext ), uno::UNO_QUERY_THROW ); + static uno::Reference< sheet::XGlobalSheetSettings > xProps = sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() ); return xProps; } bool getReplaceCellsWarning() throw ( uno::RuntimeException ) { - sal_Bool res = false; - getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res; + sal_Bool res = getGlobalSheetSettings()->getReplaceCellsWarning(); return ( res == sal_True ); } void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException ) { - getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) ); + getGlobalSheetSettings()->setReplaceCellsWarning( bState ); } public: PasteCellsWarningReseter() throw ( uno::RuntimeException ) diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx index d77fe9074b5e..d6b5552b3aa0 100644 --- a/sc/source/ui/vba/vbahelper.cxx +++ b/sc/source/ui/vba/vbahelper.cxx @@ -17,17 +17,19 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include -#include +#include +#include #include #include #include #include #include +#include #include +#include #include -#include -#include -#include +#include + #include @@ -111,26 +113,21 @@ class PasteCellsWarningReseter { private: bool bInitialWarningState; - static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException ) + static uno::Reference< sheet::XGlobalSheetSettings > getGlobalSheetSettings() throw ( uno::RuntimeException ) { - static uno::Reference xContext( - comphelper::getProcessComponentContext() ); - static uno::Reference xServiceManager( - xContext->getServiceManager() ); - static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( OUString( "com.sun.star.sheet.GlobalSheetSettings" ) ,xContext ), uno::UNO_QUERY_THROW ); + static uno::Reference< sheet::XGlobalSheetSettings > xProps = sheet::sheet( comphelper::getProcessComponentContext() ); return xProps; } bool getReplaceCellsWarning() throw ( uno::RuntimeException ) { - sal_Bool res = false; - getGlobalSheetSettings()->getPropertyValue( OUString(REPLACE_CELLS_WARNING) ) >>= res; + sal_Bool res = getGlobalSheetSettings()->getReplaceCellsWarning(); return ( res == sal_True ); } void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException ) { - getGlobalSheetSettings()->setPropertyValue( OUString(REPLACE_CELLS_WARNING), uno::makeAny( bState ) ); + getGlobalSheetSettings()->setReplaceCellsWarning( bState ); } public: PasteCellsWarningReseter() throw ( uno::RuntimeException ) -- cgit