summaryrefslogtreecommitdiff
path: root/xmloff/source/core
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-01-11 13:12:07 +0200
committerNoel Grandin <noel@peralex.com>2013-01-28 08:25:24 +0200
commit77856e81ce4d279f00d0f92e917099f4f5220034 (patch)
treeb2d006504cb2cb4cf678877de5a27f1b1dbc862a /xmloff/source/core
parentce1b932bba8f90363399a9fa6515b91d7d679efa (diff)
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
Diffstat (limited to 'xmloff/source/core')
-rw-r--r--xmloff/source/core/DocumentSettingsContext.cxx70
-rw-r--r--xmloff/source/core/SettingsExportHelper.cxx185
-rw-r--r--xmloff/source/core/xmlexp.cxx8
3 files changed, 108 insertions, 155 deletions
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() );
}
//==============================================================================