LCOV - code coverage report
Current view: top level - filter/source/msfilter - svxmsbas2.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 9 28 32.1 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          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 <config_features.h>
      21             : 
      22             : #include <basic/basmgr.hxx>
      23             : #include <sfx2/objsh.hxx>
      24             : #include <sot/storage.hxx>
      25             : #include <svx/svxerr.hxx>
      26             : #include <filter/msfilter/svxmsbas.hxx>
      27             : 
      28             : using namespace com::sun::star;
      29             : 
      30          20 : sal_uLong SvxImportMSVBasic::SaveOrDelMSVBAStorage( bool bSaveInto,
      31             :                                                 const OUString& rStorageName )
      32             : {
      33          20 :     sal_uLong nRet = ERRCODE_NONE;
      34          20 :     uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
      35          40 :     OUString aDstStgName( GetMSBasicStorageName() );
      36             :     tools::SvRef<SotStorage> xVBAStg( SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName,
      37          40 :                                 STREAM_READWRITE | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ) );
      38          20 :     if( xVBAStg.Is() && !xVBAStg->GetError() )
      39             :     {
      40           0 :         xVBAStg = 0;
      41           0 :         if( bSaveInto )
      42             :         {
      43             : #if HAVE_FEATURE_SCRIPTING
      44           0 :             BasicManager *pBasicMan = rDocSh.GetBasicManager();
      45           0 :             if( pBasicMan && pBasicMan->IsBasicModified() )
      46           0 :                 nRet = ERRCODE_SVX_MODIFIED_VBASIC_STORAGE;
      47             : #endif
      48           0 :             tools::SvRef<SotStorage> xSrc = SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName, STREAM_STD_READ );
      49           0 :             tools::SvRef<SotStorage> xDst = xRoot->OpenSotStorage( rStorageName, STREAM_READWRITE | StreamMode::TRUNC );
      50           0 :             xSrc->CopyTo( xDst );
      51           0 :             xDst->Commit();
      52           0 :             ErrCode nError = xDst->GetError();
      53           0 :             if ( nError == ERRCODE_NONE )
      54           0 :                 nError = xSrc->GetError();
      55           0 :             if ( nError != ERRCODE_NONE )
      56           0 :                 xRoot->SetError( nError );
      57             :         }
      58             :     }
      59             : 
      60          40 :     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.
      65           0 : sal_uLong SvxImportMSVBasic::GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocSh)
      66             : {
      67           0 :     uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
      68             :     tools::SvRef<SotStorage> xVBAStg( SotStorage::OpenOLEStorage( xSrcRoot, GetMSBasicStorageName(),
      69           0 :                     StreamMode::READ | StreamMode::NOCREATE | StreamMode::SHARE_DENYALL ));
      70           0 :     return ( xVBAStg.Is() && !xVBAStg->GetError() )
      71             :                     ? ERRCODE_SVX_VBASIC_STORAGE_EXIST
      72           0 :                     : ERRCODE_NONE;
      73             : }
      74             : 
      75          20 : OUString SvxImportMSVBasic::GetMSBasicStorageName()
      76             : {
      77          20 :     return OUString( "_MS_VBA_Macros" );
      78             : }
      79             : 
      80             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11