1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "oox/dump/pptxdumper.hxx"
22 #include "oox/dump/oledumper.hxx"
23 #include "oox/dump/xlsbdumper.hxx"
24 #include "oox/helper/zipstorage.hxx"
25 #include "oox/ole/olestorage.hxx"
27 #if OOX_INCLUDE_DUMPER
33 // ============================================================================
35 using namespace ::com::sun::star::io
;
36 //using namespace ::com::sun::star::lang;
37 using namespace ::com::sun::star::uno
;
39 using ::oox::core::FilterBase
;
41 // ============================================================================
43 RootStorageObject::RootStorageObject( const DumperBase
& rParent
)
45 StorageObjectBase::construct( rParent
);
48 void RootStorageObject::implDumpStream( const Reference
< XInputStream
>& rxStrm
, const OUString
& rStrgPath
, const OUString
& rStrmName
, const OUString
& rSysFileName
)
50 OUString aExt
= InputOutputHelper::getFileNameExtension( rStrmName
);
51 if( aExt
.equalsIgnoreAsciiCase("pptx") ||
52 aExt
.equalsIgnoreAsciiCase("potx") )
54 Dumper( getContext(), rxStrm
, rSysFileName
).dump();
58 aExt
.equalsIgnoreAsciiCase("xlsb") ||
59 aExt
.equalsIgnoreAsciiCase("xlsm") ||
60 aExt
.equalsIgnoreAsciiCase("xlsx") ||
61 aExt
.equalsIgnoreAsciiCase("xltm") ||
62 aExt
.equalsIgnoreAsciiCase("xltx") )
64 ::oox::dump::xlsb::Dumper( getContext(), rxStrm
, rSysFileName
).dump();
67 aExt
.equalsIgnoreAsciiCase("xla") ||
68 aExt
.equalsIgnoreAsciiCase("xlc") ||
69 aExt
.equalsIgnoreAsciiCase("xlm") ||
70 aExt
.equalsIgnoreAsciiCase("xls") ||
71 aExt
.equalsIgnoreAsciiCase("xlt") ||
72 aExt
.equalsIgnoreAsciiCase("xlw") )
74 ::oox::dump::biff::Dumper( getContext(), rxStrm
, rSysFileName
).dump();
78 aExt
.equalsIgnoreAsciiCase("xml") ||
79 aExt
.equalsIgnoreAsciiCase("vml") ||
80 aExt
.equalsIgnoreAsciiCase("rels") )
82 XmlStreamObject( *this, rxStrm
, rSysFileName
).dump();
84 else if( aExt
.equalsIgnoreAsciiCase("bin") )
86 if( rStrgPath
== "ppt" && rStrmName
== "vbaProject.bin" )
88 StorageRef
xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm
, false ) );
89 VbaProjectStorageObject( *this, xStrg
, rSysFileName
).dump();
91 else if ( rStrgPath
== "ppt/embeddings" )
93 StorageRef
xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm
, false ) );
94 OleStorageObject( *this, xStrg
, rSysFileName
).dump();
96 else if ( rStrgPath
== "ppt/activeX" )
98 StorageRef
xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm
, true ) );
99 ActiveXStorageObject( *this, xStrg
, rSysFileName
).dump();
103 BinaryStreamObject( *this, rxStrm
, rSysFileName
).dump();
108 // ============================================================================
110 #define DUMP_PPTX_CONFIG_ENVVAR "OOO_PPTXDUMPER"
112 Dumper::Dumper( const FilterBase
& rFilter
)
114 ConfigRef
xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR
, rFilter
) );
115 DumperBase::construct( xCfg
);
118 Dumper::Dumper( const Reference
< XComponentContext
>& rxContext
, const Reference
< XInputStream
>& rxInStrm
, const OUString
& rSysFileName
)
120 if( rxContext
.is() && rxInStrm
.is() )
122 StorageRef
xStrg( new ZipStorage( rxContext
, rxInStrm
) );
123 ConfigRef
xCfg( new Config( DUMP_PPTX_CONFIG_ENVVAR
, rxContext
, xStrg
, rSysFileName
) );
124 DumperBase::construct( xCfg
);
128 void Dumper::implDump()
130 RootStorageObject( *this ).dump();
133 // ============================================================================
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */