1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #include "oox/dump/pptxdumper.hxx" 29 30 #include "oox/dump/biffdumper.hxx" 31 #include "oox/dump/oledumper.hxx" 32 #include "oox/dump/xlsbdumper.hxx" 33 #include "oox/helper/zipstorage.hxx" 34 #include "oox/ole/olestorage.hxx" 35 36 #if OOX_INCLUDE_DUMPER 37 38 namespace oox { 39 namespace dump { 40 namespace pptx { 41 42 // ============================================================================ 43 44 using namespace ::com::sun::star::io; 45 using namespace ::com::sun::star::lang; 46 using namespace ::com::sun::star::uno; 47 48 using ::comphelper::MediaDescriptor; 49 using ::oox::core::FilterBase; 50 using ::rtl::OUString; 51 52 // ============================================================================ 53 54 RootStorageObject::RootStorageObject( const DumperBase& rParent ) 55 { 56 StorageObjectBase::construct( rParent ); 57 } 58 59 void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) 60 { 61 OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName ); 62 if( aExt.equalsIgnoreAsciiCaseAscii( "pptx" ) || 63 aExt.equalsIgnoreAsciiCaseAscii( "potx" ) ) 64 { 65 Dumper( getContext(), rxStrm, rSysFileName ).dump(); 66 } 67 else if( 68 aExt.equalsIgnoreAsciiCaseAscii( "xlsb" ) || 69 aExt.equalsIgnoreAsciiCaseAscii( "xlsm" ) || 70 aExt.equalsIgnoreAsciiCaseAscii( "xlsx" ) || 71 aExt.equalsIgnoreAsciiCaseAscii( "xltm" ) || 72 aExt.equalsIgnoreAsciiCaseAscii( "xltx" ) ) 73 { 74 ::oox::dump::xlsb::Dumper( getContext(), rxStrm, rSysFileName ).dump(); 75 } 76 else if( 77 aExt.equalsIgnoreAsciiCaseAscii( "xla" ) || 78 aExt.equalsIgnoreAsciiCaseAscii( "xlc" ) || 79 aExt.equalsIgnoreAsciiCaseAscii( "xlm" ) || 80 aExt.equalsIgnoreAsciiCaseAscii( "xls" ) || 81 aExt.equalsIgnoreAsciiCaseAscii( "xlt" ) || 82 aExt.equalsIgnoreAsciiCaseAscii( "xlw" ) ) 83 { 84 ::oox::dump::biff::Dumper( getContext(), rxStrm, rSysFileName ).dump(); 85 } 86 else if( 87 aExt.equalsIgnoreAsciiCaseAscii( "xml" ) || 88 aExt.equalsIgnoreAsciiCaseAscii( "vml" ) || 89 aExt.equalsIgnoreAsciiCaseAscii( "rels" ) ) 90 { 91 XmlStreamObject( *this, rxStrm, rSysFileName ).dump(); 92 } 93 else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) ) 94 { 95 if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) 96 { 97 StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); 98 VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); 99 } 100 else if( rStrgPath.equalsAscii( "ppt/embeddings" ) ) 101 { 102 StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); 103 OleStorageObject( *this, xStrg, rSysFileName ).dump(); 104 } 105 else if( rStrgPath.equalsAscii( "ppt/activeX" ) ) 106 { 107 StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, true ) ); 108 ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); 109 } 110 else 111 { 112 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); 113 } 114 } 115 } 116 117 // ============================================================================ 118 119 #define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER" 120 121 Dumper::Dumper( const FilterBase& rFilter ) 122 { 123 ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rFilter ) ); 124 DumperBase::construct( xCfg ); 125 } 126 127 Dumper::Dumper( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName ) 128 { 129 if( rxContext.is() && rxInStrm.is() ) 130 { 131 StorageRef xStrg( new ZipStorage( rxContext, rxInStrm ) ); 132 MediaDescriptor aMediaDesc; 133 ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rxContext, xStrg, rSysFileName, aMediaDesc ) ); 134 DumperBase::construct( xCfg ); 135 } 136 } 137 138 void Dumper::implDump() 139 { 140 RootStorageObject( *this ).dump(); 141 } 142 143 // ============================================================================ 144 145 } // namespace pptx 146 } // namespace dump 147 } // namespace oox 148 149 #endif 150