LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pppoptimizer.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 40 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "pppoptimizer.hxx"
      22             : #include "impoptimizer.hxx"
      23             : #include <osl/file.hxx>
      24             : 
      25             : using namespace ::rtl;
      26             : using namespace ::com::sun::star::uno;
      27             : using namespace ::com::sun::star::util;
      28             : using namespace ::com::sun::star::lang;
      29             : using namespace ::com::sun::star::frame;
      30             : using namespace ::com::sun::star::beans;
      31             : 
      32             : 
      33             : // - PPPOptimizer -
      34             : 
      35             : 
      36           0 : PPPOptimizer::PPPOptimizer(
      37             :     css::uno::Reference<css::uno::XComponentContext> const & xContext,
      38             :     css::uno::Reference< css::frame::XFrame > const & xFrame):
      39             :     mxContext( xContext ),
      40           0 :     mxController( xFrame->getController() )
      41             : {
      42           0 : }
      43             : 
      44             : 
      45             : 
      46           0 : PPPOptimizer::~PPPOptimizer()
      47             : {
      48           0 : }
      49             : 
      50             : 
      51             : // XDispatchProvider
      52             : 
      53             : 
      54           0 : Reference< com::sun::star::frame::XDispatch > SAL_CALL PPPOptimizer::queryDispatch(
      55             :     const URL& aURL, const OUString& /* aTargetFrameName */, sal_Int32 /* nSearchFlags */ ) throw( RuntimeException, std::exception )
      56             : {
      57           0 :     Reference < XDispatch > xRet;
      58           0 :     if ( aURL.Protocol.equalsAscii( "vnd.com.sun.star.comp.PPPOptimizer:" ) )
      59             :     {
      60             : //      if ( aURL.Path.equalsAscii( "Function1" ) )
      61           0 :         xRet = this;
      62             :     }
      63           0 :     return xRet;
      64             : }
      65             : 
      66             : 
      67             : 
      68           0 : Sequence< Reference< com::sun::star::frame::XDispatch > > SAL_CALL PPPOptimizer::queryDispatches(
      69             :     const Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( RuntimeException, std::exception )
      70             : {
      71           0 :     Sequence< Reference< com::sun::star::frame::XDispatch> > aReturn( aDescripts.getLength() );
      72           0 :     Reference< com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray();
      73           0 :     const com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
      74           0 :     for (sal_Int16 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
      75             :     {
      76           0 :         *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
      77             :     }
      78           0 :     return aReturn;
      79             : }
      80             : 
      81             : 
      82             : // XDispatch
      83             : 
      84             : 
      85           0 : void SAL_CALL PPPOptimizer::dispatch( const URL& rURL, const Sequence< PropertyValue >& lArguments )
      86             :     throw( RuntimeException, std::exception )
      87             : {
      88           0 :     if ( mxController.is() && rURL.Protocol.equalsAscii( "vnd.com.sun.star.comp.PPPOptimizer:" ) )
      89             :     {
      90           0 :         if ( rURL.Path.equalsAscii( "optimize" ) )
      91             :         {
      92           0 :             Reference< XModel > xModel( mxController->getModel() );
      93           0 :             if ( xModel.is() )
      94             :             {
      95             :                 try
      96             :                 {
      97           0 :                     ImpOptimizer aOptimizer( mxContext, xModel );
      98           0 :                     aOptimizer.Optimize( lArguments );
      99             :                 }
     100           0 :                 catch( Exception& )
     101             :                 {
     102             :                 }
     103           0 :             }
     104             :         }
     105             :     }
     106           0 : }
     107             : 
     108             : 
     109           0 : void SAL_CALL PPPOptimizer::addStatusListener( const Reference< XStatusListener >&, const URL& )
     110             :     throw( RuntimeException, std::exception )
     111             : {
     112             :     // TODO
     113             :     OSL_FAIL( "PPPOptimizer::addStatusListener()\nNot implemented yet!" );
     114           0 : }
     115             : 
     116             : 
     117           0 : void SAL_CALL PPPOptimizer::removeStatusListener( const Reference< XStatusListener >&, const URL& )
     118             :     throw( RuntimeException, std::exception )
     119             : {
     120             :     // TODO
     121             :     OSL_FAIL( "PPPOptimizer::removeStatusListener()\nNot implemented yet!" );
     122           0 : }
     123             : 
     124             : 
     125             : // returning filesize, on error zero is returned
     126           0 : sal_Int64 PPPOptimizer::GetFileSize( const OUString& rURL )
     127             : {
     128           0 :     sal_Int64 nFileSize = 0;
     129           0 :     osl::DirectoryItem aItem;
     130           0 :     if ( osl::DirectoryItem::get( rURL, aItem ) == osl::FileBase::E_None )
     131             :     {
     132           0 :         osl::FileStatus aStatus( osl_FileStatus_Mask_FileSize );
     133           0 :         if ( aItem.getFileStatus( aStatus ) == osl::FileBase::E_None )
     134             :         {
     135           0 :             nFileSize = aStatus.getFileSize();
     136           0 :         }
     137             :     }
     138           0 :     return nFileSize;
     139             : }
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10