Line data Source code
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 <unotools/fltrcfg.hxx>
21 :
22 : #include <sfx2/objsh.hxx>
23 : #include <sfx2/docinf.hxx>
24 : #include <filter/msfilter/svxmsbas.hxx>
25 :
26 : #include "scerrors.hxx"
27 : #include "scextopt.hxx"
28 :
29 : #include "root.hxx"
30 : #include "excdoc.hxx"
31 : #include "exp_op.hxx"
32 :
33 : #include "xcl97esc.hxx"
34 :
35 : #include "document.hxx"
36 : #include "rangenam.hxx"
37 : #include "filtopt.hxx"
38 : #include "xltools.hxx"
39 : #include "xelink.hxx"
40 :
41 : #include <com/sun/star/document/XDocumentProperties.hpp>
42 : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
43 :
44 26 : ExportBiff5::ExportBiff5( XclExpRootData& rExpData, SvStream& rStrm ):
45 : ExportTyp( rStrm, &rExpData.mrDoc, rExpData.meTextEnc ),
46 26 : XclExpRoot( rExpData )
47 : {
48 : // only need part of the Root data
49 26 : pExcRoot = &GetOldRoot();
50 26 : pExcRoot->pER = this; // ExcRoot -> XclExpRoot
51 26 : pExcRoot->eDateiTyp = Biff5;
52 26 : pExcDoc = new ExcDocument( *this );
53 26 : }
54 :
55 52 : ExportBiff5::~ExportBiff5()
56 : {
57 26 : delete pExcDoc;
58 26 : }
59 :
60 26 : FltError ExportBiff5::Write()
61 : {
62 26 : SfxObjectShell* pDocShell = GetDocShell();
63 : OSL_ENSURE( pDocShell, "ExportBiff5::Write - no document shell" );
64 :
65 26 : SotStorageRef xRootStrg = GetRootStorage();
66 : OSL_ENSURE( xRootStrg.Is(), "ExportBiff5::Write - no root storage" );
67 :
68 26 : bool bWriteBasicStrg = false;
69 26 : if( GetBiff() == EXC_BIFF8 )
70 : {
71 26 : const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
72 26 : bWriteBasicStrg = rFilterOpt.IsLoadExcelBasicStorage();
73 : }
74 :
75 26 : if( pDocShell && xRootStrg.Is() && bWriteBasicStrg )
76 : {
77 26 : SvxImportMSVBasic aBasicImport( *pDocShell, *xRootStrg );
78 26 : sal_uLong nErr = aBasicImport.SaveOrDelMSVBAStorage( true, EXC_STORAGE_VBA_PROJECT );
79 26 : if( nErr != ERRCODE_NONE )
80 0 : pDocShell->SetError( nErr, OUString( OSL_LOG_PREFIX ) );
81 : }
82 :
83 26 : pExcDoc->ReadDoc(); // ScDoc -> ExcDoc
84 26 : pExcDoc->Write( aOut ); // wechstreamen
85 :
86 26 : if( pDocShell && xRootStrg.Is() )
87 : {
88 : using namespace ::com::sun::star;
89 : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
90 26 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
91 : uno::Reference<document::XDocumentProperties> xDocProps
92 52 : = xDPS->getDocumentProperties();
93 26 : if ( SvtFilterOptions::Get().IsEnableCalcPreview() )
94 : {
95 : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
96 0 : pDocShell->GetPreviewMetaFile (false);
97 : uno::Sequence<sal_uInt8> metaFile(
98 0 : sfx2::convertMetaFile(pMetaFile.get()));
99 0 : sfx2::SaveOlePropertySet(xDocProps, xRootStrg, &metaFile);
100 : }
101 : else
102 52 : sfx2::SaveOlePropertySet(xDocProps, xRootStrg );
103 : }
104 :
105 26 : const XclExpAddressConverter& rAddrConv = GetAddressConverter();
106 26 : if( rAddrConv.IsRowTruncated() )
107 0 : return SCWARN_EXPORT_MAXROW;
108 26 : if( rAddrConv.IsColTruncated() )
109 0 : return SCWARN_EXPORT_MAXCOL;
110 26 : if( rAddrConv.IsTabTruncated() )
111 0 : return SCWARN_EXPORT_MAXTAB;
112 :
113 26 : return eERR_OK;
114 : }
115 :
116 26 : ExportBiff8::ExportBiff8( XclExpRootData& rExpData, SvStream& rStrm ) :
117 26 : ExportBiff5( rExpData, rStrm )
118 : {
119 26 : pExcRoot->eDateiTyp = Biff8;
120 26 : }
121 :
122 26 : ExportBiff8::~ExportBiff8()
123 : {
124 74 : }
125 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|