summaryrefslogtreecommitdiff
path: root/basic
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 /basic
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 'basic')
-rw-r--r--basic/source/uno/dlgcont.cxx16
-rw-r--r--basic/source/uno/namecont.cxx29
-rw-r--r--basic/source/uno/scriptcont.cxx15
3 files changed, 14 insertions, 46 deletions
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index b9ad7f19ecce..1d77d41ed59e 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xml/sax/Parser.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -125,20 +126,9 @@ bool writeOasis2OOoLibraryElement(
Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(xContext);
- Reference< xml::sax::XExtendedDocumentHandler > xWriter(
- xSMgr->createInstanceWithContext(
- OUString( RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.xml.sax.Writer" ) ),
- xContext ),
- UNO_QUERY );
-
- Reference< io::XActiveDataSource > xSource( xWriter, UNO_QUERY );
- xSource->setOutputStream( xOutput );
+ Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
- if ( !xWriter.is() )
- {
- return sal_False;
- }
+ xWriter->setOutputStream( xOutput );
Sequence<Any> aArgs( 1 );
aArgs[0] <<= xWriter;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index dfce89aa5101..fe76bf7f462f 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/xml/sax/Parser.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -1495,14 +1496,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
const ::rtl::OUString& aTargetURL, Reference< XSimpleFileAccess2 > xToUseSFI )
{
// Create sax writer
- Reference< XExtendedDocumentHandler > xHandler(
- mxMSF->createInstance(
- OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
- if( !xHandler.is() )
- {
- SAL_WARN("basic", "couldn't create sax-writer component");
- return;
- }
+ Reference< XWriter > xWriter = xml::sax::Writer::create(comphelper::getComponentContext(mxMSF));
sal_Bool bLink = pLib->mbLink;
bool bStorage = xStorage.is() && !bLink;
@@ -1587,10 +1581,9 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
return;
}
- Reference< XActiveDataSource > xSource( xHandler, UNO_QUERY );
- xSource->setOutputStream( xOut );
+ xWriter->setOutputStream( xOut );
- xmlscript::exportLibrary( xHandler, rLib );
+ xmlscript::exportLibrary( xWriter, rLib );
}
@@ -1962,14 +1955,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
// Write library container info
// Create sax writer
- Reference< XExtendedDocumentHandler > xHandler(
- mxMSF->createInstance(
- OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY );
- if( !xHandler.is() )
- {
- SAL_WARN("basic", "couldn't create sax-writer component");
- return;
- }
+ Reference< XWriter > xWriter = xml::sax::Writer::create(comphelper::getComponentContext(mxMSF));
// Write info file
uno::Reference< io::XOutputStream > xOut;
@@ -2031,12 +2017,11 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
return;
}
- Reference< XActiveDataSource > xSource( xHandler, UNO_QUERY );
- xSource->setOutputStream( xOut );
+ xWriter->setOutputStream( xOut );
try
{
- xmlscript::exportLibraryContainer( xHandler, pLibArray.get() );
+ xmlscript::exportLibraryContainer( xWriter, pLibArray.get() );
if ( bStorage )
{
uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY );
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index bbc8509d23c2..606db40bb4d6 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/xml/sax/Parser.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/Writer.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
@@ -181,22 +182,14 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
throw(Exception)
{
// Create sax writer
- Reference< XExtendedDocumentHandler > xHandler(
- mxMSF->createInstance(
- OUString( "com.sun.star.xml.sax.Writer" ) ), UNO_QUERY );
- if( !xHandler.is() )
- {
- OSL_FAIL( "### couldn't create sax-writer component\n" );
- return;
- }
+ Reference< XWriter > xWriter = xml::sax::Writer::create(comphelper::getComponentContext(mxMSF));
Reference< XTruncate > xTruncate( xOutput, UNO_QUERY );
OSL_ENSURE( xTruncate.is(), "Currently only the streams that can be truncated are expected!" );
if ( xTruncate.is() )
xTruncate->truncate();
- Reference< XActiveDataSource > xSource( xHandler, UNO_QUERY );
- xSource->setOutputStream( xOutput );
+ xWriter->setOutputStream( xOutput );
xmlscript::ModuleDescriptor aMod;
aMod.aName = aElementName;
@@ -228,7 +221,7 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
}
}
- xmlscript::exportScriptModule( xHandler, aMod );
+ xmlscript::exportScriptModule( xWriter, aMod );
}