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

Generated by: LCOV version 1.10