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 <unotools/fltrcfg.hxx>
22 #include <sfx2/objsh.hxx>
23 #include <sfx2/docinf.hxx>
24 #include <filter/msfilter/svxmsbas.hxx>
26 #include "scerrors.hxx"
27 #include "scextopt.hxx"
33 #include "xcl97esc.hxx"
35 #include "document.hxx"
36 #include "rangenam.hxx"
37 #include "filtopt.hxx"
38 #include "xltools.hxx"
41 #include <com/sun/star/document/XDocumentProperties.hpp>
42 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
45 ExportBiff5::ExportBiff5( XclExpRootData
& rExpData
, SvStream
& rStrm
):
46 ExportTyp( rStrm
, &rExpData
.mrDoc
, rExpData
.meTextEnc
),
47 XclExpRoot( rExpData
)
49 // nur Teil der Root-Daten gebraucht
50 pExcRoot
= &GetOldRoot();
51 pExcRoot
->pER
= this; // ExcRoot -> XclExpRoot
52 pExcRoot
->eDateiTyp
= Biff5
;
53 pExcDoc
= new ExcDocument( *this );
57 ExportBiff5::~ExportBiff5()
63 FltError
ExportBiff5::Write()
65 SfxObjectShell
* pDocShell
= GetDocShell();
66 OSL_ENSURE( pDocShell
, "ExportBiff5::Write - no document shell" );
68 SotStorageRef xRootStrg
= GetRootStorage();
69 OSL_ENSURE( xRootStrg
.Is(), "ExportBiff5::Write - no root storage" );
71 bool bWriteBasicStrg
= false;
72 if( GetBiff() == EXC_BIFF8
)
74 const SvtFilterOptions
& rFilterOpt
= SvtFilterOptions::Get();
75 bWriteBasicStrg
= rFilterOpt
.IsLoadExcelBasicStorage();
78 if( pDocShell
&& xRootStrg
.Is() && bWriteBasicStrg
)
80 SvxImportMSVBasic
aBasicImport( *pDocShell
, *xRootStrg
);
81 sal_uLong nErr
= aBasicImport
.SaveOrDelMSVBAStorage( sal_True
, EXC_STORAGE_VBA_PROJECT
);
82 if( nErr
!= ERRCODE_NONE
)
83 pDocShell
->SetError( nErr
, OUString( OSL_LOG_PREFIX
) );
86 pExcDoc
->ReadDoc(); // ScDoc -> ExcDoc
87 pExcDoc
->Write( aOut
); // wechstreamen
89 if( pDocShell
&& xRootStrg
.Is() )
91 // #i88642# update doc info (revision etc)
92 pDocShell
->UpdateDocInfoForSave();
94 using namespace ::com::sun::star
;
95 uno::Reference
<document::XDocumentPropertiesSupplier
> xDPS(
96 pDocShell
->GetModel(), uno::UNO_QUERY_THROW
);
97 uno::Reference
<document::XDocumentProperties
> xDocProps
98 = xDPS
->getDocumentProperties();
99 if ( SvtFilterOptions::Get().IsEnableCalcPreview() )
101 ::boost::shared_ptr
<GDIMetaFile
> pMetaFile
=
102 pDocShell
->GetPreviewMetaFile (false);
103 uno::Sequence
<sal_uInt8
> metaFile(
104 sfx2::convertMetaFile(pMetaFile
.get()));
105 sfx2::SaveOlePropertySet(xDocProps
, xRootStrg
, &metaFile
);
108 sfx2::SaveOlePropertySet(xDocProps
, xRootStrg
);
111 const XclExpAddressConverter
& rAddrConv
= GetAddressConverter();
112 if( rAddrConv
.IsRowTruncated() )
113 return SCWARN_EXPORT_MAXROW
;
114 if( rAddrConv
.IsColTruncated() )
115 return SCWARN_EXPORT_MAXCOL
;
116 if( rAddrConv
.IsTabTruncated() )
117 return SCWARN_EXPORT_MAXTAB
;
124 ExportBiff8::ExportBiff8( XclExpRootData
& rExpData
, SvStream
& rStrm
) :
125 ExportBiff5( rExpData
, rStrm
)
127 pExcRoot
->eDateiTyp
= Biff8
;
131 ExportBiff8::~ExportBiff8()
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */