Update ooo320-m1
[ooovba.git] / oox / source / dump / pptxdumper.cxx
blob0e04cb821d4aea34484bcd7fcfcff88751f9145e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pptxdumper.cxx,v $
10 * $Revision: 1.3.20.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/dump/pptxdumper.hxx"
32 #include "oox/helper/olestorage.hxx"
33 #include "oox/helper/zipstorage.hxx"
34 #include "oox/dump/biffdumper.hxx"
35 #include "oox/dump/oledumper.hxx"
36 #include "oox/dump/xlsbdumper.hxx"
38 #if OOX_INCLUDE_DUMPER
40 using ::rtl::OUString;
41 using ::com::sun::star::uno::Reference;
42 using ::com::sun::star::lang::XMultiServiceFactory;
43 using ::com::sun::star::io::XInputStream;
44 using ::comphelper::MediaDescriptor;
45 using ::oox::core::FilterBase;
47 namespace oox {
48 namespace dump {
49 namespace pptx {
51 // ============================================================================
53 RootStorageObject::RootStorageObject( const DumperBase& rParent )
55 StorageObjectBase::construct( rParent );
58 void RootStorageObject::implDumpStream( const BinaryInputStreamRef& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
60 OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName );
61 Reference< XInputStream > xInStrm = InputOutputHelper::getXInputStream( *rxStrm );
62 if( aExt.equalsIgnoreAsciiCaseAscii( "pptx" ) ||
63 aExt.equalsIgnoreAsciiCaseAscii( "potx" ) )
65 Dumper( getFactory(), xInStrm, rSysFileName ).dump();
67 else if(
68 aExt.equalsIgnoreAsciiCaseAscii( "xlsb" ) ||
69 aExt.equalsIgnoreAsciiCaseAscii( "xlsm" ) ||
70 aExt.equalsIgnoreAsciiCaseAscii( "xlsx" ) ||
71 aExt.equalsIgnoreAsciiCaseAscii( "xltm" ) ||
72 aExt.equalsIgnoreAsciiCaseAscii( "xltx" ) )
74 ::oox::dump::xlsb::Dumper( getFactory(), xInStrm, rSysFileName ).dump();
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" ) )
84 ::oox::dump::biff::Dumper( getFactory(), xInStrm, rSysFileName ).dump();
86 else if(
87 aExt.equalsIgnoreAsciiCaseAscii( "xml" ) ||
88 aExt.equalsIgnoreAsciiCaseAscii( "vml" ) ||
89 aExt.equalsIgnoreAsciiCaseAscii( "rels" ) )
91 XmlStreamObject( *this, rxStrm, rSysFileName ).dump();
93 else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) )
95 if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) )
97 StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) );
98 VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump();
100 else if( rStrgPath.equalsAscii( "ppt/embeddings" ) )
102 StorageRef xStrg( new OleStorage( getFactory(), xInStrm, false ) );
103 OleStorageObject( *this, xStrg, rSysFileName ).dump();
105 else if( rStrgPath.equalsAscii( "ppt/activeX" ) )
107 OcxGuidControlObject( *this, rxStrm, rSysFileName ).dump();
109 else
111 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
116 // ============================================================================
118 #define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER"
120 Dumper::Dumper( const FilterBase& rFilter )
122 ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rFilter ) );
123 DumperBase::construct( xCfg );
126 Dumper::Dumper( const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName )
128 if( rxFactory.is() && rxInStrm.is() )
130 StorageRef xStrg( new ZipStorage( rxFactory, rxInStrm ) );
131 MediaDescriptor aMediaDesc;
132 ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rxFactory, xStrg, rSysFileName, aMediaDesc ) );
133 DumperBase::construct( xCfg );
137 void Dumper::implDump()
139 RootStorageObject( *this ).dump();
142 // ============================================================================
144 } // namespace pptx
145 } // namespace dump
146 } // namespace oox
148 #endif