xref: /aoo41x/main/oox/source/dump/pptxdumper.cxx (revision ca5ec200)
1*ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ca5ec200SAndrew Rist  * distributed with this work for additional information
6*ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9*ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ca5ec200SAndrew Rist  *
11*ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ca5ec200SAndrew Rist  *
13*ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15*ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18*ca5ec200SAndrew Rist  * under the License.
19*ca5ec200SAndrew Rist  *
20*ca5ec200SAndrew Rist  *************************************************************/
21*ca5ec200SAndrew Rist 
22*ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/dump/pptxdumper.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include "oox/dump/biffdumper.hxx"
27cdf0e10cSrcweir #include "oox/dump/oledumper.hxx"
28cdf0e10cSrcweir #include "oox/dump/xlsbdumper.hxx"
29cdf0e10cSrcweir #include "oox/helper/zipstorage.hxx"
30cdf0e10cSrcweir #include "oox/ole/olestorage.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #if OOX_INCLUDE_DUMPER
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace oox {
35cdf0e10cSrcweir namespace dump {
36cdf0e10cSrcweir namespace pptx {
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // ============================================================================
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace ::com::sun::star::io;
41cdf0e10cSrcweir using namespace ::com::sun::star::lang;
42cdf0e10cSrcweir using namespace ::com::sun::star::uno;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir using ::comphelper::MediaDescriptor;
45cdf0e10cSrcweir using ::oox::core::FilterBase;
46cdf0e10cSrcweir using ::rtl::OUString;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // ============================================================================
49cdf0e10cSrcweir 
RootStorageObject(const DumperBase & rParent)50cdf0e10cSrcweir RootStorageObject::RootStorageObject( const DumperBase& rParent )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     StorageObjectBase::construct( rParent );
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
implDumpStream(const Reference<XInputStream> & rxStrm,const OUString & rStrgPath,const OUString & rStrmName,const OUString & rSysFileName)55cdf0e10cSrcweir void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName );
58cdf0e10cSrcweir     if( aExt.equalsIgnoreAsciiCaseAscii( "pptx" ) ||
59cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "potx" ) )
60cdf0e10cSrcweir     {
61cdf0e10cSrcweir         Dumper( getContext(), rxStrm, rSysFileName ).dump();
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir     else if(
64cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlsb" ) ||
65cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlsm" ) ||
66cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlsx" ) ||
67cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xltm" ) ||
68cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xltx" ) )
69cdf0e10cSrcweir     {
70cdf0e10cSrcweir         ::oox::dump::xlsb::Dumper( getContext(), rxStrm, rSysFileName ).dump();
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir     else if(
73cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xla" ) ||
74cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlc" ) ||
75cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlm" ) ||
76cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xls" ) ||
77cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlt" ) ||
78cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xlw" ) )
79cdf0e10cSrcweir     {
80cdf0e10cSrcweir         ::oox::dump::biff::Dumper( getContext(), rxStrm, rSysFileName ).dump();
81cdf0e10cSrcweir     }
82cdf0e10cSrcweir     else if(
83cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "xml" ) ||
84cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "vml" ) ||
85cdf0e10cSrcweir         aExt.equalsIgnoreAsciiCaseAscii( "rels" ) )
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir         XmlStreamObject( *this, rxStrm, rSysFileName ).dump();
88cdf0e10cSrcweir     }
89cdf0e10cSrcweir     else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) )
92cdf0e10cSrcweir         {
93cdf0e10cSrcweir             StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) );
94cdf0e10cSrcweir             VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump();
95cdf0e10cSrcweir         }
96cdf0e10cSrcweir         else if( rStrgPath.equalsAscii( "ppt/embeddings" ) )
97cdf0e10cSrcweir         {
98cdf0e10cSrcweir             StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) );
99cdf0e10cSrcweir             OleStorageObject( *this, xStrg, rSysFileName ).dump();
100cdf0e10cSrcweir         }
101cdf0e10cSrcweir         else if( rStrgPath.equalsAscii( "ppt/activeX" ) )
102cdf0e10cSrcweir         {
103cdf0e10cSrcweir             StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, true ) );
104cdf0e10cSrcweir             ActiveXStorageObject( *this, xStrg, rSysFileName ).dump();
105cdf0e10cSrcweir         }
106cdf0e10cSrcweir         else
107cdf0e10cSrcweir         {
108cdf0e10cSrcweir             BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
109cdf0e10cSrcweir         }
110cdf0e10cSrcweir     }
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir // ============================================================================
114cdf0e10cSrcweir 
115cdf0e10cSrcweir #define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER"
116cdf0e10cSrcweir 
Dumper(const FilterBase & rFilter)117cdf0e10cSrcweir Dumper::Dumper( const FilterBase& rFilter )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rFilter ) );
120cdf0e10cSrcweir     DumperBase::construct( xCfg );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
Dumper(const Reference<XComponentContext> & rxContext,const Reference<XInputStream> & rxInStrm,const OUString & rSysFileName)123cdf0e10cSrcweir Dumper::Dumper( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     if( rxContext.is() && rxInStrm.is() )
126cdf0e10cSrcweir     {
127cdf0e10cSrcweir         StorageRef xStrg( new ZipStorage( rxContext, rxInStrm ) );
128cdf0e10cSrcweir         MediaDescriptor aMediaDesc;
129cdf0e10cSrcweir         ConfigRef xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR, rxContext, xStrg, rSysFileName, aMediaDesc ) );
130cdf0e10cSrcweir         DumperBase::construct( xCfg );
131cdf0e10cSrcweir     }
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
implDump()134cdf0e10cSrcweir void Dumper::implDump()
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     RootStorageObject( *this ).dump();
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // ============================================================================
140cdf0e10cSrcweir 
141cdf0e10cSrcweir } // namespace pptx
142cdf0e10cSrcweir } // namespace dump
143cdf0e10cSrcweir } // namespace oox
144cdf0e10cSrcweir 
145cdf0e10cSrcweir #endif
146