1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
27 // ============================================================================
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;
52 // ============================================================================
54 bool DffStreamObject::implReadRecordHeader( BinaryInputStream
& rBaseStrm
, sal_Int64
& ornRecId
, sal_Int64
& ornRecSize
)
57 rBaseStrm
>> mnInstVer
>> nRecId
>> mnRealSize
;
59 ornRecSize
= isContainer() ? 0 : mnRealSize
;
60 return !rBaseStrm
.isEof();
63 void DffStreamObject::implWriteExtHeader()
65 const sal_Char
* pcListName
= "DFF-RECORD-INST";
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()
85 dumpDec
< sal_uInt8
>( "win-type", "DFFBSE-TYPE" );
86 dumpDec
< sal_uInt8
>( "mac-type", "DFFBSE-TYPE" );
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" );
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" );
104 case DFF_ID_CLIENTANCHOR
:
105 implDumpClientAnchor();
109 dumpDec
< sal_uInt32
>( "shape-count" );
110 dumpHex
< sal_uInt32
>( "max-shape-id", "CONV-DEC" );
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" );
138 dumpHex
< sal_uInt32
>( "shape-id", "CONV-DEC" );
139 dumpHex
< sal_uInt32
>( "shape-flags", "DFFSP-FLAGS" );
143 dumpDec
< sal_uInt32
>( "left" );
144 dumpDec
< sal_uInt32
>( "top" );
145 dumpDec
< sal_uInt32
>( "right" );
146 dumpDec
< sal_uInt32
>( "bottom" );
149 case DFF_ID_SPLITMENUCOLORS
:
150 dumpDffSimpleColor( "fill-color" );
151 dumpDffSimpleColor( "line-color" );
152 dumpDffSimpleColor( "shadow-color" );
153 dumpDffSimpleColor( "3d-color" );
158 void DffStreamObject::implDumpClientAnchor()
162 sal_uInt32
DffStreamObject::dumpDffSimpleColor( const String
& rName
)
164 return dumpHex
< sal_uInt32
>( rName
, "DFF-SIMPLE-COLOR" );
169 enum PropType
{ PROPTYPE_BINARY
, PROPTYPE_STRING
, PROPTYPE_BLIP
, PROPTYPE_COLORARRAY
};
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
;
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" );
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
) );
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;
231 nOldIgnoreFlags
= pFlagsList
->getIgnoreFlags();
232 pFlagsList
->setIgnoreFlags( nOldIgnoreFlags
| 0xFFFF0000 | ~(nValue
>> 16) );
234 writeValueItem( rItemFmt
, nValue
);
236 pFlagsList
->setIgnoreFlags( nOldIgnoreFlags
);
239 writeValueItem( rItemFmt
, nValue
);
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
);
259 case PROPTYPE_STRING
:
260 dumpUnicodeArray( aIt
->maName
, aIt
->mnSize
/ 2, true );
263 dumpBinary( aIt
->maName
, aIt
->mnSize
);
265 case PROPTYPE_COLORARRAY
:
266 dumpBinary( aIt
->maName
, aIt
->mnSize
);
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 // ============================================================================
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */