LCOV - code coverage report
Current view: top level - sdext/source/minimizer - optimizerdialog.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 390 0.0 %
Date: 2014-04-14 Functions: 0 26 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 "optimizerdialog.hxx"
      22             : #include "pppoptimizer.hxx"
      23             : #include "fileopendialog.hxx"
      24             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      25             : #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
      26             : #include <com/sun/star/io/XInputStream.hpp>
      27             : #include <com/sun/star/util/XCloseBroadcaster.hpp>
      28             : #include <com/sun/star/frame/XComponentLoader.hpp>
      29             : #include <com/sun/star/frame/XLayoutManager.hpp>
      30             : #include <sal/macros.h>
      31             : #include <osl/time.h>
      32             : 
      33             : 
      34             : // - OPTIMIZERDIALOG -
      35             : 
      36             : 
      37             : using namespace ::rtl;
      38             : using namespace ::com::sun::star::io;
      39             : using namespace ::com::sun::star::ui;
      40             : using namespace ::com::sun::star::awt;
      41             : using namespace ::com::sun::star::ucb;
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::util;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::com::sun::star::frame;
      46             : using namespace ::com::sun::star::beans;
      47             : using namespace ::com::sun::star::script;
      48             : using namespace ::com::sun::star::container;
      49             : 
      50             : 
      51             : 
      52             : 
      53           0 : void OptimizerDialog::InitDialog()
      54             : {
      55             :    // setting the dialog properties
      56             :     OUString pNames[] = {
      57             :         OUString("Closeable"),
      58             :         OUString("Height"),
      59             :         OUString("Moveable"),
      60             :         OUString("PositionX"),
      61             :         OUString("PositionY"),
      62             :         OUString("Title"),
      63           0 :         OUString("Width") };
      64             : 
      65             :     Any pValues[] = {
      66             :         Any( sal_True ),
      67             :         Any( sal_Int32( DIALOG_HEIGHT ) ),
      68             :         Any( sal_True ),
      69             :         Any( sal_Int32( 200 ) ),
      70             :         Any( sal_Int32( 52 ) ),
      71             :         Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ),
      72           0 :         Any( sal_Int32( OD_DIALOG_WIDTH ) ) };
      73             : 
      74           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
      75             : 
      76           0 :     Sequence< OUString >   aNames( pNames, nCount );
      77           0 :     Sequence< Any >             aValues( pValues, nCount );
      78             : 
      79           0 :     mxDialogModelMultiPropertySet->setPropertyValues( aNames, aValues );
      80           0 : }
      81             : 
      82             : 
      83             : 
      84           0 : void OptimizerDialog::InitRoadmap()
      85             : {
      86             :     try
      87             :     {
      88             :         OUString pNames[] = {
      89             :             OUString("Height"),
      90             :             OUString("PositionX"),
      91             :             OUString("PositionY"),
      92             :             OUString("Step"),
      93             :             OUString("TabIndex"),
      94           0 :             OUString("Width") };
      95             : 
      96             :         Any pValues[] = {
      97             :             Any( sal_Int32( DIALOG_HEIGHT - 26 ) ),
      98             :             Any( sal_Int32( 0 ) ),
      99             :             Any( sal_Int32( 0 ) ),
     100             :             Any( sal_Int32( 0 ) ),
     101             :             Any( mnTabIndex++ ),
     102           0 :             Any( sal_Int32( 85 ) ) };
     103             : 
     104           0 :         sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     105             : 
     106           0 :         Sequence< OUString >   aNames( pNames, nCount );
     107           0 :         Sequence< Any >        aValues( pValues, nCount );
     108             : 
     109           0 :         mxRoadmapControlModel = insertControlModel( OUString( "com.sun.star.awt.UnoControlRoadmapModel"  ),
     110           0 :                                                               "rdmNavi", aNames, aValues  );
     111             : 
     112           0 :         Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW );
     113           0 :         xPropertySet->setPropertyValue( "Name", Any( OUString("rdmNavi") ) );
     114           0 :         mxRoadmapControl = mxDialog->getControl( "rdmNavi" );
     115           0 :         InsertRoadmapItem( 0, sal_True, getString( STR_INTRODUCTION ), ITEM_ID_INTRODUCTION );
     116           0 :         InsertRoadmapItem( 1, sal_True, getString( STR_SLIDES ), ITEM_ID_SLIDES );
     117           0 :         InsertRoadmapItem( 2, sal_True, getString( STR_IMAGE_OPTIMIZATION ), ITEM_ID_GRAPHIC_OPTIMIZATION );
     118           0 :         InsertRoadmapItem( 3, sal_True, getString( STR_OLE_OBJECTS ), ITEM_ID_OLE_OPTIMIZATION );
     119           0 :         InsertRoadmapItem( 4, sal_True, getString( STR_SUMMARY ), ITEM_ID_SUMMARY );
     120             : 
     121             :         // Well, that's messy, but the
     122             :         // BMP_PRESENTATION_MINIMIZER from sd module cannot be used here directly
     123             :         // that UNO wizard dialog should be converted to ui
     124           0 :         OUString sURL( "private:graphicrepository/sd/res/minimize_presi_80.png" );
     125             : 
     126           0 :         xPropertySet->setPropertyValue( "ImageURL", Any( sURL ) );
     127           0 :         xPropertySet->setPropertyValue( "Activated", Any( (sal_Bool)sal_True ) );
     128           0 :         xPropertySet->setPropertyValue( "Complete", Any( (sal_Bool)sal_True ) );
     129           0 :         xPropertySet->setPropertyValue( "CurrentItemID", Any( (sal_Int16)ITEM_ID_INTRODUCTION ) );
     130           0 :         xPropertySet->setPropertyValue( "Text", Any( getString( STR_STEPS ) ) );
     131             :     }
     132           0 :     catch( Exception& )
     133             :     {
     134             :     }
     135           0 : }
     136             : 
     137             : 
     138             : 
     139           0 : void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const sal_Bool bEnabled, const OUString& rLabel, const sal_Int32 nItemID )
     140             : {
     141             :     try
     142             :     {
     143           0 :         Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
     144           0 :         Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
     145           0 :         Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_QUERY_THROW );
     146           0 :         Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW );
     147           0 :         xPropertySet->setPropertyValue( "Label", Any( rLabel ) );
     148           0 :         xPropertySet->setPropertyValue( "Enabled", Any( bEnabled ) );
     149           0 :         xPropertySet->setPropertyValue( "ID", Any( nItemID ) );
     150           0 :         aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) );
     151             :     }
     152           0 :     catch( Exception& )
     153             :     {
     154             : 
     155             :     }
     156           0 : }
     157             : 
     158             : 
     159             : 
     160           0 : void OptimizerDialog::UpdateConfiguration()
     161             : {
     162           0 :     sal_Int16   nInt16 = 0;
     163           0 :     Any         aAny;
     164             : 
     165           0 :     Sequence< sal_Int16 > aSelectedItems;
     166           0 :     Sequence< OUString > aStringItemList;
     167             : 
     168             :     // page0
     169           0 :     aAny = getControlProperty( "ListBox0Pg0", "SelectedItems" );
     170           0 :     if ( aAny >>= aSelectedItems )
     171             :     {
     172           0 :         if ( aSelectedItems.getLength() )
     173             :         {
     174           0 :             sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
     175           0 :             aAny = getControlProperty( "ListBox0Pg0", "StringItemList" );
     176           0 :             if ( aAny >>= aStringItemList )
     177             :             {
     178           0 :                 if ( aStringItemList.getLength() > nSelectedItem )
     179           0 :                     SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) );
     180             :             }
     181             :         }
     182             :     }
     183             : 
     184           0 :     aAny = getControlProperty( "CheckBox3Pg3", "State" );
     185           0 :     if ( aAny >>= nInt16 )
     186             :     {
     187           0 :         if ( nInt16 )
     188             :         {
     189           0 :             aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" );
     190           0 :             if ( aAny >>= aSelectedItems )
     191             :             {
     192           0 :                 if ( aSelectedItems.getLength() )
     193             :                 {
     194           0 :                     sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
     195           0 :                     aAny = getControlProperty( "ListBox0Pg3", "StringItemList" );
     196           0 :                     if ( aAny >>= aStringItemList )
     197             :                     {
     198           0 :                         if ( aStringItemList.getLength() > nSelectedItem )
     199           0 :                             SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
     200             :                     }
     201             :                 }
     202             :             }
     203             :         }
     204           0 :     }
     205           0 : }
     206             : 
     207             : 
     208             : 
     209           0 : OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame >& rxFrame, Reference< XDispatch > rxStatusDispatcher ) :
     210             :     UnoDialog( rxContext, rxFrame ),
     211             :     ConfigurationAccess( rxContext, NULL ),
     212             :     mnCurrentStep( 0 ),
     213             :     mnTabIndex( 0 ),
     214             :     mxContext( rxContext ),
     215             :     mxFrame( rxFrame ),
     216           0 :     mxItemListener( new ItemListener( *this ) ),
     217           0 :     mxActionListener( new ActionListener( *this ) ),
     218           0 :     mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ),
     219           0 :     mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ),
     220           0 :     mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ),
     221           0 :     mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ),
     222           0 :     mxStatusDispatcher( rxStatusDispatcher )
     223             : {
     224           0 :     Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW );
     225           0 :     mbIsReadonly = xStorable->isReadonly();
     226             : 
     227           0 :     InitDialog();
     228           0 :     InitRoadmap();
     229           0 :     InitNavigationBar();
     230           0 :     InitPage0();
     231           0 :     InitPage1();
     232           0 :     InitPage2();
     233           0 :     InitPage3();
     234           0 :     InitPage4();
     235           0 :     ActivatePage( 0 );
     236             : 
     237           0 :     OptimizationStats aStats;
     238           0 :     aStats.InitializeStatusValuesFromDocument( mxController->getModel() );
     239           0 :     Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() );
     240           0 :     UpdateStatus( aStatusSequence );
     241           0 : }
     242             : 
     243             : 
     244             : 
     245           0 : OptimizerDialog::~OptimizerDialog()
     246             : {
     247             :     // not saving configuration if the dialog has been finished via cancel or close window
     248           0 :     if ( mbStatus )
     249           0 :         SaveConfiguration();
     250           0 : }
     251             : 
     252             : 
     253             : 
     254           0 : sal_Bool OptimizerDialog::execute()
     255             : {
     256           0 :     Reference< XItemEventBroadcaster > maRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW );
     257           0 :     maRoadmapBroadcaster->addItemListener( mxItemListener );
     258           0 :     UnoDialog::execute();
     259           0 :     UpdateConfiguration();          // taking actual control settings for the configuration
     260           0 :     maRoadmapBroadcaster->removeItemListener( mxItemListener );
     261           0 :     return mbStatus;
     262             : }
     263             : 
     264             : 
     265             : 
     266           0 : void OptimizerDialog::SwitchPage( sal_Int16 nNewStep )
     267             : {
     268           0 :     if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 ) )
     269             :     {
     270           0 :         sal_Int16 nOldStep = mnCurrentStep;
     271           0 :         if ( nNewStep == 0 )
     272           0 :             disableControl( "btnNavBack" );
     273           0 :         else if ( nOldStep == 0 )
     274           0 :             enableControl( "btnNavBack" );
     275             : 
     276           0 :         if ( nNewStep == MAX_STEP )
     277           0 :             disableControl( "btnNavNext" );
     278           0 :         else if ( nOldStep == MAX_STEP )
     279           0 :             enableControl( "btnNavNext" );
     280             : 
     281           0 :         setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) );
     282             : 
     283           0 :         DeactivatePage( nOldStep );
     284           0 :         UpdateControlStates( nNewStep );
     285             : 
     286           0 :         ActivatePage( nNewStep );
     287           0 :         mnCurrentStep = nNewStep;
     288             :     }
     289           0 : }
     290             : 
     291           0 : void OptimizerDialog::UpdateControlStates( sal_Int16 nPage )
     292             : {
     293           0 :     switch( nPage )
     294             :     {
     295           0 :         case 0 : UpdateControlStatesPage0(); break;
     296           0 :         case 1 : UpdateControlStatesPage1(); break;
     297           0 :         case 2 : UpdateControlStatesPage2(); break;
     298           0 :         case 3 : UpdateControlStatesPage3(); break;
     299           0 :         case 4 : UpdateControlStatesPage4(); break;
     300             :         default:
     301             :         {
     302           0 :             UpdateControlStatesPage0();
     303           0 :             UpdateControlStatesPage1();
     304           0 :             UpdateControlStatesPage2();
     305           0 :             UpdateControlStatesPage3();
     306           0 :             UpdateControlStatesPage4();
     307             :         }
     308             :     }
     309           0 : }
     310             : 
     311             : 
     312             : 
     313           0 : OUString OptimizerDialog::GetSelectedString( OUString const & token )
     314             : {
     315           0 :     OUString aSelectedItem;
     316           0 :     Sequence< sal_Int16 > sSelectedItems;
     317           0 :     Sequence< OUString >  sItemList;
     318             : 
     319           0 :     if ( ( getControlProperty( token, "SelectedItems" ) >>= sSelectedItems ) &&
     320           0 :             ( getControlProperty( token, "StringItemList" ) >>= sItemList ) )
     321             :     {
     322           0 :         if ( sSelectedItems.getLength() == 1 )
     323             :         {
     324           0 :             sal_Int16 nSelectedItem = sSelectedItems[ 0 ];
     325           0 :             if ( nSelectedItem < sItemList.getLength() )
     326           0 :                 aSelectedItem = sItemList[ nSelectedItem ];
     327             :         }
     328             :     }
     329           0 :     return aSelectedItem;
     330             : }
     331             : 
     332             : 
     333             : 
     334           0 : void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus )
     335             : {
     336           0 :     if ( mxReschedule.is() )
     337             :     {
     338           0 :         maStats.InitializeStatusValues( rStatus );
     339           0 :         const Any* pVal( maStats.GetStatusValue( TK_Status ) );
     340           0 :         if ( pVal )
     341             :         {
     342           0 :             OUString sStatus;
     343           0 :             if ( *pVal >>= sStatus )
     344             :             {
     345           0 :                 setControlProperty( "FixedText1Pg4", "Enabled", Any( sal_True ) );
     346           0 :                 setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) );
     347           0 :             }
     348             :         }
     349           0 :         pVal = maStats.GetStatusValue( TK_Progress );
     350           0 :         if ( pVal )
     351             :         {
     352           0 :             sal_Int32 nProgress = 0;
     353           0 :             if ( *pVal >>= nProgress )
     354           0 :                 setControlProperty( "Progress", "ProgressValue", Any( nProgress ) );
     355             :         }
     356           0 :         pVal = maStats.GetStatusValue( TK_OpenNewDocument );
     357           0 :         if ( pVal )
     358           0 :             SetConfigProperty( TK_OpenNewDocument, *pVal );
     359             : 
     360           0 :         mxReschedule->reschedule();
     361             :     }
     362           0 : }
     363             : 
     364             : 
     365             : 
     366           0 : void ItemListener::itemStateChanged( const ItemEvent& Event )
     367             :     throw ( RuntimeException, std::exception )
     368             : {
     369             :     try
     370             :     {
     371             :         sal_Int16 nState;
     372           0 :         OUString aControlName;
     373           0 :         Reference< XControl > xControl;
     374           0 :         Any aSource( Event.Source );
     375           0 :         if ( aSource >>= xControl )
     376             :         {
     377           0 :             Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW );
     378           0 :             xPropertySet->getPropertyValue( "Name" ) >>= aControlName;
     379           0 :             PPPOptimizerTokenEnum eControl( TKGet( aControlName ) );
     380           0 :             switch( eControl )
     381             :             {
     382             :                 case TK_rdmNavi :
     383             :                 {
     384           0 :                     mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) );
     385             :                 }
     386           0 :                 break;
     387             :                 case TK_CheckBox1Pg1 :
     388             :                 {
     389           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     390           0 :                         mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) );
     391             :                 }
     392           0 :                 break;
     393             :                 case TK_CheckBox2Pg1 :
     394             :                 {
     395           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     396           0 :                         mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) );
     397             :                 }
     398           0 :                 break;
     399             :                 case TK_CheckBox0Pg2 :
     400             :                 {
     401           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     402             :                     {
     403           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) );
     404           0 :                         mrOptimizerDialog.setControlProperty( "RadioButton0Pg2", "Enabled", Any( nState != 0 ) );
     405           0 :                         mrOptimizerDialog.setControlProperty( "RadioButton1Pg2", "Enabled", Any( nState != 0 ) );
     406             :                     }
     407             :                 }
     408           0 :                 break;
     409             :                 case TK_RadioButton0Pg1 :
     410             :                 {
     411           0 :                     sal_Int16 nInt16 = 0;
     412           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
     413             :                     {
     414           0 :                         nInt16 ^= 1;
     415           0 :                         mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) );
     416           0 :                         mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nInt16 != 0 ) );
     417           0 :                         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nInt16 != 0 ) );
     418             :                     }
     419             :                 }
     420           0 :                 break;
     421             :                 case TK_RadioButton1Pg1 :
     422             :                 {
     423           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     424             :                     {
     425           0 :                         mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) );
     426           0 :                         mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nState != 0 ) );
     427           0 :                         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nState != 0 ) );
     428             :                     }
     429             :                 }
     430           0 :                 break;
     431             :                 case TK_RadioButton0Pg2 :
     432             :                 {
     433             :                     sal_Int16 nInt16;
     434           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
     435             :                     {
     436           0 :                         nInt16 ^= 1;
     437           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) );
     438             :                     }
     439             :                 }
     440           0 :                 break;
     441             :                 case TK_RadioButton1Pg2 :
     442             :                 {
     443           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     444           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) );
     445             :                 }
     446           0 :                 break;
     447             :                 case TK_CheckBox0Pg3 :
     448             :                 {
     449           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     450           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) );
     451             :                 }
     452           0 :                 break;
     453             :                 case TK_CheckBox1Pg3 :
     454             :                 {
     455           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     456           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) );
     457             :                 }
     458           0 :                 break;
     459             :                 case TK_CheckBox2Pg3 :
     460             :                 {
     461           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     462           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) );
     463             :                 }
     464           0 :                 break;
     465             :                 case TK_CheckBox3Pg3 :
     466             :                 {
     467           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     468           0 :                         mrOptimizerDialog.setControlProperty( "ListBox0Pg3", "Enabled", Any( nState != 0 ) );
     469             :                 }
     470           0 :                 break;
     471             :                 case TK_CheckBox1Pg4 :
     472             :                 {
     473           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     474           0 :                         mrOptimizerDialog.setControlProperty( "ComboBox0Pg4", "Enabled", Any( nState != 0 ) );
     475             :                 }
     476           0 :                 break;
     477             :                 case TK_RadioButton0Pg4 :
     478             :                 case TK_RadioButton1Pg4 :
     479             :                 {
     480           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     481           0 :                         mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) );
     482             :                 }
     483           0 :                 break;
     484             :                 default:
     485           0 :                 break;
     486           0 :             }
     487           0 :         }
     488             :     }
     489           0 :     catch ( Exception& )
     490             :     {
     491             : 
     492             :     }
     493           0 : }
     494           0 : void ItemListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     495             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     496             : {
     497           0 : }
     498             : 
     499             : 
     500             : 
     501           0 : void ActionListener::actionPerformed( const ActionEvent& rEvent )
     502             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     503             : {
     504           0 :     switch( TKGet( rEvent.ActionCommand ) )
     505             :     {
     506           0 :         case TK_btnNavBack :    mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break;
     507           0 :         case TK_btnNavNext :    mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break;
     508             :         case TK_btnNavFinish :
     509             :         {
     510           0 :             mrOptimizerDialog.UpdateConfiguration();
     511             : 
     512           0 :             mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY );
     513           0 :             mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY );
     514           0 :             mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_False ) );
     515           0 :             mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
     516           0 :             mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_False ) );
     517           0 :             mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_False ) );
     518           0 :             mrOptimizerDialog.setControlProperty( "FixedText0Pg4", "Enabled", Any( sal_True ) );
     519             : 
     520             :             // check if we have to open the FileDialog
     521           0 :             sal_Bool    bSuccessfullyExecuted = sal_True;
     522           0 :             sal_Int16   nInt16 = 0;
     523           0 :             mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) >>= nInt16;
     524           0 :             if ( nInt16 )
     525             :             {
     526           0 :                 OUString aSaveAsURL;
     527           0 :                 FileOpenDialog aFileOpenDialog( mrOptimizerDialog.GetComponentContext() );
     528             : 
     529             :                 // generating default file name
     530           0 :                 Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY );
     531           0 :                 if ( xStorable.is() && xStorable->hasLocation() )
     532             :                 {
     533           0 :                     OUString aLocation( xStorable->getLocation() );
     534           0 :                     if ( !aLocation.isEmpty() )
     535             :                     {
     536           0 :                         sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 );
     537           0 :                         if ( nIndex >= 0 )
     538             :                         {
     539           0 :                             if ( nIndex < aLocation.getLength() - 1 )
     540           0 :                                 aLocation = aLocation.copy( nIndex + 1 );
     541             : 
     542             :                             // remove extension
     543           0 :                             nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 );
     544           0 :                             if ( nIndex >= 0 )
     545           0 :                                 aLocation = aLocation.copy( 0, nIndex );
     546             : 
     547             :                             // adding .mini
     548           0 :                             aLocation = aLocation.concat( OUString(".mini") );
     549           0 :                             aFileOpenDialog.setDefaultName( aLocation );
     550             :                         }
     551           0 :                     }
     552             :                 }
     553           0 :                  sal_Bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK;
     554           0 :                 if ( bDialogExecuted )
     555             :                 {
     556           0 :                     aSaveAsURL = aFileOpenDialog.getURL();
     557           0 :                     mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) );
     558           0 :                     mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) );
     559             :                 }
     560           0 :                 if ( aSaveAsURL.isEmpty() )
     561             :                 {
     562             :                     // something goes wrong...
     563           0 :                     bSuccessfullyExecuted = sal_False;
     564             :                 }
     565             : 
     566             :                 // waiting for 500ms
     567           0 :                 if ( mrOptimizerDialog.mxReschedule.is() )
     568             :                 {
     569           0 :                     mrOptimizerDialog.mxReschedule->reschedule();
     570           0 :                     for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); )
     571           0 :                     mrOptimizerDialog.mxReschedule->reschedule();
     572           0 :                 }
     573             :             }
     574           0 :             if ( bSuccessfullyExecuted )
     575             :             {   // now check if we have to store a session template
     576           0 :                 nInt16 = 0;
     577           0 :                 OUString aSettingsName;
     578           0 :                 mrOptimizerDialog.getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
     579           0 :                 mrOptimizerDialog.getControlProperty( "ComboBox0Pg4", "Text" ) >>= aSettingsName;
     580           0 :                 if ( nInt16 && !aSettingsName.isEmpty() )
     581             :                 {
     582           0 :                     std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) );
     583           0 :                     std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() );
     584           0 :                     OptimizerSettings aNewSettings( rSettings[ 0 ] );
     585           0 :                     aNewSettings.maName = aSettingsName;
     586           0 :                     if ( aIter == rSettings.end() )
     587           0 :                         rSettings.push_back( aNewSettings );
     588             :                     else
     589           0 :                         *aIter = aNewSettings;
     590           0 :                 }
     591             :             }
     592           0 :             if ( bSuccessfullyExecuted )
     593             :             {
     594             :                 Reference < XDispatch > xDispatch(
     595             :                     new PPPOptimizer(
     596           0 :                         mrOptimizerDialog.GetComponentContext(),
     597           0 :                         mrOptimizerDialog.GetFrame()));
     598             : 
     599           0 :                 URL aURL;
     600           0 :                 aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
     601           0 :                 aURL.Path = "optimize";
     602             : 
     603           0 :                 Sequence< PropertyValue > lArguments( 3 );
     604           0 :                 lArguments[ 0 ].Name = "Settings";
     605           0 :                 lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence();
     606           0 :                 lArguments[ 1 ].Name = "StatusDispatcher";
     607           0 :                 lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher();
     608           0 :                 lArguments[ 2 ].Name = "InformationDialog";
     609           0 :                 lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
     610             : 
     611           0 :                 xDispatch->dispatch( aURL, lArguments );
     612             : 
     613           0 :                 mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
     614             :             }
     615             :             else
     616             :             {
     617           0 :                 mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_True ) );
     618           0 :                 mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
     619           0 :                 mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_True ) );
     620           0 :                 mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_True ) );
     621           0 :                 mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY );
     622             :             }
     623             :         }
     624           0 :         break;
     625           0 :         case TK_btnNavCancel :  mrOptimizerDialog.endExecute( sal_False ); break;
     626             :         case TK_Button0Pg0 :    // delete configuration
     627             :         {
     628           0 :             OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( "ListBox0Pg0" ) );
     629           0 :             if ( !aSelectedItem.isEmpty() )
     630             :             {
     631           0 :                 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) );
     632           0 :                 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
     633           0 :                 if ( aIter != rList.end() )
     634             :                 {
     635           0 :                     rList.erase( aIter );
     636           0 :                     mrOptimizerDialog.UpdateControlStates();
     637             :                 }
     638           0 :             }
     639             :         }
     640           0 :         break;
     641           0 :         default: break;
     642             :     }
     643           0 : }
     644           0 : void ActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     645             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     646             : {
     647           0 : }
     648             : 
     649             : 
     650             : 
     651           0 : void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent )
     652             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     653             : {
     654           0 :     if ( !rEvent.ActionCommand.isEmpty() )
     655             :     {
     656           0 :         std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) );
     657           0 :         std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
     658           0 :         if ( aIter != rList.end() )
     659           0 :             rList[ 0 ] = *aIter;
     660             :     }
     661           0 :     mrOptimizerDialog.UpdateControlStates();
     662           0 : }
     663           0 : void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     664             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     665             : {
     666           0 : }
     667             : 
     668             : 
     669             : 
     670           0 : void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ )
     671             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     672             : {
     673           0 :     double fDouble = 0;
     674           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     675           0 :     if ( aAny >>= fDouble )
     676           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     677           0 : }
     678           0 : void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     679             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     680             : {
     681           0 : }
     682             : 
     683             : 
     684             : 
     685           0 : void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
     686             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     687             : {
     688           0 :     OUString aString;
     689           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" );
     690           0 :     if ( aAny >>= aString )
     691             :     {
     692             :         sal_Int32 nI0, nI1, nI2, nI3, nI4;
     693           0 :         nI0 = nI1 = nI2 = nI3 = nI4 = 0;
     694             : 
     695           0 :         if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString )
     696           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 );
     697           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString )
     698           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 );
     699           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString )
     700           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 );
     701           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString )
     702           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 );
     703             : 
     704           0 :         mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) );
     705           0 :     }
     706           0 : }
     707           0 : void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     708             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     709             : {
     710           0 : }
     711             : 
     712             : 
     713             : 
     714           0 : void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ )
     715             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     716             : {
     717             :     double fDouble;
     718           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     719           0 :     if ( aAny >>= fDouble )
     720             :     {
     721           0 :         fDouble += 9;
     722           0 :         if ( fDouble > 100 )
     723           0 :             fDouble = 100;
     724           0 :         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
     725           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     726           0 :     }
     727           0 : }
     728           0 : void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ )
     729             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     730             : {
     731             :     double fDouble;
     732           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     733           0 :     if ( aAny >>= fDouble )
     734             :     {
     735           0 :         fDouble -= 9;
     736           0 :         if ( fDouble < 0 )
     737           0 :             fDouble = 0;
     738           0 :         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
     739           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     740           0 :     }
     741           0 : }
     742           0 : void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ )
     743             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     744             : {
     745           0 :     mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 0 ) ) );
     746           0 :     mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)0 ) );
     747           0 : }
     748           0 : void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ )
     749             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     750             : {
     751           0 :     mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 100 ) ) );
     752           0 :     mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)100 ) );
     753           0 : }
     754           0 : void SpinListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     755             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     756             : {
     757           0 : }
     758             : 
     759             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10