LibreOffice Module oox (master) 1
dffdumper.cxx
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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
21#include <utility>
22
23#ifdef DBG_UTIL
24
25namespace oox::dump {
26
27namespace {
28
29const sal_uInt16 DFF_ID_BSE = 0xF007;
30const sal_uInt16 DFF_ID_BSTORECONTAINER = 0xF001;
31const sal_uInt16 DFF_ID_CHILDANCHOR = 0xF00F;
32const sal_uInt16 DFF_ID_CLIENTANCHOR = 0xF010;
33const sal_uInt16 DFF_ID_DG = 0xF008;
34const sal_uInt16 DFF_ID_DGG = 0xF006;
35const sal_uInt16 DFF_ID_OPT = 0xF00B;
36const sal_uInt16 DFF_ID_OPT2 = 0xF121;
37const sal_uInt16 DFF_ID_OPT3 = 0xF122;
38const sal_uInt16 DFF_ID_SP = 0xF00A;
39const sal_uInt16 DFF_ID_SPGR = 0xF009;
40const sal_uInt16 DFF_ID_SPLITMENUCOLORS = 0xF11E;
41
42const sal_uInt16 DFF_OPT_IDMASK = 0x3FFF;
43const sal_uInt16 DFF_OPT_COMPLEX = 0x8000;
44
45} // namespace
46
47bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
48{
49 mnInstVer = rBaseStrm.readuInt16();
50 ornRecId = rBaseStrm.readuInt16();
51 mnRealSize = rBaseStrm.readInt32();
52 ornRecSize = isContainer() ? 0 : mnRealSize;
53 return !rBaseStrm.isEof();
54}
55
57{
58 const char* pcListName = "DFF-RECORD-INST";
59 switch( getRecId() )
60 {
61 case DFF_ID_BSE: pcListName = "DFFBSE-RECORD-INST"; break; // BLIP type
62 case DFF_ID_BSTORECONTAINER: pcListName = "DFFBSTORECONT-RECORD-INST"; break; // BLIP count
63 case DFF_ID_DG: pcListName = "DFFDG-RECORD-INST"; break; // drawing ID
64 case DFF_ID_OPT: pcListName = "DFFOPT-RECORD-INST"; break; // property count
65 case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type
66 case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors
67 }
68 MultiItemsGuard aMultiGuard( mxOut );
69 writeHexItem( "instance", mnInstVer, pcListName );
70 if( isContainer() ) writeDecItem( "container-size", mnRealSize );
71}
72
74{
75 switch( getRecId() )
76 {
77 case DFF_ID_BSE:
78 dumpDec< sal_uInt8 >( "win-type", "DFFBSE-TYPE" );
79 dumpDec< sal_uInt8 >( "mac-type", "DFFBSE-TYPE" );
80 dumpGuid( "guid" );
81 dumpDec< sal_uInt16 >( "tag" );
82 dumpDec< sal_uInt32 >( "blip-size" );
83 dumpDec< sal_uInt32 >( "blip-refcount" );
84 dumpDec< sal_uInt32 >( "blip-streampos" );
85 dumpDec< sal_uInt8 >( "blip-usage", "DFFBSE-USAGE" );
86 dumpDec< sal_uInt8 >( "blip-name-len" );
87 dumpUnused( 2 );
88 break;
89
90 case DFF_ID_CHILDANCHOR:
91 dumpDec< sal_uInt32 >( "left" );
92 dumpDec< sal_uInt32 >( "top" );
93 dumpDec< sal_uInt32 >( "right" );
94 dumpDec< sal_uInt32 >( "bottom" );
95 break;
96
97 case DFF_ID_CLIENTANCHOR:
98 break;
99
100 case DFF_ID_DG:
101 dumpDec< sal_uInt32 >( "shape-count" );
102 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
103 break;
104
105 case DFF_ID_DGG:
106 {
107 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
108 sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" );
109 dumpDec< sal_uInt32 >( "shape-count" );
110 dumpDec< sal_uInt32 >( "drawing-count" );
111 mxOut->resetItemIndex( 1 );
112 TableGuard aTabGuard( mxOut, 15, 16 );
113 for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster )
114 {
115 MultiItemsGuard aMultiGuard( mxOut );
116 writeEmptyItem( "#cluster" );
117 dumpDec< sal_uInt32 >( "drawing-id" );
118 dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" );
119 }
120 }
121 break;
122
123 case DFF_ID_OPT:
124 case DFF_ID_OPT2:
125 case DFF_ID_OPT3:
126 dumpDffOpt();
127 break;
128
129 case DFF_ID_SP:
130 dumpHex< sal_uInt32 >( "shape-id", "CONV-DEC" );
131 dumpHex< sal_uInt32 >( "shape-flags", "DFFSP-FLAGS" );
132 break;
133
134 case DFF_ID_SPGR:
135 dumpDec< sal_uInt32 >( "left" );
136 dumpDec< sal_uInt32 >( "top" );
137 dumpDec< sal_uInt32 >( "right" );
138 dumpDec< sal_uInt32 >( "bottom" );
139 break;
140
141 case DFF_ID_SPLITMENUCOLORS:
142 dumpDffSimpleColor( "fill-color" );
143 dumpDffSimpleColor( "line-color" );
144 dumpDffSimpleColor( "shadow-color" );
145 dumpDffSimpleColor( "3d-color" );
146 break;
147 }
148}
149
151{
152 return dumpHex< sal_uInt32 >( rName, "DFF-SIMPLE-COLOR" );
153}
154
155namespace {
156
157enum class PropType { Binary };
158
159struct PropInfo
160{
161 OUString maName;
162 PropType meType;
163 sal_uInt16 mnId;
164 sal_uInt32 mnSize;
165 explicit PropInfo( OUString aName, PropType eType, sal_uInt16 nId, sal_uInt32 nSize ) :
166 maName(std::move( aName )), meType( eType ), mnId( nId ), mnSize( nSize ) {}
167};
168
169typedef ::std::vector< PropInfo > PropInfoVector;
170
171} // namespace
172
174{
175 sal_uInt16 nPropCount = getInst();
176 PropInfoVector aPropInfos;
177 mxOut->resetItemIndex();
178 for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
179 {
180 sal_uInt16 nPropId = dumpDffOptPropHeader();
181 sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK;
182 sal_uInt32 nValue = mxStrm->readuInt32();
183
184 IndentGuard aIndent( mxOut );
185 if( getFlag( nPropId, DFF_OPT_COMPLEX ) )
186 {
187 writeHexItem( "complex-size", nValue, "CONV-DEC" );
188 aPropInfos.emplace_back( String( "property-data" ), PropType::Binary, nBaseId, nValue );
189 }
190 else
191 {
192 writeHexItem( "value", nValue );
193 }
194 }
195
196 mxOut->resetItemIndex();
197 for (auto const& propInfo : aPropInfos)
198 {
199 if (mxStrm->isEof())
200 break;
201 mxOut->startMultiItems();
202 writeEmptyItem( "#complex-data" );
203 writeHexItem( "id", propInfo.mnId, "DFFOPT-PROPERTY-NAMES" );
204 mxOut->endMultiItems();
205 IndentGuard aIndent( mxOut );
206 switch(propInfo.meType)
207 {
208 case PropType::Binary:
209 dumpBinary( propInfo.maName, propInfo.mnSize );
210 break;
211 default: assert(false && "missing implementation?");
212 }
213 }
214}
215
217{
218 MultiItemsGuard aMultiGuard( mxOut );
219 TableGuard aTabGuard( mxOut, 11 );
220 writeEmptyItem( "#prop" );
221 return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" );
222}
223
224} // namespace oox::dump
225
226#endif
227
228/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface for binary input stream classes.
bool isEof() const
Returns true, if the stream position is invalid (EOF).
sal_uInt16 dumpDffOptPropHeader()
Definition: dffdumper.cxx:216
virtual bool implReadRecordHeader(BinaryInputStream &rBaseStrm, sal_Int64 &ornRecId, sal_Int64 &ornRecSize) override
Definition: dffdumper.cxx:47
virtual void implDumpRecordBody() override
Definition: dffdumper.cxx:73
sal_uInt16 getInst() const
Definition: dffdumper.hxx:37
sal_uInt32 dumpDffSimpleColor(const String &rName)
Definition: dffdumper.cxx:150
virtual void implWriteExtHeader() override
Definition: dffdumper.cxx:56
void dumpUnused(sal_Int32 nBytes)
void dumpBinary(const String &rName, sal_Int64 nBytes, bool bShowOffset=true)
OUString dumpGuid(const String &rName=EMPTY_STRING)
BinaryInputStreamRef mxStrm
void writeEmptyItem(const String &rName)
void writeDecItem(const String &rName, Type nData, const NameListWrapper &rListWrp=NO_LIST)
void writeHexItem(const String &rName, Type nData, const NameListWrapper &rListWrp=NO_LIST)
sal_Int64 getRecId() const
PropType meType
Definition: dffdumper.cxx:162
sal_uInt16 mnId
Definition: dffdumper.cxx:163
sal_uInt32 mnSize
Definition: dffdumper.cxx:164
OUString maName
Definition: dffdumper.cxx:161
DocumentType eType
sal_Int16 nValue
OUString aName
bool getFlag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: helper.hxx:137
sal_Int16 nId
Definition: olehelper.cxx:98