LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pppoptimizerdialog.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 70 0.0 %
Date: 2014-04-14 Functions: 0 15 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 "pppoptimizerdialog.hxx"
      22             : #include "optimizerdialog.hxx"
      23             : 
      24             : using namespace ::rtl;
      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             : #define SERVICE_NAME "com.sun.star.comp.PresentationMinimizer"
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <rtl/ustrbuf.hxx>
      34             : 
      35           0 : PPPOptimizerDialog::PPPOptimizerDialog( const Reference< XComponentContext > &xContext ) :
      36             :     mxContext( xContext ),
      37           0 :     mpOptimizerDialog( NULL )
      38             : {
      39           0 : }
      40             : 
      41           0 : PPPOptimizerDialog::~PPPOptimizerDialog()
      42             : {
      43           0 : }
      44             : 
      45           0 : void SAL_CALL PPPOptimizerDialog::initialize( const Sequence< Any >& aArguments )
      46             :     throw ( Exception, RuntimeException, std::exception )
      47             : {
      48           0 :     if( aArguments.getLength() != 1 )
      49           0 :         throw IllegalArgumentException();
      50             : 
      51           0 :     aArguments[ 0 ] >>= mxFrame;
      52           0 :     if ( mxFrame.is() )
      53           0 :         mxController = mxFrame->getController();
      54           0 : }
      55             : 
      56           0 : OUString SAL_CALL PPPOptimizerDialog::getImplementationName()
      57             :     throw (RuntimeException, std::exception)
      58             : {
      59           0 :     return PPPOptimizerDialog_getImplementationName();
      60             : }
      61             : 
      62           0 : sal_Bool SAL_CALL PPPOptimizerDialog::supportsService( const OUString& ServiceName )
      63             :     throw ( RuntimeException, std::exception )
      64             : {
      65           0 :     return cppu::supportsService(this, ServiceName);
      66             : }
      67             : 
      68           0 : Sequence< OUString > SAL_CALL PPPOptimizerDialog::getSupportedServiceNames()
      69             :     throw (RuntimeException, std::exception)
      70             : {
      71           0 :     return PPPOptimizerDialog_getSupportedServiceNames();
      72             : }
      73             : 
      74           0 : Reference< com::sun::star::frame::XDispatch > SAL_CALL PPPOptimizerDialog::queryDispatch(
      75             :     const URL& aURL, const OUString& /* aTargetFrameName */, sal_Int32 /* nSearchFlags */ ) throw( RuntimeException, std::exception )
      76             : {
      77           0 :     Reference < XDispatch > xRet;
      78           0 :     if ( aURL.Protocol.equalsAscii( "vnd.com.sun.star.comp.PresentationMinimizer:" ) )
      79           0 :         xRet = this;
      80             : 
      81           0 :     return xRet;
      82             : }
      83             : 
      84           0 : Sequence< Reference< com::sun::star::frame::XDispatch > > SAL_CALL PPPOptimizerDialog::queryDispatches(
      85             :     const Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( RuntimeException, std::exception )
      86             : {
      87           0 :     Sequence< Reference< com::sun::star::frame::XDispatch> > aReturn( aDescripts.getLength() );
      88           0 :     Reference< com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray();
      89           0 :     const com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
      90           0 :     for (sal_Int16 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
      91             :     {
      92           0 :         *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
      93             :     }
      94           0 :     return aReturn;
      95             : }
      96             : 
      97           0 : void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL,
      98             :                                             const Sequence< PropertyValue >& rArguments )
      99             :     throw( RuntimeException, std::exception )
     100             : {
     101             : 
     102           0 :     if ( mxController.is() && rURL.Protocol.equalsAscii( "vnd.com.sun.star.comp.PresentationMinimizer:" ) )
     103             :     {
     104           0 :         if ( rURL.Path.equalsAscii( "execute" ) )
     105             :         {
     106             :             try
     107             :             {
     108           0 :                 sal_Int64 nFileSizeSource = 0;
     109           0 :                 sal_Int64 nFileSizeDest = 0;
     110           0 :                 mpOptimizerDialog = new OptimizerDialog( mxContext, mxFrame, this );
     111           0 :                 mpOptimizerDialog->execute();
     112             : 
     113           0 :                 const Any* pVal( mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeSource ) );
     114           0 :                 if ( pVal )
     115           0 :                     *pVal >>= nFileSizeSource;
     116           0 :                 pVal = mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeDestination );
     117           0 :                 if ( pVal )
     118           0 :                     *pVal >>= nFileSizeDest;
     119             : 
     120           0 :                 if ( nFileSizeSource && nFileSizeDest )
     121             :                 {
     122           0 :                     OUStringBuffer sBuf( "Your Presentation has been minimized from:" );
     123           0 :                     sBuf.append( OUString::number( nFileSizeSource >> 10 ) );
     124           0 :                     sBuf.append( "KB to " );
     125           0 :                     sBuf.append( OUString::number( nFileSizeDest >> 10 ) );
     126           0 :                     sBuf.append( "KB." );
     127           0 :                     OUString sResult( sBuf.makeStringAndClear() );
     128           0 :                     SAL_INFO("sdext.minimizer", sResult );
     129             :                 }
     130           0 :                 delete mpOptimizerDialog, mpOptimizerDialog = NULL;
     131             :             }
     132           0 :             catch( ... )
     133             :             {
     134             : 
     135             :             }
     136             :         }
     137           0 :         else if ( rURL.Path.equalsAscii( "statusupdate" ) )
     138             :         {
     139           0 :             if ( mpOptimizerDialog )
     140           0 :                 mpOptimizerDialog->UpdateStatus( rArguments );
     141             :         }
     142             :     }
     143           0 : }
     144             : 
     145           0 : void SAL_CALL PPPOptimizerDialog::addStatusListener( const Reference< XStatusListener >&, const URL& )
     146             :     throw( RuntimeException, std::exception )
     147             : {
     148             :     // TODO
     149             :     // OSL_FAIL( "PPPOptimizerDialog::addStatusListener()\nNot implemented yet!" );
     150           0 : }
     151             : 
     152           0 : void SAL_CALL PPPOptimizerDialog::removeStatusListener( const Reference< XStatusListener >&, const URL& )
     153             :     throw( RuntimeException, std::exception )
     154             : {
     155             :     // TODO
     156             :     // OSL_FAIL( "PPPOptimizerDialog::removeStatusListener()\nNot implemented yet!" );
     157           0 : }
     158             : 
     159           0 : OUString PPPOptimizerDialog_getImplementationName()
     160             : {
     161           0 :     return OUString( "com.sun.star.comp.PresentationMinimizerImp" );
     162             : }
     163             : 
     164           0 : Sequence< OUString > PPPOptimizerDialog_getSupportedServiceNames()
     165             : {
     166           0 :     Sequence < OUString > aRet(1);
     167           0 :     OUString* pArray = aRet.getArray();
     168           0 :     pArray[0] =  OUString ( SERVICE_NAME  );
     169           0 :     return aRet;
     170             : }
     171             : 
     172           0 : Reference< XInterface > PPPOptimizerDialog_createInstance( const Reference< XComponentContext > & rSMgr)
     173             :     throw( Exception )
     174             : {
     175           0 :     return (cppu::OWeakObject*) new PPPOptimizerDialog( rSMgr );
     176             : }
     177             : 
     178             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10