1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "oox/dump/dffdumper.hxx" 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #if OOX_INCLUDE_DUMPER 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir namespace oox { 33*cdf0e10cSrcweir namespace dump { 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir // ============================================================================ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using ::rtl::OUString; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir // ============================================================================ 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir namespace { 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir const sal_uInt16 DFF_ID_BSE = 0xF007; /// BLIP store entry. 44*cdf0e10cSrcweir const sal_uInt16 DFF_ID_BSTORECONTAINER = 0xF001; /// BLIP store container. 45*cdf0e10cSrcweir const sal_uInt16 DFF_ID_CHILDANCHOR = 0xF00F; /// Child anchor (in groups). 46*cdf0e10cSrcweir const sal_uInt16 DFF_ID_CLIENTANCHOR = 0xF010; /// Client anchor. 47*cdf0e10cSrcweir const sal_uInt16 DFF_ID_DG = 0xF008; /// Drawing. 48*cdf0e10cSrcweir const sal_uInt16 DFF_ID_DGG = 0xF006; /// Drawing group. 49*cdf0e10cSrcweir const sal_uInt16 DFF_ID_OPT = 0xF00B; /// Property set. 50*cdf0e10cSrcweir const sal_uInt16 DFF_ID_OPT2 = 0xF121; /// Secondary property set. 51*cdf0e10cSrcweir const sal_uInt16 DFF_ID_OPT3 = 0xF122; /// Ternary property set. 52*cdf0e10cSrcweir const sal_uInt16 DFF_ID_SP = 0xF00A; /// Shape. 53*cdf0e10cSrcweir const sal_uInt16 DFF_ID_SPGR = 0xF009; /// Shape group. 54*cdf0e10cSrcweir const sal_uInt16 DFF_ID_SPLITMENUCOLORS = 0xF11E; /// Current toolbar colors. 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir const sal_uInt16 DFF_OPT_IDMASK = 0x3FFF; 57*cdf0e10cSrcweir const sal_uInt16 DFF_OPT_PICTURE = 0x4000; 58*cdf0e10cSrcweir const sal_uInt16 DFF_OPT_COMPLEX = 0x8000; 59*cdf0e10cSrcweir const sal_uInt16 DFF_OPT_FLAGSMASK = 0x003F; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir } // namespace 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir // ============================================================================ 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void DffStreamObject::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir SequenceRecordObjectBase::construct( rParent, rxStrm, rSysFileName, "DFF-RECORD-NAMES" ); 68*cdf0e10cSrcweir constructDffObj(); 69*cdf0e10cSrcweir } 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir void DffStreamObject::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm ) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir SequenceRecordObjectBase::construct( rParent, rxStrm, "DFF-RECORD-NAMES" ); 74*cdf0e10cSrcweir constructDffObj(); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir bool DffStreamObject::implReadRecordHeader( BinaryInputStream& rBaseStrm, sal_Int64& ornRecId, sal_Int64& ornRecSize ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir sal_uInt16 nRecId; 80*cdf0e10cSrcweir rBaseStrm >> mnInstVer >> nRecId >> mnRealSize; 81*cdf0e10cSrcweir ornRecId = nRecId; 82*cdf0e10cSrcweir ornRecSize = isContainer() ? 0 : mnRealSize; 83*cdf0e10cSrcweir return !rBaseStrm.isEof(); 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir void DffStreamObject::implWriteExtHeader() 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir const sal_Char* pcListName = "DFF-RECORD-INST"; 89*cdf0e10cSrcweir switch( getRecId() ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir case DFF_ID_BSE: pcListName = "DFFBSE-RECORD-INST"; break; // BLIP type 92*cdf0e10cSrcweir case DFF_ID_BSTORECONTAINER: pcListName = "DFFBSTORECONT-RECORD-INST"; break; // BLIP count 93*cdf0e10cSrcweir case DFF_ID_DG: pcListName = "DFFDG-RECORD-INST"; break; // drawing ID 94*cdf0e10cSrcweir case DFF_ID_OPT: pcListName = "DFFOPT-RECORD-INST"; break; // property count 95*cdf0e10cSrcweir case DFF_ID_SP: pcListName = "DFFSP-RECORD-INST"; break; // shape type 96*cdf0e10cSrcweir case DFF_ID_SPLITMENUCOLORS: pcListName = "DFFSPLITMENUC-RECORD-INST"; break; // number of colors 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir MultiItemsGuard aMultiGuard( mxOut ); 99*cdf0e10cSrcweir writeHexItem( "instance", mnInstVer, pcListName ); 100*cdf0e10cSrcweir if( isContainer() ) writeDecItem( "container-size", mnRealSize ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir void DffStreamObject::implDumpRecordBody() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir switch( getRecId() ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir case DFF_ID_BSE: 108*cdf0e10cSrcweir dumpDec< sal_uInt8 >( "win-type", "DFFBSE-TYPE" ); 109*cdf0e10cSrcweir dumpDec< sal_uInt8 >( "mac-type", "DFFBSE-TYPE" ); 110*cdf0e10cSrcweir dumpGuid( "guid" ); 111*cdf0e10cSrcweir dumpDec< sal_uInt16 >( "tag" ); 112*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "blip-size" ); 113*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "blip-refcount" ); 114*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "blip-streampos" ); 115*cdf0e10cSrcweir dumpDec< sal_uInt8 >( "blip-usage", "DFFBSE-USAGE" ); 116*cdf0e10cSrcweir dumpDec< sal_uInt8 >( "blip-name-len" ); 117*cdf0e10cSrcweir dumpUnused( 2 ); 118*cdf0e10cSrcweir break; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir case DFF_ID_CHILDANCHOR: 121*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "left" ); 122*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "top" ); 123*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "right" ); 124*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "bottom" ); 125*cdf0e10cSrcweir break; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir case DFF_ID_CLIENTANCHOR: 128*cdf0e10cSrcweir implDumpClientAnchor(); 129*cdf0e10cSrcweir break; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir case DFF_ID_DG: 132*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "shape-count" ); 133*cdf0e10cSrcweir dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" ); 134*cdf0e10cSrcweir break; 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir case DFF_ID_DGG: 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir dumpHex< sal_uInt32 >( "max-shape-id", "CONV-DEC" ); 139*cdf0e10cSrcweir sal_uInt32 nClusters = dumpDec< sal_uInt32 >( "id-cluster-count" ); 140*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "shape-count" ); 141*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "drawing-count" ); 142*cdf0e10cSrcweir mxOut->resetItemIndex( 1 ); 143*cdf0e10cSrcweir TableGuard aTabGuard( mxOut, 15, 16 ); 144*cdf0e10cSrcweir for( sal_uInt32 nCluster = 1; !mxStrm->isEof() && (nCluster < nClusters); ++nCluster ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir MultiItemsGuard aMultiGuard( mxOut ); 147*cdf0e10cSrcweir writeEmptyItem( "#cluster" ); 148*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "drawing-id" ); 149*cdf0e10cSrcweir dumpHex< sal_uInt32 >( "next-free-id", "CONV-DEC" ); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir break; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir case DFF_ID_OPT: 155*cdf0e10cSrcweir case DFF_ID_OPT2: 156*cdf0e10cSrcweir case DFF_ID_OPT3: 157*cdf0e10cSrcweir dumpDffOpt(); 158*cdf0e10cSrcweir break; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir case DFF_ID_SP: 161*cdf0e10cSrcweir dumpHex< sal_uInt32 >( "shape-id", "CONV-DEC" ); 162*cdf0e10cSrcweir dumpHex< sal_uInt32 >( "shape-flags", "DFFSP-FLAGS" ); 163*cdf0e10cSrcweir break; 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir case DFF_ID_SPGR: 166*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "left" ); 167*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "top" ); 168*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "right" ); 169*cdf0e10cSrcweir dumpDec< sal_uInt32 >( "bottom" ); 170*cdf0e10cSrcweir break; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir case DFF_ID_SPLITMENUCOLORS: 173*cdf0e10cSrcweir dumpDffSimpleColor( "fill-color" ); 174*cdf0e10cSrcweir dumpDffSimpleColor( "line-color" ); 175*cdf0e10cSrcweir dumpDffSimpleColor( "shadow-color" ); 176*cdf0e10cSrcweir dumpDffSimpleColor( "3d-color" ); 177*cdf0e10cSrcweir break; 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir void DffStreamObject::implDumpClientAnchor() 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir void DffStreamObject::constructDffObj() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir mnInstVer = 0; 188*cdf0e10cSrcweir mnRealSize = 0; 189*cdf0e10cSrcweir if( SequenceRecordObjectBase::implIsValid() ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir maSimpleProps.insertFormats( cfg().getNameList( "DFFOPT-SIMPLE-PROPERTIES" ) ); 192*cdf0e10cSrcweir maComplexProps.insertFormats( cfg().getNameList( "DFFOPT-COMPLEX-PROPERTIES" ) ); 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir sal_uInt32 DffStreamObject::dumpDffSimpleColor( const String& rName ) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir return dumpHex< sal_uInt32 >( rName, "DFF-SIMPLE-COLOR" ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir sal_uInt32 DffStreamObject::dumpDffColor( const String& rName ) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir return dumpHex< sal_uInt32 >( rName, "DFF-COLOR" ); 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir namespace { 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir enum PropType { PROPTYPE_BINARY, PROPTYPE_STRING, PROPTYPE_BLIP, PROPTYPE_COLORARRAY }; 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir struct PropInfo 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir OUString maName; 213*cdf0e10cSrcweir PropType meType; 214*cdf0e10cSrcweir sal_uInt16 mnId; 215*cdf0e10cSrcweir sal_uInt32 mnSize; 216*cdf0e10cSrcweir inline explicit PropInfo( const OUString& rName, PropType eType, sal_uInt16 nId, sal_uInt32 nSize ) : 217*cdf0e10cSrcweir maName( rName ), meType( eType ), mnId( nId ), mnSize( nSize ) {} 218*cdf0e10cSrcweir }; 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir typedef ::std::vector< PropInfo > PropInfoVector; 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir } // namespace 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir void DffStreamObject::dumpDffOpt() 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir sal_uInt16 nPropCount = getInst(); 227*cdf0e10cSrcweir PropInfoVector aPropInfos; 228*cdf0e10cSrcweir mxOut->resetItemIndex(); 229*cdf0e10cSrcweir for( sal_uInt16 nPropIdx = 0; !mxStrm->isEof() && (nPropIdx < nPropCount); ++nPropIdx ) 230*cdf0e10cSrcweir { 231*cdf0e10cSrcweir sal_uInt16 nPropId = dumpDffOptPropHeader(); 232*cdf0e10cSrcweir sal_uInt16 nBaseId = nPropId & DFF_OPT_IDMASK; 233*cdf0e10cSrcweir sal_uInt32 nValue = mxStrm->readuInt32(); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir IndentGuard aIndent( mxOut ); 236*cdf0e10cSrcweir if( getFlag( nPropId, DFF_OPT_COMPLEX ) ) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir writeHexItem( "complex-size", nValue, "CONV-DEC" ); 239*cdf0e10cSrcweir String aName; 240*cdf0e10cSrcweir PropType eType = PROPTYPE_BINARY; 241*cdf0e10cSrcweir ItemFormatMap::const_iterator aIt = maComplexProps.find( nBaseId ); 242*cdf0e10cSrcweir if( aIt != maComplexProps.end() ) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir const ItemFormat& rItemFmt = aIt->second; 245*cdf0e10cSrcweir aName = rItemFmt.maItemName; 246*cdf0e10cSrcweir if( rItemFmt.maListName.equalsAscii( "binary" ) ) 247*cdf0e10cSrcweir eType = PROPTYPE_BINARY; 248*cdf0e10cSrcweir else if( rItemFmt.maListName.equalsAscii( "string" ) ) 249*cdf0e10cSrcweir eType = PROPTYPE_STRING; 250*cdf0e10cSrcweir else if( rItemFmt.maListName.equalsAscii( "blip" ) ) 251*cdf0e10cSrcweir eType = PROPTYPE_BLIP; 252*cdf0e10cSrcweir else if( rItemFmt.maListName.equalsAscii( "colorarray" ) ) 253*cdf0e10cSrcweir eType = PROPTYPE_COLORARRAY; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir aPropInfos.push_back( PropInfo( aName( "property-data" ), eType, nBaseId, nValue ) ); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir else 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir ItemFormatMap::const_iterator aIt = maSimpleProps.find( nBaseId ); 260*cdf0e10cSrcweir if( aIt != maSimpleProps.end() ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir const ItemFormat& rItemFmt = aIt->second; 263*cdf0e10cSrcweir // flags always at end of block of 64 properties 264*cdf0e10cSrcweir if( (nBaseId & DFF_OPT_FLAGSMASK) == DFF_OPT_FLAGSMASK ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir FlagsList* pFlagsList = dynamic_cast< FlagsList* >( cfg().getNameList( rItemFmt.maListName ).get() ); 267*cdf0e10cSrcweir sal_Int64 nOldIgnoreFlags = 0; 268*cdf0e10cSrcweir if( pFlagsList ) 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir nOldIgnoreFlags = pFlagsList->getIgnoreFlags(); 271*cdf0e10cSrcweir pFlagsList->setIgnoreFlags( nOldIgnoreFlags | 0xFFFF0000 | ~(nValue >> 16) ); 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir writeValueItem( rItemFmt, nValue ); 274*cdf0e10cSrcweir if( pFlagsList ) 275*cdf0e10cSrcweir pFlagsList->setIgnoreFlags( nOldIgnoreFlags ); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir else 278*cdf0e10cSrcweir writeValueItem( rItemFmt, nValue ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir else 281*cdf0e10cSrcweir writeHexItem( "value", nValue ); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir mxOut->resetItemIndex(); 286*cdf0e10cSrcweir for( PropInfoVector::iterator aIt = aPropInfos.begin(), aEnd = aPropInfos.end(); !mxStrm->isEof() && (aIt != aEnd); ++aIt ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir mxOut->startMultiItems(); 289*cdf0e10cSrcweir writeEmptyItem( "#complex-data" ); 290*cdf0e10cSrcweir writeHexItem( "id", aIt->mnId, "DFFOPT-PROPERTY-NAMES" ); 291*cdf0e10cSrcweir mxOut->endMultiItems(); 292*cdf0e10cSrcweir IndentGuard aIndent( mxOut ); 293*cdf0e10cSrcweir switch( aIt->meType ) 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir case PROPTYPE_BINARY: 296*cdf0e10cSrcweir dumpBinary( aIt->maName, aIt->mnSize ); 297*cdf0e10cSrcweir break; 298*cdf0e10cSrcweir case PROPTYPE_STRING: 299*cdf0e10cSrcweir dumpUnicodeArray( aIt->maName, aIt->mnSize / 2, true ); 300*cdf0e10cSrcweir break; 301*cdf0e10cSrcweir case PROPTYPE_BLIP: 302*cdf0e10cSrcweir dumpBinary( aIt->maName, aIt->mnSize ); 303*cdf0e10cSrcweir break; 304*cdf0e10cSrcweir case PROPTYPE_COLORARRAY: 305*cdf0e10cSrcweir dumpBinary( aIt->maName, aIt->mnSize ); 306*cdf0e10cSrcweir break; 307*cdf0e10cSrcweir } 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir sal_uInt16 DffStreamObject::dumpDffOptPropHeader() 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir MultiItemsGuard aMultiGuard( mxOut ); 314*cdf0e10cSrcweir TableGuard aTabGuard( mxOut, 11 ); 315*cdf0e10cSrcweir writeEmptyItem( "#prop" ); 316*cdf0e10cSrcweir return dumpHex< sal_uInt16 >( "id", "DFFOPT-PROPERTY-ID" ); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // ============================================================================ 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir } // namespace dump 322*cdf0e10cSrcweir } // namespace oox 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir #endif 325