diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-06-14 00:32:25 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-06-14 00:32:25 +0100 |
commit | 0b303af5dce580d790281418ac2277103917e704 (patch) | |
tree | 9541c4709c7aab38f249c2b6ea648023ec58553c | |
parent | gbuildize hwpfilter (diff) | |
download | core-0b303af5dce580d790281418ac2277103917e704.tar.gz core-0b303af5dce580d790281418ac2277103917e704.zip |
ditch MyDataSink and use comphelper::MediaDescriptor::addInputStream
-rw-r--r-- | hwpfilter/source/hwpreader.cxx | 42 | ||||
-rw-r--r-- | hwpfilter/source/hwpreader.hxx | 33 |
2 files changed, 7 insertions, 68 deletions
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index e23e2d9fc6c2..47e8a50d5cbe 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -134,51 +134,23 @@ HwpReader::~HwpReader() } -sal_Bool HwpReader::filter(const Sequence< PropertyValue >& aDescriptor) throw(RuntimeException) +sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(RuntimeException) { - Reference< XInputStream> rInputStream; - for ( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ ) - { - if ( aDescriptor[i].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")) ) - { - aDescriptor[i].Value >>= rInputStream; - break; - } - else if ( aDescriptor[i].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) ) - { - OUString sURL; - aDescriptor[i].Value >>= sURL; - - Reference< XContentIdentifierFactory > xIdFactory( rUCB, UNO_QUERY ); - Reference< XContentProvider > xProvider( rUCB, UNO_QUERY ); - Reference< XContentIdentifier > xId = xIdFactory->createContentIdentifier( sURL ); - Reference< XContent > xContent = xProvider->queryContent( xId ); - MyDataSink * pSink = new MyDataSink(); - OpenCommandArgument2 aArgument; - aArgument.Sink = Reference< XInterface > ((OWeakObject *)pSink); - aArgument.Mode = OpenMode::DOCUMENT; - Command aCommand; - aCommand.Name = OUString( RTL_CONSTASCII_USTRINGPARAM("open")); - aCommand.Handle = -1; - aCommand.Argument <<= aArgument; - Reference< XCommandProcessor > xCmdProcessor( xContent, UNO_QUERY ); - xCmdProcessor->execute( aCommand, 0, Reference< XCommandEnvironment > () ); - - rInputStream = pSink->getInputStream(); + comphelper::MediaDescriptor aDescriptor(rDescriptor); + aDescriptor.addInputStream(); - break; - } - } + Reference< XInputStream > xInputStream( + aDescriptor[comphelper::MediaDescriptor::PROP_INPUTSTREAM()], UNO_QUERY_THROW); HStream stream; Sequence < sal_Int8 > aBuffer; sal_Int32 nRead, nBlock = 32768, nTotal = 0; while( 1 ) { - nRead = rInputStream.get()->readBytes(aBuffer, nBlock); + nRead = xInputStream->readBytes(aBuffer, nBlock); if( nRead == 0 ) break; - stream.addData( (byte *)aBuffer.getConstArray(), nRead ); + stream.addData( (const byte *)aBuffer.getConstArray(), nRead ); nTotal += nRead; } diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx index ef8d767e9ec4..8d5a9f0dfef6 100644 --- a/hwpfilter/source/hwpreader.hxx +++ b/hwpfilter/source/hwpreader.hxx @@ -84,44 +84,11 @@ using namespace ::com::sun::star::document; #include "drawdef.h" #include "attributes.hxx" - #define IMPLEMENTATION_NAME "com.sun.comp.hwpimport.HwpImportFilter" #define SERVICE_NAME1 "com.sun.star.document.ImportFilter" #define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection" #define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter" -class MyDataSink : public ::cppu::WeakImplHelper2< XActiveDataControl, XActiveDataSink > -{ - Reference < XInputStream > m_xInputStream; -public: - - // XActiveDataControl. - virtual void SAL_CALL addListener ( const Reference<XStreamListener> &) - throw(RuntimeException) {} - virtual void SAL_CALL removeListener ( const Reference<XStreamListener> &) - throw(RuntimeException) {} - virtual void SAL_CALL start (void) throw(RuntimeException) {} - virtual void SAL_CALL terminate (void) throw(RuntimeException) {} - - // XActiveDataSink. - virtual void SAL_CALL setInputStream ( const Reference<XInputStream> &rxInputStream) - throw(RuntimeException); - virtual Reference<XInputStream> SAL_CALL getInputStream (void) - throw(RuntimeException); -}; - -void SAL_CALL MyDataSink::setInputStream ( const Reference<XInputStream> &rxInputStream) - throw(RuntimeException ) -{ - m_xInputStream = rxInputStream; -} - -Reference < XInputStream > SAL_CALL MyDataSink::getInputStream (void) - throw(RuntimeException) -{ - return m_xInputStream; -} - struct HwpReaderPrivate; /** * This class implements the external Parser interface |