fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / oox / source / dump / dffdumper.cxx
blobb530998513489442e08abf146d7f5ea4af8901ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "oox/dump/dffdumper.hxx"
22 #if OOX_INCLUDE_DUMPER
24 namespace oox {
25 namespace dump {
27 // ============================================================================
30 namespace {
32 const sal_uInt16 DFF_ID_BSE = 0xF007; /// BLIP store entry.
33 const sal_uInt16 DFF_ID_BSTORECONTAINER = 0xF001; /// BLIP store container.
34 const sal_uInt16 DFF_ID_CHILDANCHOR = 0xF00F; /// Child anchor (in groups).
35 const sal_uInt16 DFF_ID_CLIENTANCHOR = 0xF010; /// Client anchor.
36 const sal_uInt16 DFF_ID_DG = 0xF008; /// Drawing.
37 const sal_uInt16 DFF_ID_DGG = 0xF006; /// Drawing group.
38 const sal_uInt16 DFF_ID_OPT = 0xF00B; /// Property set.
39 const sal_uInt16 DFF_ID_OPT2 = 0xF121; /// Secondary property set.
40 const sal_uInt16 DFF_ID_OPT3 = 0xF122; /// Ternary property set.
41 const sal_uInt16 DFF_ID_SP = 0xF00A; /// Shape.
42 const sal_uInt16 DFF_ID_SPGR = 0xF009; /// Shape group.
43 const sal_uInt16 DFF_ID_SPLITMENUCOLORS = 0xF11E; /// Current toolbar colors.
45 const sal_uInt16 DFF_OPT_IDMASK = 0x3FFF;
46 const sal_uInt16 DFF_OPT_PICTURE = 0x4000;
47 const sal_uInt16 DFF_OPT_COMPLEX = 0x8000;
48 const sal_uInt16 DFF_OPT_FLAGSMASK = 0x003F;
50 } // namespace
52 // ============================================================================
54 bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
56 sal_uInt16 nRecId;
57 rBaseStrm >> mnInstVer >> nRecId >> mnRealSize;
58 ornRecId = nRecId;
59 ornRecSize = isContainer() ? 0 : mnRealSize;
60 return !rBaseStrm.isEof();
63 void DffStreamObject::implWriteExtHeader()
65 const sal_Char* pcListName = "DFF-RECORD-INST";
66 switch( getRecId() )
68 case DFF_ID_BSE: pcListName = "DFFBSE-RECORD-INST"; break; // BLIP type
69 case DFF_ID_BSTORECONTAINER: pcListName = "DFFBSTORECONT-RECORD-INST"; break; // BLIP count
70 case DFF_ID_DG: pcListName = "DFFDG-RECORD-INST"; break; // drawing ID
71 case DFF_ID_OPT: pcListName = "DFFOPT-RECORD-INST"; break; // property count
72 case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type
73 case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors
75 MultiItemsGuard aMultiGuard( mxOut );
76 writeHexItem( "instance", mnInstVer, pcListName );
77 if( isContainer() ) writeDecItem( "container-size", mnRealSize );
80 void DffStreamObject::implDumpRecordBody()
82 switch( getRecId() )
84 case DFF_ID_BSE:
85 dumpDec< sal_uInt8 >( "win-type", "DFFBSE-TYPE" );
86 dumpDec< sal_uInt8 >( "mac-type", "DFFBSE-TYPE" );
87 dumpGuid( "guid" );
88 dumpDec< sal_uInt16 >( "tag" );
89 dumpDec< sal_uInt32 >( "blip-size" );
90 dumpDec< sal_uInt32 >( "blip-refcount" );
91 dumpDec< sal_uInt32 >( "blip-streampos" );
92 dumpDec< sal_uInt8 >( "blip-usage", "DFFBSE-USAGE" );
93 dumpDec< sal_uInt8 >( "blip-name-len" );
94 dumpUnused( 2 );
95 break;
97 case DFF_ID_CHILDANCHOR:
98 dumpDec< sal_uInt32 >( "left" );
99 dumpDec< sal_uInt32 >( "top" );
100 dumpDec< sal_uInt32 >( "right" );
101 dumpDec< sal_uInt32 >( "bottom" );
102 break;
104 case DFF_ID_CLIENTANCHOR:
105 implDumpClientAnchor();
106 break;
108 case DFF_ID_DG:
109 dumpDec< sal_uInt32 >( "shape-count" );
110 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
111 break;
113 case DFF_ID_DGG:
115 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
116 sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" );
117 dumpDec< sal_uInt32 >( "shape-count" );
118 dumpDec< sal_uInt32 >( "drawing-count" );
119 mxOut->resetItemIndex( 1 );
120 TableGuard aTabGuard( mxOut, 15, 16 );
121 for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster )
123 MultiItemsGuard aMultiGuard( mxOut );
124 writeEmptyItem( "#cluster" );
125 dumpDec< sal_uInt32 >( "drawing-id" );
126 dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" );
129 break;
131 case DFF_ID_OPT:
132 case DFF_ID_OPT2:
133 case DFF_ID_OPT3:
134 dumpDffOpt();
135 break;
137 case DFF_ID_SP:
138 dumpHex< sal_uInt32 >( "shape-id", "CONV-DEC" );
139 dumpHex< sal_uInt32 >( "shape-flags", "DFFSP-FLAGS" );
140 break;
142 case DFF_ID_SPGR:
143 dumpDec< sal_uInt32 >( "left" );
144 dumpDec< sal_uInt32 >( "top" );
145 dumpDec< sal_uInt32 >( "right" );
146 dumpDec< sal_uInt32 >( "bottom" );
147 break;
149 case DFF_ID_SPLITMENUCOLORS:
150 dumpDffSimpleColor( "fill-color" );
151 dumpDffSimpleColor( "line-color" );
152 dumpDffSimpleColor( "shadow-color" );
153 dumpDffSimpleColor( "3d-color" );
154 break;
158 void DffStreamObject::implDumpClientAnchor()
162 sal_uInt32 DffStreamObject::dumpDffSimpleColor( const String& rName )
164 return dumpHex< sal_uInt32 >( rName, "DFF-SIMPLE-COLOR" );
167 namespace {
169 enum PropType { PROPTYPE_BINARY, PROPTYPE_STRING, PROPTYPE_BLIP, PROPTYPE_COLORARRAY };
171 struct PropInfo
173 OUString maName;
174 PropType meType;
175 sal_uInt16 mnId;
176 sal_uInt32 mnSize;
177 inline explicit PropInfo( const OUString& rName, PropType eType, sal_uInt16 nId, sal_uInt32 nSize ) :
178 maName( rName ), meType( eType ), mnId( nId ), mnSize( nSize ) {}
181 typedef ::std::vector< PropInfo > PropInfoVector;
183 } // namespace
185 void DffStreamObject::dumpDffOpt()
187 sal_uInt16 nPropCount = getInst();
188 PropInfoVector aPropInfos;
189 mxOut->resetItemIndex();
190 for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
192 sal_uInt16 nPropId = dumpDffOptPropHeader();
193 sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK;
194 sal_uInt32 nValue = mxStrm->readuInt32();
196 IndentGuard aIndent( mxOut );
197 if( getFlag( nPropId, DFF_OPT_COMPLEX ) )
199 writeHexItem( "complex-size", nValue, "CONV-DEC" );
200 String aName;
201 PropType eType = PROPTYPE_BINARY;
202 ItemFormatMap::const_iterator aIt = maComplexProps.find( nBaseId );
203 if( aIt != maComplexProps.end() )
205 const ItemFormat& rItemFmt = aIt->second;
206 aName = rItemFmt.maItemName;
207 if ( rItemFmt.maListName == "binary" )
208 eType = PROPTYPE_BINARY;
209 else if ( rItemFmt.maListName == "string" )
210 eType = PROPTYPE_STRING;
211 else if ( rItemFmt.maListName == "blip" )
212 eType = PROPTYPE_BLIP;
213 else if ( rItemFmt.maListName == "colorarray" )
214 eType = PROPTYPE_COLORARRAY;
216 aPropInfos.push_back( PropInfo( aName( "property-data" ), eType, nBaseId, nValue ) );
218 else
220 ItemFormatMap::const_iterator aIt = maSimpleProps.find( nBaseId );
221 if( aIt != maSimpleProps.end() )
223 const ItemFormat& rItemFmt = aIt->second;
224 // flags always at end of block of 64 properties
225 if( (nBaseId & DFF_OPT_FLAGSMASK) == DFF_OPT_FLAGSMASK )
227 FlagsList* pFlagsList = dynamic_cast< FlagsList* >( cfg().getNameList( rItemFmt.maListName ).get() );
228 sal_Int64 nOldIgnoreFlags = 0;
229 if( pFlagsList )
231 nOldIgnoreFlags = pFlagsList->getIgnoreFlags();
232 pFlagsList->setIgnoreFlags( nOldIgnoreFlags | 0xFFFF0000 | ~(nValue >> 16) );
234 writeValueItem( rItemFmt, nValue );
235 if( pFlagsList )
236 pFlagsList->setIgnoreFlags( nOldIgnoreFlags );
238 else
239 writeValueItem( rItemFmt, nValue );
241 else
242 writeHexItem( "value", nValue );
246 mxOut->resetItemIndex();
247 for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt )
249 mxOut->startMultiItems();
250 writeEmptyItem( "#complex-data" );
251 writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" );
252 mxOut->endMultiItems();
253 IndentGuard aIndent( mxOut );
254 switch( aIt->meType )
256 case PROPTYPE_BINARY:
257 dumpBinary( aIt->maName, aIt->mnSize );
258 break;
259 case PROPTYPE_STRING:
260 dumpUnicodeArray( aIt->maName, aIt->mnSize / 2, true );
261 break;
262 case PROPTYPE_BLIP:
263 dumpBinary( aIt->maName, aIt->mnSize );
264 break;
265 case PROPTYPE_COLORARRAY:
266 dumpBinary( aIt->maName, aIt->mnSize );
267 break;
272 sal_uInt16 DffStreamObject::dumpDffOptPropHeader()
274 MultiItemsGuard aMultiGuard( mxOut );
275 TableGuard aTabGuard( mxOut, 11 );
276 writeEmptyItem( "#prop" );
277 return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" );
280 // ============================================================================
282 } // namespace dump
283 } // namespace oox
285 #endif
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */