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