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
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;
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";
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()
79 dumpDec
< sal_uInt8
>( "win-type", "DFFBSE-TYPE" );
80 dumpDec
< sal_uInt8
>( "mac-type", "DFFBSE-TYPE" );
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" );
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" );
98 case DFF_ID_CLIENTANCHOR
:
102 dumpDec
< sal_uInt32
>( "shape-count" );
103 dumpHex
< sal_uInt32
>( "max-shape-id", "CONV-DEC" );
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" );
131 dumpHex
< sal_uInt32
>( "shape-id", "CONV-DEC" );
132 dumpHex
< sal_uInt32
>( "shape-flags", "DFFSP-FLAGS" );
136 dumpDec
< sal_uInt32
>( "left" );
137 dumpDec
< sal_uInt32
>( "top" );
138 dumpDec
< sal_uInt32
>( "right" );
139 dumpDec
< sal_uInt32
>( "bottom" );
142 case DFF_ID_SPLITMENUCOLORS
:
143 dumpDffSimpleColor( "fill-color" );
144 dumpDffSimpleColor( "line-color" );
145 dumpDffSimpleColor( "shadow-color" );
146 dumpDffSimpleColor( "3d-color" );
151 sal_uInt32
DffStreamObject::dumpDffSimpleColor( const String
& rName
)
153 return dumpHex
< sal_uInt32
>( rName
, "DFF-SIMPLE-COLOR" );
158 enum PropType
{ PROPTYPE_BINARY
, PROPTYPE_STRING
, PROPTYPE_BLIP
, PROPTYPE_COLORARRAY
};
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
;
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" );
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
) );
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;
220 nOldIgnoreFlags
= pFlagsList
->getIgnoreFlags();
221 pFlagsList
->setIgnoreFlags( nOldIgnoreFlags
| 0xFFFF0000 | ~(nValue
>> 16) );
223 writeValueItem( rItemFmt
, nValue
);
225 pFlagsList
->setIgnoreFlags( nOldIgnoreFlags
);
228 writeValueItem( rItemFmt
, nValue
);
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
);
248 case PROPTYPE_STRING
:
249 dumpUnicodeArray( aIt
->maName
, aIt
->mnSize
/ 2, true );
252 dumpBinary( aIt
->maName
, aIt
->mnSize
);
254 case PROPTYPE_COLORARRAY
:
255 dumpBinary( aIt
->maName
, aIt
->mnSize
);
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" );
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */