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 :
45 0 : ExportBiff5::ExportBiff5( XclExpRootData& rExpData, SvStream& rStrm ):
46 : ExportTyp( rStrm, &rExpData.mrDoc, rExpData.meTextEnc ),
47 0 : XclExpRoot( rExpData )
48 : {
49 : // nur Teil der Root-Daten gebraucht
50 0 : pExcRoot = &GetOldRoot();
51 0 : pExcRoot->pER = this; // ExcRoot -> XclExpRoot
52 0 : pExcRoot->eDateiTyp = Biff5;
53 0 : pExcDoc = new ExcDocument( *this );
54 0 : }
55 :
56 :
57 0 : ExportBiff5::~ExportBiff5()
58 : {
59 0 : delete pExcDoc;
60 0 : }
61 :
62 :
63 0 : FltError ExportBiff5::Write()
64 : {
65 0 : SfxObjectShell* pDocShell = GetDocShell();
66 : OSL_ENSURE( pDocShell, "ExportBiff5::Write - no document shell" );
67 :
68 0 : SotStorageRef xRootStrg = GetRootStorage();
69 : OSL_ENSURE( xRootStrg.Is(), "ExportBiff5::Write - no root storage" );
70 :
71 0 : bool bWriteBasicStrg = false;
72 0 : if( GetBiff() == EXC_BIFF8 )
73 : {
74 0 : const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
75 0 : bWriteBasicStrg = rFilterOpt.IsLoadExcelBasicStorage();
76 : }
77 :
78 0 : if( pDocShell && xRootStrg.Is() && bWriteBasicStrg )
79 : {
80 0 : SvxImportMSVBasic aBasicImport( *pDocShell, *xRootStrg );
81 0 : sal_uLong nErr = aBasicImport.SaveOrDelMSVBAStorage( sal_True, EXC_STORAGE_VBA_PROJECT );
82 0 : if( nErr != ERRCODE_NONE )
83 0 : pDocShell->SetError( nErr, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
84 : }
85 :
86 0 : pExcDoc->ReadDoc(); // ScDoc -> ExcDoc
87 0 : pExcDoc->Write( aOut ); // wechstreamen
88 :
89 0 : if( pDocShell && xRootStrg.Is() )
90 : {
91 : // #i88642# update doc info (revision etc)
92 0 : pDocShell->UpdateDocInfoForSave();
93 :
94 : using namespace ::com::sun::star;
95 : uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
96 0 : pDocShell->GetModel(), uno::UNO_QUERY_THROW);
97 : uno::Reference<document::XDocumentProperties> xDocProps
98 0 : = xDPS->getDocumentProperties();
99 0 : if ( SvtFilterOptions::Get().IsEnableCalcPreview() )
100 : {
101 : ::boost::shared_ptr<GDIMetaFile> pMetaFile =
102 0 : pDocShell->GetPreviewMetaFile (false);
103 : uno::Sequence<sal_uInt8> metaFile(
104 0 : sfx2::convertMetaFile(pMetaFile.get()));
105 0 : sfx2::SaveOlePropertySet(xDocProps, xRootStrg, &metaFile);
106 : }
107 : else
108 0 : sfx2::SaveOlePropertySet(xDocProps, xRootStrg );
109 : }
110 :
111 0 : const XclExpAddressConverter& rAddrConv = GetAddressConverter();
112 0 : if( rAddrConv.IsRowTruncated() )
113 0 : return SCWARN_EXPORT_MAXROW;
114 0 : if( rAddrConv.IsColTruncated() )
115 0 : return SCWARN_EXPORT_MAXCOL;
116 0 : if( rAddrConv.IsTabTruncated() )
117 0 : return SCWARN_EXPORT_MAXTAB;
118 :
119 0 : return eERR_OK;
120 : }
121 :
122 :
123 :
124 0 : ExportBiff8::ExportBiff8( XclExpRootData& rExpData, SvStream& rStrm ) :
125 0 : ExportBiff5( rExpData, rStrm )
126 : {
127 0 : pExcRoot->eDateiTyp = Biff8;
128 0 : }
129 :
130 :
131 0 : ExportBiff8::~ExportBiff8()
132 : {
133 9 : }
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|