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

Generated by: LCOV version 1.10