LCOV - code coverage report
Current view: top level - sdext/source/minimizer - optimizerdialogcontrols.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 490 0.0 %
Date: 2014-11-03 Functions: 0 25 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             : 
      23             : 
      24             : // - OptimizerDialog -
      25             : 
      26             : #include "pppoptimizer.hxx"
      27             : #include "graphiccollector.hxx"
      28             : #include "pagecollector.hxx"
      29             : #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
      30             : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      31             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      32             : #include <com/sun/star/awt/FontDescriptor.hpp>
      33             : #include <com/sun/star/awt/FontWeight.hpp>
      34             : #include <rtl/ustrbuf.hxx>
      35             : #include <sal/macros.h>
      36             : 
      37             : using namespace ::com::sun::star::awt;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::util;
      40             : using namespace ::com::sun::star::lang;
      41             : using namespace ::com::sun::star::frame;
      42             : using namespace ::com::sun::star::beans;
      43             : using namespace ::com::sun::star::script;
      44             : using namespace ::com::sun::star::drawing;
      45             : using namespace ::com::sun::star::container;
      46             : using namespace ::com::sun::star::presentation;
      47             : 
      48             : 
      49             : 
      50           0 : void SetBold( OptimizerDialog& rOptimizerDialog, const OUString& rControl )
      51             : {
      52           0 :     FontDescriptor aFontDescriptor;
      53           0 :     if ( rOptimizerDialog.getControlProperty( rControl, "FontDescriptor" ) >>= aFontDescriptor )
      54             :     {
      55           0 :         aFontDescriptor.Weight = FontWeight::BOLD;
      56           0 :         rOptimizerDialog.setControlProperty( rControl, "FontDescriptor", Any( aFontDescriptor ) );
      57           0 :     }
      58           0 : }
      59             : 
      60             : 
      61             : 
      62           0 : OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation,
      63             :                         sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight )
      64             : {
      65             :     OUString pNames[] = {
      66             :         OUString("Height"),
      67             :         OUString("Orientation"),
      68             :         OUString("PositionX"),
      69             :         OUString("PositionY"),
      70             :         OUString("Step"),
      71           0 :         OUString("Width") };
      72             : 
      73             :     Any pValues[] = {
      74             :         Any( nHeight ),
      75             :         Any( nOrientation ),
      76             :         Any( nPosX ),
      77             :         Any( nPosY ),
      78             :         Any( sal_Int16( 0 ) ),
      79           0 :         Any( nWidth ) };
      80             : 
      81           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
      82             : 
      83           0 :     Sequence< OUString >   aNames( pNames, nCount );
      84           0 :     Sequence< Any >             aValues( pValues, nCount );
      85             : 
      86             :     rOptimizerDialog.insertControlModel( OUString( "com.sun.star.awt.UnoControlFixedLineModel"  ),
      87           0 :         rControlName, aNames, aValues );
      88           0 :     return rControlName;
      89             : }
      90             : 
      91             : 
      92             : 
      93           0 : OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener >& xActionListener,
      94             :     sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex, bool bEnabled, PPPOptimizerTokenEnum nResID, sal_Int16 nPushButtonType )
      95             : {
      96             :     OUString pNames[] = {
      97             :         OUString("Enabled"),
      98             :         OUString("Height"),
      99             :         OUString("Label"),
     100             :         OUString("PositionX"),
     101             :         OUString("PositionY"),
     102             :         OUString("PushButtonType"),
     103             :         OUString("Step"),
     104             :         OUString("TabIndex"),
     105           0 :         OUString("Width") };
     106             : 
     107             :     Any pValues[] = {
     108             :         Any( bEnabled  ),
     109             :         Any( nHeight ),
     110             :         Any( rOptimizerDialog.getString( nResID ) ),
     111             :         Any( nXPos ),
     112             :         Any( nYPos ),
     113             :         Any( nPushButtonType ),
     114             :         Any( (sal_Int16)0 ),
     115             :         Any( nTabIndex ),
     116           0 :         Any( nWidth ) };
     117             : 
     118             : 
     119           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     120             : 
     121           0 :     Sequence< OUString >   aNames( pNames, nCount );
     122           0 :     Sequence< Any >             aValues( pValues, nCount );
     123             : 
     124           0 :     rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues );
     125           0 :     return rControlName;
     126             : }
     127             : 
     128             : 
     129             : 
     130           0 : OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const OUString& rLabel,
     131             :                                 sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, bool bBold, sal_Int16 nTabIndex )
     132             : {
     133             :     OUString pNames[] = {
     134             :         OUString("Height"),
     135             :         OUString("Label"),
     136             :         OUString("MultiLine"),
     137             :         OUString("PositionX"),
     138             :         OUString("PositionY"),
     139             :         OUString("Step"),
     140             :         OUString("TabIndex"),
     141           0 :         OUString("Width") };
     142             : 
     143             :     Any pValues[] = {
     144             :         Any( nHeight ),
     145             :         Any( rLabel ),
     146             :         Any( bMultiLine ),
     147             :         Any( nXPos ),
     148             :         Any( nYPos ),
     149             :         Any( (sal_Int16)0 ),
     150             :         Any( nTabIndex ),
     151           0 :         Any( nWidth ) };
     152             : 
     153           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     154             : 
     155           0 :     Sequence< OUString >   aNames( pNames, nCount );
     156           0 :     Sequence< Any >             aValues( pValues, nCount );
     157             : 
     158           0 :     rOptimizerDialog.insertFixedText( rControlName, aNames, aValues );
     159           0 :     if ( bBold )
     160           0 :         SetBold( rOptimizerDialog, rControlName );
     161           0 :     return rControlName;
     162             : }
     163             : 
     164             : 
     165             : 
     166           0 : OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
     167             :     const Reference< XItemListener > xItemListener, const OUString& rLabel,
     168             :         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
     169             : {
     170             :     OUString pNames[] = {
     171             :         OUString("Enabled"),
     172             :         OUString("Height"),
     173             :         OUString("Label"),
     174             :         OUString("PositionX"),
     175             :         OUString("PositionY"),
     176             :         OUString("Step"),
     177             :         OUString("TabIndex"),
     178           0 :         OUString("Width") };
     179             : 
     180             :     Any pValues[] = {
     181             :         Any( true ),
     182             :         Any( nHeight ),
     183             :         Any( rLabel ),
     184             :         Any( nXPos ),
     185             :         Any( nYPos ),
     186             :         Any( (sal_Int16)0 ),
     187             :         Any( nTabIndex ),
     188           0 :         Any( nWidth ) };
     189             : 
     190           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     191             : 
     192           0 :     Sequence< OUString >   aNames( pNames, nCount );
     193           0 :     Sequence< Any >             aValues( pValues, nCount );
     194             : 
     195           0 :     Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) );
     196           0 :     if ( xItemListener.is() )
     197           0 :         xCheckBox->addItemListener( xItemListener );
     198           0 :     return rControlName;
     199             : }
     200             : 
     201             : 
     202             : 
     203           0 : OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
     204             :         const Reference< XTextListener > xTextListener, const Reference< XSpinListener > xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth,
     205             :             double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex )
     206             : {
     207             :     OUString pNames[] = {
     208             :         OUString("EffectiveMax"),
     209             :         OUString("EffectiveMin"),
     210             :         OUString("Enabled"),
     211             :         OUString("Height"),
     212             :         OUString("PositionX"),
     213             :         OUString("PositionY"),
     214             :         OUString("Repeat"),
     215             :         OUString("Spin"),
     216             :         OUString("Step"),
     217             :         OUString("TabIndex"),
     218           0 :         OUString("Width") };
     219             : 
     220             :     Any pValues[] = {
     221             :         Any( fEffectiveMax ),
     222             :         Any( fEffectiveMin ),
     223             :         Any( true ),
     224             :         Any( (sal_Int32)12 ),
     225             :         Any( nXPos ),
     226             :         Any( nYPos ),
     227             :         Any( true ),
     228             :         Any( true ),
     229             :         Any( (sal_Int16)0 ),
     230             :         Any( nTabIndex ),
     231           0 :         Any( nWidth ) };
     232             : 
     233           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     234             : 
     235           0 :     Sequence< OUString >   aNames( pNames, nCount );
     236           0 :     Sequence< Any >             aValues( pValues, nCount );
     237             : 
     238           0 :     Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW );
     239           0 :     if ( xTextListener.is() )
     240           0 :         xTextComponent->addTextListener( xTextListener );
     241           0 :     if ( xSpinListener.is() )
     242             :     {
     243           0 :         Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW );
     244           0 :         xSpinField->addSpinListener( xSpinListener );
     245             :     }
     246           0 :     return rControlName;
     247             : }
     248             : 
     249             : 
     250             : 
     251           0 : OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
     252             :     const Reference< XTextListener > xTextListener, const bool bEnabled, const Sequence< OUString >& rItemList,
     253             :         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
     254             : {
     255             :     OUString pNames[] = {
     256             :         OUString("Dropdown"),
     257             :         OUString("Enabled"),
     258             :         OUString("Height"),
     259             :         OUString("LineCount"),
     260             :         OUString("PositionX"),
     261             :         OUString("PositionY"),
     262             :         OUString("Step"),
     263             :         OUString("StringItemList"),
     264             :         OUString("TabIndex"),
     265           0 :         OUString("Width") };
     266             : 
     267             :     Any pValues[] = {
     268             :         Any( true ),
     269             :         Any( bEnabled ),
     270             :         Any( nHeight ),
     271             :         Any( (sal_Int16)8),
     272             :         Any( nXPos ),
     273             :         Any( nYPos ),
     274             :         Any( (sal_Int16)0 ),
     275             :         Any( rItemList ),
     276             :         Any( nTabIndex ),
     277           0 :         Any( nWidth ) };
     278             : 
     279           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     280             : 
     281           0 :     Sequence< OUString >   aNames( pNames, nCount );
     282           0 :     Sequence< Any >             aValues( pValues, nCount );
     283             : 
     284           0 :     Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW );
     285           0 :     if ( xTextListener.is() )
     286           0 :         xTextComponent->addTextListener( xTextListener );
     287           0 :     return rControlName;
     288             : }
     289             : 
     290             : 
     291             : 
     292           0 : OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const Reference< XItemListener > xItemListener,
     293             :     const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, sal_Int16 nTabIndex )
     294             : {
     295             :     OUString pNames[] = {
     296             :         OUString("Height"),
     297             :         OUString("Label"),
     298             :         OUString("MultiLine"),
     299             :         OUString("PositionX"),
     300             :         OUString("PositionY"),
     301             :         OUString("Step"),
     302             :         OUString("TabIndex"),
     303           0 :         OUString("Width") };
     304             : 
     305             :     Any pValues[] = {
     306             :         Any( nHeight ),
     307             :         Any( rLabel ),
     308             :         Any( bMultiLine ),
     309             :         Any( nXPos ),
     310             :         Any( nYPos ),
     311             :         Any( (sal_Int16)0 ),
     312             :         Any( nTabIndex ),
     313           0 :         Any( nWidth ) };
     314             : 
     315           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     316             : 
     317           0 :     Sequence< OUString >   aNames( pNames, nCount );
     318           0 :     Sequence< Any >             aValues( pValues, nCount );
     319             : 
     320           0 :     Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) );
     321           0 :     if ( xItemListener.is() )
     322           0 :         xRadioButton->addItemListener( xItemListener );
     323           0 :     return rControlName;
     324             : }
     325             : 
     326             : 
     327             : 
     328           0 : OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName,
     329             :     const Reference< XActionListener > xActionListener, const bool bEnabled, const Sequence< OUString >& rItemList,
     330             :         sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int16 nTabIndex )
     331             : {
     332             :     OUString pNames[] = {
     333             :         OUString("Dropdown"),
     334             :         OUString("Enabled"),
     335             :         OUString("Height"),
     336             :         OUString("LineCount"),
     337             :         OUString("MultiSelection"),
     338             :         OUString("PositionX"),
     339             :         OUString("PositionY"),
     340             :         OUString("Step"),
     341             :         OUString("StringItemList"),
     342             :         OUString("TabIndex"),
     343           0 :         OUString("Width") };
     344             : 
     345             :     Any pValues[] = {
     346             :         Any( true ),
     347             :         Any( bEnabled ),
     348             :         Any( nHeight ),
     349             :         Any( (sal_Int16)8),
     350             :         Any( false ),
     351             :         Any( nXPos ),
     352             :         Any( nYPos ),
     353             :         Any( (sal_Int16)0 ),
     354             :         Any( rItemList ),
     355             :         Any( nTabIndex ),
     356           0 :         Any( nWidth ) };
     357             : 
     358           0 :     sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     359             : 
     360           0 :     Sequence< OUString >   aNames( pNames, nCount );
     361           0 :     Sequence< Any >             aValues( pValues, nCount );
     362             : 
     363           0 :     Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) );
     364           0 :     if ( xListBox.is() )
     365           0 :         xListBox->addActionListener( xActionListener );
     366           0 :     return rControlName;
     367             : }
     368             : 
     369             : 
     370             : 
     371           0 : void OptimizerDialog::InitNavigationBar()
     372             : {
     373           0 :     sal_Int32   nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6;
     374           0 :     sal_Int32   nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH;
     375           0 :     sal_Int32   nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH;
     376           0 :     sal_Int32   nBackPosX = nNextPosX - 3 - BUTTON_WIDTH;
     377             : 
     378           0 :     InsertSeparator( *this, "lnNavSep1", 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 );
     379           0 :     InsertSeparator( *this, "lnNavSep2", 1, 85, 0, 1, BUTTON_POS_Y - 6 );
     380             : 
     381           0 :     InsertButton( *this, "btnNavBack", mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, false, STR_BACK, PushButtonType_STANDARD );
     382           0 :     InsertButton( *this, "btnNavNext", mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_NEXT, PushButtonType_STANDARD );
     383           0 :     InsertButton( *this, "btnNavFinish", mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_FINISH, PushButtonType_STANDARD );
     384           0 :     InsertButton( *this, "btnNavCancel", mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, BUTTON_HEIGHT, mnTabIndex++, true, STR_CANCEL, PushButtonType_STANDARD );
     385             : 
     386           0 :     setControlProperty( "btnNavNext", "DefaultButton", Any( true ) );
     387           0 : }
     388             : 
     389             : 
     390             : 
     391           0 : void OptimizerDialog::UpdateControlStatesPage0()
     392             : {
     393             :     sal_uInt32 i;
     394           0 :     short nSelectedItem = -1;
     395           0 :     Sequence< OUString > aItemList;
     396           0 :     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
     397           0 :     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
     398             :     {
     399           0 :         aItemList.realloc( rList.size() - 1 );
     400           0 :         for ( i = 1; i < rList.size(); i++ )
     401             :         {
     402           0 :             aItemList[ i - 1 ] = rList[ i ].maName;
     403           0 :             if ( nSelectedItem < 0 )
     404             :             {
     405           0 :                 if ( rList[ i ] == rList[ 0 ] )
     406           0 :                     nSelectedItem = static_cast< short >( i - 1 );
     407             :             }
     408             :         }
     409             :     }
     410           0 :     bool bRemoveButtonEnabled = false;
     411           0 :     Sequence< short > aSelectedItems;
     412           0 :     if ( nSelectedItem >= 0 )
     413             :     {
     414           0 :         aSelectedItems.realloc( 1 );
     415           0 :         aSelectedItems[ 0 ] = nSelectedItem;
     416           0 :         if ( nSelectedItem > 2 )    // only allowing to delete custom themes, the first can|t be deleted
     417           0 :             bRemoveButtonEnabled = true;
     418             :     }
     419           0 :     setControlProperty( "ListBox0Pg0", "StringItemList", Any( aItemList ) );
     420           0 :     setControlProperty( "ListBox0Pg0", "SelectedItems", Any( aSelectedItems ) );
     421           0 :     setControlProperty( "Button0Pg0", "Enabled", Any( bRemoveButtonEnabled ) );
     422           0 : }
     423           0 : void OptimizerDialog::InitPage0()
     424             : {
     425           0 :     Sequence< OUString > aItemList;
     426           0 :     std::vector< OUString > aControlList;
     427           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText0Pg0", getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
     428           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText1Pg0", getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, true, false, mnTabIndex++ ) );
     429           0 :     aControlList.push_back( InsertSeparator( *this, "Separator1Pg0", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ) );
     430           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText2Pg0", getString( STR_CHOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ) );
     431           0 :     aControlList.push_back( InsertListBox(  *this, "ListBox0Pg0", mxActionListenerListBox0Pg0, true, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), 12, mnTabIndex++ ) );
     432           0 :     aControlList.push_back( InsertButton( *this, "Button0Pg0", mxActionListener, OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 40, 14, mnTabIndex++, true, STR_REMOVE, PushButtonType_STANDARD ) );
     433           0 :     maControlPages.push_back( aControlList );
     434           0 :     DeactivatePage( 0 );
     435           0 :     UpdateControlStatesPage0();
     436           0 : }
     437             : 
     438             : 
     439             : 
     440           0 : void OptimizerDialog::UpdateControlStatesPage1()
     441             : {
     442           0 :     bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, false ) );
     443           0 :     bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, false ) );
     444           0 :     bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, false ) );
     445             : 
     446           0 :     setControlProperty( "CheckBox0Pg3", "State", Any( (sal_Int16)bDeleteUnusedMasterPages ) );
     447           0 :     setControlProperty( "CheckBox1Pg3", "State", Any( (sal_Int16)bDeleteNotesPages ) );
     448           0 :     setControlProperty( "CheckBox2Pg3", "State", Any( (sal_Int16)bDeleteHiddenSlides ) );
     449           0 : }
     450           0 : void OptimizerDialog::InitPage1()
     451             : {
     452           0 :     Sequence< OUString > aCustomShowList;
     453           0 :     Reference< XModel > xModel( mxController->getModel() );
     454           0 :     if ( xModel.is() )
     455             :     {
     456           0 :         Reference< XCustomPresentationSupplier > aXCPSup( xModel, UNO_QUERY_THROW );
     457           0 :         Reference< XNameContainer > aXCont( aXCPSup->getCustomPresentations() );
     458           0 :         if ( aXCont.is() )
     459           0 :             aCustomShowList = aXCont->getElementNames();
     460             :     }
     461           0 :     std::vector< OUString > aControlList;
     462           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText0Pg3", getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
     463           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox0Pg3", mxItemListener, getString( STR_DELETE_MASTER_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     464           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox2Pg3", mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     465           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox3Pg3", mxItemListener, getString( STR_CUSTOM_SHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     466           0 :     aControlList.push_back( InsertListBox(  *this, "ListBox0Pg3", mxActionListener, true, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, 12, mnTabIndex++ ) );
     467           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox1Pg3", mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     468           0 :     maControlPages.push_back( aControlList );
     469           0 :     DeactivatePage( 1 );
     470             : 
     471           0 :     setControlProperty( "CheckBox3Pg3", "State", Any( false ) );
     472           0 :     setControlProperty( "CheckBox3Pg3", "Enabled", Any( aCustomShowList.getLength() != 0 ) );
     473           0 :     setControlProperty( "ListBox0Pg3", "Enabled", Any( false ) );
     474             : 
     475           0 :     UpdateControlStatesPage1();
     476           0 : }
     477             : 
     478             : 
     479             : 
     480           0 : void OptimizerDialog::UpdateControlStatesPage2()
     481             : {
     482           0 :     bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, false ) );
     483           0 :     bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, false ) );
     484           0 :     bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, true ) );
     485           0 :     sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
     486             : 
     487           0 :     sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
     488             : 
     489             :     sal_Int32 nI0, nI1, nI2, nI3;
     490           0 :     nI0 = nI1 = nI2 = nI3 = 0;
     491           0 :     OUString aResolutionText;
     492           0 :     Sequence< OUString > aResolutionItemList( 4 );
     493           0 :     aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
     494           0 :     aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
     495           0 :     aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
     496           0 :     aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
     497           0 :     nI0 = nI1 = nI2 = nI3 = 0;
     498           0 :     if ( getString( STR_IMAGE_RESOLUTION_0 ).getToken( 0, ';', nI0 ).toInt32() == nImageResolution )
     499           0 :         aResolutionText = aResolutionItemList[ 0 ];
     500           0 :     else if ( getString( STR_IMAGE_RESOLUTION_1 ).getToken( 0, ';', nI1 ).toInt32() == nImageResolution )
     501           0 :         aResolutionText = aResolutionItemList[ 1 ];
     502           0 :     else if ( getString( STR_IMAGE_RESOLUTION_2 ).getToken( 0, ';', nI2 ).toInt32() == nImageResolution )
     503           0 :         aResolutionText = aResolutionItemList[ 2 ];
     504           0 :     else if ( getString( STR_IMAGE_RESOLUTION_3 ).getToken( 0, ';', nI3 ).toInt32() == nImageResolution )
     505           0 :         aResolutionText = aResolutionItemList[ 3 ];
     506           0 :     if ( aResolutionText.isEmpty() )
     507           0 :         aResolutionText = OUString::number( nImageResolution );
     508             : 
     509           0 :     setControlProperty( "RadioButton0Pg1", "State", Any( (sal_Int16)( bJPEGCompression == false ) ) );
     510           0 :     setControlProperty( "RadioButton1Pg1", "State", Any( (sal_Int16)( bJPEGCompression == true ) ) );
     511           0 :     setControlProperty( "FixedText1Pg1", "Enabled", Any( bJPEGCompression ) );
     512           0 :     setControlProperty( "FormattedField0Pg1", "Enabled", Any( bJPEGCompression ) );
     513           0 :     setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( (double)nJPEGQuality ) );
     514           0 :     setControlProperty( "CheckBox1Pg1", "State", Any( (sal_Int16)bRemoveCropArea ) );
     515           0 :     setControlProperty( "ComboBox0Pg1", "Text", Any( aResolutionText ) );
     516           0 :     setControlProperty( "CheckBox2Pg1", "State", Any( (sal_Int16)bEmbedLinkedGraphics ) );
     517           0 : }
     518           0 : void OptimizerDialog::InitPage2()
     519             : {
     520             :     sal_Int32 nI0, nI1, nI2, nI3;
     521           0 :     nI0 = nI1 = nI2 = nI3 = 0;
     522           0 :     Sequence< OUString > aResolutionItemList( 4 );
     523           0 :     aResolutionItemList[ 0 ] = getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';', nI0 );
     524           0 :     aResolutionItemList[ 1 ] = getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';', nI1 );
     525           0 :     aResolutionItemList[ 2 ] = getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';', nI2 );
     526           0 :     aResolutionItemList[ 3 ] = getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';', nI3 );
     527             : 
     528           0 :     std::vector< OUString > aControlList;
     529           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText0Pg1", getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
     530           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg1", mxItemListener, getString( STR_LOSSLESS_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
     531           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg1", mxItemListener, getString( STR_JPEG_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
     532           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText1Pg1", getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, false, false, mnTabIndex++ ) );
     533           0 :     aControlList.push_back( InsertFormattedField( *this, "FormattedField0Pg1", mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 50, 0, 100, mnTabIndex++ ) );
     534           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText2Pg1", getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, false, false, mnTabIndex++ ) );
     535           0 :     aControlList.push_back( InsertComboBox(  *this, "ComboBox0Pg1", mxTextListenerComboBox0Pg1, true, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, 100, 12, mnTabIndex++ ) );
     536           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox1Pg1", mxItemListener, getString( STR_REMOVE_CROP_AREA ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     537           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox2Pg1", mxItemListener, getString( STR_EMBED_LINKED_GRAPHICS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     538           0 :     maControlPages.push_back( aControlList );
     539           0 :     DeactivatePage( 2 );
     540           0 :     UpdateControlStatesPage2();
     541           0 : }
     542             : 
     543             : 
     544             : 
     545           0 : void OptimizerDialog::UpdateControlStatesPage3()
     546             : {
     547           0 :     bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, false ) );
     548           0 :     sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, (sal_Int16)0 ) );
     549             : 
     550           0 :     setControlProperty( "CheckBox0Pg2", "State", Any( (sal_Int16)bConvertOLEObjects ) );
     551           0 :     setControlProperty( "RadioButton0Pg2", "Enabled", Any( bConvertOLEObjects ) );
     552           0 :     setControlProperty( "RadioButton0Pg2", "State", Any( (sal_Int16)( nOLEOptimizationType == 0 ) ) );
     553           0 :     setControlProperty( "RadioButton1Pg2", "Enabled", Any( bConvertOLEObjects ) );
     554           0 :     setControlProperty( "RadioButton1Pg2", "State", Any( (sal_Int16)( nOLEOptimizationType == 1 ) ) );
     555           0 : }
     556           0 : void OptimizerDialog::InitPage3()
     557             : {
     558           0 :     int nOLECount = 0;
     559           0 :     Reference< XModel > xModel( mxController->getModel() );
     560           0 :     Reference< XDrawPagesSupplier > xDrawPagesSupplier( xModel, UNO_QUERY_THROW );
     561           0 :     Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     562           0 :     for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
     563             :     {
     564           0 :         Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
     565           0 :         for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
     566             :         {
     567           0 :             const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape"  );
     568           0 :             Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
     569           0 :             if ( xShape->getShapeType() == sOLE2Shape )
     570           0 :                 nOLECount++;
     571           0 :         }
     572           0 :     }
     573             : 
     574           0 :     std::vector< OUString > aControlList;
     575           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText0Pg2", getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
     576           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox0Pg2", mxItemListener, getString( STR_OLE_REPLACE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, mnTabIndex++ ) );
     577           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg2", mxItemListener, getString( STR_ALL_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 28, PAGE_WIDTH - 22, 8, false, mnTabIndex++ ) );
     578           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg2", mxItemListener, getString( STR_ALIEN_OLE_OBJECTS_ONLY ), PAGE_POS_X + 14, PAGE_POS_Y + 40, PAGE_WIDTH - 22, 8, false, mnTabIndex++ ) );
     579           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText1Pg2", nOLECount ? getString( STR_OLE_OBJECTS_DESC ) : getString( STR_NO_OLE_OBJECTS_DESC ), PAGE_POS_X + 6, PAGE_POS_Y + 64, PAGE_WIDTH - 22, 50, true, false, mnTabIndex++ ) );
     580           0 :     maControlPages.push_back( aControlList );
     581           0 :     DeactivatePage( 3 );
     582           0 :     UpdateControlStatesPage3();
     583           0 : }
     584             : 
     585             : 
     586             : 
     587           0 : static OUString ImpValueOfInMB( const sal_Int64& rVal, sal_Unicode nSeparator = '.' )
     588             : {
     589           0 :     double fVal( static_cast<double>( rVal ) );
     590           0 :     fVal /= ( 1 << 20 );
     591           0 :     fVal += 0.05;
     592           0 :     OUStringBuffer aVal( OUString::number( fVal ) );
     593           0 :     sal_Int32 nX( OUString( aVal.getStr() ).indexOf( '.', 0 ) );
     594           0 :     if ( nX >= 0 )
     595             :     {
     596           0 :         aVal.setLength( nX + 2 );
     597           0 :         aVal[nX] = nSeparator;
     598             :     }
     599           0 :     aVal.append( " MB" );
     600           0 :     return aVal.makeStringAndClear();
     601             : }
     602             : 
     603           0 : void OptimizerDialog::UpdateControlStatesPage4()
     604             : {
     605           0 :     bool bSaveAs( GetConfigProperty( TK_SaveAs, true ) );
     606           0 :     if ( mbIsReadonly )
     607             :     {
     608           0 :         setControlProperty( "RadioButton0Pg4", "State", Any( (sal_Int16)( sal_False ) ) );
     609           0 :         setControlProperty( "RadioButton1Pg4", "State", Any( (sal_Int16)( sal_True ) ) );
     610             :     }
     611             :     else
     612             :     {
     613           0 :         setControlProperty( "RadioButton0Pg4", "State", Any( (sal_Int16)( bSaveAs == false ) ) );
     614           0 :         setControlProperty( "RadioButton1Pg4", "State", Any( (sal_Int16)( bSaveAs == true ) ) );
     615             :     }
     616           0 :     setControlProperty( "ComboBox0Pg4", "Enabled", Any( false ) );
     617             : 
     618             :     sal_uInt32 w;
     619           0 :     Sequence< OUString > aItemList;
     620           0 :     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
     621           0 :     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
     622             :     {
     623           0 :         aItemList.realloc( rList.size() - 1 );
     624           0 :         for ( w = 1; w < rList.size(); w++ )
     625           0 :             aItemList[ w - 1 ] = rList[ w ].maName;
     626             :     }
     627           0 :     setControlProperty( "ComboBox0Pg4", "StringItemList", Any( aItemList ) );
     628             : 
     629             :     // now check if it is sensible to enable the combo box
     630           0 :     bool bSaveSettingsEnabled = true;
     631           0 :     if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one
     632             :     {
     633           0 :         for ( w = 1; w < rList.size(); w++ )
     634             :         {
     635           0 :             if ( rList[ w ] == rList[ 0 ] )
     636             :             {
     637           0 :                 bSaveSettingsEnabled = false;
     638           0 :                 break;
     639             :             }
     640             :         }
     641             :     }
     642           0 :     sal_Int16 nInt16 = 0;
     643           0 :     getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
     644           0 :     setControlProperty( "CheckBox1Pg4", "Enabled", Any( bSaveSettingsEnabled ) );
     645           0 :     setControlProperty( "ComboBox0Pg4", "Enabled", Any( bSaveSettingsEnabled && nInt16 ) );
     646             : 
     647           0 :     std::vector< OUString > aSummaryStrings;
     648             : 
     649             :     // taking care of deleted slides
     650           0 :     sal_Int32 nDeletedSlides = 0;
     651           0 :     OUString aCustomShowName;
     652           0 :     if ( getControlProperty( "CheckBox3Pg3", "State" ) >>= nInt16 )
     653             :     {
     654           0 :         if ( nInt16 )
     655             :         {
     656           0 :             Sequence< short > aSelectedItems;
     657           0 :             Sequence< OUString > aStringItemList;
     658           0 :             Any aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" );
     659           0 :             if ( aAny >>= aSelectedItems )
     660             :             {
     661           0 :                 if ( aSelectedItems.getLength() )
     662             :                 {
     663           0 :                     sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
     664           0 :                     aAny = getControlProperty( "ListBox0Pg3", "StringItemList" );
     665           0 :                     if ( aAny >>= aStringItemList )
     666             :                     {
     667           0 :                         if ( aStringItemList.getLength() > nSelectedItem )
     668           0 :                             SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
     669             :                     }
     670             :                 }
     671           0 :             }
     672             :         }
     673             :     }
     674           0 :     if ( !aCustomShowName.isEmpty() )
     675             :     {
     676           0 :         std::vector< Reference< XDrawPage > > vNonUsedPageList;
     677           0 :         PageCollector::CollectNonCustomShowPages( mxController->getModel(), aCustomShowName, vNonUsedPageList );
     678           0 :         nDeletedSlides += vNonUsedPageList.size();
     679             :     }
     680           0 :     if ( GetConfigProperty( TK_DeleteHiddenSlides, false ) )
     681             :     {
     682           0 :         if ( !aCustomShowName.isEmpty() )
     683             :         {
     684           0 :             std::vector< Reference< XDrawPage > > vUsedPageList;
     685           0 :             PageCollector::CollectCustomShowPages( mxController->getModel(), aCustomShowName, vUsedPageList );
     686           0 :             std::vector< Reference< XDrawPage > >::iterator aIter( vUsedPageList.begin() );
     687           0 :             while( aIter != vUsedPageList.end() )
     688             :             {
     689           0 :                 Reference< XPropertySet > xPropSet( *aIter, UNO_QUERY_THROW );
     690           0 :                 bool bVisible = true;
     691           0 :                 const OUString sVisible( "Visible"  );
     692           0 :                 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
     693             :                 {
     694           0 :                     if (!bVisible )
     695           0 :                         nDeletedSlides++;
     696             :                 }
     697           0 :                 ++aIter;
     698           0 :             }
     699             :         }
     700             :         else
     701             :         {
     702           0 :             Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
     703           0 :             Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     704           0 :             for( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
     705             :             {
     706           0 :                 Reference< XDrawPage > xDrawPage( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
     707           0 :                 Reference< XPropertySet > xPropSet( xDrawPage, UNO_QUERY_THROW );
     708             : 
     709           0 :                 bool bVisible = true;
     710           0 :                 const OUString sVisible( "Visible"  );
     711           0 :                 if ( xPropSet->getPropertyValue( sVisible ) >>= bVisible )
     712             :                 {
     713           0 :                     if (!bVisible )
     714           0 :                         nDeletedSlides++;
     715             :                 }
     716           0 :             }
     717             :         }
     718             :     }
     719           0 :     if ( GetConfigProperty( TK_DeleteUnusedMasterPages, false ) )
     720             :     {
     721           0 :         std::vector< PageCollector::MasterPageEntity > aMasterPageList;
     722           0 :         PageCollector::CollectMasterPages( mxController->getModel(), aMasterPageList );
     723           0 :         Reference< XMasterPagesSupplier > xMasterPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
     724           0 :         Reference< XDrawPages > xMasterPages( xMasterPagesSupplier->getMasterPages(), UNO_QUERY_THROW );
     725           0 :         std::vector< PageCollector::MasterPageEntity >::iterator aIter( aMasterPageList.begin() );
     726           0 :         while( aIter != aMasterPageList.end() )
     727             :         {
     728           0 :             if ( !aIter->bUsed )
     729           0 :                 nDeletedSlides++;
     730           0 :             ++aIter;
     731           0 :         }
     732             :     }
     733           0 :     if ( nDeletedSlides > 1 )
     734             :     {
     735           0 :         OUString aStr( getString( STR_DELETE_SLIDES ) );
     736           0 :         OUString aPlaceholder( "%SLIDES"  );
     737           0 :         sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
     738           0 :         if ( i >= 0 )
     739           0 :             aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::number( nDeletedSlides ) );
     740           0 :         aSummaryStrings.push_back( aStr );
     741             :     }
     742             : 
     743             : // generating graphic compression info
     744           0 :     sal_Int32 nGraphics = 0;
     745           0 :     bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, false ) );
     746           0 :     sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, (sal_Int32)90 ) );
     747           0 :     sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, (sal_Int32)0 ) );
     748           0 :     GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, false ),
     749           0 :                                         nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, true ) );
     750           0 :     GraphicCollector::CountGraphics( mxContext, mxController->getModel(), aGraphicSettings, nGraphics );
     751           0 :     if ( nGraphics > 1 )
     752             :     {
     753           0 :         OUString aStr( getString( STR_OPTIMIZE_IMAGES ) );
     754           0 :         OUString aImagePlaceholder( "%IMAGES"  );
     755           0 :         OUString aQualityPlaceholder( "%QUALITY"  );
     756           0 :         OUString aResolutionPlaceholder( "%RESOLUTION"  );
     757           0 :         sal_Int32 i = aStr.indexOf( aImagePlaceholder, 0 );
     758           0 :         if ( i >= 0 )
     759           0 :             aStr = aStr.replaceAt( i, aImagePlaceholder.getLength(), OUString::number( nGraphics ) );
     760             : 
     761           0 :         sal_Int32 j = aStr.indexOf( aQualityPlaceholder, 0 );
     762           0 :         if ( j >= 0 )
     763           0 :             aStr = aStr.replaceAt( j, aQualityPlaceholder.getLength(), OUString::number( nJPEGQuality ) );
     764             : 
     765           0 :         sal_Int32 k = aStr.indexOf( aResolutionPlaceholder, 0 );
     766           0 :         if ( k >= 0 )
     767           0 :             aStr = aStr.replaceAt( k, aResolutionPlaceholder.getLength(), OUString::number( nImageResolution ) );
     768             : 
     769           0 :         aSummaryStrings.push_back( aStr );
     770             :     }
     771             : 
     772           0 :     if ( GetConfigProperty( TK_OLEOptimization, false ) )
     773             :     {
     774           0 :         sal_Int32 nOLEReplacements = 0;
     775           0 :         Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW );
     776           0 :         Reference< XDrawPages > xDrawPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
     777           0 :         for ( sal_Int32 i = 0; i < xDrawPages->getCount(); i++ )
     778             :         {
     779           0 :             Reference< XShapes > xShapes( xDrawPages->getByIndex( i ), UNO_QUERY_THROW );
     780           0 :             for ( sal_Int32 j = 0; j < xShapes->getCount(); j++ )
     781             :             {
     782           0 :                 const OUString sOLE2Shape( "com.sun.star.drawing.OLE2Shape"  );
     783           0 :                 Reference< XShape > xShape( xShapes->getByIndex( j ), UNO_QUERY_THROW );
     784           0 :                 if ( xShape->getShapeType() == sOLE2Shape )
     785           0 :                     nOLEReplacements++;
     786           0 :             }
     787           0 :         }
     788           0 :         if ( nOLEReplacements > 1 )
     789             :         {
     790           0 :             OUString aStr( getString( STR_CREATE_REPLACEMENT ) );
     791           0 :             OUString aPlaceholder( "%OLE"  );
     792           0 :             sal_Int32 i = aStr.indexOf( aPlaceholder, 0 );
     793           0 :             if ( i >= 0 )
     794           0 :                 aStr = aStr.replaceAt( i, aPlaceholder.getLength(), OUString::number( nOLEReplacements ) );
     795           0 :             aSummaryStrings.push_back( aStr );
     796           0 :         }
     797             :     }
     798           0 :     while( aSummaryStrings.size() < 3 )
     799           0 :         aSummaryStrings.push_back( OUString() );
     800           0 :     setControlProperty( "FixedText4Pg4", "Label", Any( aSummaryStrings[ 0 ] ) );
     801           0 :     setControlProperty( "FixedText5Pg4", "Label", Any( aSummaryStrings[ 1 ] ) );
     802           0 :     setControlProperty( "FixedText6Pg4", "Label", Any( aSummaryStrings[ 2 ] ) );
     803             : 
     804           0 :     sal_Int64 nCurrentFileSize = 0;
     805           0 :     sal_Int64 nEstimatedFileSize = 0;
     806           0 :     Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
     807           0 :     if ( xStorable.is() && xStorable->hasLocation() )
     808           0 :         nCurrentFileSize = PPPOptimizer::GetFileSize( xStorable->getLocation() );
     809             : 
     810           0 :     if ( nCurrentFileSize )
     811             :     {
     812           0 :         double fE = static_cast< double >( nCurrentFileSize );
     813           0 :         if ( nImageResolution )
     814             :         {
     815           0 :             double v = ( static_cast< double >( nImageResolution ) + 75.0 ) / 300.0;
     816           0 :             if ( v < 1.0 )
     817           0 :                 fE *= v;
     818             :         }
     819           0 :         if ( bJPEGCompression )
     820             :         {
     821           0 :             double v = 0.75 - ( ( 100.0 - static_cast< double >( nJPEGQuality ) ) / 400.0 ) ;
     822           0 :             fE *= v;
     823             :         }
     824           0 :         nEstimatedFileSize = static_cast< sal_Int64 >( fE );
     825             :     }
     826           0 :     sal_Unicode nSeparator = '.';
     827           0 :     OUString aStr( getString( STR_FILESIZESEPARATOR ) );
     828           0 :     if ( !aStr.isEmpty() )
     829           0 :         nSeparator = aStr[ 0 ];
     830           0 :     setControlProperty( "FixedText7Pg4", "Label", Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) );
     831           0 :     setControlProperty( "FixedText8Pg4", "Label", Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) );
     832           0 :     SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) );
     833           0 : }
     834             : 
     835           0 : void OptimizerDialog::InitPage4()
     836             : {
     837             :     {   // creating progress bar:
     838             :         OUString pNames[] = {
     839             :             OUString("Height"),
     840             :             OUString("Name"),
     841             :             OUString("PositionX"),
     842             :             OUString("PositionY"),
     843             :             OUString("ProgressValue"),
     844             :             OUString("ProgressValueMax"),
     845             :             OUString("ProgressValueMin"),
     846           0 :             OUString("Width") };
     847             : 
     848             :         Any pValues[] = {
     849             :             Any( (sal_Int32)12 ),
     850             :             Any( OUString("STR_SAVE_AS") ),
     851             :             Any( (sal_Int32)( PAGE_POS_X + 6 ) ),
     852             :             Any( (sal_Int32)( DIALOG_HEIGHT - 75 ) ),
     853             :             Any( (sal_Int32)( 0 ) ),
     854             :             Any( (sal_Int32)( 100 ) ),
     855             :             Any( (sal_Int32)( 0 ) ),
     856           0 :             Any( (sal_Int32)( PAGE_WIDTH - 12 ) ) };
     857             : 
     858           0 :         sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
     859             : 
     860           0 :         Sequence< OUString >   aNames( pNames, nCount );
     861           0 :         Sequence< Any >             aValues( pValues, nCount );
     862             : 
     863             :         Reference< XMultiPropertySet > xMultiPropertySet( insertControlModel( OUString( "com.sun.star.awt.UnoControlProgressBarModel"  ),
     864           0 :             "Progress", aNames, aValues ), UNO_QUERY );
     865             :     }
     866           0 :     Reference< XTextListener > xTextListener;
     867           0 :     Sequence< OUString > aItemList;
     868           0 :     std::vector< OUString > aControlList;
     869           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText0Pg4", getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ) );
     870             : //  aControlList.push_back( InsertSeparator( *this, "Separator0Pg4", 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ) );
     871             : 
     872           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText4Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
     873           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText5Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
     874           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText6Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ) );
     875             : 
     876           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText2Pg4", getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 88, 8, false, false, mnTabIndex++ ) );
     877           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText7Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, false, false, mnTabIndex++ ) );
     878           0 :     setControlProperty( "FixedText7Pg4", "Align", Any( static_cast< short >( 2 ) ) );
     879           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText3Pg4", getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 88, 8, false, false, mnTabIndex++ ) );
     880           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText8Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, false, false, mnTabIndex++ ) );
     881           0 :     setControlProperty( "FixedText8Pg4", "Align", Any( static_cast< short >( 2 ) ) );
     882             : 
     883           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg4", mxItemListener, getString(  STR_APPLY_TO_CURRENT ), PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
     884           0 :     aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg4", mxItemListener, getString( STR_SAVE_AS ), PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 8, false, mnTabIndex++ ) );
     885           0 :     aControlList.push_back( InsertFixedText( *this, "FixedText1Pg4", OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 87, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ) );
     886           0 :     aControlList.push_back( "Progress" );
     887           0 :     aControlList.push_back( InsertSeparator( *this, "Separator1Pg4", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) );
     888           0 :     aControlList.push_back( InsertCheckBox(  *this, "CheckBox1Pg4", mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, 8, mnTabIndex++ ) );
     889           0 :     aControlList.push_back( InsertComboBox(  *this, "ComboBox0Pg4", xTextListener, true, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, 100, 12, mnTabIndex++ ) );
     890           0 :     maControlPages.push_back( aControlList );
     891           0 :     DeactivatePage( 4 );
     892             : 
     893             :     // creating a default session name that hasn't been used yet
     894           0 :     OUString aSettingsName;
     895           0 :     OUString aDefault( getString( STR_MY_SETTINGS ) );
     896           0 :     sal_Int32 nSession = 1;
     897             :     sal_uInt32 i;
     898           0 :     const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() );
     899           0 :     do
     900             :     {
     901           0 :         OUString aTemp( aDefault.concat( OUString::number( nSession++ ) ) );
     902           0 :         for ( i = 1; i < rList.size(); i++ )
     903             :         {
     904           0 :             if ( rList[ i ].maName == aTemp )
     905           0 :                 break;
     906             :         }
     907           0 :         if ( i == rList.size() )
     908           0 :             aSettingsName = aTemp;
     909             :     }
     910             :     while( aSettingsName.isEmpty() );
     911             : 
     912           0 :     setControlProperty( "ComboBox0Pg4", "Text", Any( aSettingsName ) );
     913           0 :     setControlProperty( "RadioButton0Pg4", "Enabled", Any( !mbIsReadonly ) );
     914           0 :     setControlProperty( "RadioButton1Pg4", "Enabled", Any( !mbIsReadonly ) );
     915             : 
     916           0 :     UpdateControlStatesPage4();
     917           0 : }
     918             : 
     919             : 
     920           0 : void OptimizerDialog::EnablePage( sal_Int16 nStep )
     921             : {
     922           0 :     std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
     923           0 :     std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
     924           0 :     while( aBeg != aEnd )
     925           0 :         setControlProperty( *aBeg++, "Enabled", Any( true ) );
     926           0 : }
     927           0 : void OptimizerDialog::DisablePage( sal_Int16 nStep )
     928             : {
     929           0 :     std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
     930           0 :     std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
     931           0 :     while( aBeg != aEnd )
     932           0 :         setControlProperty( *aBeg++, "Enabled", Any( false ) );
     933           0 : }
     934           0 : void OptimizerDialog::ActivatePage( sal_Int16 nStep )
     935             : {
     936           0 :     std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
     937           0 :     std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
     938           0 :     while( aBeg != aEnd )
     939           0 :         setVisible( *aBeg++, true );
     940           0 : }
     941           0 : void OptimizerDialog::DeactivatePage( sal_Int16 nStep )
     942             : {
     943           0 :     std::vector< OUString >::iterator aBeg( maControlPages[ nStep ].begin() );
     944           0 :     std::vector< OUString >::iterator aEnd( maControlPages[ nStep ].end() );
     945           0 :     while( aBeg != aEnd )
     946           0 :         setVisible( *aBeg++, false );
     947           0 : }
     948             : 
     949             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10