LCOV - code coverage report
Current view: top level - sdext/source/minimizer - pppoptimizerdialog.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-08-25 Functions: 0 15 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            :  /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "pppoptimizerdialog.hxx"
      31                 :            : #include "optimizerdialog.hxx"
      32                 :            : 
      33                 :            : using namespace ::rtl;
      34                 :            : using namespace ::com::sun::star::uno;
      35                 :            : using namespace ::com::sun::star::util;
      36                 :            : using namespace ::com::sun::star::lang;
      37                 :            : using namespace ::com::sun::star::frame;
      38                 :            : using namespace ::com::sun::star::beans;
      39                 :            : 
      40                 :            : #define SERVICE_NAME "com.sun.star.comp.SunPresentationMinimizer"
      41                 :            : #include <rtl/ustrbuf.hxx>
      42                 :            : 
      43                 :            : // ----------------------
      44                 :            : // - PPPOptimizerDialog -
      45                 :            : // ----------------------
      46                 :            : 
      47                 :          0 : PPPOptimizerDialog::PPPOptimizerDialog( const Reference< XComponentContext > &rxMSF ) :
      48                 :            :     mxMSF( rxMSF ),
      49                 :          0 :     mpOptimizerDialog( NULL )
      50                 :            : {
      51                 :          0 : }
      52                 :            : 
      53                 :            : // -----------------------------------------------------------------------------
      54                 :            : 
      55                 :          0 : PPPOptimizerDialog::~PPPOptimizerDialog()
      56                 :            : {
      57                 :          0 : }
      58                 :            : 
      59                 :            : // -----------------------------------------------------------------------------
      60                 :            : // XInitialization
      61                 :            : // -----------------------------------------------------------------------------
      62                 :            : 
      63                 :          0 : void SAL_CALL PPPOptimizerDialog::initialize( const Sequence< Any >& aArguments )
      64                 :            :     throw ( Exception, RuntimeException )
      65                 :            : {
      66                 :          0 :     if( aArguments.getLength() != 1 )
      67                 :          0 :         throw IllegalArgumentException();
      68                 :            : 
      69                 :          0 :     aArguments[ 0 ] >>= mxFrame;
      70                 :          0 :     if ( mxFrame.is() )
      71                 :          0 :         mxController = mxFrame->getController();
      72                 :          0 : }
      73                 :            : 
      74                 :            : // -----------------------------------------------------------------------------
      75                 :            : // XServiceInfo
      76                 :            : // -----------------------------------------------------------------------------
      77                 :            : 
      78                 :          0 : OUString SAL_CALL PPPOptimizerDialog::getImplementationName()
      79                 :            :     throw (RuntimeException)
      80                 :            : {
      81                 :          0 :     return PPPOptimizerDialog_getImplementationName();
      82                 :            : }
      83                 :            : 
      84                 :          0 : sal_Bool SAL_CALL PPPOptimizerDialog::supportsService( const OUString& ServiceName )
      85                 :            :     throw ( RuntimeException )
      86                 :            : {
      87                 :          0 :     return ServiceName == SERVICE_NAME;
      88                 :            : }
      89                 :            : 
      90                 :          0 : Sequence< OUString > SAL_CALL PPPOptimizerDialog::getSupportedServiceNames()
      91                 :            :     throw (RuntimeException)
      92                 :            : {
      93                 :          0 :     return PPPOptimizerDialog_getSupportedServiceNames();
      94                 :            : }
      95                 :            : 
      96                 :            : // -----------------------------------------------------------------------------
      97                 :            : // XDispatchProvider
      98                 :            : // -----------------------------------------------------------------------------
      99                 :            : 
     100                 :          0 : Reference< com::sun::star::frame::XDispatch > SAL_CALL PPPOptimizerDialog::queryDispatch(
     101                 :            :     const URL& aURL, const ::rtl::OUString& /* aTargetFrameName */, sal_Int32 /* nSearchFlags */ ) throw( RuntimeException )
     102                 :            : {
     103                 :          0 :     Reference < XDispatch > xRet;
     104                 :          0 :     if ( aURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) == 0 )
     105                 :          0 :         xRet = this;
     106                 :            : 
     107                 :          0 :     return xRet;
     108                 :            : }
     109                 :            : 
     110                 :            : //------------------------------------------------------------------------------
     111                 :            : 
     112                 :          0 : Sequence< Reference< com::sun::star::frame::XDispatch > > SAL_CALL PPPOptimizerDialog::queryDispatches(
     113                 :            :     const Sequence< com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw( RuntimeException )
     114                 :            : {
     115                 :          0 :     Sequence< Reference< com::sun::star::frame::XDispatch> > aReturn( aDescripts.getLength() );
     116                 :          0 :     Reference< com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray();
     117                 :          0 :     const com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
     118                 :          0 :     for (sal_Int16 i = 0; i < aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
     119                 :            :     {
     120                 :          0 :         *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
     121                 :            :     }
     122                 :          0 :     return aReturn;
     123                 :            : }
     124                 :            : 
     125                 :            : // -----------------------------------------------------------------------------
     126                 :            : // XDispatch
     127                 :            : // -----------------------------------------------------------------------------
     128                 :            : 
     129                 :          0 : void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL,
     130                 :            :                                             const Sequence< PropertyValue >& rArguments )
     131                 :            :     throw( RuntimeException )
     132                 :            : {
     133                 :            : 
     134                 :          0 :     if ( mxController.is() && ( rURL.Protocol.compareToAscii( "vnd.com.sun.star.comp.SunPresentationMinimizer:" ) == 0 ) )
     135                 :            :     {
     136                 :          0 :         if ( rURL.Path.compareToAscii( "execute" ) == 0 )
     137                 :            :         {
     138                 :            :             try
     139                 :            :             {
     140                 :          0 :                 sal_Int64 nFileSizeSource = 0;
     141                 :          0 :                 sal_Int64 nFileSizeDest = 0;
     142                 :          0 :                 mpOptimizerDialog = new OptimizerDialog( mxMSF, mxFrame, this );
     143                 :          0 :                 mpOptimizerDialog->execute();
     144                 :            : 
     145                 :          0 :                 const Any* pVal( mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeSource ) );
     146                 :          0 :                 if ( pVal )
     147                 :          0 :                     *pVal >>= nFileSizeSource;
     148                 :          0 :                 pVal = mpOptimizerDialog->maStats.GetStatusValue( TK_FileSizeDestination );
     149                 :          0 :                 if ( pVal )
     150                 :          0 :                     *pVal >>= nFileSizeDest;
     151                 :            : 
     152                 :          0 :                 if ( nFileSizeSource && nFileSizeDest )
     153                 :            :                 {
     154                 :          0 :                     rtl::OUStringBuffer sBuf( rtl::OUString("Your Presentation has been minimized from:") );
     155                 :          0 :                     sBuf.append( rtl::OUString::valueOf( nFileSizeSource >> 10 ) );
     156                 :          0 :                     sBuf.append( rtl::OUString("KB to ") );
     157                 :          0 :                     sBuf.append( rtl::OUString::valueOf( nFileSizeDest >> 10 ) );
     158                 :          0 :                     sBuf.append( rtl::OUString("KB.") );
     159                 :          0 :                     OUString sResult( sBuf.makeStringAndClear() );
     160                 :            : //                  mpOptimizerDialog->showMessageBox( sResult, sResult, sal_False );
     161                 :            :                 }
     162                 :          0 :                 delete mpOptimizerDialog, mpOptimizerDialog = NULL;
     163                 :            :             }
     164                 :          0 :             catch( ... )
     165                 :            :             {
     166                 :            : 
     167                 :            :             }
     168                 :            :         }
     169                 :          0 :         else if ( rURL.Path.compareToAscii( "statusupdate" ) == 0 )
     170                 :            :         {
     171                 :          0 :             if ( mpOptimizerDialog )
     172                 :          0 :                 mpOptimizerDialog->UpdateStatus( rArguments );
     173                 :            :         }
     174                 :            :     }
     175                 :          0 : }
     176                 :            : 
     177                 :            : //===============================================
     178                 :          0 : void SAL_CALL PPPOptimizerDialog::addStatusListener( const Reference< XStatusListener >&, const URL& )
     179                 :            :     throw( RuntimeException )
     180                 :            : {
     181                 :            :     // TODO
     182                 :            :     // OSL_FAIL( "PPPOptimizerDialog::addStatusListener()\nNot implemented yet!" );
     183                 :          0 : }
     184                 :            : 
     185                 :            : //===============================================
     186                 :          0 : void SAL_CALL PPPOptimizerDialog::removeStatusListener( const Reference< XStatusListener >&, const URL& )
     187                 :            :     throw( RuntimeException )
     188                 :            : {
     189                 :            :     // TODO
     190                 :            :     // OSL_FAIL( "PPPOptimizerDialog::removeStatusListener()\nNot implemented yet!" );
     191                 :          0 : }
     192                 :            : 
     193                 :            : // -----------------------------------------------------------------------------
     194                 :            : 
     195                 :          0 : OUString PPPOptimizerDialog_getImplementationName()
     196                 :            : {
     197                 :          0 :     return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.SunPresentationMinimizerImp" ) );
     198                 :            : }
     199                 :            : 
     200                 :          0 : Sequence< OUString > PPPOptimizerDialog_getSupportedServiceNames()
     201                 :            : {
     202                 :          0 :     Sequence < OUString > aRet(1);
     203                 :          0 :     OUString* pArray = aRet.getArray();
     204                 :          0 :     pArray[0] =  OUString ( SERVICE_NAME  );
     205                 :          0 :     return aRet;
     206                 :            : }
     207                 :            : 
     208                 :          0 : Reference< XInterface > PPPOptimizerDialog_createInstance( const Reference< XComponentContext > & rSMgr)
     209                 :            :     throw( Exception )
     210                 :            : {
     211                 :          0 :     return (cppu::OWeakObject*) new PPPOptimizerDialog( rSMgr );
     212                 :            : }
     213                 :            : 
     214                 :            : // -----------------------------------------------------------------------------
     215                 :            : 
     216                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10