LCOV - code coverage report
Current view: top level - filter/source/msfilter - svxmsbas2.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 10 29 34.5 %
Date: 2014-11-03 Functions: 4 5 80.0 %
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 <svx/svxerr.hxx>
      25             : #include <filter/msfilter/svxmsbas.hxx>
      26             : 
      27             : using namespace com::sun::star;
      28             : 
      29          26 : sal_uLong SvxImportMSVBasic::SaveOrDelMSVBAStorage( bool bSaveInto,
      30             :                                                 const OUString& rStorageName )
      31             : {
      32          26 :     sal_uLong nRet = ERRCODE_NONE;
      33          26 :     uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
      34          52 :     OUString aDstStgName( GetMSBasicStorageName() );
      35             :     SotStorageRef xVBAStg( SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName,
      36          52 :                                 STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYALL ) );
      37          26 :     if( xVBAStg.Is() && !xVBAStg->GetError() )
      38             :     {
      39           0 :         xVBAStg = 0;
      40           0 :         if( bSaveInto )
      41             :         {
      42             : #if HAVE_FEATURE_SCRIPTING
      43           0 :             BasicManager *pBasicMan = rDocSh.GetBasicManager();
      44           0 :             if( pBasicMan && pBasicMan->IsBasicModified() )
      45           0 :                 nRet = ERRCODE_SVX_MODIFIED_VBASIC_STORAGE;
      46             : #endif
      47           0 :             SotStorageRef xSrc = SotStorage::OpenOLEStorage( xSrcRoot, aDstStgName, STREAM_STD_READ );
      48           0 :             SotStorageRef xDst = xRoot->OpenSotStorage( rStorageName, STREAM_READWRITE | STREAM_TRUNC );
      49           0 :             xSrc->CopyTo( xDst );
      50           0 :             xDst->Commit();
      51           0 :             ErrCode nError = xDst->GetError();
      52           0 :             if ( nError == ERRCODE_NONE )
      53           0 :                 nError = xSrc->GetError();
      54           0 :             if ( nError != ERRCODE_NONE )
      55           0 :                 xRoot->SetError( nError );
      56             :         }
      57             :     }
      58             : 
      59          52 :     return nRet;
      60             : }
      61             : 
      62             : // check if the MS-VBA-Storage exists in the RootStorage of the DocShell.
      63             : // If it exists, then return the WarningId for losing the information.
      64           0 : sal_uLong SvxImportMSVBasic::GetSaveWarningOfMSVBAStorage( SfxObjectShell &rDocSh)
      65             : {
      66           0 :     uno::Reference < embed::XStorage > xSrcRoot( rDocSh.GetStorage() );
      67             :     SvStorageRef xVBAStg( SotStorage::OpenOLEStorage( xSrcRoot, GetMSBasicStorageName(),
      68           0 :                     STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYALL ));
      69           0 :     return ( xVBAStg.Is() && !xVBAStg->GetError() )
      70             :                     ? ERRCODE_SVX_VBASIC_STORAGE_EXIST
      71           0 :                     : ERRCODE_NONE;
      72             : }
      73             : 
      74          26 : OUString SvxImportMSVBasic::GetMSBasicStorageName()
      75             : {
      76          26 :     return OUString( "_MS_VBA_Macros" );
      77         570 : }
      78             : 
      79             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10