fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / dump / dffdumper.cxx
blob220bf29aba82f0937cb0796bed1c63ef406e3e07
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 namespace {
29 const sal_uInt16 DFF_ID_BSE = 0xF007; /// BLIP store entry.
30 const sal_uInt16 DFF_ID_BSTORECONTAINER = 0xF001; /// BLIP store container.
31 const sal_uInt16 DFF_ID_CHILDANCHOR = 0xF00F; /// Child anchor (in groups).
32 const sal_uInt16 DFF_ID_CLIENTANCHOR = 0xF010; /// Client anchor.
33 const sal_uInt16 DFF_ID_DG = 0xF008; /// Drawing.
34 const sal_uInt16 DFF_ID_DGG = 0xF006; /// Drawing group.
35 const sal_uInt16 DFF_ID_OPT = 0xF00B; /// Property set.
36 const sal_uInt16 DFF_ID_OPT2 = 0xF121; /// Secondary property set.
37 const sal_uInt16 DFF_ID_OPT3 = 0xF122; /// Ternary property set.
38 const sal_uInt16 DFF_ID_SP = 0xF00A; /// Shape.
39 const sal_uInt16 DFF_ID_SPGR = 0xF009; /// Shape group.
40 const sal_uInt16 DFF_ID_SPLITMENUCOLORS = 0xF11E; /// Current toolbar colors.
42 const sal_uInt16 DFF_OPT_IDMASK = 0x3FFF;
43 const sal_uInt16 DFF_OPT_COMPLEX = 0x8000;
44 const sal_uInt16 DFF_OPT_FLAGSMASK = 0x003F;
46 } // namespace
48 bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize )
50 mnInstVer = rBaseStrm.readuInt16();
51 ornRecId = rBaseStrm.readuInt16();
52 mnRealSize = rBaseStrm.readInt32();
53 ornRecSize = isContainer() ? 0 : mnRealSize;
54 return !rBaseStrm.isEof();
57 void DffStreamObject::implWriteExtHeader()
59 const sal_Char* pcListName = "DFF-RECORD-INST";
60 switch( getRecId() )
62 case DFF_ID_BSE: pcListName = "DFFBSE-RECORD-INST"; break; // BLIP type
63 case DFF_ID_BSTORECONTAINER: pcListName = "DFFBSTORECONT-RECORD-INST"; break; // BLIP count
64 case DFF_ID_DG: pcListName = "DFFDG-RECORD-INST"; break; // drawing ID
65 case DFF_ID_OPT: pcListName = "DFFOPT-RECORD-INST"; break; // property count
66 case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type
67 case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors
69 MultiItemsGuard aMultiGuard( mxOut );
70 writeHexItem( "instance", mnInstVer, pcListName );
71 if( isContainer() ) writeDecItem( "container-size", mnRealSize );
74 void DffStreamObject::implDumpRecordBody()
76 switch( getRecId() )
78 case DFF_ID_BSE:
79 dumpDec< sal_uInt8 >( "win-type", "DFFBSE-TYPE" );
80 dumpDec< sal_uInt8 >( "mac-type", "DFFBSE-TYPE" );
81 dumpGuid( "guid" );
82 dumpDec< sal_uInt16 >( "tag" );
83 dumpDec< sal_uInt32 >( "blip-size" );
84 dumpDec< sal_uInt32 >( "blip-refcount" );
85 dumpDec< sal_uInt32 >( "blip-streampos" );
86 dumpDec< sal_uInt8 >( "blip-usage", "DFFBSE-USAGE" );
87 dumpDec< sal_uInt8 >( "blip-name-len" );
88 dumpUnused( 2 );
89 break;
91 case DFF_ID_CHILDANCHOR:
92 dumpDec< sal_uInt32 >( "left" );
93 dumpDec< sal_uInt32 >( "top" );
94 dumpDec< sal_uInt32 >( "right" );
95 dumpDec< sal_uInt32 >( "bottom" );
96 break;
98 case DFF_ID_CLIENTANCHOR:
99 break;
101 case DFF_ID_DG:
102 dumpDec< sal_uInt32 >( "shape-count" );
103 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
104 break;
106 case DFF_ID_DGG:
108 dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" );
109 sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" );
110 dumpDec< sal_uInt32 >( "shape-count" );
111 dumpDec< sal_uInt32 >( "drawing-count" );
112 mxOut->resetItemIndex( 1 );
113 TableGuard aTabGuard( mxOut, 15, 16 );
114 for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster )
116 MultiItemsGuard aMultiGuard( mxOut );
117 writeEmptyItem( "#cluster" );
118 dumpDec< sal_uInt32 >( "drawing-id" );
119 dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" );
122 break;
124 case DFF_ID_OPT:
125 case DFF_ID_OPT2:
126 case DFF_ID_OPT3:
127 dumpDffOpt();
128 break;
130 case DFF_ID_SP:
131 dumpHex< sal_uInt32 >( "shape-id", "CONV-DEC" );
132 dumpHex< sal_uInt32 >( "shape-flags", "DFFSP-FLAGS" );
133 break;
135 case DFF_ID_SPGR:
136 dumpDec< sal_uInt32 >( "left" );
137 dumpDec< sal_uInt32 >( "top" );
138 dumpDec< sal_uInt32 >( "right" );
139 dumpDec< sal_uInt32 >( "bottom" );
140 break;
142 case DFF_ID_SPLITMENUCOLORS:
143 dumpDffSimpleColor( "fill-color" );
144 dumpDffSimpleColor( "line-color" );
145 dumpDffSimpleColor( "shadow-color" );
146 dumpDffSimpleColor( "3d-color" );
147 break;
151 sal_uInt32 DffStreamObject::dumpDffSimpleColor( const String& rName )
153 return dumpHex< sal_uInt32 >( rName, "DFF-SIMPLE-COLOR" );
156 namespace {
158 enum PropType { PROPTYPE_BINARY, PROPTYPE_STRING, PROPTYPE_BLIP, PROPTYPE_COLORARRAY };
160 struct PropInfo
162 OUString maName;
163 PropType meType;
164 sal_uInt16 mnId;
165 sal_uInt32 mnSize;
166 inline explicit PropInfo( const OUString& rName, PropType eType, sal_uInt16 nId, sal_uInt32 nSize ) :
167 maName( rName ), meType( eType ), mnId( nId ), mnSize( nSize ) {}
170 typedef ::std::vector< PropInfo > PropInfoVector;
172 } // namespace
174 void DffStreamObject::dumpDffOpt()
176 sal_uInt16 nPropCount = getInst();
177 PropInfoVector aPropInfos;
178 mxOut->resetItemIndex();
179 for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx )
181 sal_uInt16 nPropId = dumpDffOptPropHeader();
182 sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK;
183 sal_uInt32 nValue = mxStrm->readuInt32();
185 IndentGuard aIndent( mxOut );
186 if( getFlag( nPropId, DFF_OPT_COMPLEX ) )
188 writeHexItem( "complex-size", nValue, "CONV-DEC" );
189 String aName;
190 PropType eType = PROPTYPE_BINARY;
191 ::std::map< sal_Int64, ItemFormat >::const_iterator aIt = maComplexProps.find( nBaseId );
192 if( aIt != maComplexProps.end() )
194 const ItemFormat& rItemFmt = aIt->second;
195 aName = rItemFmt.maItemName;
196 if ( rItemFmt.maListName == "binary" )
197 eType = PROPTYPE_BINARY;
198 else if ( rItemFmt.maListName == "string" )
199 eType = PROPTYPE_STRING;
200 else if ( rItemFmt.maListName == "blip" )
201 eType = PROPTYPE_BLIP;
202 else if ( rItemFmt.maListName == "colorarray" )
203 eType = PROPTYPE_COLORARRAY;
205 aPropInfos.push_back( PropInfo( aName( "property-data" ), eType, nBaseId, nValue ) );
207 else
209 ::std::map< sal_Int64, ItemFormat >::const_iterator aIt = maSimpleProps.find( nBaseId );
210 if( aIt != maSimpleProps.end() )
212 const ItemFormat& rItemFmt = aIt->second;
213 // flags always at end of block of 64 properties
214 if( (nBaseId & DFF_OPT_FLAGSMASK) == DFF_OPT_FLAGSMASK )
216 FlagsList* pFlagsList = dynamic_cast< FlagsList* >( cfg().getNameList( rItemFmt.maListName ).get() );
217 sal_Int64 nOldIgnoreFlags = 0;
218 if( pFlagsList )
220 nOldIgnoreFlags = pFlagsList->getIgnoreFlags();
221 pFlagsList->setIgnoreFlags( nOldIgnoreFlags | 0xFFFF0000 | ~(nValue >> 16) );
223 writeValueItem( rItemFmt, nValue );
224 if( pFlagsList )
225 pFlagsList->setIgnoreFlags( nOldIgnoreFlags );
227 else
228 writeValueItem( rItemFmt, nValue );
230 else
231 writeHexItem( "value", nValue );
235 mxOut->resetItemIndex();
236 for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt )
238 mxOut->startMultiItems();
239 writeEmptyItem( "#complex-data" );
240 writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" );
241 mxOut->endMultiItems();
242 IndentGuard aIndent( mxOut );
243 switch( aIt->meType )
245 case PROPTYPE_BINARY:
246 dumpBinary( aIt->maName, aIt->mnSize );
247 break;
248 case PROPTYPE_STRING:
249 dumpUnicodeArray( aIt->maName, aIt->mnSize / 2, true );
250 break;
251 case PROPTYPE_BLIP:
252 dumpBinary( aIt->maName, aIt->mnSize );
253 break;
254 case PROPTYPE_COLORARRAY:
255 dumpBinary( aIt->maName, aIt->mnSize );
256 break;
261 sal_uInt16 DffStreamObject::dumpDffOptPropHeader()
263 MultiItemsGuard aMultiGuard( mxOut );
264 TableGuard aTabGuard( mxOut, 11 );
265 writeEmptyItem( "#prop" );
266 return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" );
269 } // namespace dump
270 } // namespace oox
272 #endif
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */