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

Generated by: LCOV version 1.11