LibreOffice Module sdext (master)  1
optimizerdialog.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include "optimizerdialog.hxx"
22 #include "impoptimizer.hxx"
23 #include "fileopendialog.hxx"
24 #include <com/sun/star/awt/XItemEventBroadcaster.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/container/XIndexContainer.hpp>
27 #include <com/sun/star/frame/XStorable.hpp>
28 #include <com/sun/star/frame/XTitle.hpp>
29 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
30 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
31 #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
32 #include <com/sun/star/io/IOException.hpp>
33 #include <com/sun/star/util/XModifiable.hpp>
34 
36 #include <sal/macros.h>
37 #include <osl/time.h>
38 #include <vcl/errinf.hxx>
39 #include <vcl/svapp.hxx>
40 #include <vcl/weld.hxx>
41 #include <svtools/sfxecode.hxx>
42 #include <svtools/ehdl.hxx>
43 #include <tools/urlobj.hxx>
44 #include <o3tl/string_view.hxx>
45 #include <bitmaps.hlst>
46 
47 using namespace ::com::sun::star::io;
48 using namespace ::com::sun::star::ui;
49 using namespace ::com::sun::star::awt;
50 using namespace ::com::sun::star::ucb;
51 using namespace ::com::sun::star::uno;
52 using namespace ::com::sun::star::util;
53 using namespace ::com::sun::star::lang;
54 using namespace ::com::sun::star::frame;
55 using namespace ::com::sun::star::beans;
56 using namespace ::com::sun::star::container;
57 
58 
60 {
61  // setting the dialog properties
62  OUString pNames[] = {
63  OUString("Closeable"),
64  OUString("Height"),
65  OUString("Moveable"),
66  OUString("PositionX"),
67  OUString("PositionY"),
68  OUString("Title"),
69  OUString("Width") };
70 
71  Any pValues[] = {
72  Any( true ),
73  Any( sal_Int32( DIALOG_HEIGHT ) ),
74  Any( true ),
75  Any( sal_Int32( 200 ) ),
76  Any( sal_Int32( 52 ) ),
78  Any( sal_Int32( OD_DIALOG_WIDTH ) ) };
79 
80  sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
81 
82  Sequence< OUString > aNames( pNames, nCount );
83  Sequence< Any > aValues( pValues, nCount );
84 
85  setPropertyValues(aNames, aValues);
86 }
87 
88 
90 {
91  try
92  {
93  OUString pNames[] = {
94  OUString("Height"),
95  OUString("PositionX"),
96  OUString("PositionY"),
97  OUString("Step"),
98  OUString("TabIndex"),
99  OUString("Width") };
100 
101  Any pValues[] = {
102  Any( sal_Int32( DIALOG_HEIGHT - 26 ) ),
103  Any( sal_Int32( 0 ) ),
104  Any( sal_Int32( 0 ) ),
105  Any( sal_Int32( 0 ) ),
106  Any( mnTabIndex++ ),
107  Any( sal_Int32( 85 ) ) };
108 
109  sal_Int32 nCount = SAL_N_ELEMENTS( pNames );
110 
111  Sequence< OUString > aNames( pNames, nCount );
112  Sequence< Any > aValues( pValues, nCount );
113 
114  mxRoadmapControlModel = insertControlModel( "com.sun.star.awt.UnoControlRoadmapModel",
115  "rdmNavi", aNames, aValues );
116 
117  Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW );
118  xPropertySet->setPropertyValue( "Name", Any( OUString("rdmNavi") ) );
119  mxRoadmapControl = getControl( "rdmNavi" );
125 
126  xPropertySet->setPropertyValue( "ImageURL", Any( OUString("private:graphicrepository/" BMP_PRESENTATION_MINIMIZER) ) );
127  xPropertySet->setPropertyValue( "Activated", Any( true ) );
128  xPropertySet->setPropertyValue( "Complete", Any( true ) );
129  xPropertySet->setPropertyValue( "CurrentItemID", Any( sal_Int16(ITEM_ID_INTRODUCTION) ) );
130  xPropertySet->setPropertyValue( "Text", Any( getString( STR_STEPS ) ) );
131  }
132  catch( Exception& )
133  {
134  }
135 }
136 
137 
138 void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const OUString& rLabel, const sal_Int32 nItemID )
139 {
140  try
141  {
142  Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
143  Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW );
144  Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_SET_THROW );
145  Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW );
146  xPropertySet->setPropertyValue( "Label", Any( rLabel ) );
147  xPropertySet->setPropertyValue( "Enabled", Any( true ) );
148  xPropertySet->setPropertyValue( "ID", Any( nItemID ) );
149  aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) );
150  }
151  catch( Exception& )
152  {
153 
154  }
155 }
156 
157 
159 {
160  sal_Int16 nInt16 = 0;
161  Any aAny;
162 
163  Sequence< sal_Int16 > aSelectedItems;
164  Sequence< OUString > aStringItemList;
165 
166  // page0
167  aAny = getControlProperty( "ListBox0Pg0", "SelectedItems" );
168  if ( aAny >>= aSelectedItems )
169  {
170  if ( aSelectedItems.hasElements() )
171  {
172  sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
173  aAny = getControlProperty( "ListBox0Pg0", "StringItemList" );
174  if ( aAny >>= aStringItemList )
175  {
176  if ( aStringItemList.getLength() > nSelectedItem )
177  SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) );
178  }
179  }
180  }
181 
182  aAny = getControlProperty( "CheckBox3Pg3", "State" );
183  if ( !((aAny >>= nInt16) && nInt16) )
184  return;
185 
186  aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" );
187  if ( !(aAny >>= aSelectedItems) )
188  return;
189 
190  if ( aSelectedItems.hasElements() )
191  {
192  sal_Int16 nSelectedItem = aSelectedItems[ 0 ];
193  aAny = getControlProperty( "ListBox0Pg3", "StringItemList" );
194  if ( aAny >>= aStringItemList )
195  {
196  if ( aStringItemList.getLength() > nSelectedItem )
197  SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) );
198  }
199  }
200 }
201 
202 
203 OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame > const & rxFrame, Reference< XDispatch > const & rxStatusDispatcher ) :
204  UnoDialog( rxContext, rxFrame ),
205  ConfigurationAccess( rxContext ),
206  mnCurrentStep( 0 ),
207  mnTabIndex( 0 ),
208  mxFrame( rxFrame ),
209  mxItemListener( new ItemListener( *this ) ),
210  mxActionListener( new ActionListener( *this ) ),
211  mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ),
212  mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ),
213  mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ),
214  mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ),
215  mxStatusDispatcher( rxStatusDispatcher )
216 {
217  Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW );
218  mbIsReadonly = xStorable->isReadonly();
219 
220  InitDialog();
221  InitRoadmap();
223  InitPage0();
224  InitPage1();
225  InitPage2();
226  InitPage3();
227  InitPage4();
228  ActivatePage( 0 );
229 
230  OptimizationStats aStats;
231  aStats.InitializeStatusValuesFromDocument( mxController->getModel() );
232  Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() );
233  UpdateStatus( aStatusSequence );
234 }
235 
236 
238 {
239  // not saving configuration if the dialog has been finished via cancel or close window
240  if ( endStatus() )
242 }
243 
244 
246 {
247  Reference< XItemEventBroadcaster > xRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW );
248  xRoadmapBroadcaster->addItemListener( mxItemListener );
250  UpdateConfiguration(); // taking actual control settings for the configuration
251  xRoadmapBroadcaster->removeItemListener( mxItemListener );
252 }
253 
254 
255 void OptimizerDialog::SwitchPage( sal_Int16 nNewStep )
256 {
257  if ( !(( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 )) )
258  return;
259 
260  sal_Int16 nOldStep = mnCurrentStep;
261  if ( nNewStep == 0 )
262  disableControl( "btnNavBack" );
263  else if ( nOldStep == 0 )
264  enableControl( "btnNavBack" );
265 
266  if ( nNewStep == MAX_STEP )
267  disableControl( "btnNavNext" );
268  else if ( nOldStep == MAX_STEP )
269  enableControl( "btnNavNext" );
270 
271  setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) );
272 
273  DeactivatePage( nOldStep );
274  UpdateControlStates( nNewStep );
275 
276  ActivatePage( nNewStep );
277  mnCurrentStep = nNewStep;
278 }
279 
281 {
282  switch( nPage )
283  {
284  case 0 : UpdateControlStatesPage0(); break;
285  case 1 : UpdateControlStatesPage1(); break;
286  case 2 : UpdateControlStatesPage2(); break;
287  case 3 : UpdateControlStatesPage3(); break;
288  case 4 : UpdateControlStatesPage4(); break;
289  default:
290  {
296  }
297  }
298 }
299 
300 
301 OUString OptimizerDialog::GetSelectedString( OUString const & token )
302 {
303  OUString aSelectedItem;
304  Sequence< sal_Int16 > sSelectedItems;
305  Sequence< OUString > sItemList;
306 
307  if ( ( getControlProperty( token, "SelectedItems" ) >>= sSelectedItems ) &&
308  ( getControlProperty( token, "StringItemList" ) >>= sItemList ) )
309  {
310  if ( sSelectedItems.getLength() == 1 )
311  {
312  sal_Int16 nSelectedItem = sSelectedItems[ 0 ];
313  if ( nSelectedItem < sItemList.getLength() )
314  aSelectedItem = sItemList[ nSelectedItem ];
315  }
316  }
317  return aSelectedItem;
318 }
319 
320 
321 void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus )
322 {
323  maStats.InitializeStatusValues( rStatus );
324  const Any* pVal( maStats.GetStatusValue( TK_Status ) );
325  if ( pVal )
326  {
327  OUString sStatus;
328  if ( *pVal >>= sStatus )
329  {
330  setControlProperty( "FixedText1Pg4", "Enabled", Any( true ) );
331  setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) );
332  }
333  }
335  if ( pVal )
336  {
337  sal_Int32 nProgress = 0;
338  if ( *pVal >>= nProgress )
339  setControlProperty( "Progress", "ProgressValue", Any( nProgress ) );
340  }
342  if ( pVal )
344 
345  reschedule();
346 }
347 
348 
349 void ItemListener::itemStateChanged( const ItemEvent& Event )
350 {
351  try
352  {
353  sal_Int16 nState;
354  Reference< XControl > xControl;
355  Any aSource( Event.Source );
356  if ( aSource >>= xControl )
357  {
358  Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW );
359  OUString aControlName;
360  xPropertySet->getPropertyValue( "Name" ) >>= aControlName;
361  PPPOptimizerTokenEnum eControl( TKGet( aControlName ) );
362  switch( eControl )
363  {
364  case TK_rdmNavi :
365  {
366  mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) );
367  }
368  break;
369  case TK_CheckBox1Pg1 :
370  {
371  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
373  }
374  break;
375  case TK_CheckBox2Pg1 :
376  {
377  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
379  }
380  break;
381  case TK_CheckBox0Pg2 :
382  {
383  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
384  {
386  mrOptimizerDialog.setControlProperty( "RadioButton0Pg2", "Enabled", Any( nState != 0 ) );
387  mrOptimizerDialog.setControlProperty( "RadioButton1Pg2", "Enabled", Any( nState != 0 ) );
388  }
389  }
390  break;
391  case TK_RadioButton0Pg1 :
392  {
393  sal_Int16 nInt16 = 0;
394  if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
395  {
396  nInt16 ^= 1;
398  mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nInt16 != 0 ) );
399  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nInt16 != 0 ) );
400  }
401  }
402  break;
403  case TK_RadioButton1Pg1 :
404  {
405  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
406  {
408  mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nState != 0 ) );
409  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nState != 0 ) );
410  }
411  }
412  break;
413  case TK_RadioButton0Pg2 :
414  {
415  sal_Int16 nInt16;
416  if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 )
417  {
418  nInt16 ^= 1;
420  }
421  }
422  break;
423  case TK_RadioButton1Pg2 :
424  {
425  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
427  }
428  break;
429  case TK_CheckBox0Pg3 :
430  {
431  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
433  }
434  break;
435  case TK_CheckBox1Pg3 :
436  {
437  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
439  }
440  break;
441  case TK_CheckBox2Pg3 :
442  {
443  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
445  }
446  break;
447  case TK_CheckBox3Pg3 :
448  {
449  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
450  mrOptimizerDialog.setControlProperty( "ListBox0Pg3", "Enabled", Any( nState != 0 ) );
451  }
452  break;
453  case TK_CheckBox1Pg4 :
454  {
455  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
456  mrOptimizerDialog.setControlProperty( "ComboBox0Pg4", "Enabled", Any( nState != 0 ) );
457  }
458  break;
459  case TK_RadioButton0Pg4 :
460  case TK_RadioButton1Pg4 :
461  {
462  if ( xPropertySet->getPropertyValue( "State" ) >>= nState )
463  mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) );
464  }
465  break;
466  default:
467  break;
468  }
469  }
470  }
471  catch ( Exception& )
472  {
473 
474  }
475 }
476 void ItemListener::disposing( const css::lang::EventObject& /* Source */ )
477 {
478 }
479 
480 void ActionListener::actionPerformed( const ActionEvent& rEvent )
481 {
482  switch( TKGet( rEvent.ActionCommand ) )
483  {
486  case TK_btnNavFinish :
487  {
489 
492  mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( false ) );
493  mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( false ) );
494  mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( false ) );
495  mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( false ) );
496  mrOptimizerDialog.setControlProperty( "FixedText0Pg4", "Enabled", Any( true ) );
497 
498  // check if we have to open the FileDialog
499  bool bSuccessfullyExecuted = true;
500  sal_Int16 nInt16 = 0;
501  mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) >>= nInt16;
502  if ( nInt16 )
503  {
504  // Duplicate presentation before applying changes
505  OUString aSaveAsURL;
507 
508  // generating default file name
509  OUString aName;
510  Reference< XStorable > xStorable( mrOptimizerDialog.controller()->getModel(), UNO_QUERY );
511  if ( xStorable.is() && xStorable->hasLocation() )
512  {
513  INetURLObject aURLObj( xStorable->getLocation() );
514  if ( !aURLObj.hasFinalSlash() )
515  {
516  // tdf#105382 uri-decode file name
518  aName = aURLObj.getName(INetURLObject::LAST_SEGMENT, false,
520  }
521  }
522  else
523  {
524  // If no filename, try to use model title ("Untitled 1" or something like this)
525  Reference<XTitle> xTitle(
526  mrOptimizerDialog.GetFrame()->getController()->getModel(), UNO_QUERY);
527  aName = xTitle->getTitle();
528  }
529 
530  if (!aName.isEmpty())
531  {
533  aFileOpenDialog.setDefaultName(aName);
534  }
535 
536  if (aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK)
537  {
538  aSaveAsURL = aFileOpenDialog.getURL();
540  mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) );
541  }
542  if ( aSaveAsURL.isEmpty() )
543  {
544  // something goes wrong...
545  bSuccessfullyExecuted = false;
546  }
547 
548  // waiting for 500ms
550  for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); )
552  }
553  else
554  {
555  // Apply changes to current presentation
556  Reference<XModifiable> xModifiable(mrOptimizerDialog.controller()->getModel(),
557  UNO_QUERY_THROW );
558  if ( xModifiable->isModified() )
559  {
560  SolarMutexGuard aSolarGuard;
561  std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog(
562  nullptr, VclMessageType::Question, VclButtonsType::YesNo,
564  if (popupDlg->run() != RET_YES)
565  {
566  // Selected not "yes" ("no" or dialog was cancelled) so return to previous step
567  mrOptimizerDialog.setControlProperty("btnNavBack", "Enabled",
568  Any(true));
569  mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false));
570  mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true));
571  mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true));
573  return;
574  }
575  }
576  }
577  if ( bSuccessfullyExecuted )
578  { // now check if we have to store a session template
579  nInt16 = 0;
580  OUString aSettingsName;
581  mrOptimizerDialog.getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16;
582  mrOptimizerDialog.getControlProperty( "ComboBox0Pg4", "Text" ) >>= aSettingsName;
583  if ( nInt16 && !aSettingsName.isEmpty() )
584  {
585  std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) );
586  std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() );
587  OptimizerSettings aNewSettings( rSettings[ 0 ] );
588  aNewSettings.maName = aSettingsName;
589  if ( aIter == rSettings.end() )
590  rSettings.push_back( aNewSettings );
591  else
592  *aIter = aNewSettings;
593  }
594  }
595  if ( bSuccessfullyExecuted )
596  {
597  URL aURL;
598  aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
599  aURL.Path = "optimize";
600 
601  Sequence< PropertyValue > lArguments{
605  };
606 
607  ErrCode errorCode;
608  try
609  {
610  ImpOptimizer aOptimizer(
612  mrOptimizerDialog.GetFrame()->getController()->getModel());
613  aOptimizer.Optimize(lArguments);
614  }
615  catch (css::io::IOException&)
616  {
617  // We always receive just ERRCODE_IO_CANTWRITE in case of problems, so no need to bother
618  // about extracting error code from exception text
619  errorCode = ERRCODE_IO_CANTWRITE;
620  }
621  catch (css::uno::Exception&)
622  {
623  // Other general exception
624  errorCode = ERRCODE_IO_GENERAL;
625  }
626 
627  if (errorCode != ERRCODE_NONE)
628  {
629  // Restore wizard controls
631  Any(static_cast<sal_Int32>(0)));
632  mrOptimizerDialog.setControlProperty("btnNavBack", "Enabled", Any(true));
633  mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false));
634  mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true));
635  mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true));
636 
637  OUString aFileName;
639  SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, aFileName);
640  ErrorHandler::HandleError(errorCode);
641  break;
642  }
643 
644  mrOptimizerDialog.endExecute( bSuccessfullyExecuted );
645  }
646  else
647  {
648  mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( true ) );
649  mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( false ) );
650  mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( true ) );
651  mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( true ) );
653  }
654  }
655  break;
656  case TK_btnNavCancel : mrOptimizerDialog.endExecute( false ); break;
657  case TK_Button0Pg0 : // delete configuration
658  {
659  OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( "ListBox0Pg0" ) );
660  if ( !aSelectedItem.isEmpty() )
661  {
662  std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) );
663  std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
664  if ( aIter != rList.end() )
665  {
666  rList.erase( aIter );
668  }
669  }
670  }
671  break;
672  default: break;
673  }
674 }
675 void ActionListener::disposing( const css::lang::EventObject& /* Source */ )
676 {
677 }
678 
679 
680 void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent )
681 {
682  if ( !rEvent.ActionCommand.isEmpty() )
683  {
684  std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) );
685  std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
686  if ( aIter != rList.end() )
687  rList[ 0 ] = *aIter;
688  }
690 }
691 void ActionListenerListBox0Pg0::disposing( const css::lang::EventObject& /* Source */ )
692 {
693 }
694 
695 
696 void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ )
697 {
698  double fDouble = 0;
699  Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
700  if ( aAny >>= fDouble )
701  mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) );
702 }
703 void TextListenerFormattedField0Pg1::disposing( const css::lang::EventObject& /* Source */ )
704 {
705 }
706 
707 namespace
708 {
709 
710 bool lcl_mapResolution(OUString& rResolution, std::u16string_view rImageResolution)
711 {
712  if (o3tl::getToken(rImageResolution, 1, ';')!=rResolution)
713  return false;
714  rResolution = o3tl::getToken(rImageResolution, 0, ';');
715  return true;
716 }
717 
718 }
719 
720 void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ )
721 {
722  OUString aString;
723  Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" );
724  if ( !(aAny >>= aString) )
725  return;
726 
727  for (int nIR{ STR_IMAGE_RESOLUTION_0 }; nIR <= STR_IMAGE_RESOLUTION_3; ++nIR)
728  {
729  if (lcl_mapResolution(aString, mrOptimizerDialog.getString(static_cast<PPPOptimizerTokenEnum>(nIR))))
730  break;
731  }
732 
734 }
735 void TextListenerComboBox0Pg1::disposing( const css::lang::EventObject& /* Source */ )
736 {
737 }
738 
739 
740 void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ )
741 {
742  double fDouble;
743  Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
744  if ( aAny >>= fDouble )
745  {
746  fDouble += 9;
747  if ( fDouble > 100 )
748  fDouble = 100;
749  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
750  mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) );
751  }
752 }
753 void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ )
754 {
755  double fDouble;
756  Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" );
757  if ( aAny >>= fDouble )
758  {
759  fDouble -= 9;
760  if ( fDouble < 0 )
761  fDouble = 0;
762  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) );
763  mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) );
764  }
765 }
766 void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ )
767 {
768  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 0 ) ) );
770 }
771 void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ )
772 {
773  mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 100 ) ) );
775 }
776 void SpinListenerFormattedField0Pg1::disposing( const css::lang::EventObject& /* Source */ )
777 {
778 }
779 
780 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL actionPerformed(const css::awt::ActionEvent &Event) override
void EnablePage(sal_Int16 nStep)
void disableControl(const OUString &rControlName)
Definition: unodialog.cxx:303
const css::uno::Any * GetStatusValue(const PPPOptimizerTokenEnum eStat) const
URL aURL
css::uno::Any getControlProperty(const OUString &rControlName, const OUString &rPropertyName)
Definition: unodialog.cxx:279
void InitializeStatusValues(const css::uno::Sequence< css::beans::PropertyValue > &rOptimizationStats)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
#define ITEM_ID_SLIDES
virtual void SAL_CALL up(const css::awt::SpinEvent &Event) override
OptimizerDialog & mrOptimizerDialog
#define ITEM_ID_SUMMARY
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
bool removeExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
void SetStatusValue(const PPPOptimizerTokenEnum eStat, const css::uno::Any &rStatValue)
css::uno::Sequence< css::beans::PropertyValue > GetConfigurationSequence()
OptimizerDialog(const css::uno::Reference< css::uno::XComponentContext > &rxContext, css::uno::Reference< css::frame::XFrame > const &rxFrame, css::uno::Reference< css::frame::XDispatch > const &rxStatusDispatcher)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
#define DIALOG_HEIGHT
std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName(const OUString &rName)
void ActivatePage(sal_Int16 nStep)
css::uno::Reference< css::frame::XFrame > & GetFrame()
#define MAX_STEP
virtual void SAL_CALL itemStateChanged(const css::awt::ItemEvent &Event) override
css::uno::Reference< css::frame::XDispatch > & GetStatusDispatcher()
void setPropertyValues(const css::uno::Sequence< OUString > &rNameSeq, const css::uno::Sequence< css::uno::Any > &rValueSeq)
Definition: unodialog.hxx:94
#define ITEM_ID_OLE_OPTIMIZATION
void execute()
Definition: unodialog.cxx:73
void reschedule() const
Definition: unodialog.hxx:90
void InsertRoadmapItem(const sal_Int32 nIndex, const OUString &rLabel, const sal_Int32 nItemID)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void setControlProperty(const OUString &rControlName, const OUString &rPropertyName, const css::uno::Any &rPropertyValue)
Definition: unodialog.cxx:263
RET_YES
void InitializeStatusValuesFromDocument(const css::uno::Reference< css::frame::XModel > &rxModel)
int nCount
PPPOptimizerTokenEnum
#define ERRCODE_IO_CANTWRITE
css::uno::Reference< css::uno::XInterface > mxRoadmapControl
css::uno::Reference< css::awt::XItemListener > mxItemListener
#define SAL_N_ELEMENTS(arr)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
void SwitchPage(sal_Int16 nNewStep)
OUString getString(const PPPOptimizerTokenEnum) const
#define ERRCODE_IO_GENERAL
int i
void SetConfigProperty(const PPPOptimizerTokenEnum, const css::uno::Any &aValue)
void DeactivatePage(sal_Int16 nStep)
bool endStatus() const
Definition: unodialog.hxx:91
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
#define ITEM_ID_GRAPHIC_OPTIMIZATION
#define ITEM_ID_INTRODUCTION
void UpdateStatus(const css::uno::Sequence< css::beans::PropertyValue > &rStatus)
void endExecute(bool bStatus)
Definition: unodialog.cxx:80
OptimizerDialog & mrOptimizerDialog
virtual void SAL_CALL actionPerformed(const css::awt::ActionEvent &Event) override
const css::uno::Reference< css::frame::XController > & controller() const
Definition: unodialog.hxx:93
void enableControl(const OUString &rControlName)
Definition: unodialog.cxx:297
virtual void SAL_CALL first(const css::awt::SpinEvent &Event) override
void DisablePage(sal_Int16 nStep)
#define OD_DIALOG_WIDTH
const PropertyValue * pValues
css::uno::Reference< css::frame::XController > mxController
Definition: unodialog.hxx:99
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL last(const css::awt::SpinEvent &Event) override
css::uno::Reference< css::uno::XInterface > insertControlModel(const OUString &rServiceName, const OUString &rName, const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rPropertyValues)
Definition: unodialog.cxx:86
#define ERRCODE_NONE
virtual void SAL_CALL textChanged(const css::awt::TextEvent &Event) override
#define ERRCTX_SFX_SAVEASDOC
void UpdateControlStates(sal_Int16 nStep=-1)
OUString aName
std::vector< OptimizerSettings > & GetOptimizerSettings()
css::uno::Reference< css::awt::XControl > getControl(const OUString &rControlName) const
Definition: unodialog.hxx:92
OUString GetSelectedString(OUString const &token)
PPPOptimizerTokenEnum TKGet(const OUString &rToken)
css::beans::PropertyValues GetStatusSequence()
css::uno::Any GetConfigProperty(const PPPOptimizerTokenEnum) const
css::uno::Reference< css::uno::XInterface > mxRoadmapControlModel
OptimizationStats maStats
sal_Int16 mnCurrentStep
virtual void SAL_CALL down(const css::awt::SpinEvent &Event) override
sal_Int32 nState
const css::uno::Reference< css::uno::XComponentContext > & GetComponentContext() const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
virtual void SAL_CALL textChanged(const css::awt::TextEvent &Event) override