LibreOffice Module oox (master)  1
pptxdumper.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <oox/dump/pptxdumper.hxx>
21 
22 #include <com/sun/star/io/XInputStream.hpp>
23 #include <oox/dump/oledumper.hxx>
24 #include <oox/dump/xlsbdumper.hxx>
26 #include <oox/ole/olestorage.hxx>
27 
28 #ifdef DBG_UTIL
29 
30 namespace oox::dump::pptx {
31 
32 using namespace ::com::sun::star::io;
33 //using namespace ::com::sun::star::lang;
34 using namespace ::com::sun::star::uno;
35 
36 using ::oox::core::FilterBase;
37 
39 {
41 }
42 
43 void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
44 {
45  OUString aExt = InputOutputHelper::getFileNameExtension( rStrmName );
46  if( aExt.equalsIgnoreAsciiCase("pptx") ||
47  aExt.equalsIgnoreAsciiCase("potx") )
48  {
49  Dumper( getContext(), rxStrm, rSysFileName ).dump();
50  }
51 #ifdef FIXME
52  else if(
53  aExt.equalsIgnoreAsciiCase("xlsb") ||
54  aExt.equalsIgnoreAsciiCase("xlsm") ||
55  aExt.equalsIgnoreAsciiCase("xlsx") ||
56  aExt.equalsIgnoreAsciiCase("xltm") ||
57  aExt.equalsIgnoreAsciiCase("xltx") )
58  {
59  ::oox::dump::xlsb::Dumper( getContext(), rxStrm, rSysFileName ).dump();
60  }
61  else if(
62  aExt.equalsIgnoreAsciiCase("xla") ||
63  aExt.equalsIgnoreAsciiCase("xlc") ||
64  aExt.equalsIgnoreAsciiCase("xlm") ||
65  aExt.equalsIgnoreAsciiCase("xls") ||
66  aExt.equalsIgnoreAsciiCase("xlt") ||
67  aExt.equalsIgnoreAsciiCase("xlw") )
68  {
69  ::oox::dump::biff::Dumper( getContext(), rxStrm, rSysFileName ).dump();
70  }
71 #endif
72  else if(
73  aExt.equalsIgnoreAsciiCase("xml") ||
74  aExt.equalsIgnoreAsciiCase("vml") ||
75  aExt.equalsIgnoreAsciiCase("rels") )
76  {
77  XmlStreamObject( *this, rxStrm, rSysFileName ).dump();
78  }
79  else if( aExt.equalsIgnoreAsciiCase("bin") )
80  {
81  if( rStrgPath == "ppt" && rStrmName == "vbaProject.bin" )
82  {
83  StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, false );
84  VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump();
85  }
86  else if ( rStrgPath == "ppt/embeddings" )
87  {
88  StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, false );
89  OleStorageObject( *this, xStrg, rSysFileName ).dump();
90  }
91  else if ( rStrgPath == "ppt/activeX" )
92  {
93  StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, true );
94  ActiveXStorageObject( *this, xStrg, rSysFileName ).dump();
95  }
96  else
97  {
98  BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
99  }
100  }
101 }
102 
103 #define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER"
104 
105 Dumper::Dumper( const FilterBase& rFilter )
106 {
107  ConfigRef xCfg = std::make_shared<Config>( DUMP_PPTX_CONFIG_ENVVAR, rFilter );
108  DumperBase::construct( xCfg );
109 }
110 
111 Dumper::Dumper( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName )
112 {
113  if( rxContext.is() && rxInStrm.is() )
114  {
115  StorageRef xStrg = std::make_shared<ZipStorage>( rxContext, rxInStrm );
116  ConfigRef xCfg = std::make_shared<Config>( DUMP_PPTX_CONFIG_ENVVAR, rxContext, xStrg, rSysFileName );
117  DumperBase::construct( xCfg );
118  }
119 }
120 
122 {
123  RootStorageObject( *this ).dump();
124 }
125 
126 } // namespace oox::dump::pptx
127 
128 #endif
129 
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
static OUString getFileNameExtension(const OUString &rFileUrl)
Definition: dumperbase.cxx:80
virtual void implDump() override
Definition: pptxdumper.cxx:121
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
virtual void implDumpStream(const css::uno::Reference< css::io::XInputStream > &rxStrm, const OUString &rStrgPath, const OUString &rStrmName, const OUString &rSysFileName) override
void construct(const ObjectBase &rParent, const StorageRef &rxStrg, const OUString &rSysPath)
RootStorageObject(const DumperBase &rParent)
Definition: pptxdumper.cxx:38
#define DUMP_PPTX_CONFIG_ENVVAR
Definition: pptxdumper.cxx:103
Dumper(const ::oox::core::FilterBase &rFilter)
void construct(const ConfigRef &rxConfig)
Base class for a file dumper.
std::shared_ptr< Config > ConfigRef
Definition: dumperbase.hxx:893