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/attributelist.hxx192
-rw-r--r--oox/inc/oox/helper/binaryinputstream.hxx291
-rw-r--r--oox/inc/oox/helper/binaryoutputstream.hxx161
-rw-r--r--oox/inc/oox/helper/binarystreambase.hxx147
-rw-r--r--oox/inc/oox/helper/containerhelper.hxx702
-rw-r--r--oox/inc/oox/helper/graphichelper.hxx175
-rw-r--r--oox/inc/oox/helper/helper.hxx325
-rw-r--r--oox/inc/oox/helper/modelobjecthelper.hxx94
-rw-r--r--oox/inc/oox/helper/progressbar.hxx145
-rw-r--r--oox/inc/oox/helper/propertymap.hxx106
-rw-r--r--oox/inc/oox/helper/propertyset.hxx170
-rw-r--r--oox/inc/oox/helper/recordinputstream.hxx58
-rw-r--r--oox/inc/oox/helper/storagebase.hxx195
-rwxr-xr-xoox/inc/oox/helper/textinputstream.hxx58
-rw-r--r--oox/inc/oox/helper/zipstorage.hxx95
15 files changed, 2914 insertions, 0 deletions
diff --git a/oox/inc/oox/helper/attributelist.hxx b/oox/inc/oox/helper/attributelist.hxx
new file mode 100644
index 000000000000..631d7ec4b66e
--- /dev/null
+++ b/oox/inc/oox/helper/attributelist.hxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_ATTRIBUTELIST_HXX
+#define OOX_HELPER_ATTRIBUTELIST_HXX
+
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/xml/sax/XFastAttributeList.hpp>
+#include "oox/helper/helper.hxx"
+#include "tokens.hxx"
+
+namespace oox {
+
+// ============================================================================
+
+/** Static helpers for conversion of strings to attribute values of various
+ different data types.
+ */
+class AttributeConversion
+{
+public:
+ /** Returns the decoded string value. All characters in the format
+ '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
+ static ::rtl::OUString decodeXString( const ::rtl::OUString& rValue );
+
+ /** Returns the double value from the passed string. */
+ static double decodeDouble( const ::rtl::OUString& rValue );
+
+ /** Returns the 32-bit signed integer value from the passed string (decimal). */
+ static sal_Int32 decodeInteger( const ::rtl::OUString& rValue );
+
+ /** Returns the 32-bit unsigned integer value from the passed string (decimal). */
+ static sal_uInt32 decodeUnsigned( const ::rtl::OUString& rValue );
+
+ /** Returns the 64-bit signed integer value from the passed string (decimal). */
+ static sal_Int64 decodeHyper( const ::rtl::OUString& rValue );
+
+ /** Returns the 32-bit signed integer value from the passed string (hexadecimal). */
+ static sal_Int32 decodeIntegerHex( const ::rtl::OUString& rValue );
+
+ /** Returns the 32-bit unsigned integer value from the passed string (hexadecimal). */
+ static sal_uInt32 decodeUnsignedHex( const ::rtl::OUString& rValue );
+
+ /** Returns the 64-bit signed integer value from the passed string (hexadecimal). */
+ static sal_Int64 decodeHyperHex( const ::rtl::OUString& rValue );
+};
+
+// ============================================================================
+
+/** Provides access to attribute values of an element.
+
+ Wraps a com.sun.star.xml.sax.XFastAttributeList object. Provides
+ convenience functions that convert the string value of an attribute to
+ various other data types.
+ */
+class AttributeList
+{
+public:
+ explicit AttributeList(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs );
+
+ /** Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object. */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >
+ getFastAttributeList() const { return mxAttribs; }
+
+ /** Returns true, if the specified attribute is present. */
+ bool hasAttribute( sal_Int32 nAttrToken ) const;
+
+ // optional return values -------------------------------------------------
+
+ /** Returns the token identifier of the value of the specified attribute. */
+ OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const;
+
+ /** Returns the string value of the specified attribute. */
+ OptValue< ::rtl::OUString > getString( sal_Int32 nAttrToken ) const;
+
+ /** Returns the string value of the specified attribute. All characters in
+ the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
+ OptValue< ::rtl::OUString > getXString( sal_Int32 nAttrToken ) const;
+
+ /** Returns the double value of the specified attribute. */
+ OptValue< double > getDouble( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (decimal). */
+ OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute (decimal). */
+ OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute (decimal). */
+ OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal). */
+ OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute (hexadecimal). */
+ OptValue< sal_uInt32 > getUnsignedHex( sal_Int32 nAttrToken ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute (hexadecimal). */
+ OptValue< sal_Int64 > getHyperHex( sal_Int32 nAttrToken ) const;
+
+ /** Returns the boolean value of the specified attribute. */
+ OptValue< bool > getBool( sal_Int32 nAttrToken ) const;
+
+ /** Returns the date/time value of the specified attribute. */
+ OptValue< ::com::sun::star::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const;
+
+ // defaulted return values ------------------------------------------------
+
+ /** Returns the token identifier of the value of the specified attribute,
+ or the passed default identifier if the attribute is missing. */
+ sal_Int32 getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ /** Returns the string value of the specified attribute, or the passed
+ default string if the attribute is missing. */
+ ::rtl::OUString getString( sal_Int32 nAttrToken, const ::rtl::OUString& rDefault ) const;
+
+ /** Returns the decoded string value of the specified attribute, or the
+ passed default string if the attribute is missing. */
+ ::rtl::OUString getXString( sal_Int32 nAttrToken, const ::rtl::OUString& rDefault ) const;
+
+ /** Returns the double value of the specified attribute, or the passed
+ default value if the attribute is missing or not convertible to a double. */
+ double getDouble( sal_Int32 nAttrToken, double fDefault ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to integer. */
+ sal_Int32 getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to unsigned. */
+ sal_uInt32 getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute, or the
+ passed default value if the attribute is missing or not convertible to integer. */
+ sal_Int64 getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
+
+ /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal),
+ or the passed default value if the attribute is missing or not convertible. */
+ sal_Int32 getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
+
+ /** Returns the 32-bit unsigned integer value of the specified attribute (hexadecimal),
+ or the passed default value if the attribute is missing or not convertible. */
+ sal_uInt32 getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
+
+ /** Returns the 64-bit signed integer value of the specified attribute (hexadecimal),
+ or the passed default value if the attribute is missing or not convertible. */
+ sal_Int64 getHyperHex( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
+
+ /** Returns the boolean value of the specified attribute, or the passed
+ default value if the attribute is missing or not convertible to bool. */
+ bool getBool( sal_Int32 nAttrToken, bool bDefault ) const;
+
+ /** Returns the date/time value of the specified attribute, or the default
+ value if the attribute is missing or not convertible to a date/time value. */
+ ::com::sun::star::util::DateTime getDateTime( sal_Int32 nAttrToken, const ::com::sun::star::util::DateTime& rDefault ) const;
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >
+ mxAttribs;
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/binaryinputstream.hxx b/oox/inc/oox/helper/binaryinputstream.hxx
new file mode 100644
index 000000000000..8f58e2de4d9e
--- /dev/null
+++ b/oox/inc/oox/helper/binaryinputstream.hxx
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_BINARYINPUTSTREAM_HXX
+#define OOX_HELPER_BINARYINPUTSTREAM_HXX
+
+#include <boost/shared_ptr.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include "oox/helper/binarystreambase.hxx"
+
+namespace oox {
+
+class BinaryOutputStream;
+
+// ============================================================================
+
+/** Interface for binary input stream classes.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+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;
+ /** 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;
+
+ /** Reads a value from the stream and converts it to platform byte order.
+ Supported types: SAL integers (8 to 64 bit), float, double. */
+ 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. */
+ template< typename Type >
+ inline Type readValue() { Type nValue; readValue( nValue ); return nValue; }
+ /** Stream operator for integral and floating-point types. */
+ template< typename Type >
+ inline BinaryInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
+
+ inline sal_Int8 readInt8() { return readValue< sal_Int8 >(); }
+ inline sal_uInt8 readuInt8() { return readValue< sal_uInt8 >(); }
+ inline sal_Int16 readInt16() { return readValue< sal_Int16 >(); }
+ inline sal_uInt16 readuInt16() { return readValue< sal_uInt16 >(); }
+ inline sal_Int32 readInt32() { return readValue< sal_Int32 >(); }
+ inline sal_uInt32 readuInt32() { return readValue< sal_uInt32 >(); }
+ inline sal_Int64 readInt64() { return readValue< sal_Int64 >(); }
+ inline sal_uInt64 readuInt64() { return readValue< sal_uInt64 >(); }
+ inline float readFloat() { return readValue< float >(); }
+ inline double readDouble() { return readValue< double >(); }
+
+ /** 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. */
+ ::rtl::OUString readNulCharArrayUC( rtl_TextEncoding eTextEnc );
+
+ /** 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.
+ @param bAllowNulChars
+ True = NUL characters are inserted into the imported string.
+ 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.
+ @param bAllowNulChars
+ True = NUL characters are inserted into the imported string.
+ 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.
+ @param bAllowNulChars
+ True = NUL characters are inserted into the imported string.
+ 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 );
+
+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 );
+};
+
+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 ) ) );
+ ByteOrderConverter::convertLittleEndian( ornValue );
+}
+
+// ============================================================================
+
+/** Wraps a com.sun.star.io.XInputStream and provides convenient access functions.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+class BinaryXInputStream : public BinaryXSeekableStream, public BinaryInputStream
+{
+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.
+ */
+ explicit BinaryXInputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm,
+ bool bAutoClose );
+
+ virtual ~BinaryXInputStream();
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes );
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes );
+ /** Seeks the stream forward by the passed number of bytes. This works for
+ non-seekable streams too. */
+ virtual void skip( sal_Int32 nBytes );
+
+ /** Stream operator for integral and floating-point types. */
+ 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 >
+ mxInStrm; /// Reference to the input stream.
+ bool mbAutoClose; /// True = automatically close stream on destruction.
+};
+
+typedef ::boost::shared_ptr< BinaryXInputStream > BinaryXInputStreamRef;
+
+// ============================================================================
+
+/** Wraps a StreamDataSequence and provides convenient access functions.
+
+ The binary data in the stream is assumed to be in little-endian format.
+ */
+class SequenceInputStream : public SequenceSeekableStream, public BinaryInputStream
+{
+public:
+ /** 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 read from it.
+ */
+ explicit SequenceInputStream( const StreamDataSequence& rData );
+
+ /** Reads nBytes bytes to the passed sequence.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readData( StreamDataSequence& orData, sal_Int32 nBytes );
+ /** Reads nBytes bytes to the (existing) buffer opMem.
+ @return Number of bytes really read. */
+ virtual sal_Int32 readMemory( void* opMem, sal_Int32 nBytes );
+ /** Seeks the stream forward by the passed number of bytes. This works for
+ non-seekable streams too. */
+ virtual void skip( sal_Int32 nBytes );
+
+ /** Stream operator for integral and floating-point types. */
+ template< typename Type >
+ inline SequenceInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
+};
+
+typedef ::boost::shared_ptr< SequenceInputStream > SequenceInputStreamRef;
+
+// ============================================================================
+
+/** 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).
+ */
+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
+ 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 );
+
+ /** 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;
+ /** 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 );
+
+ /** 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 );
+ /** 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 );
+ /** 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 );
+
+ /** Stream operator for integral and floating-point types. */
+ template< typename Type >
+ inline RelativeInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
+
+private:
+ BinaryInputStream& mrInStrm;
+ sal_Int64 mnStartPos;
+ sal_Int64 mnRelPos;
+ sal_Int64 mnLength;
+};
+
+typedef ::boost::shared_ptr< RelativeInputStream > RelativeInputStreamRef;
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/binaryoutputstream.hxx b/oox/inc/oox/helper/binaryoutputstream.hxx
new file mode 100644
index 000000000000..d2f0f8b36ffa
--- /dev/null
+++ b/oox/inc/oox/helper/binaryoutputstream.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#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 oox {
+
+// ============================================================================
+
+/** Interface for binary output stream classes.
+
+ The binary data in the stream is written in little-endian format.
+ */
+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;
+
+ /** Writes a value to the stream and converts it to platform byte order.
+ Supported types: SAL integers (8 to 64 bit), float, double. */
+ template< typename Type >
+ void writeValue( Type nValue );
+ /** Stream operator for integral and floating-point types. */
+ 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 );
+};
+
+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 ) ) );
+}
+
+// ============================================================================
+
+/** Wraps a com.sun.star.io.XOutputStream and provides convenient access functions.
+
+ The binary data in the stream is written in little-endian format.
+ */
+class BinaryXOutputStream : public BinaryXSeekableStream, public BinaryOutputStream
+{
+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.
+ */
+ explicit BinaryXOutputStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rxOutStrm,
+ bool bAutoClose );
+
+ virtual ~BinaryXOutputStream();
+
+ /** 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 );
+
+ /** Stream operator for integral and floating-point types. */
+ 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.
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ mxOutStrm; /// Reference to the output stream.
+ bool mbAutoClose; /// True = automatically close stream on destruction.
+};
+
+typedef ::boost::shared_ptr< BinaryXOutputStream > BinaryXOutputStreamRef;
+
+// ============================================================================
+
+/** Wraps a StreamDataSequence and provides convenient access functions.
+
+ The binary data in the stream is written in little-endian format. After
+ construction, the stream points to the beginning of the passed data
+ sequence. The data sequence is expanded automatically while writing to it.
+ */
+class SequenceOutputStream : public SequenceSeekableStream, public BinaryOutputStream
+{
+public:
+ /** 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 write to it.
+ */
+ 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 );
+
+ /** Stream operator for integral and floating-point types. */
+ template< typename Type >
+ inline SequenceOutputStream& operator<<( Type nValue ) { writeValue( nValue ); return *this; }
+};
+
+typedef ::boost::shared_ptr< SequenceOutputStream > SequenceOutputStreamRef;
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/binarystreambase.hxx b/oox/inc/oox/helper/binarystreambase.hxx
new file mode 100644
index 000000000000..abe4c5f1c274
--- /dev/null
+++ b/oox/inc/oox/helper/binarystreambase.hxx
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_BINARYSTREAMBASE_HXX
+#define OOX_HELPER_BINARYSTREAMBASE_HXX
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/io/XSeekable.hpp>
+#include "oox/helper/helper.hxx"
+
+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. */
+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 );
+
+ /** Returns true, if the stream position is invalid (EOF). This flag turns
+ 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. */
+ sal_Int64 getRemaining() const;
+ /** 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 forward to a position that is a multiple of the passed
+ block size, relative to the passed stream position, if stream is seekable. */
+ void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos = 0 );
+
+protected:
+ inline explicit BinaryStreamBase() : mbEof( false ) {}
+
+private:
+ BinaryStreamBase( const BinaryStreamBase& );
+ BinaryStreamBase& operator=( const BinaryStreamBase& );
+
+protected:
+ bool mbEof;
+};
+
+// ============================================================================
+
+/** Base class for binary input and output streams wrapping an API 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 sal_Int64 tell() const;
+ /** Seeks the stream to the passed position, if stream is seekable. */
+ virtual void seek( sal_Int64 nPos );
+
+protected:
+ explicit BinaryXSeekableStream(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >& rxSeekable );
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >
+ mxSeekable; /// Stream seeking interface.
+};
+
+// ============================================================================
+
+/** Base class for binary input and output streams wrapping a
+ StreamDataSequence, which is always seekable. */
+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;
+ /** Returns the current stream position. */
+ virtual sal_Int64 tell() const;
+ /** Seeks the stream to the passed position. */
+ virtual void seek( sal_Int64 nPos );
+
+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 ) {}
+
+protected:
+ const StreamDataSequence& mrData; /// Wrapped data sequence.
+ sal_Int32 mnPos; /// Current position in the sequence.
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx
new file mode 100644
index 000000000000..f4f3717eac3f
--- /dev/null
+++ b/oox/inc/oox/helper/containerhelper.hxx
@@ -0,0 +1,702 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_CONTAINERHELPER_HXX
+#define OOX_HELPER_CONTAINERHELPER_HXX
+
+#include <vector>
+#include <map>
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.h>
+
+namespace rtl { class OUString; }
+
+namespace com { namespace sun { namespace star {
+ namespace container { class XIndexAccess; }
+ namespace container { class XIndexContainer; }
+ namespace container { class XNameAccess; }
+ namespace container { class XNameContainer; }
+ namespace lang { class XMultiServiceFactory; }
+} } }
+
+namespace oox {
+
+// ============================================================================
+
+/** Template for a vector of ref-counted objects with additional accessor functions.
+
+ An instance of the class RefVector< Type > stores elements of the type
+ ::boost::shared_ptr< Type >. The new accessor functions has() and get()
+ work correctly for indexes out of the current range, there is no need to
+ check the passed index before.
+ */
+template< typename ObjType >
+class RefVector : public ::std::vector< ::boost::shared_ptr< ObjType > >
+{
+public:
+ typedef ::std::vector< ::boost::shared_ptr< ObjType > > container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::size_type size_type;
+
+public:
+ /** Returns true, if the object with the passed index exists. Returns
+ false, if the vector element exists but is an empty reference. */
+ inline bool has( sal_Int32 nIndex ) const
+ {
+ const value_type* pxRef = getRef( nIndex );
+ return pxRef && pxRef->get();
+ }
+
+ /** Returns a reference to the object with the passed index, or 0 on error. */
+ inline value_type get( sal_Int32 nIndex ) const
+ {
+ if( const value_type* pxRef = getRef( nIndex ) ) return *pxRef;
+ return value_type();
+ }
+
+ /** Returns the index of the last element, or -1, if the vector is empty.
+ Does *not* check whether the last element is an empty reference. */
+ inline sal_Int32 getLastIndex() const { return static_cast< sal_Int32 >( this->size() ) - 1; }
+
+ /** Calls the passed functor for every contained object, automatically
+ skips all elements that are empty references. */
+ template< typename FunctorType >
+ inline void forEach( FunctorType aFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( aFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType >
+ inline void forEachMem( FuncType pFunc ) const
+ {
+ forEach( ::boost::bind( pFunc, _1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType >
+ inline void forEachMem( FuncType pFunc, ParamType aParam ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
+ }
+
+ /** Calls the passed functor for every contained object. Passes the index as
+ first argument and the object reference as second argument to rFunctor. */
+ template< typename FunctorType >
+ inline void forEachWithIndex( const FunctorType& rFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctorWithIndex< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the vector index to the member function. */
+ template< typename FuncType >
+ inline void forEachMemWithIndex( FuncType pFunc ) const
+ {
+ forEachWithIndex( ::boost::bind( pFunc, _2, _1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the vector index as first argument to the member function. */
+ template< typename FuncType, typename ParamType >
+ inline void forEachMemWithIndex( FuncType pFunc, ParamType aParam ) const
+ {
+ forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the vector index as first argument to the member function. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the vector index as first argument to the member function. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ inline void forEachMemWithIndex( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEachWithIndex( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) );
+ }
+
+ /** Searches for an element by using the passed functor that takes a
+ constant reference of the object type (const ObjType&). */
+ template< typename FunctorType >
+ inline value_type findIf( const FunctorType& rFunctor ) const
+ {
+ typename container_type::const_iterator aIt = ::std::find_if( this->begin(), this->end(), FindFunctor< FunctorType >( rFunctor ) );
+ return (aIt == this->end()) ? value_type() : *aIt;
+ }
+
+private:
+ template< typename FunctorType >
+ struct ForEachFunctor
+ {
+ FunctorType maFunctor;
+ inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( *rxValue ); }
+ };
+
+ template< typename FunctorType >
+ struct ForEachFunctorWithIndex
+ {
+ FunctorType maFunctor;
+ sal_Int32 mnIndex;
+ inline explicit ForEachFunctorWithIndex( const FunctorType& rFunctor ) : maFunctor( rFunctor ), mnIndex( 0 ) {}
+ inline void operator()( const value_type& rxValue ) { if( rxValue.get() ) maFunctor( mnIndex, *rxValue ); ++mnIndex; }
+ };
+
+ template< typename FunctorType >
+ struct FindFunctor
+ {
+ FunctorType maFunctor;
+ inline explicit FindFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ inline bool operator()( const value_type& rxValue ) { return rxValue.get() && maFunctor( *rxValue ); }
+ };
+
+ inline const value_type* getRef( sal_Int32 nIndex ) const
+ {
+ return ((0 <= nIndex) && (static_cast< size_type >( nIndex ) < this->size())) ?
+ &(*this)[ static_cast< size_type >( nIndex ) ] : 0;
+ }
+};
+
+// ============================================================================
+
+/** Template for a map of ref-counted objects with additional accessor functions.
+
+ An instance of the class RefMap< Type > stores elements of the type
+ ::boost::shared_ptr< Type >. The new accessor functions has() and get()
+ work correctly for nonexisting keys, there is no need to check the passed
+ key before.
+ */
+template< typename KeyType, typename ObjType, typename CompType = ::std::less< KeyType > >
+class RefMap : public ::std::map< KeyType, ::boost::shared_ptr< ObjType >, CompType >
+{
+public:
+ typedef ::std::map< KeyType, ::boost::shared_ptr< ObjType >, CompType > container_type;
+ typedef typename container_type::key_type key_type;
+ typedef typename container_type::mapped_type mapped_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::key_compare key_compare;
+
+public:
+ /** Returns true, if the object accossiated to the passed key exists.
+ Returns false, if the key exists but points to an empty reference. */
+ inline bool has( key_type nKey ) const
+ {
+ const mapped_type* pxRef = getRef( nKey );
+ return pxRef && pxRef->get();
+ }
+
+ /** Returns a reference to the object accossiated to the passed key, or an
+ empty reference on error. */
+ inline mapped_type get( key_type nKey ) const
+ {
+ if( const mapped_type* pxRef = getRef( nKey ) ) return *pxRef;
+ return mapped_type();
+ }
+
+ /** Calls the passed functor for every contained object, automatically
+ skips all elements that are empty references. */
+ template< typename FunctorType >
+ inline void forEach( const FunctorType& rFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType >
+ inline void forEachMem( FuncType pFunc ) const
+ {
+ forEach( ::boost::bind( pFunc, _1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType >
+ inline void forEachMem( FuncType pFunc, ParamType aParam ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object,
+ automatically skips all elements that are empty references. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ inline void forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
+ }
+ /** Calls the passed functor for every contained object. Passes the key as
+ first argument and the object reference as second argument to rFunctor. */
+ template< typename FunctorType >
+ inline void forEachWithKey( const FunctorType& rFunctor ) const
+ {
+ ::std::for_each( this->begin(), this->end(), ForEachFunctorWithKey< FunctorType >( rFunctor ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the object key as argument to the member function. */
+ template< typename FuncType >
+ inline void forEachMemWithKey( FuncType pFunc ) const
+ {
+ forEachWithKey( ::boost::bind( pFunc, _2, _1 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the object key as first argument to the member function. */
+ template< typename FuncType, typename ParamType >
+ inline void forEachMemWithKey( FuncType pFunc, ParamType aParam ) const
+ {
+ forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the object key as first argument to the member function. */
+ template< typename FuncType, typename ParamType1, typename ParamType2 >
+ inline void forEachMemWithKey( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2 ) const
+ {
+ forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2 ) );
+ }
+
+ /** Calls the passed member function of ObjType on every contained object.
+ Passes the object key as first argument to the member function. */
+ template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3 >
+ inline void forEachMemWithKey( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
+ {
+ forEachWithKey( ::boost::bind( pFunc, _2, _1, aParam1, aParam2, aParam3 ) );
+ }
+
+private:
+ template< typename FunctorType >
+ struct ForEachFunctor
+ {
+ FunctorType maFunctor;
+ inline explicit ForEachFunctor( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( *rValue.second ); }
+ };
+
+ template< typename FunctorType >
+ struct ForEachFunctorWithKey
+ {
+ FunctorType maFunctor;
+ inline explicit ForEachFunctorWithKey( const FunctorType& rFunctor ) : maFunctor( rFunctor ) {}
+ inline void operator()( const value_type& rValue ) { if( rValue.second.get() ) maFunctor( rValue.first, *rValue.second ); }
+ };
+
+ inline const mapped_type* getRef( key_type nKey ) const
+ {
+ typename container_type::const_iterator aIt = find( nKey );
+ return (aIt == this->end()) ? 0 : &aIt->second;
+ }
+};
+
+// ============================================================================
+
+/** Template for a 2-dimensional array of objects.
+
+ This class template provides a similar interface to the ::std::vector
+ template.
+ */
+template< typename Type >
+class Matrix
+{
+public:
+ typedef ::std::vector< Type > container_type;
+ typedef typename container_type::value_type value_type;
+ typedef typename container_type::pointer pointer;
+ typedef typename container_type::reference reference;
+ typedef typename container_type::const_reference const_reference;
+ typedef typename container_type::size_type size_type;
+ typedef typename container_type::iterator iterator;
+ typedef typename container_type::const_iterator const_iterator;
+
+ inline explicit Matrix() : mnWidth( 0 ) {}
+ inline explicit Matrix( size_type nWidth, size_type nHeight ) { this->resize( nWidth, nHeight ); }
+ inline explicit Matrix( size_type nWidth, size_type nHeight, const_reference rData ) { this->resize( nWidth, nHeight, rData ); }
+
+ inline size_type capacity() const { return maData.capacity(); }
+ inline bool empty() const { return maData.empty(); }
+ inline size_type size() const { return maData.size(); }
+ inline size_type width() const { return mnWidth; }
+ inline size_type height() const { return this->empty() ? 0 : (this->size() / this->width()); }
+ inline bool has( size_type nX, size_type nY ) const { return (nX < this->width()) && (nY < this->height()); }
+
+ inline void reserve( size_type nWidth, size_type nHeight ) { maData.reserve( nWidth * nHeight ); }
+ inline void clear() { this->resize( 0, 0 ); }
+ inline void resize( size_type nWidth, size_type nHeight ) { mnWidth = nWidth; maData.resize( nWidth * nHeight ); }
+ inline void resize( size_type nWidth, size_type nHeight, const_reference rData ) { mnWidth = nWidth; maData.resize( nWidth * nHeight, rData ); }
+
+ inline iterator at( size_type nX, size_type nY ) { return maData.begin() + mnWidth * nY + nX; }
+ inline const_iterator at( size_type nX, size_type nY ) const { return maData.begin() + mnWidth * nY + nX; }
+
+ inline reference operator()( size_type nX, size_type nY ) { return *this->at( nX, nY ); }
+ inline const_reference operator()( size_type nX, size_type nY ) const { return *this->at( nX, nY ); }
+
+ inline iterator begin() { return maData.begin(); }
+ inline const_iterator begin() const { return maData.begin(); }
+ inline iterator end() { return maData.end(); }
+ inline const_iterator end() const { return maData.end(); }
+
+ inline reference front() { return maData.front(); }
+ inline const_reference front() const { return maData.front(); }
+ inline reference back() { return maData.back(); }
+ inline const_reference back() const { return maData.back(); }
+
+ inline iterator row_begin( size_type nY ) { return this->at( 0, nY ); }
+ inline const_iterator row_begin( size_type nY ) const { return this->at( 0, nY ); }
+ inline iterator row_end( size_type nY ) { return this->at( mnWidth, nY ); }
+ inline const_iterator row_end( size_type nY ) const { return this->at( mnWidth, nY ); }
+
+ inline reference row_front( size_type nY ) { return (*this)( 0, nY ); }
+ inline const_reference row_front( size_type nY ) const { return (*this)( 0, nY ); }
+ inline reference row_back( size_type nY ) { return (*this)( mnWidth - 1, nY ); }
+ inline const_reference row_back( size_type nY ) const { return (*this)( mnWidth - 1, nY ); }
+
+ inline void swap( Matrix& rMatrix ) { maData.swap( rMatrix.maData ); }
+
+private:
+ container_type maData;
+ size_type mnWidth;
+};
+
+// ============================================================================
+
+/** Static helper functions for improved API container handling. */
+class ContainerHelper
+{
+public:
+ // com.sun.star.container.XIndexContainer ---------------------------------
+
+ /** 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 );
+
+ /** Inserts an object into an indexed container.
+
+ @param rxIndexContainer com.sun.star.container.XIndexContainer
+ interface of the indexed container.
+
+ @param nIndex Insertion index for the object.
+
+ @param rObject The object to be inserted.
+
+ @return True = object successfully inserted.
+ */
+ static bool insertByIndex(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rxIndexContainer,
+ sal_Int32 nIndex,
+ const ::com::sun::star::uno::Any& rObject );
+
+ // com.sun.star.container.XNameContainer ----------------------------------
+
+ /** 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 );
+
+ /** Returns a name that is not used in the passed name container.
+
+ @param rxNameAccess com.sun.star.container.XNameAccess interface of
+ the name container.
+
+ @param rSuggestedName Suggested name for the object.
+
+ @return An unused name. Will be equal to the suggested name, if not
+ contained, otherwise a numerical index will be appended.
+ */
+ static ::rtl::OUString getUnusedName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxNameAccess,
+ const ::rtl::OUString& rSuggestedName,
+ sal_Unicode cSeparator,
+ sal_Int32 nFirstIndexToAppend = 1 );
+
+ /** Inserts an object into a name container.
+
+ @param rxNameContainer com.sun.star.container.XNameContainer interface
+ of the name container.
+
+ @param rName Exact name for the object.
+
+ @param rObject The object to be inserted.
+
+ @return True = object successfully inserted.
+ */
+ static bool insertByName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxNameContainer,
+ const ::rtl::OUString& rName,
+ const ::com::sun::star::uno::Any& rObject,
+ bool bReplaceOldExisting = true );
+
+ /** Inserts an object into a name container.
+
+ The function will use an unused name to insert the object, based on the
+ suggested object name. It is possible to specify whether the existing
+ object or the new inserted object will be renamed, if the container
+ already has an object with the name suggested for the new object.
+
+ @param rxNameContainer com.sun.star.container.XNameContainer interface
+ of the name container.
+
+ @param rSuggestedName Suggested name for the object.
+
+ @param rObject The object to be inserted.
+
+ @param bRenameOldExisting Specifies behaviour if an object with the
+ suggested name already exists. If false (default), the new object
+ will be inserted with a name not yet extant in the container (this
+ is done by appending a numerical index to the suggested name). If
+ true, the existing object will be removed and inserted with an
+ unused name, and the new object will be inserted with the suggested
+ name.
+
+ @return The final name the object is inserted with. Will always be
+ equal to the suggested name, if parameter bRenameOldExisting is
+ true.
+ */
+ static ::rtl::OUString insertByUnusedName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxNameContainer,
+ const ::rtl::OUString& rSuggestedName,
+ sal_Unicode cSeparator,
+ const ::com::sun::star::uno::Any& rObject,
+ bool bRenameOldExisting = false );
+
+ // std::vector and std::map element access --------------------------------
+
+ /** Returns the pointer to an existing element of the passed vector, or a
+ null pointer, if the passed index is out of bounds. */
+ template< typename Type >
+ static const Type* getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex );
+
+ /** Returns the pointer to an existing element of the passed vector, or a
+ null pointer, if the passed index is out of bounds. */
+ template< typename Type >
+ static Type* getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex );
+
+ /** Returns the reference to an existing element of the passed vector, or
+ the passed default value, if the passed index is out of bounds. */
+ template< typename Type >
+ static const Type& getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, const Type& rDefault );
+
+ /** Returns the reference to an existing element of the passed vector, or
+ the passed default value, if the passed index is out of bounds. */
+ template< typename Type >
+ static Type& getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault );
+
+ /** Returns the pointer to an existing element of the passed map, or a null
+ pointer, if an element with the passed key does not exist. */
+ template< typename Type, typename KeyType >
+ static const Type* getMapElement( const ::std::map< KeyType, Type >& rMap, KeyType nKey );
+
+ /** Returns the pointer to an existing element of the passed map, or a null
+ pointer, if an element with the passed key does not exist. */
+ template< typename Type, typename KeyType >
+ static Type* getMapElement( ::std::map< KeyType, Type >& rMap, KeyType nKey );
+
+ /** Returns the reference to an existing element of the passed map, or the
+ passed default value, if an element with the passed key does not exist. */
+ template< typename Type, typename KeyType >
+ static const Type& getMapElement( const ::std::map< KeyType, Type >& rMap, KeyType nKey, const Type& rDefault );
+
+ /** Returns the reference to an existing element of the passed map, or the
+ passed default value, if an element with the passed key does not exist. */
+ template< typename Type, typename KeyType >
+ static Type& getMapElement( ::std::map< KeyType, Type >& rMap, KeyType nKey, Type& rDefault );
+
+ // vector/matrix to Sequence ----------------------------------------------
+
+ /** Creates a UNO sequence from a std::vector with copies of all elements.
+
+ @param rVector The vector to be converted to a sequence.
+
+ @return A com.sun.star.uno.Sequence object with copies of all objects
+ contained in the passed vector.
+ */
+ template< typename Type >
+ static ::com::sun::star::uno::Sequence< Type >
+ vectorToSequence( const ::std::vector< Type >& rVector );
+
+ /** Creates a UNO sequence of sequences from a matrix with copies of all elements.
+
+ @param rMatrix The matrix to be converted to a sequence of sequences.
+
+ @return A com.sun.star.uno.Sequence object containing
+ com.sun.star.uno.Sequence objects with copies of all objects
+ contained in the passed matrix.
+ */
+ template< typename Type >
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Type > >
+ matrixToSequenceSequence( const Matrix< Type >& rMatrix );
+};
+
+// ----------------------------------------------------------------------------
+
+template< typename Type >
+const Type* ContainerHelper::getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : 0;
+}
+
+template< typename Type >
+Type* ContainerHelper::getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? &rVector[ static_cast< size_t >( nIndex ) ] : 0;
+}
+
+template< typename Type >
+const Type& ContainerHelper::getVectorElement( const ::std::vector< Type >& rVector, sal_Int32 nIndex, const Type& rDefault )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault;
+}
+
+template< typename Type >
+Type& ContainerHelper::getVectorElement( ::std::vector< Type >& rVector, sal_Int32 nIndex, Type& rDefault )
+{
+ return ((0 <= nIndex) && (static_cast< size_t >( nIndex ) < rVector.size())) ? rVector[ static_cast< size_t >( nIndex ) ] : rDefault;
+}
+
+template< typename Type, typename KeyType >
+const Type* ContainerHelper::getMapElement( const ::std::map< KeyType, Type >& rMap, KeyType nKey )
+{
+ typename ::std::map< KeyType, Type >::const_iterator aIt = rMap.find( nKey );
+ return (aIt == rMap.end()) ? 0 : &aIt->second;
+}
+
+template< typename Type, typename KeyType >
+Type* ContainerHelper::getMapElement( ::std::map< KeyType, Type >& rMap, KeyType nKey )
+{
+ typename ::std::map< KeyType, Type >::iterator aIt = rMap.find( nKey );
+ return (aIt == rMap.end()) ? 0 : &aIt->second;
+}
+
+template< typename Type, typename KeyType >
+const Type& ContainerHelper::getMapElement( const ::std::map< KeyType, Type >& rMap, KeyType nKey, const Type& rDefault )
+{
+ typename ::std::map< KeyType, Type >::const_iterator aIt = rMap.find( nKey );
+ return (aIt == rMap.end()) ? rDefault : aIt->second;
+}
+
+template< typename Type, typename KeyType >
+Type& ContainerHelper::getMapElement( ::std::map< KeyType, Type >& rMap, KeyType nKey, Type& rDefault )
+{
+ typename ::std::map< KeyType, Type >::iterator aIt = rMap.find( nKey );
+ return (aIt == rMap.end()) ? rDefault : aIt->second;
+}
+
+template< typename Type >
+::com::sun::star::uno::Sequence< Type > ContainerHelper::vectorToSequence( const ::std::vector< Type >& rVector )
+{
+ if( rVector.empty() )
+ return ::com::sun::star::uno::Sequence< Type >();
+ return ::com::sun::star::uno::Sequence< Type >( &rVector.front(), static_cast< sal_Int32 >( rVector.size() ) );
+}
+
+template< typename Type >
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Type > > ContainerHelper::matrixToSequenceSequence( const Matrix< Type >& rMatrix )
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< Type > > aSeq;
+ if( !rMatrix.empty() )
+ {
+ aSeq.realloc( static_cast< sal_Int32 >( rMatrix.height() ) );
+ for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow )
+ aSeq[ static_cast< sal_Int32 >( nRow ) ] =
+ ::com::sun::star::uno::Sequence< Type >( &rMatrix.row_front( nRow ), static_cast< sal_Int32 >( rMatrix.width() ) );
+ }
+ return aSeq;
+}
+
+// ============================================================================
+
+/** This helper manages named objects in a container, which is created on demand.
+ */
+class ObjectContainer
+{
+public:
+ explicit ObjectContainer(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxFactory,
+ const ::rtl::OUString& rServiceName );
+ ~ObjectContainer();
+
+ /** Returns true, if the object with the passed name exists in the container. */
+ bool hasObject( const ::rtl::OUString& rObjName ) const;
+
+ /** Returns the object with the passed name from the container. */
+ ::com::sun::star::uno::Any getObject( const ::rtl::OUString& rObjName ) const;
+
+ /** Inserts the passed object into the container, returns its final name. */
+ ::rtl::OUString insertObject(
+ const ::rtl::OUString& rObjName,
+ const ::com::sun::star::uno::Any& rObj,
+ bool bInsertByUnusedName );
+
+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::container::XNameContainer >
+ mxContainer; /// Container for the objects.
+ ::rtl::OUString maServiceName; /// Service name to create the container.
+ sal_Int32 mnIndex; /// Index to create unique identifiers.
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx
new file mode 100644
index 000000000000..37002940cb17
--- /dev/null
+++ b/oox/inc/oox/helper/graphichelper.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_GRAPHICHELPER_HXX
+#define OOX_HELPER_GRAPHICHELPER_HXX
+
+#include <deque>
+#include <map>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/awt/DeviceInfo.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include "oox/helper/binarystreambase.hxx"
+#include "oox/helper/storagebase.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace awt { struct Point; }
+ namespace awt { struct Size; }
+ namespace awt { class XUnitConversion; }
+ namespace io { class XInputStream; }
+ namespace frame { class XFrame; }
+ namespace graphic { class XGraphic; }
+ namespace graphic { class XGraphicObject; }
+ namespace graphic { class XGraphicProvider; }
+ namespace lang { class XMultiServiceFactory; }
+ namespace uno { class XComponentContext; }
+} } }
+
+namespace oox {
+
+// ============================================================================
+
+/** Provides helper functions for colors, device measurement conversion,
+ graphics, and graphic objects handling.
+
+ All createGraphicObject() and importGraphicObject() functions create
+ persistent graphic objects internally and store them in an internal
+ container to prevent their early destruction. This makes it possible to use
+ the returned URL of the graphic object in any way (e.g. insert it into a
+ property map) without needing to store it immediatly at an object that
+ resolves the graphic object from the passed URL and thus prevents it from
+ being destroyed.
+ */
+class GraphicHelper
+{
+public:
+ explicit GraphicHelper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rxTargetFrame,
+ const StorageRef& rxStorage );
+ virtual ~GraphicHelper();
+
+ // System colors and predefined colors ------------------------------------
+
+ /** Returns a system color specified by the passed XML token identifier. */
+ sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const;
+ /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */
+ virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const;
+ /** Derived classes may implement to resolve a palette index to an RGB color. */
+ virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const;
+
+ // Device info and device dependent unit conversion -----------------------
+
+ /** Returns information about the output device. */
+ const ::com::sun::star::awt::DeviceInfo& getDeviceInfo() const;
+
+ /** Converts the passed value from horizontal screen pixels to 1/100 mm. */
+ sal_Int32 convertScreenPixelXToHmm( double fPixelX ) const;
+ /** Converts the passed value from vertical screen pixels to 1/100 mm. */
+ sal_Int32 convertScreenPixelYToHmm( double fPixelY ) const;
+ /** Converts the passed point from screen pixels to 1/100 mm. */
+ ::com::sun::star::awt::Point convertScreenPixelToHmm( const ::com::sun::star::awt::Point& rPixel ) const;
+ /** Converts the passed size from screen pixels to 1/100 mm. */
+ ::com::sun::star::awt::Size convertScreenPixelToHmm( const ::com::sun::star::awt::Size& rPixel ) const;
+
+ /** Converts the passed value from 1/100 mm to horizontal screen pixels. */
+ double convertHmmToScreenPixelX( sal_Int32 nHmmX ) const;
+ /** Converts the passed value from 1/100 mm to vertical screen pixels. */
+ double convertHmmToScreenPixelY( sal_Int32 nHmmY ) const;
+ /** Converts the passed point from 1/100 mm to screen pixels. */
+ ::com::sun::star::awt::Point convertHmmToScreenPixel( const ::com::sun::star::awt::Point& rHmm ) const;
+ /** Converts the passed size from 1/100 mm to screen pixels. */
+ ::com::sun::star::awt::Size convertHmmToScreenPixel( const ::com::sun::star::awt::Size& rHmm ) const;
+
+ /** Converts the passed point from AppFont units to 1/100 mm. */
+ ::com::sun::star::awt::Point convertAppFontToHmm( const ::com::sun::star::awt::Point& rAppFont ) const;
+ /** Converts the passed point from AppFont units to 1/100 mm. */
+ ::com::sun::star::awt::Size convertAppFontToHmm( const ::com::sun::star::awt::Size& rAppFont ) const;
+
+ /** Converts the passed point from 1/100 mm to AppFont units. */
+ ::com::sun::star::awt::Point convertHmmToAppFont( const ::com::sun::star::awt::Point& rHmm ) const;
+ /** Converts the passed size from 1/100 mm to AppFont units. */
+ ::com::sun::star::awt::Size convertHmmToAppFont( const ::com::sun::star::awt::Size& rHmm ) const;
+
+ // Graphics and graphic objects ------------------------------------------
+
+ /** Imports a graphic from the passed input stream. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
+ importGraphic(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const;
+
+ /** Imports a graphic from the passed binary memory block. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
+ importGraphic( const StreamDataSequence& rGraphicData ) const;
+
+ /** Imports a graphic from the storage stream with the passed path and name. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
+ importEmbeddedGraphic( const ::rtl::OUString& rStreamName ) const;
+
+ /** Creates a persistent graphic object from the passed graphic.
+ @return The URL of the created and internally cached graphic object. */
+ ::rtl::OUString createGraphicObject(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const;
+
+ /** Creates a persistent graphic object from the passed input stream.
+ @return The URL of the created and internally cached graphic object. */
+ ::rtl::OUString importGraphicObject(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStrm ) const;
+
+ /** Creates a persistent graphic object from the passed binary memory block.
+ @return The URL of the created and internally cached graphic object. */
+ ::rtl::OUString importGraphicObject( const StreamDataSequence& rGraphicData ) const;
+
+ /** Imports a graphic object from the storage stream with the passed path and name.
+ @return The URL of the created and internally cached graphic object. */
+ ::rtl::OUString importEmbeddedGraphicObject( const ::rtl::OUString& rStreamName ) const;
+
+ // ------------------------------------------------------------------------
+private:
+ typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette;
+ 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::graphic::XGraphicProvider > mxGraphicProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XUnitConversion > mxUnitConversion;
+ ::com::sun::star::awt::DeviceInfo maDeviceInfo; /// Current output device info.
+ SystemPalette maSystemPalette; /// Maps system colors (XML tokens) to RGB color values.
+ StorageRef mxStorage; /// Storage containing embedded graphics.
+ mutable GraphicObjectDeque maGraphicObjects; /// Caches all created graphic objects to keep them alive.
+ mutable EmbeddedGraphicMap maEmbeddedGraphics; /// Maps all embedded graphics by their storage path.
+ const ::rtl::OUString maGraphicObjScheme; /// The URL scheme name for graphic objects.
+ double mfPixelPerHmmX; /// Number of screen pixels per 1/100 mm in X direction.
+ double mfPixelPerHmmY; /// Number of screen pixels per 1/100 mm in Y direction.
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx
new file mode 100644
index 000000000000..c68fe9ce83f8
--- /dev/null
+++ b/oox/inc/oox/helper/helper.hxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_HELPER_HXX
+#define OOX_HELPER_HELPER_HXX
+
+#include <algorithm>
+#include <limits>
+#include <boost/static_assert.hpp>
+#include <osl/endian.h>
+#include <rtl/math.hxx>
+#include <rtl/string.hxx>
+#include <rtl/ustring.hxx>
+#include <string.h>
+
+namespace oox {
+
+// Helper macros ==============================================================
+
+/** Expands to the number of elements in a STATIC data array. */
+#define STATIC_ARRAY_SIZE( array ) \
+ (sizeof(array)/sizeof(*(array)))
+
+/** Expands to a pointer behind the last element of a STATIC data array (like
+ STL end()). */
+#define STATIC_ARRAY_END( array ) \
+ ((array)+STATIC_ARRAY_SIZE(array))
+
+/** Expands to the 'index'-th element of a STATIC data array, or to 'def', if
+ 'index' is out of the array limits. */
+#define STATIC_ARRAY_SELECT( array, index, def ) \
+ ((static_cast<size_t>(index) < STATIC_ARRAY_SIZE(array)) ? ((array)[static_cast<size_t>(index)]) : (def))
+
+/** Expands to a temporary ::rtl::OString, created from a literal(!) character
+ array. */
+#define CREATE_OSTRING( ascii ) \
+ ::rtl::OString( RTL_CONSTASCII_STRINGPARAM( ascii ) )
+
+/** Expands to a temporary ::rtl::OUString, created from a literal(!) ASCII(!)
+ character array. */
+#define CREATE_OUSTRING( ascii ) \
+ ::rtl::OUString::intern( RTL_CONSTASCII_USTRINGPARAM( ascii ) )
+
+/** Convert an OUString to an ASCII C string. Use for debug purposes only. */
+#define OUSTRING_TO_CSTR( str ) \
+ ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US ).getStr()
+
+// Common constants ===========================================================
+
+const sal_uInt8 WINDOWS_CHARSET_ANSI = 0;
+const sal_uInt8 WINDOWS_CHARSET_DEFAULT = 1;
+const sal_uInt8 WINDOWS_CHARSET_SYMBOL = 2;
+const sal_uInt8 WINDOWS_CHARSET_APPLE_ROMAN = 77;
+const sal_uInt8 WINDOWS_CHARSET_SHIFTJIS = 128;
+const sal_uInt8 WINDOWS_CHARSET_HANGEUL = 129;
+const sal_uInt8 WINDOWS_CHARSET_JOHAB = 130;
+const sal_uInt8 WINDOWS_CHARSET_GB2312 = 134;
+const sal_uInt8 WINDOWS_CHARSET_BIG5 = 136;
+const sal_uInt8 WINDOWS_CHARSET_GREEK = 161;
+const sal_uInt8 WINDOWS_CHARSET_TURKISH = 162;
+const sal_uInt8 WINDOWS_CHARSET_VIETNAMESE = 163;
+const sal_uInt8 WINDOWS_CHARSET_HEBREW = 177;
+const sal_uInt8 WINDOWS_CHARSET_ARABIC = 178;
+const sal_uInt8 WINDOWS_CHARSET_BALTIC = 186;
+const sal_uInt8 WINDOWS_CHARSET_RUSSIAN = 204;
+const sal_uInt8 WINDOWS_CHARSET_THAI = 222;
+const sal_uInt8 WINDOWS_CHARSET_EASTERN = 238;
+const sal_uInt8 WINDOWS_CHARSET_OEM = 255;
+
+// ----------------------------------------------------------------------------
+
+const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color for API calls.
+const sal_Int32 API_RGB_BLACK = 0x00000; /// Black color for API calls.
+const sal_Int32 API_RGB_WHITE = 0xFFFFF; /// White color for API calls.
+
+const sal_Int16 API_LINE_NONE = 0;
+const sal_Int16 API_LINE_HAIR = 2;
+const sal_Int16 API_LINE_THIN = 35;
+const sal_Int16 API_LINE_MEDIUM = 88;
+const sal_Int16 API_LINE_THICK = 141;
+
+const sal_Int16 API_ESCAPE_NONE = 0; /// No escapement.
+const sal_Int16 API_ESCAPE_SUPERSCRIPT = 101; /// Superscript: raise characters automatically (magic value 101).
+const sal_Int16 API_ESCAPE_SUBSCRIPT = -101; /// Subscript: lower characters automatically (magic value -101).
+
+const sal_Int8 API_ESCAPEHEIGHT_NONE = 100; /// Relative character height if not escaped.
+const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; /// Relative character height if escaped.
+
+// ============================================================================
+
+// Limitate values ------------------------------------------------------------
+
+template< typename ReturnType, typename Type >
+inline ReturnType getLimitedValue( Type nValue, Type nMin, Type nMax )
+{
+ return static_cast< ReturnType >( ::std::min( ::std::max( nValue, nMin ), nMax ) );
+}
+
+template< typename ReturnType, typename Type >
+inline ReturnType getIntervalValue( Type nValue, Type nBegin, Type nEnd )
+{
+// this BOOST_STATIC_ASSERT fails with suncc
+// BOOST_STATIC_ASSERT( ::std::numeric_limits< Type >::is_integer );
+ Type nInterval = nEnd - nBegin;
+ Type nCount = (nValue < nBegin) ? -((nBegin - nValue - 1) / nInterval + 1) : ((nValue - nBegin) / nInterval);
+ return static_cast< ReturnType >( nValue - nCount * nInterval );
+}
+
+template< typename ReturnType >
+inline ReturnType getDoubleIntervalValue( double fValue, double fBegin, double fEnd )
+{
+ double fInterval = fEnd - fBegin;
+ double fCount = (fValue < fBegin) ? -(::rtl::math::approxFloor( (fBegin - fValue - 1.0) / fInterval ) + 1.0) : ::rtl::math::approxFloor( (fValue - fBegin) / fInterval );
+ return static_cast< ReturnType >( fValue - fCount * fInterval );
+}
+
+// Read from bitfields --------------------------------------------------------
+
+/** Returns true, if at least one of the bits set in nMask is set in nBitField. */
+template< typename Type >
+inline bool getFlag( Type nBitField, Type nMask )
+{
+ return (nBitField & nMask) != 0;
+}
+
+/** Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset. */
+template< typename ReturnType, typename Type >
+inline ReturnType getFlagValue( Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset )
+{
+ return getFlag( nBitField, nMask ) ? nSet : nUnset;
+}
+
+/** Extracts a value from a bit field.
+
+ Returns the data fragment from nBitField, that starts at bit nStartBit
+ (0-based, bit 0 is rightmost) with the width of nBitCount. The returned
+ value will be right-aligned (normalized).
+ For instance: extractValue<T>(0x4321,8,4) returns 3 (value in bits 8-11).
+ */
+template< typename ReturnType, typename Type >
+inline ReturnType extractValue( Type nBitField, sal_uInt8 nStartBit, sal_uInt8 nBitCount )
+{
+ sal_uInt64 nMask = 1; nMask <<= nBitCount; --nMask;
+ return static_cast< ReturnType >( nMask & (nBitField >> nStartBit) );
+}
+
+// Write to bitfields ---------------------------------------------------------
+
+/** Sets or clears (according to bSet) all set bits of nMask in ornBitField. */
+template< typename Type >
+inline void setFlag( Type& ornBitField, Type nMask, bool bSet = true )
+{
+ if( bSet ) ornBitField |= nMask; else ornBitField &= ~nMask;
+}
+
+/** Inserts a value into a bitfield.
+
+ Inserts the lower nBitCount bits of nValue into ornBitField, starting
+ there at bit nStartBit. Other contents of ornBitField keep unchanged.
+ */
+template< typename Type, typename InsertType >
+void insertValue( Type& ornBitField, InsertType nValue, sal_uInt8 nStartBit, sal_uInt8 nBitCount )
+{
+ sal_uInt64 nMask = 1; nMask <<= nBitCount; --nMask;
+ Type nNewValue = static_cast< Type >( nValue & nMask );
+ (ornBitField &= ~(nMask << nStartBit)) |= (nNewValue << nStartBit);
+}
+
+// ============================================================================
+
+/** Optional value, similar to ::boost::optional<>, with convenience accessors.
+ */
+template< typename Type >
+class OptValue
+{
+public:
+ inline explicit OptValue() : mbHasValue( false ) {}
+ inline explicit OptValue( const Type& rValue ) : maValue( rValue ), mbHasValue( true ) {}
+ inline explicit OptValue( bool bHasValue, const Type& rValue ) : maValue( rValue ), mbHasValue( bHasValue ) {}
+
+ inline bool has() const { return mbHasValue; }
+ inline bool operator!() const { return !mbHasValue; }
+ inline bool differsFrom( const Type& rValue ) const { return mbHasValue && (maValue != rValue); }
+
+ inline const Type& get() const { return maValue; }
+ inline const Type& get( const Type& rDefValue ) const { return mbHasValue ? maValue : rDefValue; }
+
+ inline void reset() { mbHasValue = false; }
+ inline void set( const Type& rValue ) { maValue = rValue; mbHasValue = true; }
+ inline Type& use() { mbHasValue = true; return maValue; }
+
+ inline OptValue& operator=( const Type& rValue ) { set( rValue ); return *this; }
+ inline void assignIfUsed( const OptValue& rValue ) { if( rValue.mbHasValue ) set( rValue.maValue ); }
+
+private:
+ Type maValue;
+ bool mbHasValue;
+};
+
+// ============================================================================
+
+/** Provides platform independent functions to convert from or to little-endian
+ byte order, e.g. for reading data from or writing data to memory or a
+ binary stream.
+
+ On big-endian platforms, the byte order in the passed values is swapped,
+ this can be used for converting big-endian to and from little-endian data.
+
+ On little-endian platforms, the conversion functions are implemented empty,
+ thus compilers should completely optimize away the function call.
+ */
+class ByteOrderConverter
+{
+public:
+ 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 ) ); }
+ inline static void convertLittleEndian( sal_uInt32& rnValue ) { swap4( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ inline static void convertLittleEndian( sal_Int64& rnValue ) { swap8( reinterpret_cast< sal_uInt8* >( &rnValue ) ); }
+ 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 ) ); }
+#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& ) {}
+#endif
+
+ /** Reads a value from memory, assuming memory buffer in little-endian.
+ @param ornValue (out-parameter) Contains the value read from memory.
+ @param pSrcBuffer The memory buffer to read the value from.
+ */
+ template< typename Type >
+ inline static void readLittleEndian( Type& ornValue, const void* pSrcBuffer );
+
+ /** Writes a value to memory, while converting it to little-endian.
+ @param pDstBuffer The memory buffer to write the value to.
+ @param nValue The value to be written to memory in little-endian.
+ */
+ template< typename Type >
+ inline static void writeLittleEndian( void* pDstBuffer, Type nValue );
+
+#ifdef OSL_BIGENDIAN
+private:
+ inline static void swap2( sal_uInt8* pnData );
+ inline static void swap4( sal_uInt8* pnData );
+ inline static void swap8( sal_uInt8* pnData );
+#endif
+};
+
+// ----------------------------------------------------------------------------
+
+template< typename Type >
+inline void ByteOrderConverter::readLittleEndian( Type& ornValue, const void* pSrcBuffer )
+{
+ memcpy( &ornValue, pSrcBuffer, sizeof( Type ) );
+ convertLittleEndian( ornValue );
+}
+
+template< typename Type >
+inline void ByteOrderConverter::writeLittleEndian( void* pDstBuffer, Type nValue )
+{
+ convertLittleEndian( nValue );
+ memcpy( pDstBuffer, &nValue, sizeof( Type ) );
+}
+
+#ifdef OSL_BIGENDIAN
+inline void ByteOrderConverter::swap2( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 1 ] );
+}
+
+inline void ByteOrderConverter::swap4( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 3 ] );
+ ::std::swap( pnData[ 1 ], pnData[ 2 ] );
+}
+
+inline void ByteOrderConverter::swap8( sal_uInt8* pnData )
+{
+ ::std::swap( pnData[ 0 ], pnData[ 7 ] );
+ ::std::swap( pnData[ 1 ], pnData[ 6 ] );
+ ::std::swap( pnData[ 2 ], pnData[ 5 ] );
+ ::std::swap( pnData[ 3 ], pnData[ 4 ] );
+}
+#endif
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/modelobjecthelper.hxx b/oox/inc/oox/helper/modelobjecthelper.hxx
new file mode 100644
index 000000000000..a9ef27e8cb98
--- /dev/null
+++ b/oox/inc/oox/helper/modelobjecthelper.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_MODELOBJECTHELPER_HXX
+#define OOX_HELPER_MODELOBJECTHELPER_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include "oox/helper/containerhelper.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace lang { class XMultiServiceFactory; }
+ namespace awt { struct Gradient; }
+ namespace drawing { struct LineDash; }
+ namespace drawing { struct PolyPolygonBezierCoords; }
+} } }
+
+namespace oox {
+
+// ============================================================================
+
+/** 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.
+ */
+class ModelObjectHelper
+{
+public:
+ explicit ModelObjectHelper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory );
+
+ /** Returns true, if the model contains a line marker with the passed name. */
+ bool hasLineMarker( const ::rtl::OUString& rMarkerName ) const;
+
+ /** Inserts a new named line marker, overwrites an existing line marker
+ with the same name. Returns true, if the marker could be inserted. */
+ bool insertLineMarker(
+ const ::rtl::OUString& rMarkerName,
+ const ::com::sun::star::drawing::PolyPolygonBezierCoords& rMarker );
+
+ /** Inserts a new named line dash, returns the line dash name, based on an
+ internal constant name with a new unused index appended. */
+ ::rtl::OUString insertLineDash( const ::com::sun::star::drawing::LineDash& rDash );
+
+ /** Inserts a new named fill gradient, returns the gradient name, based on
+ 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 );
+
+private:
+ ObjectContainer maMarkerContainer;
+ ObjectContainer maDashContainer;
+ ObjectContainer maGradientContainer;
+ ObjectContainer maBitmapContainer;
+ const ::rtl::OUString maDashNameBase;
+ const ::rtl::OUString maGradientNameBase;
+ const ::rtl::OUString maBitmapNameBase;
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/progressbar.hxx b/oox/inc/oox/helper/progressbar.hxx
new file mode 100644
index 000000000000..f5ea98816915
--- /dev/null
+++ b/oox/inc/oox/helper/progressbar.hxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_PROGRESSBAR_HXX
+#define OOX_HELPER_PROGRESSBAR_HXX
+
+#include <boost/shared_ptr.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+namespace rtl { class OUString; }
+
+namespace com { namespace sun { namespace star {
+ namespace task { class XStatusIndicator; }
+} } }
+
+namespace oox {
+
+// Interfaces =================================================================
+
+/** Interface for progress bar classes.
+ */
+class IProgressBar
+{
+public:
+ virtual ~IProgressBar();
+
+ /** Returns the current position of the progress bar.
+
+ @return Position of the progress bar, in the range from 0.0 (beginning
+ of the progress bar) to 1.0 (end of the progress bar) inclusive.
+ */
+ virtual double getPosition() const = 0;
+
+ /** Sets the current position of the progress bar.
+
+ @param fPosition New position of the progress bar, in the range from
+ 0.0 (beginning of the progress bar) to 1.0 (end of the progress bar)
+ inclusive.
+ */
+ virtual void setPosition( double fPosition ) = 0;
+};
+
+typedef ::boost::shared_ptr< IProgressBar > IProgressBarRef;
+
+// ----------------------------------------------------------------------------
+
+class ISegmentProgressBar;
+typedef ::boost::shared_ptr< ISegmentProgressBar > ISegmentProgressBarRef;
+
+/** Interface for a segment in a progress bar, that is able to create sub
+ segments from itself.
+ */
+class ISegmentProgressBar : public IProgressBar
+{
+public:
+ virtual ~ISegmentProgressBar();
+
+ /** Returns the length that is still free for creating sub segments. */
+ virtual double getFreeLength() const = 0;
+
+ /** Adds a new segment with the specified length. */
+ virtual ISegmentProgressBarRef createSegment( double fLength ) = 0;
+};
+
+// ============================================================================
+// ============================================================================
+
+/** A simple progress bar.
+ */
+class ProgressBar : public IProgressBar
+{
+public:
+ explicit ProgressBar(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& rxIndicator,
+ const ::rtl::OUString& rText );
+
+ virtual ~ProgressBar();
+
+ /** Returns the current position of the progress bar. */
+ virtual double getPosition() const;
+ /** Sets the current position of the progress bar. */
+ virtual void setPosition( double fPosition );
+
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >
+ mxIndicator;
+ double mfPosition;
+};
+
+// ============================================================================
+
+/** A progress bar containing several independent segments.
+ */
+class SegmentProgressBar : public ISegmentProgressBar
+{
+public:
+ explicit SegmentProgressBar(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator >& rxIndicator,
+ const ::rtl::OUString& rText );
+
+ /** Returns the current position of the progress bar segment. */
+ virtual double getPosition() const;
+ /** Sets the current position of the progress bar segment. */
+ virtual void setPosition( double fPosition );
+
+ /** Returns the length that is still free for creating sub segments. */
+ virtual double getFreeLength() const;
+ /** Adds a new segment with the specified length. */
+ virtual ISegmentProgressBarRef createSegment( double fLength );
+
+private:
+ ProgressBar maProgress;
+ double mfFreeStart;
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/propertymap.hxx b/oox/inc/oox/helper/propertymap.hxx
new file mode 100644
index 000000000000..150f5c3d9364
--- /dev/null
+++ b/oox/inc/oox/helper/propertymap.hxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_PROPERTYMAP_HXX
+#define OOX_HELPER_PROPERTYMAP_HXX
+
+#include <vector>
+#include <map>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace com { namespace sun { namespace star { namespace beans {
+ struct PropertyValue;
+ class XPropertySet;
+} } } }
+
+namespace oox {
+
+struct PropertyList;
+
+// ============================================================================
+
+typedef ::std::map< sal_Int32, ::com::sun::star::uno::Any > PropertyMapBase;
+
+/** A helper that maps property identifiers to property values.
+
+ The property identifiers are generated on compile time and refer to the
+ property name strings that are held by a static vector. The identifier to
+ name mapping is done internally while the properties are written to
+ property sets.
+ */
+class PropertyMap : public PropertyMapBase
+{
+public:
+ explicit PropertyMap();
+ ~PropertyMap();
+
+ /** Returns the name of the passed property identifier. */
+ static const ::rtl::OUString& getPropertyName( sal_Int32 nPropId );
+
+ /** Returns true, if the map contains a property with the passed identifier. */
+ inline bool hasProperty( sal_Int32 nPropId ) const
+ { return find( nPropId ) != end(); }
+
+ /** Returns the property value of the specified property, or 0 if not found. */
+ const ::com::sun::star::uno::Any* getProperty( sal_Int32 nPropId ) const;
+
+ /** 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; }
+
+ /** Returns a sequence of property values, filled with all contained properties. */
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
+ makePropertyValueSequence() const;
+
+ /** Fills the passed sequences of names and anys with all contained properties. */
+ void fillSequences(
+ ::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. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ makePropertySet() const;
+
+#if OSL_DEBUG_LEVEL > 0
+ static void dump( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet);
+ void dump();
+#endif
+
+private:
+ const PropertyList* mpPropNames;
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/propertyset.hxx b/oox/inc/oox/helper/propertyset.hxx
new file mode 100644
index 000000000000..8ddfaff44421
--- /dev/null
+++ b/oox/inc/oox/helper/propertyset.hxx
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_PROPERTYSET_HXX
+#define OOX_HELPER_PROPERTYSET_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+
+namespace oox {
+
+class PropertyMap;
+
+// ============================================================================
+
+/** A wrapper for a UNO property set.
+
+ This class provides functions to silently get and set properties (without
+ exceptions, without the need to check validity of the UNO property set).
+
+ An instance is constructed with the reference to a UNO property set or any
+ other interface (the constructor will query for the
+ com.sun.star.beans.XPropertySet interface then). The reference to the
+ property set will be kept as long as the instance of this class is alive.
+
+ The functions getProperties() and setProperties() try to handle all passed
+ values at once, using the com.sun.star.beans.XMultiPropertySet interface.
+ If the implementation does not support the XMultiPropertySet interface, all
+ properties are handled separately in a loop.
+ */
+class PropertySet
+{
+public:
+ inline explicit PropertySet() {}
+
+ /** Constructs a property set wrapper with the passed UNO property set. */
+ inline explicit PropertySet(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxPropSet )
+ { set( rxPropSet ); }
+
+ /** Constructs a property set wrapper after querying the XPropertySet interface. */
+ template< typename Type >
+ inline explicit PropertySet( const Type& rObject ) { set( rObject ); }
+
+ /** Sets the passed UNO property set and releases the old UNO property set. */
+ void set( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxPropSet );
+
+ /** Queries the passed object (interface or any) for an XPropertySet and releases the old UNO property set. */
+ template< typename Type >
+ inline void set( const Type& rObject )
+ { set( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >( rObject, ::com::sun::star::uno::UNO_QUERY ) ); }
+
+ /** Returns true, if the contained XPropertySet interface is valid. */
+ inline bool is() const { return mxPropSet.is(); }
+
+ /** Returns the contained XPropertySet interface. */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getXPropertySet() const { return mxPropSet; }
+
+ // 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;
+
+ /** 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;
+
+ /** 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;
+
+ /** Gets the specified properties from the property set. Tries to use the XMultiPropertySet interface.
+ @param orValues (out-parameter) The related property values.
+ @param rPropNames The property names. MUST be ordered alphabetically. */
+ void getProperties(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& orValues,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropNames ) const;
+
+ // Set properties ---------------------------------------------------------
+
+ /** Puts the passed any into the property set. */
+ void 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 );
+
+ /** Puts the passed properties into the property set. Tries to use the XMultiPropertySet interface.
+ @param rPropNames The property names. MUST be ordered alphabetically.
+ @param rValues The related property values. */
+ void setProperties(
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rPropNames,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rValues );
+
+ /** Puts the passed property map into the property set. Tries to use the XMultiPropertySet interface.
+ @param rPropertyMap The property map. */
+ void setProperties( const PropertyMap& rPropertyMap );
+
+#if OSL_DEBUG_LEVEL > 0
+ void dump();
+#endif
+
+ // ------------------------------------------------------------------------
+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;
+
+ /** Puts the passed any into the property set. */
+ void setAnyProperty( 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.
+};
+
+// ----------------------------------------------------------------------------
+
+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
+
+#endif
+
diff --git a/oox/inc/oox/helper/recordinputstream.hxx b/oox/inc/oox/helper/recordinputstream.hxx
new file mode 100644
index 000000000000..ee05ce480a75
--- /dev/null
+++ b/oox/inc/oox/helper/recordinputstream.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX
+#define OOX_HELPER_RECORDINPUTSTREAM_HXX
+
+#include "oox/helper/binaryinputstream.hxx"
+
+namespace oox {
+
+// ============================================================================
+
+/** Reads the contents of a record from a binary OOBIN stream. */
+class RecordInputStream : public SequenceInputStream
+{
+public:
+ explicit RecordInputStream( const StreamDataSequence& rData );
+
+ /** Reads a string with leading 16-bit or 32-bit length field. */
+ ::rtl::OUString readString( bool b32BitLen = true );
+
+ /** Stream operator for integral types. */
+ template< typename Type >
+ inline RecordInputStream& operator>>( Type& ornValue ) { readValue( ornValue ); return *this; }
+ /** Stream operator for an ::rtl::OUString, reads 32-bit string length and Unicode array. */
+ inline RecordInputStream& operator>>( ::rtl::OUString& orString ) { orString = readString(); return *this; }
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/storagebase.hxx b/oox/inc/oox/helper/storagebase.hxx
new file mode 100644
index 000000000000..5a179e73cf75
--- /dev/null
+++ b/oox/inc/oox/helper/storagebase.hxx
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_STORAGEBASE_HXX
+#define OOX_HELPER_STORAGEBASE_HXX
+
+#include "oox/dllapi.h"
+#include "oox/helper/containerhelper.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace embed { class XStorage; }
+ namespace io { class XInputStream; }
+ namespace io { class XOutputStream; }
+ namespace io { class XStream; }
+} } }
+
+namespace oox {
+
+// ============================================================================
+
+class StorageBase;
+typedef ::boost::shared_ptr< StorageBase > StorageRef;
+
+/** Base class for storage access implementations.
+
+ Derived classes will be used to encapsulate storage access implementations
+ for ZIP storages containing XML streams, and OLE storages containing binary
+ data streams.
+ */
+class OOX_DLLPUBLIC StorageBase
+{
+public:
+ explicit StorageBase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rxInStream,
+ bool bBaseStreamAccess );
+
+ explicit StorageBase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& rxOutStream,
+ bool bBaseStreamAccess );
+
+ virtual ~StorageBase();
+
+ /** Returns true, if the object represents a valid storage. */
+ bool isStorage() const;
+
+ /** Returns true, if the object represents the root storage. */
+ bool isRootStorage() const;
+
+ /** Returns true, if the storage operates in read-only mode (based on an
+ input stream). */
+ bool isReadOnly() const;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ getXStorage() const;
+
+ /** Returns the element name of this storage. */
+ const ::rtl::OUString& getName() const;
+
+ /** Returns the full path of this storage. */
+ ::rtl::OUString getPath() const;
+
+ /** Fills the passed vector with the names of all direct elements of this
+ storage. */
+ void getElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const;
+
+ /** Opens and returns the specified sub storage from the storage.
+
+ @param rStorageName
+ The name of the embedded storage. The name may contain slashes to
+ open storages from embedded substorages.
+ @param bCreateMissing
+ True = create missing sub storages (for export filters). Must be
+ false for storages based on input streams.
+ */
+ StorageRef openSubStorage( const ::rtl::OUString& rStorageName, bool bCreateMissing );
+
+ /** Opens and returns the specified input stream from the storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to open streams from embedded substorages. If base stream
+ access has been enabled in the constructor, the base stream can be
+ accessed by passing an empty string as stream name.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ openInputStream( const ::rtl::OUString& rStreamName );
+
+ /** Opens and returns the specified output stream from the storage.
+
+ @param rStreamName
+ The name of the embedded storage stream. The name may contain
+ slashes to create and open streams in embedded substorages. If base
+ stream access has been enabled in the constructor, the base stream
+ can be accessed by passing an empty string as stream name.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ openOutputStream( const ::rtl::OUString& rStreamName );
+
+ /** Copies the specified element from this storage to the passed
+ destination storage.
+
+ @param rElementName
+ The name of the embedded storage or stream. The name may contain
+ slashes to specify an element in an embedded substorage. In this
+ case, the element will be copied to the same substorage in the
+ destination storage.
+ */
+ void copyToStorage( StorageBase& rDestStrg, const ::rtl::OUString& rElementName );
+
+ /** Copies all streams of this storage and of all substorages to the passed
+ destination. */
+ void copyStorageToStorage( StorageBase& rDestStrg );
+
+ /** Commits the changes to the storage and all substorages. */
+ void commit();
+
+protected:
+ /** Special constructor for sub storage objects. */
+ explicit StorageBase( const StorageBase& rParentStorage, const ::rtl::OUString& rStorageName, bool bReadOnly );
+
+private:
+ StorageBase( const StorageBase& );
+ StorageBase& operator=( const StorageBase& );
+
+ /** Returns true, if the object represents a valid storage. */
+ virtual bool implIsStorage() const = 0;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ implGetXStorage() const = 0;
+
+ /** Returns the names of all elements of this storage. */
+ virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const = 0;
+
+ /** Implementation of opening a storage element. */
+ virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreate ) = 0;
+
+ /** Implementation of opening an input stream element. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ implOpenInputStream( const ::rtl::OUString& rElementName ) = 0;
+
+ /** Implementation of opening an output stream element. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ implOpenOutputStream( const ::rtl::OUString& rElementName ) = 0;
+
+ /** Commits the current storage. */
+ virtual void implCommit() const = 0;
+
+ /** Helper that opens and caches the specified direct substorage. */
+ StorageRef getSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing );
+
+private:
+ typedef RefMap< ::rtl::OUString, StorageBase > SubStorageMap;
+
+ SubStorageMap maSubStorages; /// Map of direct sub storages.
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ mxInStream; /// Cached base input stream (to keep it alive).
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >
+ mxOutStream; /// Cached base output stream (to keep it alive).
+ ::rtl::OUString maParentPath; /// Full path of parent storage.
+ ::rtl::OUString maStorageName; /// Name of this storage, if it is a substorage.
+ bool mbBaseStreamAccess; /// True = access base streams with empty stream name.
+ bool mbReadOnly; /// True = storage opened read-only (based on input stream).
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
diff --git a/oox/inc/oox/helper/textinputstream.hxx b/oox/inc/oox/helper/textinputstream.hxx
new file mode 100755
index 000000000000..1e74825ee713
--- /dev/null
+++ b/oox/inc/oox/helper/textinputstream.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_RECORDINPUTSTREAM_HXX
+#define OOX_HELPER_RECORDINPUTSTREAM_HXX
+
+#include "oox/helper/binaryinputstream.hxx"
+
+namespace oox {
+
+// ============================================================================
+
+class TextInputStream
+{
+public:
+ explicit TextInputStream( BinaryInputStream& rInStrm, rtl_TextEncoding eTextEnc );
+
+ /** Returns true, if the wrapped input stream is in EOF state. */
+ bool isEof() const;
+ /** Reads a text line from the stream. */
+ ::rtl::OUString readLine();
+
+private:
+ BinaryInputStream& mrInStrm;
+ rtl_TextEncoding meTextEnc;
+ sal_Unicode mcLastEolChar;
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif
+
diff --git a/oox/inc/oox/helper/zipstorage.hxx b/oox/inc/oox/helper/zipstorage.hxx
new file mode 100644
index 000000000000..0c9a15c10077
--- /dev/null
+++ b/oox/inc/oox/helper/zipstorage.hxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OOX_HELPER_ZIPSTORAGE_HXX
+#define OOX_HELPER_ZIPSTORAGE_HXX
+
+#include "oox/helper/storagebase.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace lang { class XMultiServiceFactory; }
+} } }
+
+namespace oox {
+
+// ============================================================================
+
+/** Implements stream access for ZIP storages containing XML streams. */
+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::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::io::XStream >& rxStream );
+
+ virtual ~ZipStorage();
+
+private:
+ explicit ZipStorage(
+ const ZipStorage& rParentStorage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage,
+ const ::rtl::OUString& rElementName );
+
+ /** Returns true, if the object represents a valid storage. */
+ virtual bool implIsStorage() const;
+
+ /** Returns the com.sun.star.embed.XStorage interface of the current storage. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >
+ implGetXStorage() const;
+
+ /** Returns the names of all elements of this storage. */
+ virtual void implGetElementNames( ::std::vector< ::rtl::OUString >& orElementNames ) const;
+
+ /** Opens and returns the specified sub storage from the storage. */
+ virtual StorageRef implOpenSubStorage( const ::rtl::OUString& rElementName, bool bCreateMissing );
+
+ /** Opens and returns the specified input stream from the storage. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
+ implOpenInputStream( const ::rtl::OUString& rElementName );
+
+ /** Opens and returns the specified output stream from the storage. */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >
+ implOpenOutputStream( const ::rtl::OUString& rElementName );
+
+ /** Commits the current storage. */
+ 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.
+};
+
+// ============================================================================
+
+} // namespace oox
+
+#endif