summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-06-14 00:32:25 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-06-14 00:32:25 +0100
commit3dfb3945531d8edb6a829ae344472b39f0eb9f20 (patch)
treee31acedfe4f932d9c691d348d246fe972b07d33d
parent4e65328bce1d7a3c9dff5ca32df5aaf470572f8a (diff)
ditch MyDataSink and use comphelper::MediaDescriptor::addInputStream
-rw-r--r--hwpfilter/source/hwpreader.cxx42
-rw-r--r--hwpfilter/source/hwpreader.hxx33
2 files changed, 7 insertions, 68 deletions
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index a179a5f58..177a6df7d 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 543c7edd8..5bb6469d1 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