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
21
22#include <com/sun/star/io/XInputStream.hpp>
27#include <o3tl/string_view.hxx>
28
29#ifdef DBG_UTIL
30
31namespace oox::dump::pptx {
32
33using namespace ::com::sun::star::io;
34//using namespace ::com::sun::star::lang;
35using namespace ::com::sun::star::uno;
36
37using ::oox::core::FilterBase;
38
40{
42}
43
44void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
45{
46 std::u16string_view aExt( InputOutputHelper::getFileNameExtension( rStrmName ) );
47 if( o3tl::equalsIgnoreAsciiCase(aExt, u"pptx") ||
48 o3tl::equalsIgnoreAsciiCase(aExt, u"potx") )
49 {
50 Dumper( getContext(), rxStrm, rSysFileName ).dump();
51 }
52#ifdef FIXME
53 else if(
54 o3tl::equalsIgnoreAsciiCase(aExt, u"xlsb") ||
55 o3tl::equalsIgnoreAsciiCase(aExt, u"xlsm") ||
56 o3tl::equalsIgnoreAsciiCase(aExt, u"xlsx") ||
57 o3tl::equalsIgnoreAsciiCase(aExt, u"xltm") ||
58 o3tl::equalsIgnoreAsciiCase(aExt, u"xltx") )
59 {
60 ::oox::dump::xlsb::Dumper( getContext(), rxStrm, rSysFileName ).dump();
61 }
62 else if(
63 o3tl::equalsIgnoreAsciiCase(aExt, u"xla") ||
64 o3tl::equalsIgnoreAsciiCase(aExt, u"xlc") ||
65 o3tl::equalsIgnoreAsciiCase(aExt, u"xlm") ||
66 o3tl::equalsIgnoreAsciiCase(aExt, u"xls") ||
67 o3tl::equalsIgnoreAsciiCase(aExt, u"xlt") ||
68 o3tl::equalsIgnoreAsciiCase(aExt, u"xlw") )
69 {
70 ::oox::dump::biff::Dumper( getContext(), rxStrm, rSysFileName ).dump();
71 }
72#endif
73 else if(
74 o3tl::equalsIgnoreAsciiCase(aExt, u"xml") ||
75 o3tl::equalsIgnoreAsciiCase(aExt, u"vml") ||
76 o3tl::equalsIgnoreAsciiCase(aExt, u"rels") )
77 {
78 XmlStreamObject( *this, rxStrm, rSysFileName ).dump();
79 }
80 else if( o3tl::equalsIgnoreAsciiCase(aExt, u"bin") )
81 {
82 if( rStrgPath == "ppt" && rStrmName == "vbaProject.bin" )
83 {
84 StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, false );
85 VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump();
86 }
87 else if ( rStrgPath == "ppt/embeddings" )
88 {
89 StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, false );
90 OleStorageObject( *this, xStrg, rSysFileName ).dump();
91 }
92 else if ( rStrgPath == "ppt/activeX" )
93 {
94 StorageRef xStrg = std::make_shared<::oox::ole::OleStorage>( getContext(), rxStrm, true );
95 ActiveXStorageObject( *this, xStrg, rSysFileName ).dump();
96 }
97 else
98 {
99 BinaryStreamObject( *this, rxStrm, rSysFileName ).dump();
100 }
101 }
102}
103
104#define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER"
105
106Dumper::Dumper( const FilterBase& rFilter )
107{
108 ConfigRef xCfg = std::make_shared<Config>( DUMP_PPTX_CONFIG_ENVVAR, rFilter );
109 DumperBase::construct( xCfg );
110}
111
112Dumper::Dumper( const Reference< XComponentContext >& rxContext, const Reference< XInputStream >& rxInStrm, const OUString& rSysFileName )
113{
114 if( rxContext.is() && rxInStrm.is() )
115 {
116 StorageRef xStrg = std::make_shared<ZipStorage>( rxContext, rxInStrm );
117 ConfigRef xCfg = std::make_shared<Config>( DUMP_PPTX_CONFIG_ENVVAR, rxContext, xStrg, rSysFileName );
118 DumperBase::construct( xCfg );
119 }
120}
121
123{
124 RootStorageObject( *this ).dump();
125}
126
127} // namespace oox::dump::pptx
128
129#endif
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for a file dumper.
void construct(const ConfigRef &rxConfig)
static std::u16string_view getFileNameExtension(std::u16string_view rFileUrl)
Definition: dumperbase.cxx:82
const css::uno::Reference< css::uno::XComponentContext > & getContext() const
void construct(const ObjectBase &rParent, const StorageRef &rxStrg, const OUString &rSysPath)
Dumper(const ::oox::core::FilterBase &rFilter)
virtual void implDump() override
Definition: pptxdumper.cxx:122
virtual void implDumpStream(const css::uno::Reference< css::io::XInputStream > &rxStrm, const OUString &rStrgPath, const OUString &rStrmName, const OUString &rSysFileName) override
RootStorageObject(const DumperBase &rParent)
Definition: pptxdumper.cxx:39
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
std::shared_ptr< Config > ConfigRef
Definition: dumperbase.hxx:893
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
#define DUMP_PPTX_CONFIG_ENVVAR
Definition: pptxdumper.cxx:104