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

Generated by: LCOV version 1.10