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

Generated by: LCOV version 1.10