summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-10-10 10:13:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-10-22 17:01:11 +0200
commitfb741b5e1e6aeaee74cf14af4f1cc152f0ab0952 (patch)
tree24864ba5addb12799a508ce4718868026519f057 /comphelper
parent9cabab002b1180650236f3d1f5fd32dfdd4bf79a (diff)
fdo#46808, Adapt xml::sax::XWriter UNO service to new style
Create a merged XWriter interface for the service. The xml.sax.Writer service already existed, it just did not have an IDL file. Change-Id: I4e6d3f3c68f9282a55fc7aa19778f97632fd8ad5
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/inc/comphelper/ofopxmlhelper.hxx4
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx59
2 files changed, 28 insertions, 35 deletions
diff --git a/comphelper/inc/comphelper/ofopxmlhelper.hxx b/comphelper/inc/comphelper/ofopxmlhelper.hxx
index e18d08f727ef..c263022166cd 100644
--- a/comphelper/inc/comphelper/ofopxmlhelper.hxx
+++ b/comphelper/inc/comphelper/ofopxmlhelper.hxx
@@ -96,7 +96,7 @@ public:
void SAL_CALL WriteRelationsInfoSequence(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream,
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair > >& aSequence,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext )
throw( ::com::sun::star::uno::Exception );
// writes two entries of type sequence<StringPair>
@@ -109,7 +109,7 @@ public:
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutStream,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aDefaultsSequence,
const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::StringPair >& aOverridesSequence,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext )
throw( ::com::sun::star::uno::Exception );
// XDocumentHandler
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 739b27d1512d..41f5a5ca620c 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -23,6 +23,7 @@
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/xml/sax/Parser.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <comphelper/ofopxmlhelper.hxx>
@@ -54,19 +55,15 @@ uno::Sequence< uno::Sequence< beans::StringPair > > SAL_CALL OFOPXMLHelper::Read
}
// -----------------------------------
-void SAL_CALL OFOPXMLHelper::WriteRelationsInfoSequence( const uno::Reference< io::XOutputStream >& xOutStream, const uno::Sequence< uno::Sequence< beans::StringPair > >& aSequence, const uno::Reference< lang::XMultiServiceFactory > xFactory )
+void SAL_CALL OFOPXMLHelper::WriteRelationsInfoSequence( const uno::Reference< io::XOutputStream >& xOutStream, const uno::Sequence< uno::Sequence< beans::StringPair > >& aSequence, const uno::Reference< uno::XComponentContext > xContext )
throw( uno::Exception )
{
if ( !xOutStream.is() )
throw uno::RuntimeException();
- uno::Reference< io::XActiveDataSource > xWriterSource(
- xFactory->createInstance(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ),
- uno::UNO_QUERY_THROW );
- uno::Reference< xml::sax::XDocumentHandler > xWriterHandler( xWriterSource, uno::UNO_QUERY_THROW );
+ uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
- xWriterSource->setOutputStream( xOutStream );
+ xWriter->setOutputStream( xOutStream );
::rtl::OUString aRelListElement( RTL_CONSTASCII_USTRINGPARAM( "Relationships" ) );
::rtl::OUString aRelElement( RTL_CONSTASCII_USTRINGPARAM( "Relationship" ) );
@@ -85,8 +82,8 @@ void SAL_CALL OFOPXMLHelper::WriteRelationsInfoSequence( const uno::Reference< i
aCDATAString,
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "http://schemas.openxmlformats.org/package/2006/relationships" ) ) );
- xWriterHandler->startDocument();
- xWriterHandler->startElement( aRelListElement, xRootAttrList );
+ xWriter->startDocument();
+ xWriter->startElement( aRelListElement, xRootAttrList );
for ( sal_Int32 nInd = 0; nInd < aSequence.getLength(); nInd++ )
{
@@ -108,30 +105,26 @@ void SAL_CALL OFOPXMLHelper::WriteRelationsInfoSequence( const uno::Reference< i
}
}
- xWriterHandler->startElement( aRelElement, xAttrList );
- xWriterHandler->ignorableWhitespace( aWhiteSpace );
- xWriterHandler->endElement( aRelElement );
+ xWriter->startElement( aRelElement, xAttrList );
+ xWriter->ignorableWhitespace( aWhiteSpace );
+ xWriter->endElement( aRelElement );
}
- xWriterHandler->ignorableWhitespace( aWhiteSpace );
- xWriterHandler->endElement( aRelListElement );
- xWriterHandler->endDocument();
+ xWriter->ignorableWhitespace( aWhiteSpace );
+ xWriter->endElement( aRelListElement );
+ xWriter->endDocument();
}
// -----------------------------------
-void SAL_CALL OFOPXMLHelper::WriteContentSequence( const uno::Reference< io::XOutputStream >& xOutStream, const uno::Sequence< beans::StringPair >& aDefaultsSequence, const uno::Sequence< beans::StringPair >& aOverridesSequence, const uno::Reference< lang::XMultiServiceFactory > xFactory )
+void SAL_CALL OFOPXMLHelper::WriteContentSequence( const uno::Reference< io::XOutputStream >& xOutStream, const uno::Sequence< beans::StringPair >& aDefaultsSequence, const uno::Sequence< beans::StringPair >& aOverridesSequence, const uno::Reference< uno::XComponentContext > xContext )
throw( uno::Exception )
{
if ( !xOutStream.is() )
throw uno::RuntimeException();
- uno::Reference< io::XActiveDataSource > xWriterSource(
- xFactory->createInstance(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ),
- uno::UNO_QUERY_THROW );
- uno::Reference< xml::sax::XDocumentHandler > xWriterHandler( xWriterSource, uno::UNO_QUERY_THROW );
+ uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
- xWriterSource->setOutputStream( xOutStream );
+ xWriter->setOutputStream( xOutStream );
::rtl::OUString aTypesElement( RTL_CONSTASCII_USTRINGPARAM( "Types" ) );
::rtl::OUString aDefaultElement( RTL_CONSTASCII_USTRINGPARAM( "Default" ) );
@@ -150,8 +143,8 @@ void SAL_CALL OFOPXMLHelper::WriteContentSequence( const uno::Reference< io::XOu
aCDATAString,
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "http://schemas.openxmlformats.org/package/2006/content-types" ) ) );
- xWriterHandler->startDocument();
- xWriterHandler->startElement( aTypesElement, xRootAttrList );
+ xWriter->startDocument();
+ xWriter->startElement( aTypesElement, xRootAttrList );
for ( sal_Int32 nInd = 0; nInd < aDefaultsSequence.getLength(); nInd++ )
{
@@ -160,9 +153,9 @@ void SAL_CALL OFOPXMLHelper::WriteContentSequence( const uno::Reference< io::XOu
pAttrList->AddAttribute( aExtensionAttr, aCDATAString, aDefaultsSequence[nInd].First );
pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, aDefaultsSequence[nInd].Second );
- xWriterHandler->startElement( aDefaultElement, xAttrList );
- xWriterHandler->ignorableWhitespace( aWhiteSpace );
- xWriterHandler->endElement( aDefaultElement );
+ xWriter->startElement( aDefaultElement, xAttrList );
+ xWriter->ignorableWhitespace( aWhiteSpace );
+ xWriter->endElement( aDefaultElement );
}
for ( sal_Int32 nInd = 0; nInd < aOverridesSequence.getLength(); nInd++ )
@@ -172,14 +165,14 @@ void SAL_CALL OFOPXMLHelper::WriteContentSequence( const uno::Reference< io::XOu
pAttrList->AddAttribute( aPartNameAttr, aCDATAString, aOverridesSequence[nInd].First );
pAttrList->AddAttribute( aContentTypeAttr, aCDATAString, aOverridesSequence[nInd].Second );
- xWriterHandler->startElement( aOverrideElement, xAttrList );
- xWriterHandler->ignorableWhitespace( aWhiteSpace );
- xWriterHandler->endElement( aOverrideElement );
+ xWriter->startElement( aOverrideElement, xAttrList );
+ xWriter->ignorableWhitespace( aWhiteSpace );
+ xWriter->endElement( aOverrideElement );
}
- xWriterHandler->ignorableWhitespace( aWhiteSpace );
- xWriterHandler->endElement( aTypesElement );
- xWriterHandler->endDocument();
+ xWriter->ignorableWhitespace( aWhiteSpace );
+ xWriter->endElement( aTypesElement );
+ xWriter->endDocument();
}