1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "optimizerdialog.hxx"
22 #include "fileopendialog.hxx"
23 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
24 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
25 #include <com/sun/star/io/XInputStream.hpp>
26 #include <com/sun/star/util/XCloseBroadcaster.hpp>
27 #include <com/sun/star/frame/XComponentLoader.hpp>
28 #include <com/sun/star/frame/XLayoutManager.hpp>
29 #include <sal/macros.h>
32 // -------------------
33 // - OPTIMIZERDIALOG -
34 // -------------------
36 using namespace ::rtl
;
37 using namespace ::com::sun::star::io
;
38 using namespace ::com::sun::star::ui
;
39 using namespace ::com::sun::star::awt
;
40 using namespace ::com::sun::star::ucb
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::util
;
43 using namespace ::com::sun::star::lang
;
44 using namespace ::com::sun::star::frame
;
45 using namespace ::com::sun::star::beans
;
46 using namespace ::com::sun::star::script
;
47 using namespace ::com::sun::star::container
;
50 // -----------------------------------------------------------------------------
52 void OptimizerDialog::InitDialog()
54 // setting the dialog properties
56 TKGet( TK_Closeable
),
59 TKGet( TK_PositionX
),
60 TKGet( TK_PositionY
),
66 Any( sal_Int32( DIALOG_HEIGHT
) ),
68 Any( sal_Int32( 200 ) ),
69 Any( sal_Int32( 52 ) ),
70 Any( getString( STR_SUN_OPTIMIZATION_WIZARD2
) ),
71 Any( sal_Int32( OD_DIALOG_WIDTH
) ) };
73 sal_Int32 nCount
= SAL_N_ELEMENTS( pNames
);
75 Sequence
< OUString
> aNames( pNames
, nCount
);
76 Sequence
< Any
> aValues( pValues
, nCount
);
78 mxDialogModelMultiPropertySet
->setPropertyValues( aNames
, aValues
);
81 // -----------------------------------------------------------------------------
83 void OptimizerDialog::InitRoadmap()
89 TKGet( TK_PositionX
),
90 TKGet( TK_PositionY
),
96 Any( sal_Int32( DIALOG_HEIGHT
- 26 ) ),
97 Any( sal_Int32( 0 ) ),
98 Any( sal_Int32( 0 ) ),
99 Any( sal_Int32( 0 ) ),
101 Any( sal_Int32( 85 ) ) };
103 sal_Int32 nCount
= SAL_N_ELEMENTS( pNames
);
105 Sequence
< OUString
> aNames( pNames
, nCount
);
106 Sequence
< Any
> aValues( pValues
, nCount
);
108 mxRoadmapControlModel
= insertControlModel( OUString( "com.sun.star.awt.UnoControlRoadmapModel" ),
109 TKGet( TK_rdmNavi
), aNames
, aValues
);
111 Reference
< XPropertySet
> xPropertySet( mxRoadmapControlModel
, UNO_QUERY_THROW
);
112 xPropertySet
->setPropertyValue( TKGet( TK_Name
), Any( TKGet( TK_rdmNavi
) ) );
113 mxRoadmapControl
= mxDialogControlContainer
->getControl( TKGet( TK_rdmNavi
) );
114 InsertRoadmapItem( 0, sal_True
, getString( STR_INTRODUCTION
), ITEM_ID_INTRODUCTION
);
115 InsertRoadmapItem( 1, sal_True
, getString( STR_SLIDES
), ITEM_ID_SLIDES
);
116 InsertRoadmapItem( 2, sal_True
, getString( STR_IMAGE_OPTIMIZATION
), ITEM_ID_GRAPHIC_OPTIMIZATION
);
117 InsertRoadmapItem( 3, sal_True
, getString( STR_OLE_OBJECTS
), ITEM_ID_OLE_OPTIMIZATION
);
118 InsertRoadmapItem( 4, sal_True
, getString( STR_SUMMARY
), ITEM_ID_SUMMARY
);
120 OUString
sBitmapPath( getPath( TK_BitmapPath
) );
121 OUString
sBitmap( "/minimizepresi_80.png" );
122 OUString
sURL( sBitmapPath
+= sBitmap
);
124 xPropertySet
->setPropertyValue( TKGet( TK_ImageURL
), Any( sURL
) );
125 xPropertySet
->setPropertyValue( TKGet( TK_Activated
), Any( (sal_Bool
)sal_True
) );
126 xPropertySet
->setPropertyValue( TKGet( TK_Complete
), Any( (sal_Bool
)sal_True
) );
127 xPropertySet
->setPropertyValue( TKGet( TK_CurrentItemID
), Any( (sal_Int16
)ITEM_ID_INTRODUCTION
) );
128 xPropertySet
->setPropertyValue( TKGet( TK_Text
), Any( getString( STR_STEPS
) ) );
135 // -----------------------------------------------------------------------------
137 void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex
, const sal_Bool bEnabled
, const OUString
& rLabel
, const sal_Int32 nItemID
)
141 Reference
< XSingleServiceFactory
> xSFRoadmap( mxRoadmapControlModel
, UNO_QUERY_THROW
);
142 Reference
< XIndexContainer
> aIndexContainerRoadmap( mxRoadmapControlModel
, UNO_QUERY_THROW
);
143 Reference
< XInterface
> xRoadmapItem( xSFRoadmap
->createInstance(), UNO_QUERY_THROW
);
144 Reference
< XPropertySet
> xPropertySet( xRoadmapItem
, UNO_QUERY_THROW
);
145 xPropertySet
->setPropertyValue( TKGet( TK_Label
), Any( rLabel
) );
146 xPropertySet
->setPropertyValue( TKGet( TK_Enabled
), Any( bEnabled
) );
147 xPropertySet
->setPropertyValue( TKGet( TK_ID
), Any( nItemID
) );
148 aIndexContainerRoadmap
->insertByIndex( nIndex
, Any( xRoadmapItem
) );
156 // -----------------------------------------------------------------------------
158 void OptimizerDialog::UpdateConfiguration()
160 sal_Int16 nInt16
= 0;
163 Sequence
< sal_Int16
> aSelectedItems
;
164 Sequence
< OUString
> aStringItemList
;
167 aAny
= getControlProperty( TKGet( TK_ListBox0Pg0
), TKGet( TK_SelectedItems
) );
168 if ( aAny
>>= aSelectedItems
)
170 if ( aSelectedItems
.getLength() )
172 sal_Int16 nSelectedItem
= aSelectedItems
[ 0 ];
173 aAny
= getControlProperty( TKGet( TK_ListBox0Pg0
), TKGet( TK_StringItemList
) );
174 if ( aAny
>>= aStringItemList
)
176 if ( aStringItemList
.getLength() > nSelectedItem
)
177 SetConfigProperty( TK_Name
, Any( aStringItemList
[ nSelectedItem
] ) );
182 aAny
= getControlProperty( TKGet( TK_CheckBox3Pg3
), TKGet( TK_State
) );
183 if ( aAny
>>= nInt16
)
187 aAny
= getControlProperty( TKGet( TK_ListBox0Pg3
), TKGet( TK_SelectedItems
) );
188 if ( aAny
>>= aSelectedItems
)
190 if ( aSelectedItems
.getLength() )
192 sal_Int16 nSelectedItem
= aSelectedItems
[ 0 ];
193 aAny
= getControlProperty( TKGet( TK_ListBox0Pg3
), TKGet( TK_StringItemList
) );
194 if ( aAny
>>= aStringItemList
)
196 if ( aStringItemList
.getLength() > nSelectedItem
)
197 SetConfigProperty( TK_CustomShowName
, Any( aStringItemList
[ nSelectedItem
] ) );
205 // -----------------------------------------------------------------------------
207 OptimizerDialog::OptimizerDialog( const Reference
< XComponentContext
> &rxMSF
, Reference
< XFrame
>& rxFrame
, Reference
< XDispatch
> rxStatusDispatcher
) :
208 UnoDialog( rxMSF
, rxFrame
),
209 ConfigurationAccess( rxMSF
, NULL
),
214 mxItemListener( new ItemListener( *this ) ),
215 mxActionListener( new ActionListener( *this ) ),
216 mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ),
217 mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ),
218 mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ),
219 mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ),
220 mxStatusDispatcher( rxStatusDispatcher
)
222 Reference
< XStorable
> xStorable( mxController
->getModel(), UNO_QUERY_THROW
);
223 mbIsReadonly
= xStorable
->isReadonly();
235 OptimizationStats aStats
;
236 aStats
.InitializeStatusValuesFromDocument( mxController
->getModel() );
237 Sequence
< PropertyValue
> aStatusSequence( aStats
.GetStatusSequence() );
238 UpdateStatus( aStatusSequence
);
241 // -----------------------------------------------------------------------------
243 OptimizerDialog::~OptimizerDialog()
245 // not saving configuration if the dialog has been finished via cancel or close window
250 // -----------------------------------------------------------------------------
252 sal_Bool
OptimizerDialog::execute()
254 Reference
< XItemEventBroadcaster
> maRoadmapBroadcaster( mxRoadmapControl
, UNO_QUERY_THROW
);
255 maRoadmapBroadcaster
->addItemListener( mxItemListener
);
256 UnoDialog::execute();
257 UpdateConfiguration(); // taking actual control settings for the configuration
258 maRoadmapBroadcaster
->removeItemListener( mxItemListener
);
262 // -----------------------------------------------------------------------------
264 void OptimizerDialog::SwitchPage( sal_Int16 nNewStep
)
266 if ( ( nNewStep
!= mnCurrentStep
) && ( nNewStep
<= MAX_STEP
) && ( nNewStep
>= 0 ) )
268 sal_Int16 nOldStep
= mnCurrentStep
;
270 disableControl( TKGet( TK_btnNavBack
) );
271 else if ( nOldStep
== 0 )
272 enableControl( TKGet( TK_btnNavBack
) );
274 if ( nNewStep
== MAX_STEP
)
275 disableControl( TKGet( TK_btnNavNext
) );
276 else if ( nOldStep
== MAX_STEP
)
277 enableControl( TKGet( TK_btnNavNext
) );
279 setControlProperty( TKGet( TK_rdmNavi
), TKGet( TK_CurrentItemID
), Any( nNewStep
) );
281 DeactivatePage( nOldStep
);
282 UpdateControlStates( nNewStep
);
284 ActivatePage( nNewStep
);
285 mnCurrentStep
= nNewStep
;
289 void OptimizerDialog::UpdateControlStates( sal_Int16 nPage
)
293 case 0 : UpdateControlStatesPage0(); break;
294 case 1 : UpdateControlStatesPage1(); break;
295 case 2 : UpdateControlStatesPage2(); break;
296 case 3 : UpdateControlStatesPage3(); break;
297 case 4 : UpdateControlStatesPage4(); break;
300 UpdateControlStatesPage0();
301 UpdateControlStatesPage1();
302 UpdateControlStatesPage2();
303 UpdateControlStatesPage3();
304 UpdateControlStatesPage4();
309 // -----------------------------------------------------------------------------
311 OUString
OptimizerDialog::GetSelectedString( const PPPOptimizerTokenEnum eToken
)
313 OUString aSelectedItem
;
314 Sequence
< sal_Int16
> sSelectedItems
;
315 Sequence
< OUString
> sItemList
;
317 if ( ( getControlProperty( TKGet( eToken
), TKGet( TK_SelectedItems
) ) >>= sSelectedItems
) &&
318 ( getControlProperty( TKGet( eToken
), TKGet( TK_StringItemList
) ) >>= sItemList
) )
320 if ( sSelectedItems
.getLength() == 1 )
322 sal_Int16 nSelectedItem
= sSelectedItems
[ 0 ];
323 if ( nSelectedItem
< sItemList
.getLength() )
324 aSelectedItem
= sItemList
[ nSelectedItem
];
327 return aSelectedItem
;
330 // -----------------------------------------------------------------------------
332 void OptimizerDialog::UpdateStatus( const com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& rStatus
)
334 if ( mxReschedule
.is() )
336 maStats
.InitializeStatusValues( rStatus
);
337 const Any
* pVal( maStats
.GetStatusValue( TK_Status
) );
341 if ( *pVal
>>= sStatus
)
343 setControlProperty( TKGet( TK_FixedText1Pg4
), TKGet( TK_Enabled
), Any( sal_True
) );
344 setControlProperty( TKGet( TK_FixedText1Pg4
), TKGet( TK_Label
), Any( getString( TKGet( sStatus
) ) ) );
347 pVal
= maStats
.GetStatusValue( TK_Progress
);
350 sal_Int32 nProgress
= 0;
351 if ( *pVal
>>= nProgress
)
352 setControlProperty( TKGet( TK_Progress
), TKGet( TK_ProgressValue
), Any( nProgress
) );
354 pVal
= maStats
.GetStatusValue( TK_OpenNewDocument
);
356 SetConfigProperty( TK_OpenNewDocument
, *pVal
);
358 mxReschedule
->reschedule();
362 // -----------------------------------------------------------------------------
364 void ItemListener::itemStateChanged( const ItemEvent
& Event
)
365 throw ( RuntimeException
)
370 OUString aControlName
;
371 Reference
< XControl
> xControl
;
372 Any
aSource( Event
.Source
);
373 if ( aSource
>>= xControl
)
375 Reference
< XPropertySet
> xPropertySet( xControl
->getModel(), UNO_QUERY_THROW
);
376 xPropertySet
->getPropertyValue( TKGet( TK_Name
) ) >>= aControlName
;
377 PPPOptimizerTokenEnum
eControl( TKGet( aControlName
) );
382 mrOptimizerDialog
.SwitchPage( static_cast< sal_Int16
>( Event
.ItemId
) );
385 case TK_CheckBox1Pg1
:
387 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
388 mrOptimizerDialog
.SetConfigProperty( TK_RemoveCropArea
, Any( nState
!= 0 ) );
391 case TK_CheckBox2Pg1
:
393 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
394 mrOptimizerDialog
.SetConfigProperty( TK_EmbedLinkedGraphics
, Any( nState
!= 0 ) );
397 case TK_CheckBox0Pg2
:
399 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
401 mrOptimizerDialog
.SetConfigProperty( TK_OLEOptimization
, Any( nState
!= 0 ) );
402 mrOptimizerDialog
.setControlProperty( TKGet( TK_RadioButton0Pg2
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
403 mrOptimizerDialog
.setControlProperty( TKGet( TK_RadioButton1Pg2
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
407 case TK_RadioButton0Pg1
:
409 sal_Int16 nInt16
= 0;
410 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nInt16
)
413 mrOptimizerDialog
.SetConfigProperty( TK_JPEGCompression
, Any( nInt16
!= 0 ) );
414 mrOptimizerDialog
.setControlProperty( TKGet( TK_FixedText1Pg1
), TKGet( TK_Enabled
), Any( nInt16
!= 0 ) );
415 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_Enabled
), Any( nInt16
!= 0 ) );
419 case TK_RadioButton1Pg1
:
421 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
423 mrOptimizerDialog
.SetConfigProperty( TK_JPEGCompression
, Any( nState
!= 0 ) );
424 mrOptimizerDialog
.setControlProperty( TKGet( TK_FixedText1Pg1
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
425 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
429 case TK_RadioButton0Pg2
:
432 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nInt16
)
435 mrOptimizerDialog
.SetConfigProperty( TK_OLEOptimizationType
, Any( nInt16
) );
439 case TK_RadioButton1Pg2
:
441 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
442 mrOptimizerDialog
.SetConfigProperty( TK_OLEOptimizationType
, Any( nState
) );
445 case TK_CheckBox0Pg3
:
447 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
448 mrOptimizerDialog
.SetConfigProperty( TK_DeleteUnusedMasterPages
, Any( nState
!= 0 ) );
451 case TK_CheckBox1Pg3
:
453 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
454 mrOptimizerDialog
.SetConfigProperty( TK_DeleteNotesPages
, Any( nState
!= 0 ) );
457 case TK_CheckBox2Pg3
:
459 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
460 mrOptimizerDialog
.SetConfigProperty( TK_DeleteHiddenSlides
, Any( nState
!= 0 ) );
463 case TK_CheckBox3Pg3
:
465 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
466 mrOptimizerDialog
.setControlProperty( TKGet( TK_ListBox0Pg3
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
469 case TK_CheckBox1Pg4
:
471 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
472 mrOptimizerDialog
.setControlProperty( TKGet( TK_ComboBox0Pg4
), TKGet( TK_Enabled
), Any( nState
!= 0 ) );
475 case TK_RadioButton0Pg4
:
476 case TK_RadioButton1Pg4
:
478 if ( xPropertySet
->getPropertyValue( TKGet( TK_State
) ) >>= nState
)
479 mrOptimizerDialog
.SetConfigProperty( TK_SaveAs
, Any( eControl
== TK_RadioButton1Pg4
? nState
!= 0 : nState
== 0 ) );
492 void ItemListener::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
493 throw ( com::sun::star::uno::RuntimeException
)
497 // -----------------------------------------------------------------------------
499 void ActionListener::actionPerformed( const ActionEvent
& rEvent
)
500 throw ( com::sun::star::uno::RuntimeException
)
502 switch( TKGet( rEvent
.ActionCommand
) )
504 case TK_btnNavBack
: mrOptimizerDialog
.SwitchPage( mrOptimizerDialog
.mnCurrentStep
- 1 ); break;
505 case TK_btnNavNext
: mrOptimizerDialog
.SwitchPage( mrOptimizerDialog
.mnCurrentStep
+ 1 ); break;
506 case TK_btnNavFinish
:
508 mrOptimizerDialog
.UpdateConfiguration();
510 mrOptimizerDialog
.SwitchPage( ITEM_ID_SUMMARY
);
511 mrOptimizerDialog
.DisablePage( ITEM_ID_SUMMARY
);
512 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavBack
), TKGet( TK_Enabled
), Any( sal_False
) );
513 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavNext
), TKGet( TK_Enabled
), Any( sal_False
) );
514 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavFinish
), TKGet( TK_Enabled
), Any( sal_False
) );
515 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavCancel
), TKGet( TK_Enabled
), Any( sal_False
) );
516 mrOptimizerDialog
.setControlProperty( TKGet( TK_FixedText0Pg4
), TKGet( TK_Enabled
), Any( sal_True
) );
518 // check if we have to open the FileDialog
519 sal_Bool bSuccessfullyExecuted
= sal_True
;
520 sal_Int16 nInt16
= 0;
521 mrOptimizerDialog
.getControlProperty( TKGet( TK_RadioButton1Pg4
), TKGet( TK_State
) ) >>= nInt16
;
525 FileOpenDialog
aFileOpenDialog( ((UnoDialog
&)mrOptimizerDialog
).mxMSF
);
527 // generating default file name
528 Reference
< XStorable
> xStorable( mrOptimizerDialog
.mxController
->getModel(), UNO_QUERY
);
529 if ( xStorable
.is() && xStorable
->hasLocation() )
531 OUString
aLocation( xStorable
->getLocation() );
532 if ( !aLocation
.isEmpty() )
534 sal_Int32 nIndex
= aLocation
.lastIndexOf( '/', aLocation
.getLength() - 1 );
537 if ( nIndex
< aLocation
.getLength() - 1 )
538 aLocation
= aLocation
.copy( nIndex
+ 1 );
541 nIndex
= aLocation
.lastIndexOf( '.', aLocation
.getLength() - 1 );
543 aLocation
= aLocation
.copy( 0, nIndex
);
546 aLocation
= aLocation
.concat( OUString(".mini") );
547 aFileOpenDialog
.setDefaultName( aLocation
);
551 sal_Bool bDialogExecuted
= aFileOpenDialog
.execute() == dialogs::ExecutableDialogResults::OK
;
552 if ( bDialogExecuted
)
554 aSaveAsURL
= aFileOpenDialog
.getURL();
555 mrOptimizerDialog
.SetConfigProperty( TK_SaveAsURL
, Any( aSaveAsURL
) );
556 mrOptimizerDialog
.SetConfigProperty( TK_FilterName
, Any( aFileOpenDialog
.getFilterName() ) );
558 if ( aSaveAsURL
.isEmpty() )
560 // something goes wrong...
561 bSuccessfullyExecuted
= sal_False
;
565 if ( mrOptimizerDialog
.mxReschedule
.is() )
567 mrOptimizerDialog
.mxReschedule
->reschedule();
568 for ( sal_uInt32 i
= osl_getGlobalTimer(); ( i
+ 500 ) > ( osl_getGlobalTimer() ); )
569 mrOptimizerDialog
.mxReschedule
->reschedule();
572 if ( bSuccessfullyExecuted
)
573 { // now check if we have to store a session template
575 OUString aSettingsName
;
576 mrOptimizerDialog
.getControlProperty( TKGet( TK_CheckBox1Pg4
), TKGet( TK_State
) ) >>= nInt16
;
577 mrOptimizerDialog
.getControlProperty( TKGet( TK_ComboBox0Pg4
), TKGet( TK_Text
) ) >>= aSettingsName
;
578 if ( nInt16
&& !aSettingsName
.isEmpty() )
580 std::vector
< OptimizerSettings
>::iterator
aIter( mrOptimizerDialog
.GetOptimizerSettingsByName( aSettingsName
) );
581 std::vector
< OptimizerSettings
>& rSettings( mrOptimizerDialog
.GetOptimizerSettings() );
582 OptimizerSettings
aNewSettings( rSettings
[ 0 ] );
583 aNewSettings
.maName
= aSettingsName
;
584 if ( aIter
== rSettings
.end() )
585 rSettings
.push_back( aNewSettings
);
587 *aIter
= aNewSettings
;
590 if ( bSuccessfullyExecuted
)
592 Sequence
< Any
> aArgs( 1 );
593 aArgs
[ 0 ] <<= mrOptimizerDialog
.GetFrame();
595 Reference
< XDispatch
> xDispatch( mrOptimizerDialog
.GetComponentContext()->getServiceManager()->createInstanceWithArgumentsAndContext(
596 OUString("com.sun.star.comp.PPPOptimizer"), aArgs
, mrOptimizerDialog
.GetComponentContext() ), UNO_QUERY
);
599 aURL
.Protocol
= OUString( "vnd.com.sun.star.comp.PPPOptimizer:" );
600 aURL
.Path
= OUString( "optimize" );
602 Sequence
< PropertyValue
> lArguments( 3 );
603 lArguments
[ 0 ].Name
= TKGet( TK_Settings
);
604 lArguments
[ 0 ].Value
<<= mrOptimizerDialog
.GetConfigurationSequence();
605 lArguments
[ 1 ].Name
= TKGet( TK_StatusDispatcher
);
606 lArguments
[ 1 ].Value
<<= mrOptimizerDialog
.GetStatusDispatcher();
607 lArguments
[ 2 ].Name
= TKGet( TK_InformationDialog
);
608 lArguments
[ 2 ].Value
<<= mrOptimizerDialog
.GetFrame();
611 xDispatch
->dispatch( aURL
, lArguments
);
613 mrOptimizerDialog
.endExecute( bSuccessfullyExecuted
);
617 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavBack
), TKGet( TK_Enabled
), Any( sal_True
) );
618 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavNext
), TKGet( TK_Enabled
), Any( sal_False
) );
619 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavFinish
), TKGet( TK_Enabled
), Any( sal_True
) );
620 mrOptimizerDialog
.setControlProperty( TKGet( TK_btnNavCancel
), TKGet( TK_Enabled
), Any( sal_True
) );
621 mrOptimizerDialog
.EnablePage( ITEM_ID_SUMMARY
);
625 case TK_btnNavCancel
: mrOptimizerDialog
.endExecute( sal_False
); break;
626 case TK_Button0Pg0
: // delete configuration
628 OUString
aSelectedItem( mrOptimizerDialog
.GetSelectedString( TK_ListBox0Pg0
) );
629 if ( !aSelectedItem
.isEmpty() )
631 std::vector
< OptimizerSettings
>::iterator
aIter( mrOptimizerDialog
.GetOptimizerSettingsByName( aSelectedItem
) );
632 std::vector
< OptimizerSettings
>& rList( mrOptimizerDialog
.GetOptimizerSettings() );
633 if ( aIter
!= rList
.end() )
635 rList
.erase( aIter
);
636 mrOptimizerDialog
.UpdateControlStates();
644 void ActionListener::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
645 throw ( com::sun::star::uno::RuntimeException
)
649 // -----------------------------------------------------------------------------
651 void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent
& rEvent
)
652 throw ( com::sun::star::uno::RuntimeException
)
654 if ( !rEvent
.ActionCommand
.isEmpty() )
656 std::vector
< OptimizerSettings
>::iterator
aIter( mrOptimizerDialog
.GetOptimizerSettingsByName( rEvent
.ActionCommand
) );
657 std::vector
< OptimizerSettings
>& rList( mrOptimizerDialog
.GetOptimizerSettings() );
658 if ( aIter
!= rList
.end() )
661 mrOptimizerDialog
.UpdateControlStates();
663 void ActionListenerListBox0Pg0::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
664 throw ( com::sun::star::uno::RuntimeException
)
668 // -----------------------------------------------------------------------------
670 void TextListenerFormattedField0Pg1::textChanged( const TextEvent
& /* rEvent */ )
671 throw ( com::sun::star::uno::RuntimeException
)
674 Any aAny
= mrOptimizerDialog
.getControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
) );
675 if ( aAny
>>= fDouble
)
676 mrOptimizerDialog
.SetConfigProperty( TK_JPEGQuality
, Any( (sal_Int32
)fDouble
) );
678 void TextListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
679 throw ( com::sun::star::uno::RuntimeException
)
683 // -----------------------------------------------------------------------------
685 void TextListenerComboBox0Pg1::textChanged( const TextEvent
& /* rEvent */ )
686 throw ( com::sun::star::uno::RuntimeException
)
689 Any aAny
= mrOptimizerDialog
.getControlProperty( TKGet( TK_ComboBox0Pg1
), TKGet( TK_Text
) );
690 if ( aAny
>>= aString
)
692 sal_Int32 nI0
, nI1
, nI2
, nI3
, nI4
;
693 nI0
= nI1
= nI2
= nI3
= nI4
= 0;
695 if ( mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_0
).getToken( 1, ';', nI0
) == aString
)
696 aString
= mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_0
).getToken( 0, ';', nI4
);
697 else if ( mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_1
).getToken( 1, ';', nI1
) == aString
)
698 aString
= mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_1
).getToken( 0, ';', nI4
);
699 else if ( mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_2
).getToken( 1, ';', nI2
) == aString
)
700 aString
= mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_2
).getToken( 0, ';', nI4
);
701 else if ( mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_3
).getToken( 1, ';', nI3
) == aString
)
702 aString
= mrOptimizerDialog
.getString( STR_IMAGE_RESOLUTION_3
).getToken( 0, ';', nI4
);
704 mrOptimizerDialog
.SetConfigProperty( TK_ImageResolution
, Any( aString
.toInt32() ) );
707 void TextListenerComboBox0Pg1::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
708 throw ( com::sun::star::uno::RuntimeException
)
712 // -----------------------------------------------------------------------------
714 void SpinListenerFormattedField0Pg1::up( const SpinEvent
& /* rEvent */ )
715 throw ( com::sun::star::uno::RuntimeException
)
718 Any aAny
= mrOptimizerDialog
.getControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
) );
719 if ( aAny
>>= fDouble
)
724 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
), Any( fDouble
) );
725 mrOptimizerDialog
.SetConfigProperty( TK_JPEGQuality
, Any( (sal_Int32
)fDouble
) );
728 void SpinListenerFormattedField0Pg1::down( const SpinEvent
& /* rEvent */ )
729 throw ( com::sun::star::uno::RuntimeException
)
732 Any aAny
= mrOptimizerDialog
.getControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
) );
733 if ( aAny
>>= fDouble
)
738 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
), Any( fDouble
) );
739 mrOptimizerDialog
.SetConfigProperty( TK_JPEGQuality
, Any( (sal_Int32
)fDouble
) );
742 void SpinListenerFormattedField0Pg1::first( const SpinEvent
& /* rEvent */ )
743 throw ( com::sun::star::uno::RuntimeException
)
745 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
), Any( static_cast< double >( 0 ) ) );
746 mrOptimizerDialog
.SetConfigProperty( TK_JPEGQuality
, Any( (sal_Int32
)0 ) );
748 void SpinListenerFormattedField0Pg1::last( const SpinEvent
& /* rEvent */ )
749 throw ( com::sun::star::uno::RuntimeException
)
751 mrOptimizerDialog
.setControlProperty( TKGet( TK_FormattedField0Pg1
), TKGet( TK_EffectiveValue
), Any( static_cast< double >( 100 ) ) );
752 mrOptimizerDialog
.SetConfigProperty( TK_JPEGQuality
, Any( (sal_Int32
)100 ) );
754 void SpinListenerFormattedField0Pg1::disposing( const ::com::sun::star::lang::EventObject
& /* Source */ )
755 throw ( com::sun::star::uno::RuntimeException
)
759 // -----------------------------------------------------------------------------
761 void HelpCloseListener::addCloseListener( const Reference
< XCloseListener
>& ) throw( RuntimeException
)
764 void HelpCloseListener::removeCloseListener( const Reference
< XCloseListener
>& ) throw( RuntimeException
)
767 void HelpCloseListener::queryClosing( const EventObject
&, sal_Bool
/* bDeliverOwnership */ )
768 throw ( RuntimeException
, CloseVetoException
)
771 void HelpCloseListener::notifyClosing( const EventObject
& )
772 throw ( RuntimeException
)
775 void HelpCloseListener::disposing( const EventObject
& ) throw ( RuntimeException
)
780 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */