summaryrefslogtreecommitdiff
path: root/oox/inc/oox/helper
diff options
context:
space:
mode:
Diffstat (limited to 'oox/inc/oox/helper')
-rw-r--r--oox/inc/oox/helper/binaryinputstream.hxx323
-rw-r--r--oox/inc/oox/helper/binaryoutputstream.hxx86
-rw-r--r--oox/inc/oox/helper/binarystreambase.hxx130
-rw-r--r--oox/inc/oox/helper/containerhelper.hxx54
-rw-r--r--oox/inc/oox/helper/graphichelper.hxx2
-rw-r--r--oox/inc/oox/helper/helper.hxx30
-rw-r--r--oox/inc/oox/helper/modelobjecthelper.hxx22
-rw-r--r--oox/inc/oox/helper/propertymap.hxx16
-rw-r--r--oox/inc/oox/helper/propertyset.hxx46
-rwxr-xr-x[-rw-r--r--]oox/inc/oox/helper/textinputstream.hxx89
-rw-r--r--oox/inc/oox/helper/zipstorage.hxx11
11 files changed, 582 insertions, 227 deletions
diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx
index 52a3a4de9f0f..8bb554a2b57d 100644
--- a/oox/inc/oox/helper/binaryinputstream.hxx
+++ b/oox/inc/oox/helper/binaryinputstream.hxx
@@ -28,10 +28,14 @@
#ifndef OOX_HELPER_BINARYINPUTSTREAM_HXX
#define OOX_HELPER_BINARYINPUTSTREAM_HXX
-#include <boost/shared_ptr.hpp>
+#include <vector>
#include <com/sun/star/io/XInputStream.hpp>
#include "oox/helper/binarystreambase.hxx"
+namespace com { namespace sun { namespace star {
+ namespace io { class XInputStream; }
+} } }
+
namespace oox {
class BinaryOutputStream;
@@ -46,24 +50,51 @@ class BinaryInputStream : public virtual BinaryStreamBase
{
public:
/** Derived classes implement reading nBytes bytes to the passed sequence.
- @return Number of bytes really read. */
- virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes ) = 0;
- /** Derived classes implement reading nBytes bytes to the (existing) buffer opMem.
- @return Number of bytes really read. */
- virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes ) = 0;
+ The sequence will be reallocated internally.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+
+ @return
+ Number of bytes really read.
+ */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
+ /** Derived classes implement reading nBytes bytes to the (preallocated!)
+ memory buffer opMem.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+
+ @return
+ Number of bytes really read.
+ */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
+
/** Derived classes implement seeking the stream forward by the passed
- number of bytes. This should work for non-seekable streams too. */
- virtual void skip( sal_Int32 nBytes ) = 0;
+ number of bytes. This should work for non-seekable streams too.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
/** Reads a value from the stream and converts it to platform byte order.
- Supported types: SAL integers (8 to 64 bit), float, double. */
+ All data types supported by the ByteOrderConverter class can be used.
+ */
template< typename Type >
void readValue( Type& ornValue );
+
/** Reads a value from the stream and converts it to platform byte order.
- Supported types: SAL integers (8 to 64 bit), float, double. */
+ All data types supported by the ByteOrderConverter class can be used.
+ */
template< typename Type >
inline Type readValue() { Type nValue; readValue( nValue ); return nValue; }
- /** Stream operator for integral and floating-point types. */
+
+ /** Stream operator for all data types supported by the readValue() function. */
template< typename Type >
inline BinaryInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
@@ -78,46 +109,135 @@ public:
inline float readFloat() { return readValue< float >(); }
inline double readDouble() { return readValue< double >(); }
- /** Reads a NUL-terminated byte character array and returns the string. */
+ /** Reads a (preallocated!) C array of values from the stream.
+
+ Converts all values in the array to platform byte order. All data types
+ supported by the ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of array elements to read (NOT byte count).
+
+ @return
+ Number of array elements really read (NOT byte count).
+ */
+ template< typename Type >
+ sal_Int32 readArray( Type* opnArray, sal_Int32 nElemCount );
+
+ /** Reads a sequence of values from the stream.
+
+ The sequence will be reallocated internally. Converts all values in the
+ array to platform byte order. All data types supported by the
+ ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of elements to put into the sequence (NOT byte count).
+
+ @return
+ Number of sequence elements really read (NOT byte count).
+ */
+ template< typename Type >
+ sal_Int32 readArray( ::com::sun::star::uno::Sequence< Type >& orSequence, sal_Int32 nElemCount );
+
+ /** Reads a vector of values from the stream.
+
+ The vector will be resized internally. Converts all values in the
+ vector to platform byte order. All data types supported by the
+ ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of elements to put into the vector (NOT byte count).
+
+ @return
+ Number of vector elements really read (NOT byte count).
+ */
+ template< typename Type >
+ sal_Int32 readArray( ::std::vector< Type >& orVector, sal_Int32 nElemCount );
+
+ /** Skips an array of values of a certain type in the stream.
+
+ All data types supported by the ByteOrderConverter class can be used.
+
+ @param nElemCount
+ Number of array elements to skip (NOT byte count).
+ */
+ template< typename Type >
+ void skipArray( sal_Int32 nElemCount );
+
+ /** Reads a NUL-terminated byte character array and returns the string.
+ */
::rtl::OString readNulCharArray();
/** Reads a NUL-terminated byte character array and returns a Unicode string.
- @param eTextEnc The text encoding used to create the Unicode string. */
+
+ @param eTextEnc
+ The text encoding used to create the Unicode string.
+ */
::rtl::OUString readNulCharArrayUC( rtl_TextEncoding eTextEnc );
- /** Reads a NUL-terminated Unicode character array and returns the string. */
+ /** Reads a NUL-terminated Unicode character array and returns the string.
+ */
::rtl::OUString readNulUnicodeArray();
- /** Reads nChar byte characters and returns the string.
- @param nChars Number of characters (bytes) to read from the stream.
+ /** Reads a byte character array and returns the string.
+
+ @param nChars
+ Number of characters (bytes) to read from the stream.
+
@param bAllowNulChars
True = NUL characters are inserted into the imported string.
- False = NUL characters are replaced by question marks (default). */
+ False = NUL characters are replaced by question marks (default).
+ */
::rtl::OString readCharArray( sal_Int32 nChars, bool bAllowNulChars = false );
- /** Reads nChar byte characters and returns a Unicode string.
- @param nChars Number of characters (bytes) to read from the stream.
- @param eTextEnc The text encoding used to create the Unicode string.
+ /** Reads a byte character array and returns a Unicode string.
+
+ @param nChars
+ Number of characters (bytes) to read from the stream.
+
+ @param eTextEnc
+ The text encoding used to create the Unicode string.
+
@param bAllowNulChars
True = NUL characters are inserted into the imported string.
- False = NUL characters are replaced by question marks (default). */
+ False = NUL characters are replaced by question marks (default).
+ */
::rtl::OUString readCharArrayUC( sal_Int32 nChars, rtl_TextEncoding eTextEnc, bool bAllowNulChars = false );
- /** Reads nChars Unicode characters and returns the string.
- @param nChars Number of 16-bit characters to read from the stream.
+ /** Reads a Unicode character array and returns the string.
+
+ @param nChars
+ Number of 16-bit characters to read from the stream.
+
@param bAllowNulChars
True = NUL characters are inserted into the imported string.
- False = NUL characters are replaced by question marks (default). */
+ False = NUL characters are replaced by question marks (default).
+ */
::rtl::OUString readUnicodeArray( sal_Int32 nChars, bool bAllowNulChars = false );
- /** Copies nBytes bytes from the current position to the passed output stream. */
- void copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes = SAL_MAX_INT64 );
+ /** Reads a Unicode character array (may be compressed) and returns the
+ string.
-private:
- /** Used by the readValue() template functions to read built-in types.
- @descr Derived classes may overwrite this default implementation which
- simply calls readMemory() with something own. */
- virtual void readAtom( void* opMem, sal_uInt8 nSize );
+ @param nChars
+ Number of 8-bit or 16-bit characters to read from the stream.
+
+ @param bCompressed
+ True = Character array is compressed (stored as 8-bit characters).
+ False = Character array is not compressed (stored as 16-bit characters).
+
+ @param bAllowNulChars
+ True = NUL characters are inserted into the imported string.
+ False = NUL characters are replaced by question marks (default).
+ */
+ ::rtl::OUString readCompressedUnicodeArray( sal_Int32 nChars, bool bCompressed, bool bAllowNulChars = false );
+
+ /** Copies nBytes bytes from the current position to the passed output stream.
+ */
+ void copyToStream( BinaryOutputStream& rOutStrm, sal_Int64 nBytes = SAL_MAX_INT64, sal_Int32 nAtomSize = 1 );
+
+protected:
+ /** This dummy default c'tor will never call the c'tor of the virtual base
+ class BinaryStreamBase as this class cannot be instanciated directly. */
+ inline explicit BinaryInputStream() : BinaryStreamBase( false ) {}
};
typedef ::boost::shared_ptr< BinaryInputStream > BinaryInputStreamRef;
@@ -127,14 +247,47 @@ typedef ::boost::shared_ptr< BinaryInputStream > BinaryInputStreamRef;
template< typename Type >
void BinaryInputStream::readValue( Type& ornValue )
{
- // can be instanciated for all types supported in class ByteOrderConverter
- readAtom( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ) );
+ readMemory( &ornValue, static_cast< sal_Int32 >( sizeof( Type ) ), sizeof( Type ) );
ByteOrderConverter::convertLittleEndian( ornValue );
}
+template< typename Type >
+sal_Int32 BinaryInputStream::readArray( Type* opnArray, sal_Int32 nElemCount )
+{
+ sal_Int32 nRet = 0;
+ if( !mbEof )
+ {
+ sal_Int32 nReadSize = getLimitedValue< sal_Int32, sal_Int32 >( nElemCount, 0, SAL_MAX_INT32 / sizeof( Type ) ) * sizeof( Type );
+ nRet = readMemory( opnArray, nReadSize, sizeof( Type ) ) / sizeof( Type );
+ ByteOrderConverter::convertLittleEndianArray( opnArray, static_cast< size_t >( nRet ) );
+ }
+ return nRet;
+}
+
+template< typename Type >
+sal_Int32 BinaryInputStream::readArray( ::com::sun::star::uno::Sequence< Type >& orSequence, sal_Int32 nElemCount )
+{
+ orSequence.reallocate( nElemCount );
+ return orSequence.hasElements() ? readArray( orSequence.getArray(), nElemCount ) : 0;
+}
+
+template< typename Type >
+sal_Int32 BinaryInputStream::readArray( ::std::vector< Type >& orVector, sal_Int32 nElemCount )
+{
+ orVector.resize( static_cast< size_t >( nElemCount ) );
+ return orVector.empty() ? 0 : readArray( &orVector.front(), nElemCount );
+}
+
+template< typename Type >
+void BinaryInputStream::skipArray( sal_Int32 nElemCount )
+{
+ sal_Int32 nSkipSize = getLimitedValue< sal_Int32, sal_Int32 >( nElemCount, 0, SAL_MAX_INT32 / sizeof( Type ) ) * sizeof( Type );
+ skip( nSkipSize, sizeof( Type ) );
+}
+
// ============================================================================
-/** Wraps a com.sun.star.io.XInputStream and provides convenient access functions.
+/** Wraps a UNO input stream and provides convenient access functions.
The binary data in the stream is assumed to be in little-endian format.
*/
@@ -143,10 +296,13 @@ class BinaryXInputStream : public BinaryXSeekableStream, public BinaryInputStrea
public:
/** Constructs the wrapper object for the passed input stream.
- @param rxInStream The com.sun.star.io.XInputStream interface of the
- input stream to be wrapped.
- @param bAutoClose True = automatically close the wrapped input stream
- on destruction of this wrapper.
+ @param rxInStream
+ The com.sun.star.io.XInputStream interface of the UNO input stream
+ to be wrapped.
+
+ @param bAutoClose
+ True = automatically close the wrapped input stream on destruction
+ of this wrapper or when close() is called.
*/
explicit BinaryXInputStream(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
@@ -154,26 +310,26 @@ public:
virtual ~BinaryXInputStream();
+ /** Closes the input stream. Does also close the wrapped UNO input stream
+ if bAutoClose has been set to true in the constructor. */
+ virtual void close();
+
/** Reads nBytes bytes to the passed sequence.
@return Number of bytes really read. */
- virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes );
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Reads nBytes bytes to the (existing) buffer opMem.
@return Number of bytes really read. */
- virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes );
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Seeks the stream forward by the passed number of bytes. This works for
non-seekable streams too. */
- virtual void skip( sal_Int32 nBytes );
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 );
- /** Stream operator for integral and floating-point types. */
+ /** Stream operator for all data types supported by the readValue() function. */
template< typename Type >
inline BinaryXInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
- /** Returns the XInputStream interface of the wrapped input stream. */
- inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
- getXInputStream() const { return mxInStrm; }
- /** Closes the wrapped XInputStream. */
- void close();
-
private:
StreamDataSequence maBuffer; /// Data buffer used in readMemory() function.
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
@@ -181,8 +337,6 @@ private:
bool mbAutoClose; /// True = automatically close stream on destruction.
};
-typedef ::boost::shared_ptr< BinaryXInputStream > BinaryXInputStreamRef;
-
// ============================================================================
/** Wraps a StreamDataSequence and provides convenient access functions.
@@ -203,86 +357,97 @@ public:
/** Reads nBytes bytes to the passed sequence.
@return Number of bytes really read. */
- virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes );
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Reads nBytes bytes to the (existing) buffer opMem.
@return Number of bytes really read. */
- virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes );
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Seeks the stream forward by the passed number of bytes. This works for
non-seekable streams too. */
- virtual void skip( sal_Int32 nBytes );
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 );
- /** Stream operator for integral and floating-point types. */
+ /** Stream operator for all data types supported by the readValue() function. */
template< typename Type >
inline SequenceInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
-};
-typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef;
+private:
+ /** Returns the number of bytes available in the sequence for the passed byte count. */
+ inline sal_Int32 getMaxBytes( sal_Int32 nBytes ) const
+ { return getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, mpData->getLength() - mnPos ); }
+};
// ============================================================================
/** Wraps a BinaryInputStream and provides access to a specific part of the
stream data.
- @descr
- Provides access to the stream data block starting at the current
- position of the stream, and with a specific length. If the wrapped
- stream is seekable, this wrapper will treat the position the wrapped
- has at construction time as position "0" (therefore the class name).
+ Provides access to the stream data block starting at the current position
+ of the stream, and with a specific length. If the wrapped stream is
+ seekable, this wrapper will treat the position of the wrapped stream at
+ construction time as position "0" (therefore the class name).
+
+ The passed input stream MUST live at least as long as this stream wrapper.
+ The stream MUST NOT be changed from outside as long as this stream wrapper
+ is used to read from it.
*/
class RelativeInputStream : public BinaryInputStream
{
public:
/** Constructs the wrapper object for the passed stream.
- @attention
- The passed input stream MUST live at least as long as this stream
- wrapper. The stream MUST NOT be changed from outside as long as
- this stream wrapper is used to read from it.
-
- @param nLength
+ @param nSize
If specified, restricts the amount of data that can be read from
the passed input stream.
*/
explicit RelativeInputStream(
BinaryInputStream& rInStrm,
- sal_Int64 nLength = SAL_MAX_INT64 );
+ sal_Int64 nSize = SAL_MAX_INT64 );
- /** Returns whether the wrapped stream is seekable. */
- virtual bool isSeekable() const;
/** Returns the size of the data block in the wrapped stream offered by
this wrapper. */
- virtual sal_Int64 getLength() const;
+ virtual sal_Int64 size() const;
+
/** Returns the current relative stream position. */
virtual sal_Int64 tell() const;
+
/** Seeks the stream to the passed relative position, if the wrapped stream
is seekable. */
virtual void seek( sal_Int64 nPos );
+ /** Closes the input stream but not the wrapped stream. */
+ virtual void close();
+
/** Reads nBytes bytes to the passed sequence. Does not read out of the
data block whose size has been specified on construction.
@return Number of bytes really read. */
- virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes );
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Reads nBytes bytes to the (existing) buffer opMem. Does not read out of
the data block whose size has been specified on construction.
@return Number of bytes really read. */
- virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes );
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
/** Seeks the stream forward by the passed number of bytes. This works for
non-seekable streams too. Does not seek out of the data block. */
- virtual void skip( sal_Int32 nBytes );
+ virtual void skip( sal_Int32 nBytes, size_t nAtomSize = 1 );
- /** Stream operator for integral and floating-point types. */
+ /** Stream operator for all data types supported by the readValue() function. */
template< typename Type >
inline RelativeInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
private:
- BinaryInputStream& mrInStrm;
+ /** Returns the number of bytes available in the sequence for the passed byte count. */
+ inline sal_Int32 getMaxBytes( sal_Int32 nBytes ) const
+ { return getLimitedValue< sal_Int32, sal_Int64 >( nBytes, 0, mnSize - mnRelPos ); }
+
+private:
+ BinaryInputStream* mpInStrm;
sal_Int64 mnStartPos;
sal_Int64 mnRelPos;
- sal_Int64 mnLength;
+ sal_Int64 mnSize;
};
-typedef ::boost::shared_ptr< RelativeInputStream > RelativeInputStreamRef;
-
// ============================================================================
} // namespace oox
diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx
index e24777c4f296..362c7fbdea87 100644
--- a/oox/inc/oox/helper/binaryoutputstream.hxx
+++ b/oox/inc/oox/helper/binaryoutputstream.hxx
@@ -28,10 +28,12 @@
#ifndef OOX_HELPER_BINARYOUTPUTSTREAM_HXX
#define OOX_HELPER_BINARYOUTPUTSTREAM_HXX
-#include <boost/shared_ptr.hpp>
-#include <com/sun/star/io/XOutputStream.hpp>
#include "oox/helper/binarystreambase.hxx"
+namespace com { namespace sun { namespace star {
+ namespace io { class XOutputStream; }
+} } }
+
namespace oox {
// ============================================================================
@@ -43,24 +45,38 @@ namespace oox {
class BinaryOutputStream : public virtual BinaryStreamBase
{
public:
- /** Derived classes implement writing the passed data sequence. */
- virtual void writeData( const StreamDataSequence& rData ) = 0;
- /** Derived classes implement writing from the (existing) buffer pMem. */
- virtual void writeMemory( const void* pMem, sal_Int32 nBytes ) = 0;
+ /** Derived classes implement writing the contents of the passed data
+ sequence.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 ) = 0;
+
+ /** Derived classes implement writing the contents of the (preallocated!)
+ memory buffer pMem.
+
+ @param nAtomSize
+ The size of the elements in the memory block, if available. Derived
+ classes may be interested in this information.
+ */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) = 0;
/** Writes a value to the stream and converts it to platform byte order.
- Supported types: SAL integers (8 to 64 bit), float, double. */
+ All data types supported by the ByteOrderConverter class can be used.
+ */
template< typename Type >
void writeValue( Type nValue );
- /** Stream operator for integral and floating-point types. */
+
+ /** Stream operator for all data types supported by the writeValue() function. */
template< typename Type >
inline BinaryOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; }
-private:
- /** Used by the writeValue() template function to write built-in types.
- @descr Derived classes may overwrite this default implementation which
- simply calls writeMemory() with something own. */
- virtual void writeAtom( const void* pMem, sal_uInt8 nSize );
+protected:
+ /** This dummy default c'tor will never call the c'tor of the virtual base
+ class BinaryStreamBase as this class cannot be instanciated directly. */
+ inline explicit BinaryOutputStream() : BinaryStreamBase( false ) {}
};
typedef ::boost::shared_ptr< BinaryOutputStream > BinaryOutputStreamRef;
@@ -70,14 +86,13 @@ typedef ::boost::shared_ptr< BinaryOutputStream > BinaryOutputStreamRef;
template< typename Type >
void BinaryOutputStream::writeValue( Type nValue )
{
- // can be instanciated for all types supported in class ByteOrderConverter
ByteOrderConverter::convertLittleEndian( nValue );
- writeMemory( &nValue, static_cast< sal_Int32 >( sizeof( Type ) ) );
+ writeMemory( &nValue, static_cast< sal_Int32 >( sizeof( Type ) ), sizeof( Type ) );
}
// ============================================================================
-/** Wraps a com.sun.star.io.XOutputStream and provides convenient access functions.
+/** Wraps a UNO output stream and provides convenient access functions.
The binary data in the stream is written in little-endian format.
*/
@@ -86,10 +101,13 @@ class BinaryXOutputStream : public BinaryXSeekableStream, public BinaryOutputStr
public:
/** Constructs the wrapper object for the passed output stream.
- @param rxOutStream The com.sun.star.io.XOutputStream interface of the
- output stream to be wrapped.
- @param bAutoClose True = automatically close the wrapped output stream
- on destruction of this wrapper.
+ @param rxOutStream
+ The com.sun.star.io.XOutputStream interface of the output stream to
+ be wrapped.
+
+ @param bAutoClose
+ True = automatically close the wrapped output stream on destruction
+ of this wrapper or when close() is called.
*/
explicit BinaryXOutputStream(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxOutStrm,
@@ -97,20 +115,23 @@ public:
virtual ~BinaryXOutputStream();
+ /** Flushes and closes the output stream. Does also close the wrapped UNO
+ output stream if bAutoClose has been set to true in the constructor. */
+ void close();
+
/** Writes the passed data sequence. */
- virtual void writeData( const StreamDataSequence& rData );
- /** Write nBytes bytes from the (existing) buffer pMem. */
- virtual void writeMemory( const void* pMem, sal_Int32 nBytes );
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 );
+
+ /** Write nBytes bytes from the (preallocated!) buffer pMem. */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
- /** Stream operator for integral and floating-point types. */
+ /** Stream operator for all data types supported by the writeValue() function. */
template< typename Type >
inline BinaryXOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; }
/** Returns the XOutputStream interface of the wrapped output stream. */
inline ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
getXOutputStream() const { return mxOutStrm; }
- /** Flushes and closes the wrapped XOutputStream. */
- void close();
private:
StreamDataSequence maBuffer; /// Data buffer used in writeMemory() function.
@@ -119,8 +140,6 @@ private:
bool mbAutoClose; /// True = automatically close stream on destruction.
};
-typedef ::boost::shared_ptr< BinaryXOutputStream > BinaryXOutputStreamRef;
-
// ============================================================================
/** Wraps a StreamDataSequence and provides convenient access functions.
@@ -142,17 +161,16 @@ public:
explicit SequenceOutputStream( StreamDataSequence& rData );
/** Writes the passed data sequence. */
- virtual void writeData( const StreamDataSequence& rData );
- /** Write nBytes bytes from the (existing) buffer pMem. */
- virtual void writeMemory( const void* pMem, sal_Int32 nBytes );
+ virtual void writeData( const StreamDataSequence& rData, size_t nAtomSize = 1 );
- /** Stream operator for integral and floating-point types. */
+ /** Write nBytes bytes from the (preallocated!) buffer pMem. */
+ virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 );
+
+ /** Stream operator for all data types supported by the writeValue() function. */
template< typename Type >
inline SequenceOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; }
};
-typedef ::boost::shared_ptr< SequenceOutputStream > SequenceOutputStreamRef;
-
// ============================================================================
} // namespace oox
diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx
index ba0f34b21f40..0088b29208b0 100644
--- a/oox/inc/oox/helper/binarystreambase.hxx
+++ b/oox/inc/oox/helper/binarystreambase.hxx
@@ -29,75 +29,123 @@
#define OOX_HELPER_BINARYSTREAMBASE_HXX
#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/io/XSeekable.hpp>
+#include <boost/shared_ptr.hpp>
#include "oox/helper/helper.hxx"
+namespace com { namespace sun { namespace star {
+ namespace io { class XSeekable; }
+} } }
+
namespace oox {
typedef ::com::sun::star::uno::Sequence< sal_Int8 > StreamDataSequence;
// ============================================================================
-/** Base interface for binary stream classes. Implemenetations may or may not
- support seeking the stream. */
+/** Base class for binary stream classes.
+ */
class BinaryStreamBase
{
public:
virtual ~BinaryStreamBase();
- /** Derived classes return whether the stream is seekable. Default: false. */
- virtual bool isSeekable() const;
- /** Derived classes return the size of the stream, if possible,
- otherwise/default: -1. May return something for unseekable streams. */
- virtual sal_Int64 getLength() const;
- /** Derived classes return the current stream position, if possible,
- otherwise/default: -1. May return something for unseekable streams. */
- virtual sal_Int64 tell() const;
- /** Derived classes implement seeking the stream to the passed position, if
- the stream is seekable. */
- virtual void seek( sal_Int64 nPos );
+ /** Implementations return the size of the stream, if possible.
+
+ This function may be implemented for some types of unseekable streams,
+ and MUST be implemented for all seekable streams.
+
+ @return
+ The size of the stream in bytes, or -1, if not implemented.
+ */
+ virtual sal_Int64 size() const = 0;
+
+ /** Implementations return the current stream position, if possible.
+
+ This function may be implemented for some types of unseekable streams,
+ and MUST be implemented for all seekable streams.
+
+ @return
+ The current position in the stream, or -1, if not implemented.
+ */
+ virtual sal_Int64 tell() const = 0;
+
+ /** Implementations seek the stream to the passed position, if
+ the stream is seekable.
+ */
+ virtual void seek( sal_Int64 nPos ) = 0;
+
+ /** Implementations close the stream.
+ */
+ virtual void close() = 0;
+
+ /** Returns true, if the implementation supports the seek() operation.
+
+ Implementations may still implement size() and tell() even if the
+ stream is not seekable.
+ */
+ inline bool isSeekable() const { return mbSeekable; }
/** Returns true, if the stream position is invalid (EOF). This flag turns
- true *after* the first attempt to seek/read beyond the stream end. */
+ true *after* the first attempt to seek/read beyond the stream end.
+ */
inline bool isEof() const { return mbEof; }
- /** Returns the size of the remaining data, if stream is seekable, otherwise -1. */
+ /** Returns the size of the remaining data available in the stream, if
+ stream supports size() and tell(), otherwise -1.
+ */
sal_Int64 getRemaining() const;
- /** Seeks the stream to the beginning, if stream is seekable. */
+
+ /** Seeks the stream to the beginning, if stream is seekable.
+ */
inline void seekToStart() { seek( 0 ); }
- /** Seeks the stream to the end, if stream is seekable. */
- inline void seekToEnd() { seek( getLength() ); }
+
+ /** Seeks the stream to the end, if stream is seekable.
+ */
+ inline void seekToEnd() { seek( size() ); }
+
/** Seeks the stream forward to a position that is a multiple of the passed
- block size, relative to the passed stream position, if stream is seekable. */
+ block size, if stream is seekable.
+
+ @param nBlockSize
+ The size of the data blocks the streams needs to be aligned to.
+
+ @param nAnchorPos
+ Position in the stream the data blocks are aligned to.
+ */
void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 );
protected:
- inline explicit BinaryStreamBase() : mbEof( false ) {}
+ inline explicit BinaryStreamBase( bool bSeekable ) : mbEof( false ), mbSeekable( bSeekable ) {}
private:
BinaryStreamBase( const BinaryStreamBase& );
BinaryStreamBase& operator=( const BinaryStreamBase& );
protected:
- bool mbEof;
+ bool mbEof; /// End of stream flag.
+
+private:
+ const bool mbSeekable; /// True = implementation supports seeking.
};
// ============================================================================
-/** Base class for binary input and output streams wrapping an API stream,
+/** Base class for binary input and output streams wrapping a UNO stream,
seekable via the com.sun.star.io.XSeekable interface.
*/
class BinaryXSeekableStream : public virtual BinaryStreamBase
{
public:
- /** Returns true, if the wrapped stream is seekable. */
- virtual bool isSeekable() const;
- /** Returns the size of the stream, if stream is seekable, otherwise -1. */
- virtual sal_Int64 getLength() const;
- /** Returns the current stream position, if stream is seekable, otherwise -1. */
+ virtual ~BinaryXSeekableStream();
+
+ /** Returns the size of the stream, if wrapped stream is seekable, otherwise -1. */
+ virtual sal_Int64 size() const;
+ /** Returns the current stream position, if wrapped stream is seekable, otherwise -1. */
virtual sal_Int64 tell() const;
- /** Seeks the stream to the passed position, if stream is seekable. */
+ /** Seeks the stream to the passed position, if wrapped stream is seekable. */
virtual void seek( sal_Int64 nPos );
+ /** Releases the reference to the UNO XSeekable interface. */
+ virtual void close();
protected:
explicit BinaryXSeekableStream(
@@ -111,31 +159,29 @@ private:
// ============================================================================
/** Base class for binary input and output streams wrapping a
- StreamDataSequence, which is always seekable. */
+ StreamDataSequence, which is always seekable.
+
+ The wrapped data sequence MUST live at least as long as this stream
+ wrapper. The data sequence MUST NOT be changed from outside as long as this
+ stream wrapper is used to modify it.
+ */
class SequenceSeekableStream : public virtual BinaryStreamBase
{
public:
- /** Returns true (data sequence streams are always seekable). */
- virtual bool isSeekable() const;
/** Returns the size of the wrapped data sequence. */
- virtual sal_Int64 getLength() const;
+ virtual sal_Int64 size() const;
/** Returns the current stream position. */
virtual sal_Int64 tell() const;
/** Seeks the stream to the passed position. */
virtual void seek( sal_Int64 nPos );
+ /** Releases the reference to the data sequence. */
+ virtual void close();
protected:
- /** Constructs the wrapper object for the passed data sequence.
-
- @attention
- The passed data sequence MUST live at least as long as this stream
- wrapper. The data sequence MUST NOT be changed from outside as long
- as this stream wrapper is used to modify it.
- */
- inline explicit SequenceSeekableStream( const StreamDataSequence& rData ) : mrData( rData ), mnPos( 0 ) {}
+ explicit SequenceSeekableStream( const StreamDataSequence& rData );
protected:
- const StreamDataSequence& mrData; /// Wrapped data sequence.
+ const StreamDataSequence* mpData; /// Wrapped data sequence.
sal_Int32 mnPos; /// Current position in the sequence.
};
diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx
index 96b9feeffe07..1f5874070a7b 100644
--- a/oox/inc/oox/helper/containerhelper.hxx
+++ b/oox/inc/oox/helper/containerhelper.hxx
@@ -28,8 +28,8 @@
#ifndef OOX_HELPER_CONTAINERHELPER_HXX
#define OOX_HELPER_CONTAINERHELPER_HXX
-#include <vector>
#include <map>
+#include <vector>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Sequence.h>
@@ -40,13 +40,59 @@ namespace com { namespace sun { namespace star {
namespace container { class XIndexContainer; }
namespace container { class XNameAccess; }
namespace container { class XNameContainer; }
- namespace lang { class XMultiServiceFactory; }
+ namespace uno { class XComponentContext; }
} } }
namespace oox {
// ============================================================================
+/** A range of signed 32-bit integer values. */
+struct ValueRange
+{
+ sal_Int32 mnFirst;
+ sal_Int32 mnLast;
+
+ inline explicit ValueRange( sal_Int32 nValue = 0 ) : mnFirst( nValue ), mnLast( nValue ) {}
+ inline explicit ValueRange( sal_Int32 nFirst, sal_Int32 nLast ) : mnFirst( nFirst ), mnLast( nLast ) {}
+
+ inline bool operator==( const ValueRange& rRange ) const { return (mnFirst == rRange.mnFirst) && (mnLast == rRange.mnLast); }
+ inline bool operator!=( const ValueRange& rRange ) const { return !(*this == rRange); }
+ inline bool contains( sal_Int32 nValue ) const { return (mnFirst <= nValue) && (nValue <= mnLast); }
+ inline bool contains( const ValueRange& rRange ) const { return (mnFirst <= rRange.mnFirst) && (rRange.mnLast <= mnLast); }
+ inline bool intersects( const ValueRange& rRange ) const { return (mnFirst <= rRange.mnLast) && (rRange.mnFirst <= mnLast); }
+};
+
+// ----------------------------------------------------------------------------
+
+typedef ::std::vector< ValueRange > ValueRangeVector;
+
+// ----------------------------------------------------------------------------
+
+/** An ordered list of value ranges. The insertion operation will merge
+ consecutive value ranges.
+ */
+class ValueRangeSet
+{
+public:
+ inline explicit ValueRangeSet() {}
+
+ /** Inserts the passed value into the range list. */
+ inline void insert( sal_Int32 nValue ) { insert( ValueRange( nValue ) ); }
+ /** Inserts the passed value range into the range list. */
+ void insert( const ValueRange& rRange );
+
+ /** Returns the ordered list of all value ranges. */
+ inline const ValueRangeVector& getRanges() const { return maRanges; }
+ /** Returns an intersection of the range list and the passed range. */
+ ValueRangeVector getIntersection( const ValueRange& rRange ) const;
+
+private:
+ ValueRangeVector maRanges;
+};
+
+// ============================================================================
+
/** Template for a 2-dimensional array of objects.
This class template provides a similar interface to the ::std::vector
@@ -124,7 +170,7 @@ public:
/** Creates a new index container object from scratch. */
static ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
- createIndexContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory );
+ createIndexContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
/** Inserts an object into an indexed container.
@@ -146,7 +192,7 @@ public:
/** Creates a new name container object from scratch. */
static ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
- createNameContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory );
+ createNameContainer( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
/** Returns a name that is not used in the passed name container.
diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx
index b2b9e1cd133b..a8544196d790 100644
--- a/oox/inc/oox/helper/graphichelper.hxx
+++ b/oox/inc/oox/helper/graphichelper.hxx
@@ -157,7 +157,7 @@ private:
typedef ::std::deque< ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > > GraphicObjectDeque;
typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > > EmbeddedGraphicMap;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxCompContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicProvider > mxGraphicProvider;
::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion;
::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info.
diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx
index 84c501fae2e5..bb9877008e89 100644
--- a/oox/inc/oox/helper/helper.hxx
+++ b/oox/inc/oox/helper/helper.hxx
@@ -236,9 +236,9 @@ private:
class ByteOrderConverter
{
public:
+#ifdef OSL_BIGENDIAN
inline static void convertLittleEndian( sal_Int8& ) {} // present for usage in templates
inline static void convertLittleEndian( sal_uInt8& ) {} // present for usage in templates
-#ifdef OSL_BIGENDIAN
inline static void convertLittleEndian( sal_Int16& rnValue ) { swap2( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
inline static void convertLittleEndian( sal_uInt16& rnValue ) { swap2( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
inline static void convertLittleEndian( sal_Int32& rnValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
@@ -247,15 +247,20 @@ public:
inline static void convertLittleEndian( sal_uInt64& rnValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
inline static void convertLittleEndian( float& rfValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rfValue ) ); }
inline static void convertLittleEndian( double& rfValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rfValue ) ); }
+
+ template< typename Type >
+ inline static void convertLittleEndianArray( Type* pnArray, size_t nElemCount );
+
+ inline static void convertLittleEndianArray( sal_Int8*, size_t ) {}
+ inline static void convertLittleEndianArray( sal_uInt8*, size_t ) {}
+
#else
- inline static void convertLittleEndian( sal_Int16& ) {}
- inline static void convertLittleEndian( sal_uInt16& ) {}
- inline static void convertLittleEndian( sal_Int32& ) {}
- inline static void convertLittleEndian( sal_uInt32& ) {}
- inline static void convertLittleEndian( sal_Int64& ) {}
- inline static void convertLittleEndian( sal_uInt64& ) {}
- inline static void convertLittleEndian( float& ) {}
- inline static void convertLittleEndian( double& ) {}
+ template< typename Type >
+ inline static void convertLittleEndian( Type& ) {}
+
+ template< typename Type >
+ inline static void convertLittleEndianArray( Type*, size_t ) {}
+
#endif
/** Reads a value from memory, assuming memory buffer in little-endian.
@@ -297,6 +302,13 @@ inline void ByteOrderConverter::writeLittleEndian( void* pDstBuffer, Type nValue
}
#ifdef OSL_BIGENDIAN
+template< typename Type >
+inline void ByteOrderConverter::convertLittleEndianArray( Type* pnArray, size_t nElemCount )
+{
+ for( Type* pnArrayEnd = pnArray + nElemCount; pnArray != pnArrayEnd; ++pnArray )
+ convertLittleEndian( *pnArray );
+}
+
inline void ByteOrderConverter::swap2( sal_uInt8* pnData )
{
::std::swap( pnData[ 0 ], pnData[ 1 ] );
diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx
index e36e7001e613..b25035dd7107 100644
--- a/oox/inc/oox/helper/modelobjecthelper.hxx
+++ b/oox/inc/oox/helper/modelobjecthelper.hxx
@@ -48,7 +48,7 @@ class ObjectContainer
{
public:
explicit ObjectContainer(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory,
const ::rtl::OUString& rServiceName );
~ObjectContainer();
@@ -68,8 +68,8 @@ private:
void createContainer() const;
private:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- mxFactory; /// Factory to create the container.
+ mutable ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ mxModelFactory; /// Factory to create the container.
mutable ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
mxContainer; /// Container for the objects.
::rtl::OUString maServiceName; /// Service name to create the container.
@@ -81,9 +81,9 @@ private:
/** Contains tables for named drawing objects for a document model.
Contains tables for named line markers, line dashes, fill gradients, and
- fill bitmaps. The class is needed to handle different document models in
- the same filter (e.g. embedded charts) which carry their own drawing object
- tables.
+ fill bitmap URLs. The class is needed to handle different document models
+ in the same filter (e.g. embedded charts) which carry their own drawing
+ object tables.
*/
class ModelObjectHelper
{
@@ -108,18 +108,18 @@ public:
an internal constant name with a new unused index appended. */
::rtl::OUString insertFillGradient( const ::com::sun::star::awt::Gradient& rGradient );
- /** Inserts a new named fill bitmap, returns the bitmap name, based on an
- internal constant name with a new unused index appended. */
- ::rtl::OUString insertFillBitmap( const ::rtl::OUString& rGraphicUrl );
+ /** Inserts a new named fill bitmap URL, returns the bitmap name, based on
+ an internal constant name with a new unused index appended. */
+ ::rtl::OUString insertFillBitmapUrl( const ::rtl::OUString& rGraphicUrl );
private:
ObjectContainer maMarkerContainer; /// Contains all named line markers (line end polygons).
ObjectContainer maDashContainer; /// Contains all named line dsahes.
ObjectContainer maGradientContainer; /// Contains all named fill gradients.
- ObjectContainer maBitmapContainer; /// Contains all named fill bitmaps.
+ ObjectContainer maBitmapUrlContainer; /// Contains all named fill bitmap URLs.
const ::rtl::OUString maDashNameBase; /// Base name for all named line dashes.
const ::rtl::OUString maGradientNameBase; /// Base name for all named fill gradients.
- const ::rtl::OUString maBitmapNameBase; /// Base name for all named fill bitmaps.
+ const ::rtl::OUString maBitmapUrlNameBase; /// Base name for all named fill bitmap URLs.
};
// ============================================================================
diff --git a/oox/inc/oox/helper/propertymap.hxx b/oox/inc/oox/helper/propertymap.hxx
index 9e7196381002..7177a7f95cef 100644
--- a/oox/inc/oox/helper/propertymap.hxx
+++ b/oox/inc/oox/helper/propertymap.hxx
@@ -59,7 +59,6 @@ class PropertyMap : public PropertyMapBase
{
public:
explicit PropertyMap();
- ~PropertyMap();
/** Returns the name of the passed property identifier. */
static const ::rtl::OUString& getPropertyName( sal_Int32 nPropId );
@@ -73,9 +72,18 @@ public:
/** Sets the specified property to the passed value. Does nothing, if the
identifier is invalid. */
+ inline bool setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue )
+ { if( nPropId < 0 ) return false; (*this)[ nPropId ] = rValue; return true; }
+
+ /** Sets the specified property to the passed value. Does nothing, if the
+ identifier is invalid. */
template< typename Type >
- inline void setProperty( sal_Int32 nPropId, const Type& rValue )
- { if( nPropId >= 0 ) (*this)[ nPropId ] <<= rValue; }
+ inline bool setProperty( sal_Int32 nPropId, const Type& rValue )
+ { if( nPropId < 0 ) return false; (*this)[ nPropId ] <<= rValue; return true; }
+
+ /** Inserts all properties contained in the passed property map. */
+ inline void assignUsed( const PropertyMap& rPropMap )
+ { insert( rPropMap.begin(), rPropMap.end() ); }
/** Returns a sequence of property values, filled with all contained properties. */
::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
@@ -86,7 +94,7 @@ public:
::com::sun::star::uno::Sequence< ::rtl::OUString >& rNames,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues ) const;
- /** Creates and fills a new instance supporting the XPropertySet interface. */
+ /** Creates a property set supporting the XPropertySet interface and inserts all properties. */
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
makePropertySet() const;
diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx
index 9a49bb48cf92..8b5b562e84f2 100644
--- a/oox/inc/oox/helper/propertyset.hxx
+++ b/oox/inc/oox/helper/propertyset.hxx
@@ -28,8 +28,9 @@
#ifndef OOX_HELPER_PROPERTYSET_HXX
#define OOX_HELPER_PROPERTYSET_HXX
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include "oox/token/properties.hxx"
namespace oox {
@@ -82,24 +83,25 @@ public:
inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
getXPropertySet() const { return mxPropSet; }
+ /** Returns true, if the specified property is supported by the property set. */
+ bool hasProperty( sal_Int32 nPropId ) const;
+
// Get properties ---------------------------------------------------------
/** Gets the specified property from the property set.
- @return true, if the any could be filled with the property value. */
- bool getAnyProperty( ::com::sun::star::uno::Any& orValue, sal_Int32 nPropId ) const;
+ @return the property value, or an empty Any, if the property is missing. */
+ ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const;
/** Gets the specified property from the property set.
@return true, if the passed variable could be filled with the property value. */
template< typename Type >
- inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const;
-
- /** Gets the specified property from the property set.
- @return the property value, or an empty Any, if the property is missing. */
- ::com::sun::star::uno::Any getAnyProperty( sal_Int32 nPropId ) const;
+ inline bool getProperty( Type& orValue, sal_Int32 nPropId ) const
+ { return getAnyProperty( nPropId ) >>= orValue; }
/** Gets the specified boolean property from the property set.
@return true = property contains true; false = property contains false or error occured. */
- bool getBoolProperty( sal_Int32 nPropId ) const;
+ inline bool getBoolProperty( sal_Int32 nPropId ) const
+ { bool bValue = false; return getProperty( bValue, nPropId ) && bValue; }
/** Gets the specified properties from the property set. Tries to use the XMultiPropertySet interface.
@param orValues (out-parameter) The related property values.
@@ -111,11 +113,12 @@ public:
// Set properties ---------------------------------------------------------
/** Puts the passed any into the property set. */
- void setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
+ bool setAnyProperty( sal_Int32 nPropId, const ::com::sun::star::uno::Any& rValue );
/** Puts the passed value into the property set. */
template< typename Type >
- inline void setProperty( sal_Int32 nPropId, const Type& rValue );
+ inline bool setProperty( sal_Int32 nPropId, const Type& rValue )
+ { return setAnyProperty( nPropId, ::com::sun::star::uno::Any( rValue ) ); }
/** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface.
@param rPropNames The property names. MUST be ordered alphabetically.
@@ -132,33 +135,20 @@ public:
private:
/** Gets the specified property from the property set.
@return true, if the any could be filled with the property value. */
- bool getAnyProperty( ::com::sun::star::uno::Any& orValue, const ::rtl::OUString& rPropName ) const;
+ bool implGetPropertyValue( ::com::sun::star::uno::Any& orValue, const ::rtl::OUString& rPropName ) const;
/** Puts the passed any into the property set. */
- void setAnyProperty( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue );
+ bool implSetPropertyValue( const ::rtl::OUString& rPropName, const ::com::sun::star::uno::Any& rValue );
private:
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
mxPropSet; /// The mandatory property set interface.
::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet >
mxMultiPropSet; /// The optional multi property set interface.
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ mxPropSetInfo; /// Property information.
};
-// ----------------------------------------------------------------------------
-
-template< typename Type >
-inline bool PropertySet::getProperty( Type& orValue, sal_Int32 nPropId ) const
-{
- ::com::sun::star::uno::Any aAny;
- return getAnyProperty( aAny, nPropId ) && (aAny >>= orValue);
-}
-
-template< typename Type >
-inline void PropertySet::setProperty( sal_Int32 nPropId, const Type& rValue )
-{
- setAnyProperty( nPropId, ::com::sun::star::uno::Any( rValue ) );
-}
-
// ============================================================================
} // namespace oox
diff --git a/oox/inc/oox/helper/textinputstream.hxx b/oox/inc/oox/helper/textinputstream.hxx
index 2e98d3fc8c84..1c8ef471c587 100644..100755
--- a/oox/inc/oox/helper/textinputstream.hxx
+++ b/oox/inc/oox/helper/textinputstream.hxx
@@ -25,29 +25,100 @@
*
************************************************************************/
-#ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX
-#define OOX_HELPER_RECORDINPUTSTREAM_HXX
+#ifndef OOX_HELPER_TEXTINPUTSTREAM_HXX
+#define OOX_HELPER_TEXTINPUTSTREAM_HXX
-#include "oox/helper/binaryinputstream.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+#include <rtl/ustring.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace io { class XInputStream; }
+ namespace io { class XTextInputStream; }
+ namespace uno { class XComponentContext; }
+} } }
namespace oox {
+class BinaryInputStream;
+
// ============================================================================
class TextInputStream
{
public:
- explicit TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc );
+ explicit TextInputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ explicit TextInputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ BinaryInputStream& rInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ ~TextInputStream();
- /** Returns true, if the wrapped input stream is in EOF state. */
+ /** Returns true, if no more text is available in the stream.
+ */
bool isEof() const;
- /** Reads a text line from the stream. */
+
+ /** Reads a text line from the stream.
+
+ If the last line in the stream is not terminated with line-end
+ character(s), the stream will immediately go into EOF state and return
+ the text line. Otherwise, if the last character in the stream is a
+ line-end character, the next call to this function will turn the stream
+ into EOF state and return an empty string.
+ */
::rtl::OUString readLine();
+ /** Reads a text portion from the stream until the specified character is
+ found.
+
+ If the end of the stream is not terminated with the specified
+ character, the stream will immediately go into EOF state and return the
+ remaining text portion. Otherwise, if the last character in the stream
+ is the specified character (and caller specifies to read and return it,
+ see parameter bIncludeChar), the next call to this function will turn
+ the stream into EOF state and return an empty string.
+
+ @param cChar
+ The separator character to be read to.
+
+ @param bIncludeChar
+ True = if found, the specified character will be read from stream
+ and included in the returned string.
+ False = the specified character will neither be read from the
+ stream nor included in the returned string, but will be
+ returned as first character in the next call of this function
+ or readLine().
+ */
+ ::rtl::OUString readToChar( sal_Unicode cChar, bool bIncludeChar );
+
+ // ------------------------------------------------------------------------
+
+ /** Creates a UNO text input stream object from the passed UNO input stream.
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
+ createXTextInputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ // ------------------------------------------------------------------------
+private:
+ void init(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ rtl_TextEncoding eTextEnc );
+
+ /** Adds the pending character in front of the passed string, if existing. */
+ ::rtl::OUString createFinalString( const ::rtl::OUString& rString );
+
private:
- BinaryInputStream& mrInStrm;
- rtl_TextEncoding meTextEnc;
- sal_Unicode mcLastEolChar;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XTextInputStream >
+ mxTextStrm;
+ sal_Unicode mcPendingChar;
};
// ============================================================================
diff --git a/oox/inc/oox/helper/zipstorage.hxx b/oox/inc/oox/helper/zipstorage.hxx
index 0c9a15c10077..26eeebc47979 100644
--- a/oox/inc/oox/helper/zipstorage.hxx
+++ b/oox/inc/oox/helper/zipstorage.hxx
@@ -31,7 +31,7 @@
#include "oox/helper/storagebase.hxx"
namespace com { namespace sun { namespace star {
- namespace lang { class XMultiServiceFactory; }
+ namespace uno { class XComponentContext; }
} } }
namespace oox {
@@ -43,11 +43,11 @@ class ZipStorage : public StorageBase
{
public:
explicit ZipStorage(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream );
explicit ZipStorage(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxStream );
virtual ~ZipStorage();
@@ -83,9 +83,8 @@ private:
virtual void implCommit() const;
private:
- typedef ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > XStorageRef;
-
- XStorageRef mxStorage; /// Storage based on input or output stream.
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ mxStorage; /// Storage based on input or output stream.
};
// ============================================================================