LCOV - code coverage report
Current view: top level - sdext/source/minimizer - optimizerdialog.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 390 0.0 %
Date: 2014-11-03 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             :     mxContext( rxContext ),
     214             :     mxFrame( rxFrame ),
     215           0 :     mxItemListener( new ItemListener( *this ) ),
     216           0 :     mxActionListener( new ActionListener( *this ) ),
     217           0 :     mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ),
     218           0 :     mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ),
     219           0 :     mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ),
     220           0 :     mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ),
     221           0 :     mxStatusDispatcher( rxStatusDispatcher )
     222             : {
     223           0 :     Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW );
     224           0 :     mbIsReadonly = xStorable->isReadonly();
     225             : 
     226           0 :     InitDialog();
     227           0 :     InitRoadmap();
     228           0 :     InitNavigationBar();
     229           0 :     InitPage0();
     230           0 :     InitPage1();
     231           0 :     InitPage2();
     232           0 :     InitPage3();
     233           0 :     InitPage4();
     234           0 :     ActivatePage( 0 );
     235             : 
     236           0 :     OptimizationStats aStats;
     237           0 :     aStats.InitializeStatusValuesFromDocument( mxController->getModel() );
     238           0 :     Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() );
     239           0 :     UpdateStatus( aStatusSequence );
     240           0 : }
     241             : 
     242             : 
     243             : 
     244           0 : OptimizerDialog::~OptimizerDialog()
     245             : {
     246             :     // not saving configuration if the dialog has been finished via cancel or close window
     247           0 :     if ( mbStatus )
     248           0 :         SaveConfiguration();
     249           0 : }
     250             : 
     251             : 
     252             : 
     253           0 : bool OptimizerDialog::execute()
     254             : {
     255           0 :     Reference< XItemEventBroadcaster > maRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW );
     256           0 :     maRoadmapBroadcaster->addItemListener( mxItemListener );
     257           0 :     UnoDialog::execute();
     258           0 :     UpdateConfiguration();          // taking actual control settings for the configuration
     259           0 :     maRoadmapBroadcaster->removeItemListener( mxItemListener );
     260           0 :     return mbStatus;
     261             : }
     262             : 
     263             : 
     264             : 
     265           0 : void OptimizerDialog::SwitchPage( sal_Int16 nNewStep )
     266             : {
     267           0 :     if ( ( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 ) )
     268             :     {
     269           0 :         sal_Int16 nOldStep = mnCurrentStep;
     270           0 :         if ( nNewStep == 0 )
     271           0 :             disableControl( "btnNavBack" );
     272           0 :         else if ( nOldStep == 0 )
     273           0 :             enableControl( "btnNavBack" );
     274             : 
     275           0 :         if ( nNewStep == MAX_STEP )
     276           0 :             disableControl( "btnNavNext" );
     277           0 :         else if ( nOldStep == MAX_STEP )
     278           0 :             enableControl( "btnNavNext" );
     279             : 
     280           0 :         setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) );
     281             : 
     282           0 :         DeactivatePage( nOldStep );
     283           0 :         UpdateControlStates( nNewStep );
     284             : 
     285           0 :         ActivatePage( nNewStep );
     286           0 :         mnCurrentStep = nNewStep;
     287             :     }
     288           0 : }
     289             : 
     290           0 : void OptimizerDialog::UpdateControlStates( sal_Int16 nPage )
     291             : {
     292           0 :     switch( nPage )
     293             :     {
     294           0 :         case 0 : UpdateControlStatesPage0(); break;
     295           0 :         case 1 : UpdateControlStatesPage1(); break;
     296           0 :         case 2 : UpdateControlStatesPage2(); break;
     297           0 :         case 3 : UpdateControlStatesPage3(); break;
     298           0 :         case 4 : UpdateControlStatesPage4(); break;
     299             :         default:
     300             :         {
     301           0 :             UpdateControlStatesPage0();
     302           0 :             UpdateControlStatesPage1();
     303           0 :             UpdateControlStatesPage2();
     304           0 :             UpdateControlStatesPage3();
     305           0 :             UpdateControlStatesPage4();
     306             :         }
     307             :     }
     308           0 : }
     309             : 
     310             : 
     311             : 
     312           0 : OUString OptimizerDialog::GetSelectedString( OUString const & token )
     313             : {
     314           0 :     OUString aSelectedItem;
     315           0 :     Sequence< sal_Int16 > sSelectedItems;
     316           0 :     Sequence< OUString >  sItemList;
     317             : 
     318           0 :     if ( ( getControlProperty( token, "SelectedItems" ) >>= sSelectedItems ) &&
     319           0 :             ( getControlProperty( token, "StringItemList" ) >>= sItemList ) )
     320             :     {
     321           0 :         if ( sSelectedItems.getLength() == 1 )
     322             :         {
     323           0 :             sal_Int16 nSelectedItem = sSelectedItems[ 0 ];
     324           0 :             if ( nSelectedItem < sItemList.getLength() )
     325           0 :                 aSelectedItem = sItemList[ nSelectedItem ];
     326             :         }
     327             :     }
     328           0 :     return aSelectedItem;
     329             : }
     330             : 
     331             : 
     332             : 
     333           0 : void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rStatus )
     334             : {
     335           0 :     if ( mxReschedule.is() )
     336             :     {
     337           0 :         maStats.InitializeStatusValues( rStatus );
     338           0 :         const Any* pVal( maStats.GetStatusValue( TK_Status ) );
     339           0 :         if ( pVal )
     340             :         {
     341           0 :             OUString sStatus;
     342           0 :             if ( *pVal >>= sStatus )
     343             :             {
     344           0 :                 setControlProperty( "FixedText1Pg4", "Enabled", Any( sal_True ) );
     345           0 :                 setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) );
     346           0 :             }
     347             :         }
     348           0 :         pVal = maStats.GetStatusValue( TK_Progress );
     349           0 :         if ( pVal )
     350             :         {
     351           0 :             sal_Int32 nProgress = 0;
     352           0 :             if ( *pVal >>= nProgress )
     353           0 :                 setControlProperty( "Progress", "ProgressValue", Any( nProgress ) );
     354             :         }
     355           0 :         pVal = maStats.GetStatusValue( TK_OpenNewDocument );
     356           0 :         if ( pVal )
     357           0 :             SetConfigProperty( TK_OpenNewDocument, *pVal );
     358             : 
     359           0 :         mxReschedule->reschedule();
     360             :     }
     361           0 : }
     362             : 
     363             : 
     364             : 
     365           0 : void ItemListener::itemStateChanged( const ItemEvent& Event )
     366             :     throw ( RuntimeException, std::exception )
     367             : {
     368             :     try
     369             :     {
     370             :         sal_Int16 nState;
     371           0 :         OUString aControlName;
     372           0 :         Reference< XControl > xControl;
     373           0 :         Any aSource( Event.Source );
     374           0 :         if ( aSource >>= xControl )
     375             :         {
     376           0 :             Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW );
     377           0 :             xPropertySet->getPropertyValue( "Name" ) >>= aControlName;
     378           0 :             PPPOptimizerTokenEnum eControl( TKGet( aControlName ) );
     379           0 :             switch( eControl )
     380             :             {
     381             :                 case TK_rdmNavi :
     382             :                 {
     383           0 :                     mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) );
     384             :                 }
     385           0 :                 break;
     386             :                 case TK_CheckBox1Pg1 :
     387             :                 {
     388           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     389           0 :                         mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) );
     390             :                 }
     391           0 :                 break;
     392             :                 case TK_CheckBox2Pg1 :
     393             :                 {
     394           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     395           0 :                         mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) );
     396             :                 }
     397           0 :                 break;
     398             :                 case TK_CheckBox0Pg2 :
     399             :                 {
     400           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     401             :                     {
     402           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) );
     403           0 :                         mrOptimizerDialog.setControlProperty( "RadioButton0Pg2", "Enabled", Any( nState != 0 ) );
     404           0 :                         mrOptimizerDialog.setControlProperty( "RadioButton1Pg2", "Enabled", Any( nState != 0 ) );
     405             :                     }
     406             :                 }
     407           0 :                 break;
     408             :                 case TK_RadioButton0Pg1 :
     409             :                 {
     410           0 :                     sal_Int16 nInt16 = 0;
     411           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
     412             :                     {
     413           0 :                         nInt16 ^= 1;
     414           0 :                         mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) );
     415           0 :                         mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nInt16 != 0 ) );
     416           0 :                         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nInt16 != 0 ) );
     417             :                     }
     418             :                 }
     419           0 :                 break;
     420             :                 case TK_RadioButton1Pg1 :
     421             :                 {
     422           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     423             :                     {
     424           0 :                         mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) );
     425           0 :                         mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nState != 0 ) );
     426           0 :                         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nState != 0 ) );
     427             :                     }
     428             :                 }
     429           0 :                 break;
     430             :                 case TK_RadioButton0Pg2 :
     431             :                 {
     432             :                     sal_Int16 nInt16;
     433           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
     434             :                     {
     435           0 :                         nInt16 ^= 1;
     436           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) );
     437             :                     }
     438             :                 }
     439           0 :                 break;
     440             :                 case TK_RadioButton1Pg2 :
     441             :                 {
     442           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     443           0 :                         mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) );
     444             :                 }
     445           0 :                 break;
     446             :                 case TK_CheckBox0Pg3 :
     447             :                 {
     448           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     449           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) );
     450             :                 }
     451           0 :                 break;
     452             :                 case TK_CheckBox1Pg3 :
     453             :                 {
     454           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     455           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) );
     456             :                 }
     457           0 :                 break;
     458             :                 case TK_CheckBox2Pg3 :
     459             :                 {
     460           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     461           0 :                         mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) );
     462             :                 }
     463           0 :                 break;
     464             :                 case TK_CheckBox3Pg3 :
     465             :                 {
     466           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     467           0 :                         mrOptimizerDialog.setControlProperty( "ListBox0Pg3", "Enabled", Any( nState != 0 ) );
     468             :                 }
     469           0 :                 break;
     470             :                 case TK_CheckBox1Pg4 :
     471             :                 {
     472           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     473           0 :                         mrOptimizerDialog.setControlProperty( "ComboBox0Pg4", "Enabled", Any( nState != 0 ) );
     474             :                 }
     475           0 :                 break;
     476             :                 case TK_RadioButton0Pg4 :
     477             :                 case TK_RadioButton1Pg4 :
     478             :                 {
     479           0 :                     if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
     480           0 :                         mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) );
     481             :                 }
     482           0 :                 break;
     483             :                 default:
     484           0 :                 break;
     485           0 :             }
     486           0 :         }
     487             :     }
     488           0 :     catch ( Exception& )
     489             :     {
     490             : 
     491             :     }
     492           0 : }
     493           0 : void ItemListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     494             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     495             : {
     496           0 : }
     497             : 
     498             : 
     499             : 
     500           0 : void ActionListener::actionPerformed( const ActionEvent& rEvent )
     501             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     502             : {
     503           0 :     switch( TKGet( rEvent.ActionCommand ) )
     504             :     {
     505           0 :         case TK_btnNavBack :    mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break;
     506           0 :         case TK_btnNavNext :    mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break;
     507             :         case TK_btnNavFinish :
     508             :         {
     509           0 :             mrOptimizerDialog.UpdateConfiguration();
     510             : 
     511           0 :             mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY );
     512           0 :             mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY );
     513           0 :             mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_False ) );
     514           0 :             mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
     515           0 :             mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_False ) );
     516           0 :             mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_False ) );
     517           0 :             mrOptimizerDialog.setControlProperty( "FixedText0Pg4", "Enabled", Any( sal_True ) );
     518             : 
     519             :             // check if we have to open the FileDialog
     520           0 :             bool    bSuccessfullyExecuted = true;
     521           0 :             sal_Int16   nInt16 = 0;
     522           0 :             mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) >>= nInt16;
     523           0 :             if ( nInt16 )
     524             :             {
     525           0 :                 OUString aSaveAsURL;
     526           0 :                 FileOpenDialog aFileOpenDialog( mrOptimizerDialog.GetComponentContext() );
     527             : 
     528             :                 // generating default file name
     529           0 :                 Reference< XStorable > xStorable( mrOptimizerDialog.mxController->getModel(), UNO_QUERY );
     530           0 :                 if ( xStorable.is() && xStorable->hasLocation() )
     531             :                 {
     532           0 :                     OUString aLocation( xStorable->getLocation() );
     533           0 :                     if ( !aLocation.isEmpty() )
     534             :                     {
     535           0 :                         sal_Int32 nIndex = aLocation.lastIndexOf( '/', aLocation.getLength() - 1 );
     536           0 :                         if ( nIndex >= 0 )
     537             :                         {
     538           0 :                             if ( nIndex < aLocation.getLength() - 1 )
     539           0 :                                 aLocation = aLocation.copy( nIndex + 1 );
     540             : 
     541             :                             // remove extension
     542           0 :                             nIndex = aLocation.lastIndexOf( '.', aLocation.getLength() - 1 );
     543           0 :                             if ( nIndex >= 0 )
     544           0 :                                 aLocation = aLocation.copy( 0, nIndex );
     545             : 
     546             :                             // adding .mini
     547           0 :                             aLocation = aLocation.concat( OUString(".mini") );
     548           0 :                             aFileOpenDialog.setDefaultName( aLocation );
     549             :                         }
     550           0 :                     }
     551             :                 }
     552           0 :                  bool bDialogExecuted = aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK;
     553           0 :                 if ( bDialogExecuted )
     554             :                 {
     555           0 :                     aSaveAsURL = aFileOpenDialog.getURL();
     556           0 :                     mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) );
     557           0 :                     mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) );
     558             :                 }
     559           0 :                 if ( aSaveAsURL.isEmpty() )
     560             :                 {
     561             :                     // something goes wrong...
     562           0 :                     bSuccessfullyExecuted = false;
     563             :                 }
     564             : 
     565             :                 // waiting for 500ms
     566           0 :                 if ( mrOptimizerDialog.mxReschedule.is() )
     567             :                 {
     568           0 :                     mrOptimizerDialog.mxReschedule->reschedule();
     569           0 :                     for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); )
     570           0 :                     mrOptimizerDialog.mxReschedule->reschedule();
     571           0 :                 }
     572             :             }
     573           0 :             if ( bSuccessfullyExecuted )
     574             :             {   // now check if we have to store a session template
     575           0 :                 nInt16 = 0;
     576           0 :                 OUString aSettingsName;
     577           0 :                 mrOptimizerDialog.getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
     578           0 :                 mrOptimizerDialog.getControlProperty( "ComboBox0Pg4", "Text" ) >>= aSettingsName;
     579           0 :                 if ( nInt16 && !aSettingsName.isEmpty() )
     580             :                 {
     581           0 :                     std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) );
     582           0 :                     std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() );
     583           0 :                     OptimizerSettings aNewSettings( rSettings[ 0 ] );
     584           0 :                     aNewSettings.maName = aSettingsName;
     585           0 :                     if ( aIter == rSettings.end() )
     586           0 :                         rSettings.push_back( aNewSettings );
     587             :                     else
     588           0 :                         *aIter = aNewSettings;
     589           0 :                 }
     590             :             }
     591           0 :             if ( bSuccessfullyExecuted )
     592             :             {
     593             :                 Reference < XDispatch > xDispatch(
     594             :                     new PPPOptimizer(
     595           0 :                         mrOptimizerDialog.GetComponentContext(),
     596           0 :                         mrOptimizerDialog.GetFrame()));
     597             : 
     598           0 :                 URL aURL;
     599           0 :                 aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
     600           0 :                 aURL.Path = "optimize";
     601             : 
     602           0 :                 Sequence< PropertyValue > lArguments( 3 );
     603           0 :                 lArguments[ 0 ].Name = "Settings";
     604           0 :                 lArguments[ 0 ].Value <<= mrOptimizerDialog.GetConfigurationSequence();
     605           0 :                 lArguments[ 1 ].Name = "StatusDispatcher";
     606           0 :                 lArguments[ 1 ].Value <<= mrOptimizerDialog.GetStatusDispatcher();
     607           0 :                 lArguments[ 2 ].Name = "InformationDialog";
     608           0 :                 lArguments[ 2 ].Value <<= mrOptimizerDialog.GetFrame();
     609             : 
     610           0 :                 xDispatch->dispatch( aURL, lArguments );
     611             : 
     612           0 :                 mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
     613             :             }
     614             :             else
     615             :             {
     616           0 :                 mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( sal_True ) );
     617           0 :                 mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( sal_False ) );
     618           0 :                 mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( sal_True ) );
     619           0 :                 mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( sal_True ) );
     620           0 :                 mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY );
     621             :             }
     622             :         }
     623           0 :         break;
     624           0 :         case TK_btnNavCancel :  mrOptimizerDialog.endExecute( false ); break;
     625             :         case TK_Button0Pg0 :    // delete configuration
     626             :         {
     627           0 :             OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( "ListBox0Pg0" ) );
     628           0 :             if ( !aSelectedItem.isEmpty() )
     629             :             {
     630           0 :                 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) );
     631           0 :                 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
     632           0 :                 if ( aIter != rList.end() )
     633             :                 {
     634           0 :                     rList.erase( aIter );
     635           0 :                     mrOptimizerDialog.UpdateControlStates();
     636             :                 }
     637           0 :             }
     638             :         }
     639           0 :         break;
     640           0 :         default: break;
     641             :     }
     642           0 : }
     643           0 : void ActionListener::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     644             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     645             : {
     646           0 : }
     647             : 
     648             : 
     649             : 
     650           0 : void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent )
     651             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     652             : {
     653           0 :     if ( !rEvent.ActionCommand.isEmpty() )
     654             :     {
     655           0 :         std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) );
     656           0 :         std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
     657           0 :         if ( aIter != rList.end() )
     658           0 :             rList[ 0 ] = *aIter;
     659             :     }
     660           0 :     mrOptimizerDialog.UpdateControlStates();
     661           0 : }
     662           0 : void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     663             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     664             : {
     665           0 : }
     666             : 
     667             : 
     668             : 
     669           0 : void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ )
     670             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     671             : {
     672           0 :     double fDouble = 0;
     673           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     674           0 :     if ( aAny >>= fDouble )
     675           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     676           0 : }
     677           0 : void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     678             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     679             : {
     680           0 : }
     681             : 
     682             : 
     683             : 
     684           0 : void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
     685             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     686             : {
     687           0 :     OUString aString;
     688           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" );
     689           0 :     if ( aAny >>= aString )
     690             :     {
     691             :         sal_Int32 nI0, nI1, nI2, nI3, nI4;
     692           0 :         nI0 = nI1 = nI2 = nI3 = nI4 = 0;
     693             : 
     694           0 :         if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 ) == aString )
     695           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI4 );
     696           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 ) == aString )
     697           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI4 );
     698           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 ) == aString )
     699           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI4 );
     700           0 :         else if ( mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 ) == aString )
     701           0 :             aString = mrOptimizerDialog.getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI4 );
     702             : 
     703           0 :         mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) );
     704           0 :     }
     705           0 : }
     706           0 : void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     707             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     708             : {
     709           0 : }
     710             : 
     711             : 
     712             : 
     713           0 : void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ )
     714             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     715             : {
     716             :     double fDouble;
     717           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     718           0 :     if ( aAny >>= fDouble )
     719             :     {
     720           0 :         fDouble += 9;
     721           0 :         if ( fDouble > 100 )
     722           0 :             fDouble = 100;
     723           0 :         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
     724           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     725           0 :     }
     726           0 : }
     727           0 : void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ )
     728             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     729             : {
     730             :     double fDouble;
     731           0 :     Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
     732           0 :     if ( aAny >>= fDouble )
     733             :     {
     734           0 :         fDouble -= 9;
     735           0 :         if ( fDouble < 0 )
     736           0 :             fDouble = 0;
     737           0 :         mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
     738           0 :         mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)fDouble ) );
     739           0 :     }
     740           0 : }
     741           0 : void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ )
     742             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     743             : {
     744           0 :     mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 0 ) ) );
     745           0 :     mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)0 ) );
     746           0 : }
     747           0 : void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ )
     748             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     749             : {
     750           0 :     mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 100 ) ) );
     751           0 :     mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( (sal_Int32)100 ) );
     752           0 : }
     753           0 : void SpinListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject& /* Source */ )
     754             :     throw ( com::sun::star::uno::RuntimeException, std::exception )
     755             : {
     756           0 : }
     757             : 
     758             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10