diff options
author | Noel Grandin <noel@peralex.com> | 2013-01-11 13:12:07 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-01-28 08:25:24 +0200 |
commit | 77856e81ce4d279f00d0f92e917099f4f5220034 (patch) | |
tree | b2d006504cb2cb4cf678877de5a27f1b1dbc862a | |
parent | fdo#46808, don't cache the result of comphelper::getProcessComponentContext (diff) | |
download | core-77856e81ce4d279f00d0f92e917099f4f5220034.tar.gz core-77856e81ce4d279f00d0f92e917099f4f5220034.zip |
fdo#46808, Adapt document::*PropertyValues UNO service to new style
The services are:
document::NamedPropertyValues
document::IndexedPropertyValues
The services already existed, they just did not have IDL files
Change-Id: Ibafe9b5afb9b30785df4f66aa923f4b96ceabeed
23 files changed, 258 insertions, 296 deletions
diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx index 3f738336682a..951f47604145 100644 --- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx +++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx @@ -213,8 +213,8 @@ namespace dbaccess virtual void EndElement ( const sal_Bool i_bIgnoreWhitespace ); virtual void Characters( const ::rtl::OUString& i_rCharacters ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - GetServiceFactory() const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + GetComponentContext() const; private: ::rtl::OUString impl_prefix( const ::xmloff::token::XMLTokenEnum i_eToken ) @@ -267,9 +267,9 @@ namespace dbaccess } //-------------------------------------------------------------------- - Reference< XMultiServiceFactory > SettingsExportContext::GetServiceFactory() const + Reference< com::sun::star::uno::XComponentContext > SettingsExportContext::GetComponentContext() const { - return m_rContext.getLegacyServiceFactory(); + return m_rContext.getUNOContext(); } //================================================================================================================== diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 5960919e09e4..eda41014c68d 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -95,8 +95,10 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/deployment $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/document,\ DocumentProperties \ DocumentRevisionListPersistence \ + IndexedPropertyValues \ FilterConfigRefresh \ GraphicObjectResolver \ + NamedPropertyValues \ OleEmbeddedServerRegistration \ OOXMLDocumentPropertiesImporter \ )) diff --git a/offapi/com/sun/star/document/IndexedPropertyValues.idl b/offapi/com/sun/star/document/IndexedPropertyValues.idl new file mode 100644 index 000000000000..e9b96febdfab --- /dev/null +++ b/offapi/com/sun/star/document/IndexedPropertyValues.idl @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_document_IndexedPropertyValues_idl__ +#define __com_sun_star_document_IndexedPropertyValues_idl__ + +#include <com/sun/star/container/XIndexContainer.idl> + + +module com { module sun { module star { module document { + +/** + @since LibreOffice 4.1 + */ +service IndexedPropertyValues : com::sun::star::container::XIndexContainer; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/offapi/com/sun/star/document/NamedPropertyValues.idl b/offapi/com/sun/star/document/NamedPropertyValues.idl new file mode 100644 index 000000000000..08b0035cdb86 --- /dev/null +++ b/offapi/com/sun/star/document/NamedPropertyValues.idl @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef __com_sun_star_document_NamedPropertyValues_idl__ +#define __com_sun_star_document_NamedPropertyValues_idl__ + +#include <com/sun/star/container/XNameContainer.idl> + + +module com { module sun { module star { module document { + +/** + @since LibreOffice 4.1 + */ +service NamedPropertyValues : com::sun::star::container::XNameContainer; + + +}; }; }; }; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index 494729bd36d9..48432268780f 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -157,17 +157,6 @@ private: class OOX_DLLPUBLIC ContainerHelper { public: - // com.sun.star.container.XIndexContainer --------------------------------- - - /** Creates a new index container object from scratch. */ - static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > - createIndexContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); - - // com.sun.star.container.XNameContainer ---------------------------------- - - /** Creates a new name container object from scratch. */ - static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > - createNameContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); /** Returns a name that is not used in the passed name container. diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx index 75bd99e6a4d3..0686395010e2 100644 --- a/oox/source/helper/containerhelper.cxx +++ b/oox/source/helper/containerhelper.cxx @@ -82,36 +82,6 @@ void ValueRangeSet::insert( const ValueRange& rRange ) // ============================================================================ -Reference< XIndexContainer > ContainerHelper::createIndexContainer( const Reference< XComponentContext >& rxContext ) -{ - Reference< XIndexContainer > xContainer; - if( rxContext.is() ) try - { - Reference< XMultiServiceFactory > xFactory( rxContext->getServiceManager(), UNO_QUERY_THROW ); - xContainer.set( xFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), UNO_QUERY_THROW ); - } - catch( Exception& ) - { - } - OSL_ENSURE( xContainer.is(), "ContainerHelper::createIndexContainer - cannot create container" ); - return xContainer; -} - -Reference< XNameContainer > ContainerHelper::createNameContainer( const Reference< XComponentContext >& rxContext ) -{ - Reference< XNameContainer > xContainer; - if( rxContext.is() ) try - { - Reference< XMultiServiceFactory > xFactory( rxContext->getServiceManager(), UNO_QUERY_THROW ); - xContainer.set( xFactory->createInstance( "com.sun.star.document.NamedPropertyValues" ), UNO_QUERY_THROW ); - } - catch( Exception& ) - { - } - OSL_ENSURE( xContainer.is(), "ContainerHelper::createNameContainer - cannot create container" ); - return xContainer; -} - OUString ContainerHelper::getUnusedName( const Reference< XNameAccess >& rxNameAccess, const OUString& rSuggestedName, sal_Unicode cSeparator, sal_Int32 nFirstIndexToAppend ) diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 1dc60566372c..14592bc3bd57 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/beans/XMultiPropertyStates.hpp> #include <com/sun/star/chart2/data/DatabaseDataProvider.hpp> #include <com/sun/star/document/DocumentProperties.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/document/EventObject.hpp> #include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XExporter.hpp> @@ -2032,8 +2033,7 @@ uno::Reference< container::XIndexAccess > SAL_CALL OReportDefinition::getViewDat ::connectivity::checkDisposed(ReportDefinitionBase::rBHelper.bDisposed); if ( !m_pImpl->m_xViewData.is() ) { - m_pImpl->m_xViewData.set(m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")),m_aProps->m_xContext ),uno::UNO_QUERY); + m_pImpl->m_xViewData.set( document::IndexedPropertyValues::create(m_aProps->m_xContext), uno::UNO_QUERY); uno::Reference< container::XIndexContainer > xContainer(m_pImpl->m_xViewData,uno::UNO_QUERY); ::std::vector< uno::Reference< frame::XController> >::iterator aIter = m_pImpl->m_aControllers.begin(); ::std::vector< uno::Reference< frame::XController> >::iterator aEnd = m_pImpl->m_aControllers.end(); diff --git a/sc/source/filter/excel/xltoolbar.cxx b/sc/source/filter/excel/xltoolbar.cxx index 2bb994e379fb..cfc058e0bbe1 100644 --- a/sc/source/filter/excel/xltoolbar.cxx +++ b/sc/source/filter/excel/xltoolbar.cxx @@ -31,6 +31,7 @@ #include "xltoolbar.hxx" #include <rtl/ustrbuf.hxx> #include <stdarg.h> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/ui/XUIConfigurationPersistence.hpp> #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -293,9 +294,7 @@ bool ScTBC::ImportToolBarControl( ScCTBWrapper& rWrapper, const css::uno::Refere ScCTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() ); if ( pCustTB ) { - uno::Reference< container::XIndexContainer > xMenuDesc; - uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - xMenuDesc.set( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.IndexedPropertyValues" ) ) ), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexContainer > xMenuDesc = document::IndexedPropertyValues::create( comphelper::getProcessComponentContext() ); if ( !pCustTB->ImportMenuTB( rWrapper, xMenuDesc, helper ) ) return false; if ( !bIsMenuToolbar ) diff --git a/sc/source/filter/oox/viewsettings.cxx b/sc/source/filter/oox/viewsettings.cxx index d3d86219c6c4..40c50db9362d 100644 --- a/sc/source/filter/oox/viewsettings.cxx +++ b/sc/source/filter/oox/viewsettings.cxx @@ -24,7 +24,9 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> +#include <com/sun/star/document/NamedPropertyValues.hpp> #include <comphelper/mediadescriptor.hxx> #include "oox/core/filterbase.hxx" #include "oox/helper/attributelist.hxx" @@ -579,7 +581,7 @@ void ViewSettings::finalizeImport() sal_Int16 nShowMode = getWorkbookSettings().getApiShowObjectMode(); // view settings for all sheets - Reference< XNameContainer > xSheetsNC = ContainerHelper::createNameContainer( getBaseFilter().getComponentContext() ); + Reference< XNameContainer > xSheetsNC = NamedPropertyValues::create( getBaseFilter().getComponentContext() ); if( !xSheetsNC.is() ) return; for( SheetPropertiesMap::const_iterator aIt = maSheetProps.begin(), aEnd = maSheetProps.end(); aIt != aEnd; ++aIt ) ContainerHelper::insertByName( xSheetsNC, rWorksheets.getCalcSheetName( aIt->first ), aIt->second ); @@ -591,7 +593,7 @@ void ViewSettings::finalizeImport() if( !rxActiveSheetView ) rxActiveSheetView.reset( new SheetViewModel ); - Reference< XIndexContainer > xContainer = ContainerHelper::createIndexContainer( getBaseFilter().getComponentContext() ); + Reference< XIndexContainer > xContainer = IndexedPropertyValues::create( getBaseFilter().getComponentContext() ); if( xContainer.is() ) try { PropertyMap aPropMap; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index a501a32b8666..1e174bbfc8b4 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/script/XInvocation.hpp> #include <com/sun/star/script/vba/XVBAEventProcessor.hpp> #include <comphelper/processfactory.hxx> @@ -1560,21 +1561,17 @@ uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData( ) SolarMutexGuard aGuard; if (pDocShell && pDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) { - xRet.set(uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues"))))); - - uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY ); - OSL_ENSURE( xCont.is(), "ScModelObj::getViewData() failed for OLE object" ); - if( xCont.is() ) - { - uno::Sequence< beans::PropertyValue > aSeq; - aSeq.realloc(1); - rtl::OUString sName; - pDocShell->GetDocument()->GetName( pDocShell->GetDocument()->GetVisibleTab(), sName ); - rtl::OUString sOUName(sName); - aSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE)); - aSeq[0].Value <<= sOUName; - xCont->insertByIndex( 0, uno::makeAny( aSeq ) ); - } + uno::Reference < container::XIndexContainer > xCont = document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ); + xRet.set( xCont, uno::UNO_QUERY_THROW ); + + uno::Sequence< beans::PropertyValue > aSeq; + aSeq.realloc(1); + rtl::OUString sName; + pDocShell->GetDocument()->GetName( pDocShell->GetDocument()->GetVisibleTab(), sName ); + rtl::OUString sOUName(sName); + aSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE)); + aSeq[0].Value <<= sOUName; + xCont->insertByIndex( 0, uno::makeAny( aSeq ) ); } } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index c1ce5ff2dc65..f727b7562bc1 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -62,6 +62,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/document/NamedPropertyValues.hpp> using namespace com::sun::star; @@ -2628,44 +2629,35 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe static_cast<sal_Int32>(nViewID)); pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear(); - uno::Reference<lang::XMultiServiceFactory> xServiceFactory = - comphelper::getProcessServiceFactory(); - OSL_ENSURE( xServiceFactory.is(), "got no service manager" ); - if( xServiceFactory.is() ) + uno::Reference<container::XNameContainer> xNameContainer = + document::NamedPropertyValues::create( comphelper::getProcessComponentContext() ); + for (SCTAB nTab=0; nTab<static_cast<SCTAB>(maTabData.size()); nTab++) { - rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues")); - uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY); - if (xNameContainer.is()) + if (maTabData[nTab]) { - for (SCTAB nTab=0; nTab<static_cast<SCTAB>(maTabData.size()); nTab++) + uno::Sequence <beans::PropertyValue> aTableViewSettings; + maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab); + rtl::OUString sTabName; + GetDocument()->GetName( nTab, sTabName ); + uno::Any aAny; + aAny <<= aTableViewSettings; + try { - if (maTabData[nTab]) - { - uno::Sequence <beans::PropertyValue> aTableViewSettings; - maTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab); - rtl::OUString sTabName; - GetDocument()->GetName( nTab, sTabName ); - uno::Any aAny; - aAny <<= aTableViewSettings; - try - { - xNameContainer->insertByName(sTabName, aAny); - } - //#101739#; two tables with the same name are possible - catch ( container::ElementExistException& ) - { - OSL_FAIL("seems there are two tables with the same name"); - } - catch ( uno::RuntimeException& ) - { - OSL_FAIL("something went wrong"); - } - } + xNameContainer->insertByName(sTabName, aAny); + } + //#101739#; two tables with the same name are possible + catch ( container::ElementExistException& ) + { + OSL_FAIL("seems there are two tables with the same name"); + } + catch ( uno::RuntimeException& ) + { + OSL_FAIL("something went wrong"); } - pSettings[SC_TABLE_VIEWSETTINGS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES)); - pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer; } } + pSettings[SC_TABLE_VIEWSETTINGS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES)); + pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer; rtl::OUString sName; GetDocument()->GetName( nTabNo, sName ); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 37ea63392a2d..a5cbde331e59 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/embed/Aspects.hpp> @@ -607,7 +608,7 @@ uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewD if( !rList.empty() ) { - xRet = uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance("com.sun.star.document.IndexedPropertyValues")); + xRet = uno::Reference< container::XIndexAccess >(document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ), uno::UNO_QUERY); uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY ); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 9eb6026ea6f7..cb7d3ae035da 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/embed/EmbedMapUnits.hpp> #include <com/sun/star/document/XStorageChangeListener.hpp> #include <com/sun/star/document/XActionLockable.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/container/XIndexContainer.hpp> @@ -3197,8 +3198,8 @@ uno::Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() return uno::Reference < container::XIndexAccess >(); m_pData->m_contViewData = Reference < container::XIndexAccess >( - ::comphelper::getProcessServiceFactory()->createInstance( - DEFINE_CONST_UNICODE("com.sun.star.document.IndexedPropertyValues") ), + document::IndexedPropertyValues::create( + ::comphelper::getProcessComponentContext() ), uno::UNO_QUERY ); if ( !m_pData->m_contViewData.is() ) diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 6cabcbd54e95..fdef14c3dc35 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -91,6 +91,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <svl/itemiter.hxx> //SfxItemIter #include <comphelper/processfactory.hxx> @@ -1504,8 +1505,7 @@ void SwWW8ImplReader::ImportDop() aViewProps[2].Value <<= sal_Int16(0); uno::Reference< uno::XComponentContext > xComponentContext(comphelper::getProcessComponentContext()); - uno::Reference<container::XIndexContainer> xBox(xComponentContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.IndexedPropertyValues", - xComponentContext), uno::UNO_QUERY); + uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(xComponentContext); xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps)); uno::Reference<container::XIndexAccess> xIndexAccess(xBox, uno::UNO_QUERY); uno::Reference<document::XViewDataSupplier> xViewDataSupplier(mpDocShell->GetModel(), uno::UNO_QUERY); diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index 5d8c5028458f..f74857bd6fde 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -32,6 +32,7 @@ #include "ww8scan.hxx" #include <rtl/ustrbuf.hxx> #include <stdarg.h> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/ui/XUIConfigurationPersistence.hpp> #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -731,9 +732,7 @@ SwTBC::ImportToolBarControl( SwCTBWrapper& rWrapper, const css::uno::Reference< SwCTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() ); if ( pCustTB ) { - uno::Reference< container::XIndexContainer > xMenuDesc; - uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); - xMenuDesc.set( xMSF->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY_THROW ); + uno::Reference< container::XIndexContainer > xMenuDesc = document::IndexedPropertyValues::create( comphelper::getProcessComponentContext() ); if ( !pCustTB->ImportMenuTB( rWrapper,xMenuDesc, helper ) ) return false; if ( !bIsMenuBar ) diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index 84a49a34ba45..736a5a8baea0 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/io/XActiveDataControl.hpp> #include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/document/NamedPropertyValues.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/NamedValue.hpp> @@ -514,10 +515,8 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, con // Get service factory uno::Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); - OSL_ENSURE( xServiceFactory.is(), - "XMLReader::Read: got no service manager" ); - if( !xServiceFactory.is() ) - return ERR_SWG_READ_ERROR; + uno::Reference< uno::XComponentContext > xContext = + comphelper::getProcessComponentContext(); uno::Reference< io::XActiveDataSource > xSource; uno::Reference< XInterface > xPipe; @@ -696,9 +695,7 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, con OUString sProgressRange(RTL_CONSTASCII_USTRINGPARAM("ProgressRange")); xInfoSet->setPropertyValue(sProgressRange, aProgRange); - ::comphelper::ComponentContext aContext( xServiceFactory ); - Reference< container::XNameAccess > xLateInitSettings( - aContext.createComponent( "com.sun.star.document.NamedPropertyValues" ), UNO_QUERY_THROW ); + Reference< container::XNameAccess > xLateInitSettings( document::NamedPropertyValues::create(xContext), UNO_QUERY_THROW ); beans::NamedValue aLateInitSettings( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LateInitSettings" ) ), makeAny( xLateInitSettings ) @@ -872,7 +869,7 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, con const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, uno::UNO_QUERY_THROW); const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( - aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); + xContext, xStorage, aBaseURL, StreamPath) ); const uno::Reference<task::XInteractionHandler> xHandler( pDocSh->GetMedium()->GetInteractionHandler() ); xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); @@ -1054,10 +1051,8 @@ size_t XMLReader::GetSectionList( SfxMedium& rMedium, comphelper::getProcessServiceFactory(); uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); - OSL_ENSURE( xServiceFactory.is(), - "XMLReader::Read: got no service manager" ); uno::Reference < embed::XStorage > xStg2; - if( xServiceFactory.is() && ( xStg2 = rMedium.GetStorage() ).is() ) + if( ( xStg2 = rMedium.GetStorage() ).is() ) { try { diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 578269fd47c1..7148709f854d 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/xforms/XFormsSupplier.hpp> @@ -367,25 +368,14 @@ void SwXMLExport::_ExportFontDecls() #define NUM_EXPORTED_VIEW_SETTINGS 11 void SwXMLExport::GetViewSettings(Sequence<PropertyValue>& aProps) { - Reference< XMultiServiceFactory > xServiceFactory = - comphelper::getProcessServiceFactory(); - OSL_ENSURE( xServiceFactory.is(), - "XMLReader::Read: got no service manager" ); - if( !xServiceFactory.is() ) - return; - aProps.realloc( NUM_EXPORTED_VIEW_SETTINGS ); // Currently exporting 9 properties PropertyValue *pValue = aProps.getArray(); sal_Int32 nIndex = 0; - Reference < XIndexContainer > xBox (xServiceFactory->createInstance - (OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), UNO_QUERY); - if (xBox.is() ) - { - pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "Views") ); - pValue[nIndex++].Value <<= Reference < XIndexAccess > ( xBox, UNO_QUERY ); - } + Reference < XIndexContainer > xBox = IndexedPropertyValues::create( comphelper::getProcessComponentContext() ); + pValue[nIndex].Name = OUString( RTL_CONSTASCII_USTRINGPARAM ( "Views") ); + pValue[nIndex++].Value <<= Reference < XIndexAccess > ( xBox, UNO_QUERY ); Reference < XText > xText; SwXText *pText = 0; diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 33d264620ce8..c808d7611546 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> @@ -3710,8 +3711,7 @@ void DomainMapper_Impl::ApplySettingsTable() aViewProps[2].Name = "ZoomType"; aViewProps[2].Value <<= sal_Int16(0); - uno::Reference<container::XIndexContainer> xBox(m_xComponentContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.IndexedPropertyValues", - m_xComponentContext), uno::UNO_QUERY ); + uno::Reference<container::XIndexContainer> xBox = document::IndexedPropertyValues::create(m_xComponentContext); xBox->insertByIndex(sal_Int32(0), uno::makeAny(aViewProps)); uno::Reference<container::XIndexAccess> xIndexAccess(xBox, uno::UNO_QUERY); uno::Reference<document::XViewDataSupplier> xViewDataSupplier(m_xTextDocument, uno::UNO_QUERY); diff --git a/xmloff/inc/xmloff/XMLSettingsExportContext.hxx b/xmloff/inc/xmloff/XMLSettingsExportContext.hxx index 7859b387734b..46e51baa69aa 100644 --- a/xmloff/inc/xmloff/XMLSettingsExportContext.hxx +++ b/xmloff/inc/xmloff/XMLSettingsExportContext.hxx @@ -20,7 +20,7 @@ #ifndef XML_SETTINGS_EXPORT_CONTEXT_HXX #define XML_SETTINGS_EXPORT_CONTEXT_HXX -#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include "xmloff/xmltoken.hxx" @@ -46,8 +46,8 @@ namespace xmloff virtual void Characters( const ::rtl::OUString& i_rCharacters ) = 0; - virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - GetServiceFactory() const = 0; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + GetComponentContext() const = 0; protected: ~XMLSettingsExportContext() {} diff --git a/xmloff/source/core/DocumentSettingsContext.cxx b/xmloff/source/core/DocumentSettingsContext.cxx index 6ec025ce021a..c0dc4ce7e135 100644 --- a/xmloff/source/core/DocumentSettingsContext.cxx +++ b/xmloff/source/core/DocumentSettingsContext.cxx @@ -41,6 +41,8 @@ #include <com/sun/star/util/DateTime.hpp> #include <com/sun/star/document/XViewDataSupplier.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> +#include <com/sun/star/document/NamedPropertyValues.hpp> #include <rtl/ustrbuf.hxx> #include <xmlenums.hxx> @@ -52,13 +54,10 @@ class XMLMyList std::list<beans::PropertyValue> aProps; sal_uInt32 nCount; - // #110680# - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; public: - // #110680# - XMLMyList(const uno::Reference<lang::XMultiServiceFactory>& xServiceFactory); - ~XMLMyList(); + XMLMyList(const uno::Reference<uno::XComponentContext>& rxContext); void push_back(beans::PropertyValue& aProp) { aProps.push_back(aProp); nCount++; } uno::Sequence<beans::PropertyValue> GetSequence(); @@ -66,17 +65,11 @@ public: uno::Reference<container::XIndexContainer> GetIndexContainer(); }; -// #110680# -XMLMyList::XMLMyList(const uno::Reference<lang::XMultiServiceFactory>& xServiceFactory) +XMLMyList::XMLMyList(const uno::Reference<uno::XComponentContext>& rxContext) : nCount(0), - mxServiceFactory(xServiceFactory) -{ - DBG_ASSERT( mxServiceFactory.is(), "got no service manager" ); -} - -// #110680# -XMLMyList::~XMLMyList() + m_xContext(rxContext) { + DBG_ASSERT( rxContext.is(), "got no service manager" ); } uno::Sequence<beans::PropertyValue> XMLMyList::GetSequence() @@ -100,48 +93,29 @@ uno::Sequence<beans::PropertyValue> XMLMyList::GetSequence() uno::Reference<container::XNameContainer> XMLMyList::GetNameContainer() { - uno::Reference<container::XNameContainer> xNameContainer; - - // #110680# - - if( mxServiceFactory.is() ) + uno::Reference<container::XNameContainer> xNameContainer = document::NamedPropertyValues::create(m_xContext); + std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); + while (aItr != aProps.end()) { - rtl::OUString sName("com.sun.star.document.NamedPropertyValues"); - xNameContainer = uno::Reference<container::XNameContainer>(mxServiceFactory->createInstance(sName), uno::UNO_QUERY); - if (xNameContainer.is()) - { - std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); - while (aItr != aProps.end()) - { - xNameContainer->insertByName(aItr->Name, aItr->Value); - ++aItr; - } - } + xNameContainer->insertByName(aItr->Name, aItr->Value); + ++aItr; } + return xNameContainer; } uno::Reference<container::XIndexContainer> XMLMyList::GetIndexContainer() { - uno::Reference<container::XIndexContainer> xIndexContainer; - // #110680# - - if( mxServiceFactory.is() ) + uno::Reference<container::XIndexContainer> xIndexContainer = document::IndexedPropertyValues::create(m_xContext); + std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); + sal_uInt32 i(0); + while (aItr != aProps.end()) { - rtl::OUString sName("com.sun.star.document.IndexedPropertyValues"); - xIndexContainer = uno::Reference<container::XIndexContainer>(mxServiceFactory->createInstance(sName), uno::UNO_QUERY); - if (xIndexContainer.is()) - { - std::list<beans::PropertyValue>::iterator aItr = aProps.begin(); - sal_uInt32 i(0); - while (aItr != aProps.end()) - { - xIndexContainer->insertByIndex(i, aItr->Value); - ++aItr; - ++i; - } - } + xIndexContainer->insertByIndex(i, aItr->Value); + ++aItr; + ++i; } + return xIndexContainer; } @@ -488,7 +462,7 @@ XMLConfigBaseContext::XMLConfigBaseContext(SvXMLImport& rImport, sal_uInt16 nPrf XMLConfigBaseContext* pTempBaseContext) : SvXMLImportContext( rImport, nPrfx, rLName ), // #110680# - maProps(rImport.getServiceFactory()), + maProps( comphelper::getComponentContext(rImport.getServiceFactory())), maProp(), mrAny(rTempAny), mpBaseContext(pTempBaseContext) diff --git a/xmloff/source/core/SettingsExportHelper.cxx b/xmloff/source/core/SettingsExportHelper.cxx index d28dab4f7ff8..a1de3f713322 100644 --- a/xmloff/source/core/SettingsExportHelper.cxx +++ b/xmloff/source/core/SettingsExportHelper.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/formula/SymbolDescriptor.hpp> #include <com/sun/star/document/PrinterIndependentLayout.hpp> +#include <com/sun/star/document/IndexedPropertyValues.hpp> #include <xmloff/XMLSettingsExportContext.hxx> #include <xmlenums.hxx> @@ -291,63 +292,53 @@ void XMLSettingsExportHelper::exportSymbolDescriptors( const uno::Sequence < formula::SymbolDescriptor > &rProps, const rtl::OUString rName) const { - // #110680# - uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() ); - DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportSymbolDescriptors: got no service manager" ); - - if( xServiceFactory.is() ) + uno::Reference< container::XIndexContainer > xBox = document::IndexedPropertyValues::create(m_rContext.GetComponentContext()); + + const rtl::OUString sName ( "Name" ); + const rtl::OUString sExportName ( "ExportName" ); + const rtl::OUString sSymbolSet ( "SymbolSet" ); + const rtl::OUString sCharacter ( "Character" ); + const rtl::OUString sFontName ( "FontName" ); + const rtl::OUString sCharSet ( "CharSet" ); + const rtl::OUString sFamily ( "Family" ); + const rtl::OUString sPitch ( "Pitch" ); + const rtl::OUString sWeight ( "Weight" ); + const rtl::OUString sItalic ( "Italic" ); + + sal_Int32 nCount = rProps.getLength(); + const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray(); + + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ ) { - uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY); - DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" ); - if (xBox.is() ) - { - const rtl::OUString sName ( "Name" ); - const rtl::OUString sExportName ( "ExportName" ); - const rtl::OUString sSymbolSet ( "SymbolSet" ); - const rtl::OUString sCharacter ( "Character" ); - const rtl::OUString sFontName ( "FontName" ); - const rtl::OUString sCharSet ( "CharSet" ); - const rtl::OUString sFamily ( "Family" ); - const rtl::OUString sPitch ( "Pitch" ); - const rtl::OUString sWeight ( "Weight" ); - const rtl::OUString sItalic ( "Italic" ); - - sal_Int32 nCount = rProps.getLength(); - const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray(); - - for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ ) - { - uno::Sequence < beans::PropertyValue > aSequence ( XML_SYMBOL_DESCRIPTOR_MAX ); - beans::PropertyValue *pSymbol = aSequence.getArray(); - - pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Name = sName; - pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Value <<= pDescriptor->sName; - pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Name = sExportName; - pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Value<<= pDescriptor->sExportName; - pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Name = sFontName; - pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Value <<= pDescriptor->sFontName; - pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Name = sCharSet; - pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Value <<= pDescriptor->nCharSet; - pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Name = sFamily; - pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Value <<= pDescriptor->nFamily; - pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Name = sPitch; - pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Value <<= pDescriptor->nPitch; - pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Name = sWeight; - pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Value <<= pDescriptor->nWeight; - pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Name = sItalic; - pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Value <<= pDescriptor->nItalic; - pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Name = sSymbolSet; - pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Value <<= pDescriptor->sSymbolSet; - pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Name = sCharacter; - pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Value <<= pDescriptor->nCharacter; - - xBox->insertByIndex(nIndex, uno::makeAny( aSequence )); - } - - uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY ); - exportIndexAccess( xIA, rName ); - } + uno::Sequence < beans::PropertyValue > aSequence ( XML_SYMBOL_DESCRIPTOR_MAX ); + beans::PropertyValue *pSymbol = aSequence.getArray(); + + pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Name = sName; + pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Value <<= pDescriptor->sName; + pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Name = sExportName; + pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Value<<= pDescriptor->sExportName; + pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Name = sFontName; + pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Value <<= pDescriptor->sFontName; + pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Name = sCharSet; + pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Value <<= pDescriptor->nCharSet; + pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Name = sFamily; + pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Value <<= pDescriptor->nFamily; + pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Name = sPitch; + pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Value <<= pDescriptor->nPitch; + pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Name = sWeight; + pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Value <<= pDescriptor->nWeight; + pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Name = sItalic; + pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Value <<= pDescriptor->nItalic; + pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Name = sSymbolSet; + pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Value <<= pDescriptor->sSymbolSet; + pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Name = sCharacter; + pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Value <<= pDescriptor->nCharacter; + + xBox->insertByIndex(nIndex, uno::makeAny( aSequence )); } + + uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY ); + exportIndexAccess( xIA, rName ); } void XMLSettingsExportHelper::exportbase64Binary( const uno::Sequence<sal_Int8>& aProps, @@ -440,56 +431,45 @@ void XMLSettingsExportHelper::exportForbiddenCharacters( if( !xForbChars.is() || !xLocales.is() ) return; - // #110680# - uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() ); - DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" ); - - if( xServiceFactory.is() ) - { - uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY); - DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" ); - if (xBox.is() ) - { - const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() ); - const lang::Locale* pLocales = aLocales.getConstArray(); + uno::Reference< container::XIndexContainer > xBox = document::IndexedPropertyValues::create(m_rContext.GetComponentContext()); + const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() ); + const lang::Locale* pLocales = aLocales.getConstArray(); - const sal_Int32 nCount = aLocales.getLength(); + const sal_Int32 nCount = aLocales.getLength(); - const rtl::OUString sLanguage ( "Language" ); - const rtl::OUString sCountry ( "Country" ); - const rtl::OUString sVariant ( "Variant" ); - const rtl::OUString sBeginLine ( "BeginLine" ); - const rtl::OUString sEndLine ( "EndLine" ); - - sal_Int32 nPos = 0; - for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ ) - { - if( xForbChars->hasForbiddenCharacters( *pLocales ) ) - { - const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) ); - - - uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX ); - beans::PropertyValue *pForChar = aSequence.getArray(); - - pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name = sLanguage; - pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language; - pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name = sCountry; - pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country; - pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name = sVariant; - pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant; - pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name = sBeginLine; - pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine; - pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name = sEndLine; - pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine; - xBox->insertByIndex(nPos++, uno::makeAny( aSequence )); - } - } + const rtl::OUString sLanguage ( "Language" ); + const rtl::OUString sCountry ( "Country" ); + const rtl::OUString sVariant ( "Variant" ); + const rtl::OUString sBeginLine ( "BeginLine" ); + const rtl::OUString sEndLine ( "EndLine" ); - uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY ); - exportIndexAccess( xIA, rName ); + sal_Int32 nPos = 0; + for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ ) + { + if( xForbChars->hasForbiddenCharacters( *pLocales ) ) + { + const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) ); + + + uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX ); + beans::PropertyValue *pForChar = aSequence.getArray(); + + pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name = sLanguage; + pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language; + pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name = sCountry; + pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country; + pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name = sVariant; + pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant; + pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name = sBeginLine; + pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine; + pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name = sEndLine; + pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine; + xBox->insertByIndex(nPos++, uno::makeAny( aSequence )); } } + + uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY ); + exportIndexAccess( xIA, rName ); } void XMLSettingsExportHelper::exportAllSettings( @@ -525,11 +505,10 @@ void XMLSettingsExportHelper::ManipulateSetting( uno::Any& rAny, const rtl::OUSt { if( !mxStringSubsitution.is() ) { - if( m_rContext.GetServiceFactory().is() ) try + try { - uno::Reference< uno::XComponentContext > xContext( comphelper::getComponentContext(m_rContext.GetServiceFactory()) ); const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution = - util::PathSubstitution::create(xContext); + util::PathSubstitution::create( m_rContext.GetComponentContext() ); } catch( uno::Exception& ) { diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 1ac34542f76c..94e145412a34 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -166,8 +166,8 @@ public: virtual void Characters( const ::rtl::OUString& i_rCharacters ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - GetServiceFactory() const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + GetComponentContext() const; private: SvXMLExport& m_rExport; ::std::stack< ::rtl::OUString > m_aElements; @@ -202,9 +202,9 @@ void SettingsExportFacade::Characters( const ::rtl::OUString& i_rCharacters ) m_rExport.GetDocHandler()->characters( i_rCharacters ); } -Reference< XMultiServiceFactory > SettingsExportFacade::GetServiceFactory() const +Reference< XComponentContext > SettingsExportFacade::GetComponentContext() const { - return m_rExport.getServiceFactory(); + return comphelper::getComponentContext( m_rExport.getServiceFactory() ); } //============================================================================== diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx index 8166f37088d5..44ca5d465b7f 100644 --- a/xmloff/source/xforms/xformsexport.cxx +++ b/xmloff/source/xforms/xformsexport.cxx @@ -38,6 +38,7 @@ #include <tools/diagnose_ex.h> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/document/NamedPropertyValues.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/form/binding/XValueBinding.hpp> #include <com/sun/star/form/binding/XBindableValue.hpp> @@ -794,10 +795,7 @@ void getXFormsSettings( const Reference< XNameAccess >& _rXForms, Sequence< Prop Sequence< ::rtl::OUString > aModelNames( _rXForms->getElementNames() ); - ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); - Reference< XNameContainer > xModelSettings( - aContext.createComponent( "com.sun.star.document.NamedPropertyValues" ), - UNO_QUERY_THROW ); + Reference< XNameContainer > xModelSettings = document::NamedPropertyValues::create( comphelper::getProcessComponentContext() ); for ( const ::rtl::OUString* pModelName = aModelNames.getConstArray(); pModelName != aModelNames.getConstArray() + aModelNames.getLength(); |