diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-09 09:09:52 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-13 09:38:02 +0200 |
commit | a39c96af53ec3364de70012ebfa7c09c4a55a7c3 (patch) | |
tree | 3c78a9b2d79d11f74290655dd1f6c633827a470e /sc | |
parent | c50c240e4048bd5c3d5017138ff37893476cc74f (diff) |
fdo#46808, Convert sheet::GlobalSheetSettings service to new style
Change-Id: If5fc10e408427fe5d87968a0ad51a3142f895709
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/appluno.hxx | 94 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 37 | ||||
-rw-r--r-- | sc/source/ui/unoobj/appluno.cxx | 16 | ||||
-rw-r--r-- | sc/source/ui/vba/excelvbahelper.cxx | 15 | ||||
-rw-r--r-- | sc/source/ui/vba/vbahelper.cxx | 23 |
5 files changed, 137 insertions, 48 deletions
diff --git a/sc/inc/appluno.hxx b/sc/inc/appluno.hxx index aba493bab79e..2189fa1cd412 100644 --- a/sc/inc/appluno.hxx +++ b/sc/inc/appluno.hxx @@ -22,9 +22,9 @@ #include <svl/itemprop.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/sheet/XRecentFunctions.hpp> #include <com/sun/star/sheet/XFunctionDescriptions.hpp> +#include <com/sun/star/sheet/XGlobalSheetSettings.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <cppuhelper/implbase2.hxx> @@ -48,12 +48,19 @@ com::sun::star::uno::Reference<com::sun::star::uno::XInterface> SAL_CALL class ScSpreadsheetSettings : public cppu::WeakImplHelper2< - com::sun::star::beans::XPropertySet, + com::sun::star::sheet::XGlobalSheetSettings, com::sun::star::lang::XServiceInfo> { private: SfxItemPropertySet aPropSet; + + sal_Bool getPropertyBool(const OUString& aPropertyName) throw (css::uno::RuntimeException); + sal_Int16 getPropertyInt16(const OUString& aPropertyName) throw (css::uno::RuntimeException); + void setProperty(const OUString& aPropertyName, sal_Bool p1) throw (css::uno::RuntimeException) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } + void setProperty(const OUString& aPropertyName, sal_Int16 p1) throw (css::uno::RuntimeException) + { setPropertyValue( aPropertyName, css::uno::Any(p1) ); } public: ScSpreadsheetSettings(); virtual ~ScSpreadsheetSettings(); @@ -61,7 +68,86 @@ public: static OUString getImplementationName_Static(); static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static(); - // XPropertySet + // XGlobalSheetSettings + virtual sal_Bool SAL_CALL getMoveSelection() throw (css::uno::RuntimeException) + { return getPropertyBool("MoveSelection"); } + virtual void SAL_CALL setMoveSelection(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("MoveSelection", p1); } + virtual sal_Int16 SAL_CALL getMoveDirection() throw (css::uno::RuntimeException) + { return getPropertyInt16("MoveDirection"); } + virtual void SAL_CALL setMoveDirection(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty("MoveDirection", p1); } + virtual sal_Bool SAL_CALL getEnterEdit() throw (css::uno::RuntimeException) + { return getPropertyBool("EnterEdit"); } + virtual void SAL_CALL setEnterEdit(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("EnterEdit", p1); } + virtual sal_Bool SAL_CALL getExtendFormat() throw (css::uno::RuntimeException) + { return getPropertyBool("ExtendFormat"); } + virtual void SAL_CALL setExtendFormat(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("ExtendFormat", p1); } + virtual sal_Bool SAL_CALL getRangeFinder() throw (css::uno::RuntimeException) + { return getPropertyBool("RangeFinder"); } + virtual void SAL_CALL setRangeFinder(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("RangeFinder", p1); } + virtual sal_Bool SAL_CALL getExpandReferences() throw (css::uno::RuntimeException) + { return getPropertyBool("ExpandReferences"); } + virtual void SAL_CALL setExpandReferences(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("ExpandReferences", p1); } + virtual sal_Bool SAL_CALL getMarkHeader() throw (css::uno::RuntimeException) + { return getPropertyBool("MarkHeader"); } + virtual void SAL_CALL setMarkHeader(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("MarkHeader", p1); } + virtual sal_Bool SAL_CALL getUseTabCol() throw (css::uno::RuntimeException) + { return getPropertyBool("UseTabCol"); } + virtual void SAL_CALL setUseTabCol(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("UseTabCol", p1); } + virtual sal_Int16 SAL_CALL getMetric() throw (css::uno::RuntimeException) + { return getPropertyInt16("Metric"); } + virtual void SAL_CALL setMetric(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty("Metric", p1); } + virtual sal_Int16 SAL_CALL getScale() throw (css::uno::RuntimeException) + { return getPropertyInt16("Scale"); } + virtual void SAL_CALL setScale(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty("Scale", p1); } + virtual sal_Bool SAL_CALL getDoAutoComplete() throw (css::uno::RuntimeException) + { return getPropertyBool("DoAutoComplete"); } + virtual void SAL_CALL setDoAutoComplete(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("DoAutoComplete", p1); } + virtual sal_Int16 SAL_CALL getStatusBarFunction() throw (css::uno::RuntimeException) + { return getPropertyInt16("StatusBarFunction"); } + virtual void SAL_CALL setStatusBarFunction(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty("StatusBarFunction", p1); } + virtual css::uno::Sequence<OUString> SAL_CALL getUserLists() throw (css::uno::RuntimeException) + { + css::uno::Any any = getPropertyValue("UserLists"); + css::uno::Sequence<OUString> b; + any >>= b; + return b; + } + virtual void SAL_CALL setUserLists(const css::uno::Sequence<OUString>& p1) throw (css::uno::RuntimeException) + { setPropertyValue( "UserLists", css::uno::Any(p1) ); } + virtual sal_Int16 SAL_CALL getLinkUpdateMode() throw (css::uno::RuntimeException) + { return getPropertyInt16("LinkUpdateMode"); } + virtual void SAL_CALL setLinkUpdateMode(sal_Int16 p1) throw (css::uno::RuntimeException) + { setProperty("LinkUpdateMode", p1); } + virtual sal_Bool SAL_CALL getPrintAllSheets() throw (css::uno::RuntimeException) + { return getPropertyBool("PrintAllSheets"); } + virtual void SAL_CALL setPrintAllSheets(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("PrintAllSheets", p1); } + virtual sal_Bool SAL_CALL getPrintEmptyPages() throw (css::uno::RuntimeException) + { return getPropertyBool("PrintEmptyPages"); } + virtual void SAL_CALL setPrintEmptyPages(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("PrintEmptyPages", p1); } + virtual sal_Bool SAL_CALL getUsePrinterMetrics() throw (css::uno::RuntimeException) + { return getPropertyBool("UsePrinterMetrics"); } + virtual void SAL_CALL setUsePrinterMetrics(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("UsePrinterMetrics", p1); } + virtual sal_Bool SAL_CALL getReplaceCellsWarning() throw (css::uno::RuntimeException) + { return getPropertyBool("ReplaceCellsWarning"); } + virtual void SAL_CALL setReplaceCellsWarning(sal_Bool p1) throw (css::uno::RuntimeException) + { setProperty("ReplaceCellsWarning", p1); } + + // XPropertySet virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); @@ -102,7 +188,7 @@ public: ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - // XServiceInfo + // XServiceInfo virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index c78c4df0ecb6..28a155a93b59 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -88,22 +88,21 @@ #include <svx/svdpage.hxx> #include <comphelper/processfactory.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XNamed.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/form/XFormsSupplier2.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/sheet/XUsedAreaCursor.hpp> #include <com/sun/star/sheet/XCellRangeAddressable.hpp> #include <com/sun/star/sheet/XAreaLinks.hpp> #include <com/sun/star/sheet/XAreaLink.hpp> -#include <com/sun/star/drawing/XDrawPageSupplier.hpp> -#include <com/sun/star/table/XColumnRowRange.hpp> #include <com/sun/star/sheet/XPrintAreas.hpp> -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/util/XProtectable.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/sheet/XUniqueCellFormatRangesSupplier.hpp> #include <com/sun/star/sheet/XCellRangesQuery.hpp> #include <com/sun/star/sheet/CellFlags.hpp> -#include <com/sun/star/util/XMergeable.hpp> #include <com/sun/star/sheet/XArrayFormulaRange.hpp> -#include <com/sun/star/text/XText.hpp> #include <com/sun/star/sheet/XLabelRanges.hpp> #include <com/sun/star/sheet/XLabelRange.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> @@ -111,10 +110,12 @@ #include <com/sun/star/sheet/XCellRangeReferrer.hpp> #include <com/sun/star/sheet/NamedRangeFlag.hpp> #include <com/sun/star/sheet/XSheetLinkable.hpp> -#include <com/sun/star/form/XFormsSupplier2.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/io/XSeekable.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/sheet/GlobalSheetSettings.hpp> +#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/util/XMergeable.hpp> +#include <com/sun/star/util/XProtectable.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> @@ -418,17 +419,9 @@ void ScXMLShapeExport::onExport( const uno::Reference < drawing::XShape >& xShap sal_Int16 ScXMLExport::GetFieldUnit() { - com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xProperties( - comphelper::getProcessServiceFactory()->createInstance( - OUString( "com.sun.star.sheet.GlobalSheetSettings" ) ), - com::sun::star::uno::UNO_QUERY); - if (xProperties.is()) - { - sal_Int16 nFieldUnit = 0; - if (xProperties->getPropertyValue(OUString("Metric")) >>= nFieldUnit) - return nFieldUnit; - } - return 0; + css::uno::Reference<css::sheet::XGlobalSheetSettings> xProperties = + css::sheet::GlobalSheetSettings::create( comphelper::getProcessComponentContext() ); + return xProperties->getMetric(); } 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<OUString> 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<beans::XPropertySetInfo> 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 <comphelper/processfactory.hxx> #include <com/sun/star/sheet/XSheetCellRange.hpp> +#include <com/sun/star/sheet/GlobalSheetSettings.hpp> + #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<uno::XComponentContext > xContext( - comphelper::getProcessComponentContext() ); - static uno::Reference<lang::XMultiComponentFactory > 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 <cppuhelper/bootstrap.hxx> -#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/Introspection.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/script/Converter.hpp> +#include <com/sun/star/sheet/GlobalSheetSettings.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/Introspection.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> + #include <comphelper/processfactory.hxx> @@ -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<uno::XComponentContext > xContext( - comphelper::getProcessComponentContext() ); - static uno::Reference<lang::XMultiComponentFactory > 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 ) |