LibreOffice Module filter (master) 1
svxmsbas2.cxx
Go to the documentation of this file.
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 <config_features.h>
21
22#include <basic/basmgr.hxx>
23#include <sfx2/objsh.hxx>
24#include <sot/storage.hxx>
25#include <svx/svxerr.hxx>
27
28using namespace com::sun::star;
29
31 const OUString& rStorageName )
32{
33 ErrCode nRet = ERRCODE_NONE;
34 uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
35 OUString aDstStgName( GetMSBasicStorageName() );
36 tools::SvRef<SotStorage> xVBAStg( SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName,
37 StreamMode::READWRITE | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ) );
38 if( xVBAStg.is() && !xVBAStg->GetError() )
39 {
40 xVBAStg = nullptr;
41 if( bSaveInto )
42 {
43#if HAVE_FEATURE_SCRIPTING
44 BasicManager *pBasicMan = rDocSh.GetBasicManager();
45 if( pBasicMan && pBasicMan->IsBasicModified() )
47#endif
48 tools::SvRef<SotStorage> xSrc = SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName, StreamMode::STD_READ );
49 tools::SvRef<SotStorage> xDst = xRoot->OpenSotStorage( rStorageName, StreamMode::READWRITE | StreamMode::TRUNC );
50 xSrc->CopyTo( xDst.get() );
51 xDst->Commit();
52 ErrCode nError = xDst->GetError();
53 if ( nError == ERRCODE_NONE )
54 nError = xSrc->GetError();
55 if ( nError != ERRCODE_NONE )
56 xRoot->SetError( nError );
57 }
58 }
59
60 return nRet;
61}
62
63// check if the MS-VBA-Storage exists in the RootStorage of the DocShell.
64// If it exists, then return the WarningId for losing the information.
66{
67 uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
69 StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ));
70 return ( xVBAStg.is() && !xVBAStg->GetError() )
73}
74
76{
77 return "_MS_VBA_Macros";
78}
79
80/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsBasicModified() const
BasicManager * GetBasicManager() const
css::uno::Reference< css::embed::XStorage > const & GetStorage()
static SotStorage * OpenOLEStorage(css::uno::Reference< css::embed::XStorage > const &xStorage, OUString const &rEleName, StreamMode=StreamMode::STD_READWRITE)
tools::SvRef< SotStorage > xRoot
Definition: svxmsbas.hxx:67
ErrCode SaveOrDelMSVBAStorage(bool bSaveInto, const OUString &rStorageName)
Definition: svxmsbas2.cxx:30
SfxObjectShell & rDocSh
Definition: svxmsbas.hxx:68
static OUString GetMSBasicStorageName()
Definition: svxmsbas2.cxx:75
static ErrCode GetSaveWarningOfMSVBAStorage(SfxObjectShell &rDocS)
Definition: svxmsbas2.cxx:65
T * get() const
bool is() const
#define ERRCODE_NONE
Shape IDs per cluster in DGG atom.
#define ERRCODE_SVX_MODIFIED_VBASIC_STORAGE
#define ERRCODE_SVX_VBASIC_STORAGE_EXIST