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>
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;
47 bool DffStreamObject::implReadRecordHeader( BinaryInputStream
& rBaseStrm
, sal_Int64
& ornRecId
, sal_Int64
& ornRecSize
)
49 mnInstVer
= rBaseStrm
.readuInt16();
50 ornRecId
= rBaseStrm
.readuInt16();
51 mnRealSize
= rBaseStrm
.readInt32();
52 ornRecSize
= isContainer() ? 0 : mnRealSize
;
53 return !rBaseStrm
.isEof();
56 void DffStreamObject::implWriteExtHeader()
58 const sal_Char
* pcListName
= "DFF-RECORD-INST";
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
68 MultiItemsGuard
aMultiGuard( mxOut
);
69 writeHexItem( "instance", mnInstVer
, pcListName
);
70 if( isContainer() ) writeDecItem( "container-size", mnRealSize
);
73 void DffStreamObject::implDumpRecordBody()
78 dumpDec
< sal_uInt8
>( "win-type", "DFFBSE-TYPE" );
79 dumpDec
< sal_uInt8
>( "mac-type", "DFFBSE-TYPE" );
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" );
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" );
97 case DFF_ID_CLIENTANCHOR
:
101 dumpDec
< sal_uInt32
>( "shape-count" );
102 dumpHex
< sal_uInt32
>( "max-shape-id", "CONV-DEC" );
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
)
115 MultiItemsGuard
aMultiGuard( mxOut
);
116 writeEmptyItem( "#cluster" );
117 dumpDec
< sal_uInt32
>( "drawing-id" );
118 dumpHex
< sal_uInt32
>( "next-free-id", "CONV-DEC" );
130 dumpHex
< sal_uInt32
>( "shape-id", "CONV-DEC" );
131 dumpHex
< sal_uInt32
>( "shape-flags", "DFFSP-FLAGS" );
135 dumpDec
< sal_uInt32
>( "left" );
136 dumpDec
< sal_uInt32
>( "top" );
137 dumpDec
< sal_uInt32
>( "right" );
138 dumpDec
< sal_uInt32
>( "bottom" );
141 case DFF_ID_SPLITMENUCOLORS
:
142 dumpDffSimpleColor( "fill-color" );
143 dumpDffSimpleColor( "line-color" );
144 dumpDffSimpleColor( "shadow-color" );
145 dumpDffSimpleColor( "3d-color" );
150 sal_uInt32
DffStreamObject::dumpDffSimpleColor( const String
& rName
)
152 return dumpHex
< sal_uInt32
>( rName
, "DFF-SIMPLE-COLOR" );
157 enum class PropType
{ Binary
};
161 OUString
const maName
;
162 PropType
const meType
;
163 sal_uInt16
const mnId
;
164 sal_uInt32
const mnSize
;
165 explicit PropInfo( const OUString
& rName
, PropType eType
, sal_uInt16 nId
, sal_uInt32 nSize
) :
166 maName( rName
), meType( eType
), mnId( nId
), mnSize( nSize
) {}
169 typedef ::std::vector
< PropInfo
> PropInfoVector
;
173 void DffStreamObject::dumpDffOpt()
175 sal_uInt16 nPropCount
= getInst();
176 PropInfoVector aPropInfos
;
177 mxOut
->resetItemIndex();
178 for( sal_uInt16 nPropIdx
= 0; !mxStrm
->isEof() && (nPropIdx
< nPropCount
); ++nPropIdx
)
180 sal_uInt16 nPropId
= dumpDffOptPropHeader();
181 sal_uInt16 nBaseId
= nPropId
& DFF_OPT_IDMASK
;
182 sal_uInt32 nValue
= mxStrm
->readuInt32();
184 IndentGuard
aIndent( mxOut
);
185 if( getFlag( nPropId
, DFF_OPT_COMPLEX
) )
187 writeHexItem( "complex-size", nValue
, "CONV-DEC" );
188 aPropInfos
.emplace_back( String( "property-data" ), PropType::Binary
, nBaseId
, nValue
);
192 writeHexItem( "value", nValue
);
196 mxOut
->resetItemIndex();
197 for (auto const& propInfo
: aPropInfos
)
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
)
208 case PropType::Binary
:
209 dumpBinary( propInfo
.maName
, propInfo
.mnSize
);
211 default: assert(false && "missing implementation?");
216 sal_uInt16
DffStreamObject::dumpDffOptPropHeader()
218 MultiItemsGuard
aMultiGuard( mxOut
);
219 TableGuard
aTabGuard( mxOut
, 11 );
220 writeEmptyItem( "#prop" );
221 return dumpHex
< sal_uInt16
>( "id", "DFFOPT-PROPERTY-ID" );
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */