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

Generated by: LCOV version 1.11