LibreOffice Module oox (master) 1
axbinarywriter.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef INCLUDED_OOX_OLE_AXBINARYWRITER_HXX
11#define INCLUDED_OOX_OLE_AXBINARYWRITER_HXX
12
13#include <cstddef>
14#include <utility>
15
19#include <rtl/ustring.hxx>
20#include <sal/types.h>
21
22namespace oox::ole {
23
24
34{
35public:
36 explicit AxAlignedOutputStream( BinaryOutputStream& rOutStrm );
37
40 virtual sal_Int64 size() const override;
43 virtual sal_Int64 tell() const override;
46 virtual void seek( sal_Int64 nPos ) override;
48 virtual void close() override;
49
52 virtual void writeData( const StreamDataSequence& orData, size_t nAtomSize = 1 ) override;
55 virtual void writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize = 1 ) override;
56
59 void align( size_t nSize );
60
61 void pad( sal_Int32 nBytes );
62
64 template< typename Type >
65 void writeAligned( Type nVal ) { align( sizeof( Type ) ); writeValue( nVal ); }
66
67private:
69 sal_Int64 mnStrmPos;
70 sal_Int64 mnStrmSize;
72};
73
75typedef ::std::pair< sal_Int32, sal_Int32 > AxPairData;
76
80{
81public:
82 explicit AxBinaryPropertyWriter( BinaryOutputStream& rOutStrm, bool b64BitPropFlags = false );
83
86 template< typename StreamType, typename DataType >
87 void writeIntProperty( DataType ornValue )
88 { startNextProperty(); maOutStrm.writeAligned< StreamType >( ornValue ); }
91 void writeBoolProperty( bool orbValue );
94 void writePairProperty( AxPairData& orPairData );
97 void writeStringProperty( OUString& orValue );
98
101 void skipProperty() { startNextProperty( true ); }
102
104 void finalizeExport();
105
106private:
107 bool ensureValid();
108 void startNextProperty( bool bSkip = false );
109
110private:
113 {
114 virtual ~ComplexProperty();
115 virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) = 0;
116 };
117
119 struct PairProperty final : public ComplexProperty
120 {
121 private:
123
124 public:
125 explicit PairProperty( AxPairData& rPairData ) :
126 mrPairData( rPairData ) {}
127 virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
128 };
129
131 struct StringProperty final : public ComplexProperty
132 {
133 private:
134 OUString& mrValue;
135 sal_uInt32 mnSize;
136 public:
137 explicit StringProperty( OUString& rValue, sal_uInt32 nSize ) :
138 mrValue( rValue ), mnSize( nSize ) {}
139 virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
140 };
141
143 struct PictureProperty final : public ComplexProperty
144 {
145 virtual bool writeProperty( AxAlignedOutputStream& rOutStrm ) override;
146 };
147
149
150private:
154 sal_Int16 mnBlockSize;
156 sal_Int64 mnPropFlags;
157 sal_Int64 mnNextProp;
158 bool mbValid;
160};
161
162
163} // namespace oox::ole
164
165#endif
166
167/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface for binary output stream classes.
void writeValue(Type nValue)
Writes a value to the stream and converts it to platform byte order.
A wrapper for a binary output stream that supports aligned write operations.
void align(size_t nSize)
Aligns the stream to a multiple of the passed size (relative to the position of the wrapped stream at...
void pad(sal_Int32 nBytes)
virtual void writeMemory(const void *pMem, sal_Int32 nBytes, size_t nAtomSize=1) override
Reads nBytes bytes to the (existing) buffer opMem.
BinaryOutputStream * mpOutStrm
The wrapped input stream.
virtual void close() override
Closes the input stream but not the wrapped stream.
sal_Int64 mnStrmPos
Tracks relative position in the stream.
virtual sal_Int64 tell() const override
Return the current relative stream position (relative to position of the wrapped stream at constructi...
void writeAligned(Type nVal)
Aligns the stream according to the passed type and reads a value.
virtual void writeData(const StreamDataSequence &orData, size_t nAtomSize=1) override
Reads nBytes bytes to the passed sequence.
AxAlignedOutputStream(BinaryOutputStream &rOutStrm)
sal_Int64 mnStrmSize
Size of the wrapped stream data.
sal_Int64 mnWrappedBeginPos
starting pos or wrapped stream
virtual sal_Int64 size() const override
Returns the size of the data this stream represents, if the wrapped stream supports the size() operat...
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed relative position, if it is behind the current position.
Export helper to write simple and complex ActiveX form control properties to a binary input stream.
ComplexPropVector maStreamProps
Stores info for all used stream data properties.
RefVector< ComplexProperty > ComplexPropVector
void finalizeExport()
Final processing, write contents of all complex properties, writes record size.
void writeIntProperty(DataType ornValue)
Write an integer property value to the stream, the respective flag in the property mask is set.
void writeBoolProperty(bool orbValue)
Write a boolean property value to the stream, the respective flag in the property mask is set.
sal_Int64 mnPropFlagsStart
pos of Prop flags
ComplexPropVector maLargeProps
Stores info for all used large properties.
void writePairProperty(AxPairData &orPairData)
Write a pair property the stream, the respective flag in the property mask is set.
bool mbValid
True = stream still valid.
AxBinaryPropertyWriter(BinaryOutputStream &rOutStrm, bool b64BitPropFlags=false)
AxAlignedOutputStream maOutStrm
The input stream to read from.
sal_Int64 mnPropFlags
Flags specifying existing properties.
void startNextProperty(bool bSkip=false)
void skipProperty()
Skips the next property clears the respective flag in the property mask.
void writeStringProperty(OUString &orValue)
Write a string property to the stream, the respective flag in the property mask is set.
sal_Int64 mnNextProp
Next property to read.
sal_uInt16 nPos
Type
DataType
Specifiers for atomic data types.
Definition: dumperbase.hxx:155
::std::pair< sal_Int32, sal_Int32 > AxPairData
A pair of integer values as a property.
css::uno::Sequence< sal_Int8 > StreamDataSequence
Base class for complex properties such as string, point, size, GUID, picture.
virtual bool writeProperty(AxAlignedOutputStream &rOutStrm)=0
Complex property for a 32-bit value pair, e.g.
virtual bool writeProperty(AxAlignedOutputStream &rOutStrm) override
Stream property for a picture or mouse icon.
virtual bool writeProperty(AxAlignedOutputStream &rOutStrm) override
Complex property for a string value.
virtual bool writeProperty(AxAlignedOutputStream &rOutStrm) override
StringProperty(OUString &rValue, sal_uInt32 nSize)