From 9d5276b3fb2de81d56e698cc8d32b2869cfb3c55 Mon Sep 17 00:00:00 2001 From: Fridrich Štrba Date: Thu, 18 Apr 2013 11:44:19 +0200 Subject: PImpl the WPXSvInputStream class Change-Id: I11a3d663e2f5a8f68edd66b7ba2af15cc57287a9 --- writerperfect/source/stream/WPXSvStream.cxx | 93 ++++++++++++++++++++++++++--- writerperfect/source/stream/WPXSvStream.h | 19 +----- 2 files changed, 87 insertions(+), 25 deletions(-) (limited to 'writerperfect') diff --git a/writerperfect/source/stream/WPXSvStream.cxx b/writerperfect/source/stream/WPXSvStream.cxx index 640ab20699a0..81d6b1bb00b4 100644 --- a/writerperfect/source/stream/WPXSvStream.cxx +++ b/writerperfect/source/stream/WPXSvStream.cxx @@ -13,6 +13,7 @@ #include #include #include +#include using namespace ::com::sun::star::uno; using namespace ::com::sun::star::io; @@ -27,7 +28,42 @@ static void splitPath( std::vector &rElems, const OUString &rPath ) } // anonymous namespace -WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) : +typedef struct +{ + SotStorageRef ref; +} SotStorageRefWrapper; + +typedef struct +{ + SotStorageStreamRef ref; +} SotStorageStreamRefWrapper; + +class WPXSvInputStreamImpl : public WPXInputStream +{ +public : + WPXSvInputStreamImpl( ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream > xStream ); + ~WPXSvInputStreamImpl(); + + bool isOLEStream(); + WPXInputStream * getDocumentOLEStream(const char *name); + + const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); + int seek(long offset, WPX_SEEK_TYPE seekType); + long tell(); + bool atEOS(); +private: + ::std::vector< SotStorageRefWrapper > mxChildrenStorages; + ::std::vector< SotStorageStreamRefWrapper > mxChildrenStreams; + ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream > mxStream; + ::com::sun::star::uno::Reference< + ::com::sun::star::io::XSeekable > mxSeekable; + ::com::sun::star::uno::Sequence< sal_Int8 > maData; + sal_Int64 mnLength; +}; + +WPXSvInputStreamImpl::WPXSvInputStreamImpl( Reference< XInputStream > xStream ) : WPXInputStream(), mxChildrenStorages(), mxChildrenStreams(), @@ -56,11 +92,11 @@ WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) : } } -WPXSvInputStream::~WPXSvInputStream() +WPXSvInputStreamImpl::~WPXSvInputStreamImpl() { } -const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned long &numBytesRead) +const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long &numBytesRead) { numBytesRead = 0; @@ -74,7 +110,7 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon return (const unsigned char *)maData.getConstArray(); } -long WPXSvInputStream::tell() +long WPXSvInputStreamImpl::tell() { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return -1L; @@ -87,7 +123,7 @@ long WPXSvInputStream::tell() } } -int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType) +int WPXSvInputStreamImpl::seek(long offset, WPX_SEEK_TYPE seekType) { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return -1; @@ -130,14 +166,14 @@ int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType) } } -bool WPXSvInputStream::atEOS() +bool WPXSvInputStreamImpl::atEOS() { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return true; return (mxSeekable->getPosition() >= mnLength); } -bool WPXSvInputStream::isOLEStream() +bool WPXSvInputStreamImpl::isOLEStream() { if ((mnLength == 0) || !mxStream.is() || !mxSeekable.is()) return false; @@ -155,7 +191,7 @@ bool WPXSvInputStream::isOLEStream() return bAns; } -WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name) +WPXInputStream *WPXSvInputStreamImpl::getDocumentOLEStream(const char *name) { if (!name) return 0; @@ -223,4 +259,45 @@ WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name) return 0; } + +WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) : + mpImpl(new WPXSvInputStreamImpl(xStream)) +{ +} + +WPXSvInputStream::~WPXSvInputStream() +{ + delete mpImpl; +} + +const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned long &numBytesRead) +{ + return mpImpl->read(numBytes, numBytesRead); +} + +long WPXSvInputStream::tell() +{ + return mpImpl->tell(); +} + +int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType) +{ + return mpImpl->seek(offset, seekType); +} + +bool WPXSvInputStream::atEOS() +{ + return mpImpl->atEOS(); +} + +bool WPXSvInputStream::isOLEStream() +{ + return mpImpl->isOLEStream(); +} + +WPXInputStream *WPXSvInputStream::getDocumentOLEStream(const char *name) +{ + return mpImpl->getDocumentOLEStream(name); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerperfect/source/stream/WPXSvStream.h b/writerperfect/source/stream/WPXSvStream.h index 0ed369b060ca..d104c4b341cc 100644 --- a/writerperfect/source/stream/WPXSvStream.h +++ b/writerperfect/source/stream/WPXSvStream.h @@ -16,15 +16,7 @@ #include -typedef struct -{ - SotStorageRef ref; -} SotStorageRefWrapper; - -typedef struct -{ - SotStorageStreamRef ref; -} SotStorageStreamRefWrapper; +class WPXSvInputStreamImpl; class WPXSvInputStream : public WPXInputStream { @@ -42,14 +34,7 @@ public: virtual bool atEOS(); private: - std::vector< SotStorageRefWrapper > mxChildrenStorages; - std::vector< SotStorageStreamRefWrapper > mxChildrenStreams; - ::com::sun::star::uno::Reference< - ::com::sun::star::io::XInputStream > mxStream; - ::com::sun::star::uno::Reference< - ::com::sun::star::io::XSeekable > mxSeekable; - ::com::sun::star::uno::Sequence< sal_Int8 > maData; - sal_Int64 mnLength; + WPXSvInputStreamImpl *mpImpl; }; #endif -- cgit