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 <sfx2/docfile.hxx>
21 #include <sfx2/docfilt.hxx>
22 #include <filter/msfilter/msoleexp.hxx>
23 #include <svx/svxerr.hxx>
24 #include <unotools/fltrcfg.hxx>
25 #include <sot/storage.hxx>
27 #include <sdpptwrp.hxx>
28 #include <DrawDocShell.hxx>
31 using namespace ::com::sun::star::uno
;
32 using namespace ::com::sun::star::beans
;
33 using namespace ::com::sun::star::task
;
34 using namespace ::com::sun::star::frame
;
36 typedef sal_Bool ( *ExportPPTPointer
)( const std::vector
< css::beans::PropertyValue
>&, tools::SvRef
<SotStorage
> const&,
37 Reference
< XModel
> const &,
38 Reference
< XStatusIndicator
> const &,
39 SvMemoryStream
*, sal_uInt32 nCnvrtFlags
);
41 typedef sal_Bool ( *ImportPPTPointer
)( SdDrawDocument
*, SvStream
&, SotStorage
&, SfxMedium
& );
43 typedef sal_Bool ( *SaveVBAPointer
)( SfxObjectShell
&, SvMemoryStream
*& );
45 #ifdef DISABLE_DYNLOADING
47 extern "C" sal_Bool
ExportPPT( const std::vector
< css::beans::PropertyValue
>&, tools::SvRef
<SotStorage
> const&,
48 Reference
< XModel
> const &,
49 Reference
< XStatusIndicator
> const &,
50 SvMemoryStream
*, sal_uInt32 nCnvrtFlags
);
52 extern "C" sal_Bool
ImportPPT( SdDrawDocument
*, SvStream
&, SotStorage
&, SfxMedium
& );
54 extern "C" sal_Bool
SaveVBA( SfxObjectShell
&, SvMemoryStream
*& );
59 SdPPTFilter::SdPPTFilter( SfxMedium
& rMedium
, ::sd::DrawDocShell
& rDocShell
) :
60 SdFilter( rMedium
, rDocShell
),
65 SdPPTFilter::~SdPPTFilter()
67 delete pBas
; // deleting the compressed basic storage
70 bool SdPPTFilter::Import()
73 tools::SvRef
<SotStorage
> pStorage
= new SotStorage( mrMedium
.GetInStream(), false );
74 if( !pStorage
->GetError() )
76 /* check if there is a dualstorage, then the
77 document is probably a PPT95 containing PPT97 */
78 tools::SvRef
<SotStorage
> xDualStorage
;
79 OUString
sDualStorage( "PP97_DUALSTORAGE" );
80 if ( pStorage
->IsContained( sDualStorage
) )
82 xDualStorage
= pStorage
->OpenSotStorage( sDualStorage
, StreamMode::STD_READ
);
83 pStorage
= xDualStorage
;
85 std::unique_ptr
<SvStream
> pDocStream(pStorage
->OpenSotStream( "PowerPoint Document" , StreamMode::STD_READ
));
88 pDocStream
->SetVersion( pStorage
->GetVersion() );
89 pDocStream
->SetCryptMaskKey(pStorage
->GetKey());
91 if ( pStorage
->IsStream( "EncryptedSummary" ) )
92 mrMedium
.SetError(ERRCODE_SVX_READ_FILTER_PPOINT
);
95 #ifdef DISABLE_DYNLOADING
96 ImportPPTPointer pPPTImport
= ImportPPT
;
98 ImportPPTPointer pPPTImport
= reinterpret_cast< ImportPPTPointer
>(
99 SdFilter::GetLibrarySymbol(mrMedium
.GetFilter()->GetUserData(), "ImportPPT"));
103 bRet
= pPPTImport( &mrDocument
, *pDocStream
, *pStorage
, mrMedium
);
106 mrMedium
.SetError(SVSTREAM_WRONGVERSION
);
114 bool SdPPTFilter::Export()
120 tools::SvRef
<SotStorage
> xStorRef
= new SotStorage( mrMedium
.GetOutStream(), false );
122 #ifdef DISABLE_DYNLOADING
123 ExportPPTPointer PPTExport
= ExportPPT
;
125 ExportPPTPointer PPTExport
= reinterpret_cast< ExportPPTPointer
>(
126 SdFilter::GetLibrarySymbol(mrMedium
.GetFilter()->GetUserData(), "ExportPPT"));
129 if( PPTExport
&& xStorRef
.is() )
131 sal_uInt32 nCnvrtFlags
= 0;
132 const SvtFilterOptions
& rFilterOptions
= SvtFilterOptions::Get();
133 if ( rFilterOptions
.IsMath2MathType() )
134 nCnvrtFlags
|= OLE_STARMATH_2_MATHTYPE
;
135 if ( rFilterOptions
.IsWriter2WinWord() )
136 nCnvrtFlags
|= OLE_STARWRITER_2_WINWORD
;
137 if ( rFilterOptions
.IsCalc2Excel() )
138 nCnvrtFlags
|= OLE_STARCALC_2_EXCEL
;
139 if ( rFilterOptions
.IsImpress2PowerPoint() )
140 nCnvrtFlags
|= OLE_STARIMPRESS_2_POWERPOINT
;
141 if ( rFilterOptions
.IsEnablePPTPreview() )
142 nCnvrtFlags
|= 0x8000;
144 CreateStatusIndicator();
146 //OUString sBaseURI( "BaseURI");
147 std::vector
< PropertyValue
> aProperties
;
148 PropertyValue aProperty
;
149 aProperty
.Name
= "BaseURI";
150 aProperty
.Value
<<= mrMedium
.GetBaseURL( true );
151 aProperties
.push_back( aProperty
);
153 bRet
= PPTExport( aProperties
, xStorRef
, mxModel
, mxStatusIndicator
, pBas
, nCnvrtFlags
);
161 void SdPPTFilter::PreSaveBasic()
163 const SvtFilterOptions
& rFilterOptions
= SvtFilterOptions::Get();
164 if( rFilterOptions
.IsLoadPPointBasicStorage() )
166 #ifdef DISABLE_DYNLOADING
167 SaveVBAPointer pSaveVBA
= SaveVBA
;
169 SaveVBAPointer pSaveVBA
= reinterpret_cast< SaveVBAPointer
>(
170 SdFilter::GetLibrarySymbol(mrMedium
.GetFilter()->GetUserData(), "SaveVBA"));
173 pSaveVBA( static_cast<SfxObjectShell
&>(mrDocShell
), pBas
);
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */