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
47using namespace ::com::sun::star::io;
48using namespace ::com::sun::star::ui;
49using namespace ::com::sun::star::awt;
50using namespace ::com::sun::star::ucb;
51using namespace ::com::sun::star::uno;
52using namespace ::com::sun::star::util;
53using namespace ::com::sun::star::lang;
54using namespace ::com::sun::star::frame;
55using namespace ::com::sun::star::beans;
56using namespace ::com::sun::star::container;
57
59 : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmintropage.ui", "PMIntroPage")
60 , mrOptimizerDialog(rOptimizerDialog)
61 , mxComboBox(m_xBuilder->weld_combo_box("LB_SETTINGS"))
62 , mxButton(m_xBuilder->weld_button("STR_REMOVE"))
63{
64 mxComboBox->connect_changed(LINK(this, IntroPage, ComboBoxActionPerformed));
65 mxButton->connect_clicked(LINK(this, IntroPage, ButtonActionPerformed));
66}
67
68void IntroPage::UpdateControlStates(const std::vector<OUString>& rItemList, int nSelectedItem, bool bRemoveButtonEnabled)
69{
70 mxComboBox->clear();
71 for (const auto& a : rItemList)
72 mxComboBox->append_text(a);
73 mxComboBox->set_active(nSelectedItem);
74 mxButton->set_sensitive(bRemoveButtonEnabled);
75}
76
78 : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmslidespage.ui", "PMSlidesPage")
79 , mrOptimizerDialog(rOptimizerDialog)
80 , mxMasterSlides(m_xBuilder->weld_check_button("STR_DELETE_MASTER_PAGES"))
81 , mxHiddenSlides(m_xBuilder->weld_check_button("STR_DELETE_HIDDEN_SLIDES"))
82 , mxUnusedSlides(m_xBuilder->weld_check_button("STR_CUSTOM_SHOW"))
83 , mxComboBox(m_xBuilder->weld_combo_box("LB_SLIDES"))
84 , mxClearNodes(m_xBuilder->weld_check_button("STR_DELETE_NOTES_PAGES"))
85{
86 mxMasterSlides->connect_toggled(LINK(this, SlidesPage, UnusedMasterPagesActionPerformed));
87 mxHiddenSlides->connect_toggled(LINK(this, SlidesPage, UnusedHiddenSlidesActionPerformed));
88 mxUnusedSlides->connect_toggled(LINK(this, SlidesPage, UnusedSlidesActionPerformed));
89 mxClearNodes->connect_toggled(LINK(this, SlidesPage, DeleteNotesActionPerformed));
90}
91
92void SlidesPage::Init(const css::uno::Sequence<OUString>& rCustomShowList)
93{
94 mxComboBox->clear();
95 for (const auto& a : rCustomShowList)
96 mxComboBox->append_text(a);
97 mxUnusedSlides->set_sensitive(rCustomShowList.hasElements());
98}
99
100void SlidesPage::UpdateControlStates(bool bDeleteUnusedMasterPages, bool bDeleteHiddenSlides, bool bDeleteNotesPages)
101{
102 mxMasterSlides->set_active(bDeleteUnusedMasterPages);
103 mxHiddenSlides->set_active(bDeleteHiddenSlides);
104 mxClearNodes->set_active(bDeleteNotesPages);
105 mxComboBox->set_sensitive(mxUnusedSlides->get_sensitive());
106}
107
109 : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmimagespage.ui", "PMImagesPage")
110 , mrOptimizerDialog(rOptimizerDialog)
111 , m_xLossLessCompression(m_xBuilder->weld_radio_button("STR_LOSSLESS_COMPRESSION"))
112 , m_xQualityLabel(m_xBuilder->weld_label("STR_QUALITY"))
113 , m_xQuality(m_xBuilder->weld_spin_button("SB_QUALITY"))
114 , m_xJpegCompression(m_xBuilder->weld_radio_button("STR_JPEG_COMPRESSION"))
115 , m_xResolution(m_xBuilder->weld_combo_box("LB_RESOLUTION"))
116 , m_xRemoveCropArea(m_xBuilder->weld_check_button("STR_REMOVE_CROP_AREA"))
117 , m_xEmbedLinkedGraphics(m_xBuilder->weld_check_button("STR_EMBED_LINKED_GRAPHICS"))
118{
119 m_xRemoveCropArea->connect_toggled(LINK(this, ImagesPage, RemoveCropAreaActionPerformed));
120 m_xEmbedLinkedGraphics->connect_toggled(LINK(this, ImagesPage, EmbedLinkedGraphicsActionPerformed));
121 m_xResolution->connect_changed(LINK(this, ImagesPage, ComboBoxActionPerformed));
122 m_xQuality->connect_value_changed(LINK(this, ImagesPage, SpinButtonActionPerformed));
123
124 m_xJpegCompression->connect_toggled(LINK(this, ImagesPage, CompressionActionPerformed));
125 m_xLossLessCompression->connect_toggled(LINK(this, ImagesPage, CompressionActionPerformed));
126}
127
128void ImagesPage::UpdateControlStates(bool bJPEGCompression, int nJPEGQuality, bool bRemoveCropArea,
129 int nResolution, bool bEmbedLinkedGraphics)
130{
131 m_xLossLessCompression->set_active(!bJPEGCompression);
132 m_xJpegCompression->set_active(bJPEGCompression);
133 m_xQualityLabel->set_sensitive(bJPEGCompression);
134 m_xQuality->set_sensitive(bJPEGCompression);
135 m_xQuality->set_value(nJPEGQuality);
136 m_xResolution->set_active_id(OUString::number(nResolution));
137 m_xRemoveCropArea->set_active(bRemoveCropArea);
138 m_xEmbedLinkedGraphics->set_active(bEmbedLinkedGraphics);
139}
140
142 : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmobjectspage.ui", "PMObjectsPage")
143 , mrOptimizerDialog(rOptimizerDialog)
144 , m_xCreateStaticImage(m_xBuilder->weld_check_button("STR_OLE_REPLACE"))
145 , m_xAllOLEObjects(m_xBuilder->weld_radio_button("STR_ALL_OLE_OBJECTS"))
146 , m_xForeignOLEObjects(m_xBuilder->weld_radio_button("STR_ALIEN_OLE_OBJECTS_ONLY"))
147 , m_xLabel(m_xBuilder->weld_label("STR_OLE_OBJECTS_DESC"))
148{
149 m_xCreateStaticImage->connect_toggled(LINK(this, ObjectsPage, OLEOptimizationActionPerformed));
150 m_xAllOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed));
151 m_xForeignOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed));
152}
153
154void ObjectsPage::Init(const OUString& rDesc)
155{
156 m_xLabel->set_label(rDesc);
157}
158
159void ObjectsPage::UpdateControlStates(bool bConvertOLEObjects, int nOLEOptimizationType)
160{
161 m_xCreateStaticImage->set_active(bConvertOLEObjects);
162 m_xAllOLEObjects->set_sensitive(bConvertOLEObjects);
163 m_xForeignOLEObjects->set_sensitive(bConvertOLEObjects);
164 m_xAllOLEObjects->set_active(nOLEOptimizationType == 0);
165 m_xForeignOLEObjects->set_active(nOLEOptimizationType == 1);
166}
167
169 : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmsummarypage.ui", "PMSummaryPage")
170 , mrOptimizerDialog(rOptimizerDialog)
171 , m_xLabel1(m_xBuilder->weld_label("LABEL1"))
172 , m_xLabel2(m_xBuilder->weld_label("LABEL2"))
173 , m_xLabel3(m_xBuilder->weld_label("LABEL3"))
174 , m_xCurrentSize(m_xBuilder->weld_label("CURRENT_FILESIZE"))
175 , m_xEstimatedSize(m_xBuilder->weld_label("ESTIMATED_FILESIZE"))
176 , m_xStatus(m_xBuilder->weld_label("STR_STATUS"))
177 , m_xProgress(m_xBuilder->weld_progress_bar("PROGRESS"))
178 , m_xApplyToCurrent(m_xBuilder->weld_radio_button("STR_APPLY_TO_CURRENT"))
179 , m_xSaveToNew(m_xBuilder->weld_radio_button("STR_SAVE_AS"))
180 , m_xComboBox(m_xBuilder->weld_combo_box("MY_SETTINGS"))
181 , m_xSaveSettings(m_xBuilder->weld_check_button("STR_SAVE_SETTINGS"))
182{
183 m_xApplyToCurrent->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed));
184 m_xSaveToNew->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed));
185 m_xSaveSettings->connect_toggled(LINK(this, SummaryPage, SaveSettingsActionPerformed));
186}
187
188void SummaryPage::Init(const OUString& rSettingsName, bool bIsReadonly)
189{
190 m_xComboBox->set_entry_text(rSettingsName);
191 m_xApplyToCurrent->set_sensitive(!bIsReadonly);
192 m_xSaveToNew->set_sensitive(!bIsReadonly);
193}
194
195void SummaryPage::UpdateControlStates(bool bSaveAs, bool bSaveSettingsEnabled,
196 const std::vector<OUString>& rItemList,
197 const std::vector<OUString>& rSummaryStrings,
198 const OUString& rCurrentFileSize,
199 const OUString& rEstimatedFileSize)
200{
201 m_xApplyToCurrent->set_active(!bSaveAs);
202 m_xSaveToNew->set_active(bSaveAs);
203
204 for (const auto& a : rItemList)
205 m_xComboBox->append_text(a);
206
207 m_xSaveSettings->set_sensitive(bSaveSettingsEnabled);
208 m_xComboBox->set_sensitive(bSaveSettingsEnabled && m_xSaveSettings->get_active());
209
210 assert(rSummaryStrings.size() == 3);
211 m_xLabel1->set_label(rSummaryStrings[0]);
212 m_xLabel2->set_label(rSummaryStrings[1]);
213 m_xLabel3->set_label(rSummaryStrings[2]);
214
215 m_xCurrentSize->set_label(rCurrentFileSize);
216 m_xEstimatedSize->set_label(rEstimatedFileSize);
217}
218
219void SummaryPage::UpdateStatusLabel(const OUString& rStatus)
220{
221 m_xStatus->set_label(rStatus);
222}
223
225{
226 m_xProgress->set_percentage(nProgress);
227}
228
230{
232}
233
235{
237 0,
243 );
244
245 m_xAssistant->set_page_side_image(BMP_PRESENTATION_MINIMIZER);
246}
247
249{
250 // page0
251 OUString sTKName(mpPage0->Get_TK_Name());
252 if (!sTKName.isEmpty())
253 SetConfigProperty(TK_Name, Any(sTKName));
254
255 // page1
256 OUString sTKCustomShowName(mpPage1->Get_TK_CustomShowName());
257 if (!sTKCustomShowName.isEmpty())
258 SetConfigProperty(TK_CustomShowName, Any(sTKCustomShowName));
259}
260
261OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame > const & rxFrame, Reference< XDispatch > const & rxStatusDispatcher )
262 : vcl::RoadmapWizardMachine(Application::GetFrameWeld(rxFrame->getComponentWindow()))
263 , ConfigurationAccess(rxContext)
264 , mnEndStatus(RET_CANCEL)
265 , mxFrame(rxFrame)
266 , mxController(rxFrame->getController())
267 , mxStatusDispatcher(rxStatusDispatcher)
268{
269 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW );
270 mbIsReadonly = xStorable->isReadonly();
271
272 InitDialog();
273 InitRoadmap();
275 InitPage0();
276 InitPage1();
277 InitPage2();
278 InitPage3();
279 InitPage4();
280
281 ActivatePage();
282 m_xAssistant->set_current_page(0);
283
284 OptimizationStats aStats;
286 Sequence< PropertyValue > aStatusSequence( aStats.GetStatusSequence() );
287 UpdateStatus( aStatusSequence );
288}
289
291{
292 switch (nState)
293 {
296 case ITEM_ID_SLIDES:
297 return getString(STR_SLIDES);
302 case ITEM_ID_SUMMARY:
303 return getString(STR_SUMMARY);
304 }
305 return OUString();
306}
307
309{
310 OString sIdent(OString::number(nState));
311 weld::Container* pPageContainer = m_xAssistant->append_page(sIdent);
312
313 std::unique_ptr<vcl::OWizardPage> xRet;
314
315 switch (nState)
316 {
318 xRet.reset(new IntroPage(pPageContainer, *this));
319 mpPage0 = static_cast<IntroPage*>(xRet.get());
320 break;
321 case ITEM_ID_SLIDES:
322 xRet.reset(new SlidesPage(pPageContainer, *this));
323 mpPage1 = static_cast<SlidesPage*>(xRet.get());
324 break;
326 xRet.reset(new ImagesPage(pPageContainer, *this));
327 mpPage2 = static_cast<ImagesPage*>(xRet.get());
328 break;
330 xRet.reset(new ObjectsPage(pPageContainer, *this));
331 mpPage3 = static_cast<ObjectsPage*>(xRet.get());
332 break;
333 case ITEM_ID_SUMMARY:
334 xRet.reset(new SummaryPage(pPageContainer, *this));
335 mpPage4 = static_cast<SummaryPage*>(xRet.get());
336 break;
337 }
338
339 m_xAssistant->set_page_title(sIdent, getStateDisplayName(nState));
340
341 return xRet;
342}
343
345{
346 // not saving configuration if the dialog has been finished via cancel or close window
347 if (mnEndStatus == RET_OK)
349}
350
352{
353 mnEndStatus = run();
354 UpdateConfiguration(); // taking actual control settings for the configuration
355}
356
358{
359 switch( nPage )
360 {
361 case 0 : UpdateControlStatesPage0(); break;
362 case 1 : UpdateControlStatesPage1(); break;
363 case 2 : UpdateControlStatesPage2(); break;
364 case 3 : UpdateControlStatesPage3(); break;
365 case 4 : UpdateControlStatesPage4(); break;
366 default:
367 {
373 }
374 }
375}
376
377void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus )
378{
380 const Any* pVal( maStats.GetStatusValue( TK_Status ) );
381 if ( pVal )
382 {
383 OUString sStatus;
384 if ( *pVal >>= sStatus )
385 {
387 }
388 }
390 if ( pVal )
391 {
392 sal_Int32 nProgress = 0;
393 if ( *pVal >>= nProgress )
394 mpPage4->UpdateProgressValue(nProgress);
395 }
397 if ( pVal )
399
401}
402
403IMPL_LINK(SummaryPage, SaveAsNewActionPerformed, weld::Toggleable&, rBox, void)
404{
405 if (!rBox.get_active())
406 return;
407
408 const bool bSaveToNew = &rBox == m_xSaveToNew.get();
409 mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any(bSaveToNew) );
410}
411
412IMPL_LINK(SummaryPage, SaveSettingsActionPerformed, weld::Toggleable&, rBox, void)
413{
414 m_xComboBox->set_sensitive(rBox.get_active());
415}
416
417IMPL_LINK(ObjectsPage, OLEActionPerformed, weld::Toggleable&, rBox, void)
418{
419 if (!rBox.get_active())
420 return;
421
422 const bool bALLOles = &rBox == m_xAllOLEObjects.get();
423 sal_Int16 nInt16 = bALLOles ? 0 : 1;
424 mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) );
425}
426
427IMPL_LINK(ObjectsPage, OLEOptimizationActionPerformed, weld::Toggleable&, rBox, void)
428{
429 const bool bOLEOptimization = rBox.get_active();
430 mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any(bOLEOptimization) );
431 m_xAllOLEObjects->set_sensitive(bOLEOptimization);
432 m_xForeignOLEObjects->set_sensitive(bOLEOptimization);
433}
434
435IMPL_LINK(ImagesPage, CompressionActionPerformed, weld::Toggleable&, rBox, void)
436{
437 if (!rBox.get_active())
438 return;
439
440 const bool bJPEGCompression = &rBox == m_xJpegCompression.get();
441 mrOptimizerDialog.SetConfigProperty(TK_JPEGCompression, Any(bJPEGCompression));
442 m_xQualityLabel->set_sensitive(bJPEGCompression);
443 m_xQuality->set_sensitive(bJPEGCompression);
444}
445
446IMPL_LINK(ImagesPage, RemoveCropAreaActionPerformed, weld::Toggleable&, rBox, void)
447{
448 mrOptimizerDialog.SetConfigProperty(TK_RemoveCropArea, Any(rBox.get_active()));
449}
450
451IMPL_LINK(ImagesPage, EmbedLinkedGraphicsActionPerformed, weld::Toggleable&, rBox, void)
452{
453 mrOptimizerDialog.SetConfigProperty(TK_EmbedLinkedGraphics, Any(rBox.get_active()));
454}
455
456IMPL_LINK(SlidesPage, UnusedHiddenSlidesActionPerformed, weld::Toggleable&, rBox, void)
457{
458 mrOptimizerDialog.SetConfigProperty(TK_DeleteHiddenSlides, Any(rBox.get_active()));
459}
460
461IMPL_LINK(SlidesPage, UnusedMasterPagesActionPerformed, weld::Toggleable&, rBox, void)
462{
463 mrOptimizerDialog.SetConfigProperty(TK_DeleteUnusedMasterPages, Any(rBox.get_active()));
464}
465
466IMPL_LINK(SlidesPage, DeleteNotesActionPerformed, weld::Toggleable&, rBox, void)
467{
468 mrOptimizerDialog.SetConfigProperty(TK_DeleteNotesPages, Any(rBox.get_active()));
469}
470
471IMPL_LINK(SlidesPage, UnusedSlidesActionPerformed, weld::Toggleable&, rBox, void)
472{
473 mxComboBox->set_sensitive(rBox.get_active());
474}
475
477{
479
481 m_xPrevPage->set_sensitive(false);
482 m_xNextPage->set_sensitive(false);
483 m_xFinish->set_sensitive(false);
484 m_xCancel->set_sensitive(false);
485
486 // check if we have to open the FileDialog
487 bool bSuccessfullyExecuted = true;
488 if (mpPage4->GetSaveAsNew())
489 {
490 // Duplicate presentation before applying changes
491 OUString aSaveAsURL;
492 FileOpenDialog aFileOpenDialog(mxContext);
493
494 // generating default file name
495 OUString aName;
496 Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY );
497 if ( xStorable.is() && xStorable->hasLocation() )
498 {
499 INetURLObject aURLObj( xStorable->getLocation() );
500 if ( !aURLObj.hasFinalSlash() )
501 {
502 // tdf#105382 uri-decode file name
506 }
507 }
508 else
509 {
510 // If no filename, try to use model title ("Untitled 1" or something like this)
511 Reference<XTitle> xTitle(
512 GetFrame()->getController()->getModel(), UNO_QUERY);
513 aName = xTitle->getTitle();
514 }
515
516 if (!aName.isEmpty())
517 {
519 aFileOpenDialog.setDefaultName(aName);
520 }
521
522 if (aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK)
523 {
524 aSaveAsURL = aFileOpenDialog.getURL();
525 SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) );
526 SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) );
527 }
528 if ( aSaveAsURL.isEmpty() )
529 {
530 // something goes wrong...
531 bSuccessfullyExecuted = false;
532 }
533
534 // waiting for 500ms
536 for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); )
538 }
539 else
540 {
541 // Apply changes to current presentation
542 Reference<XModifiable> xModifiable(mxController->getModel(),
543 UNO_QUERY_THROW );
544 if ( xModifiable->isModified() )
545 {
546 SolarMutexGuard aSolarGuard;
547 std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog(
548 m_xAssistant.get(), VclMessageType::Question, VclButtonsType::YesNo,
550 if (popupDlg->run() != RET_YES)
551 {
552 // Selected not "yes" ("no" or dialog was cancelled) so return to previous step
553 m_xPrevPage->set_sensitive(true);
554 m_xNextPage->set_sensitive(true);
555 m_xFinish->set_sensitive(true);
556 m_xCancel->set_sensitive(true);
557 return false;
558 }
559 }
560 }
561 if ( bSuccessfullyExecuted )
562 {
563 // now check if we have to store a session template
564 const bool bSaveSettings = mpPage4->GetSaveSettings();
565 OUString aSettingsName = mpPage4->GetSettingsName();
566 if (bSaveSettings && !aSettingsName.isEmpty())
567 {
568 std::vector< OptimizerSettings >::iterator aIter( GetOptimizerSettingsByName( aSettingsName ) );
569 std::vector< OptimizerSettings >& rSettings( GetOptimizerSettings() );
570 OptimizerSettings aNewSettings( rSettings[ 0 ] );
571 aNewSettings.maName = aSettingsName;
572 if ( aIter == rSettings.end() )
573 rSettings.push_back( aNewSettings );
574 else
575 *aIter = aNewSettings;
576 }
577 }
578 if ( bSuccessfullyExecuted )
579 {
580 URL aURL;
581 aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:";
582 aURL.Path = "optimize";
583
584 Sequence< PropertyValue > lArguments{
587 comphelper::makePropertyValue("DocumentFrame", GetFrame()),
588 comphelper::makePropertyValue("DialogParentWindow", m_xAssistant->GetXWindow())
589 };
590
591 ErrCode errorCode;
592 try
593 {
594 ImpOptimizer aOptimizer(mxContext, GetFrame()->getController()->getModel());
595 aOptimizer.Optimize(lArguments);
596 }
597 catch (css::io::IOException&)
598 {
599 // We always receive just ERRCODE_IO_CANTWRITE in case of problems, so no need to bother
600 // about extracting error code from exception text
601 errorCode = ERRCODE_IO_CANTWRITE;
602 }
603 catch (css::uno::Exception&)
604 {
605 // Other general exception
606 errorCode = ERRCODE_IO_GENERAL;
607 }
608
609 if (errorCode != ERRCODE_NONE)
610 {
611 // Restore wizard controls
612 maStats.SetStatusValue(TK_Progress, Any(static_cast<sal_Int32>(0)));
613 m_xPrevPage->set_sensitive(true);
614 m_xNextPage->set_sensitive(false);
615 m_xFinish->set_sensitive(true);
616 m_xCancel->set_sensitive(true);
617
618 OUString aFileName;
619 GetConfigProperty(TK_SaveAsURL) >>= aFileName;
621 ErrorHandler::HandleError(errorCode);
622 return false;
623 }
624 }
625 else
626 {
627 m_xPrevPage->set_sensitive(true);
628 m_xNextPage->set_sensitive(false);
629 m_xFinish->set_sensitive(true);
630 m_xCancel->set_sensitive(true);
631 }
632
634}
635
636IMPL_LINK_NOARG(IntroPage, ButtonActionPerformed, weld::Button&, void)
637{
638 // delete configuration
639 OUString aSelectedItem(mxComboBox->get_active_text());
640 if ( !aSelectedItem.isEmpty() )
641 {
642 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) );
643 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
644 if ( aIter != rList.end() )
645 {
646 rList.erase( aIter );
647 mrOptimizerDialog.UpdateControlStates();
648 }
649 }
650}
651
652IMPL_LINK(IntroPage, ComboBoxActionPerformed, weld::ComboBox&, rBox, void)
653{
654 OUString sActionCommand(rBox.get_active_text());
655 if (!sActionCommand.isEmpty())
656 {
657 std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName(sActionCommand) );
658 std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() );
659 if ( aIter != rList.end() )
660 rList[ 0 ] = *aIter;
661 }
662 mrOptimizerDialog.UpdateControlStates();
663}
664
665IMPL_LINK(ImagesPage, SpinButtonActionPerformed, weld::SpinButton&, rBox, void)
666{
667 mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(rBox.get_value()) ) );
668}
669
670IMPL_LINK_NOARG(ImagesPage, ComboBoxActionPerformed, weld::ComboBox&, void)
671{
672 mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( m_xResolution->get_active_id().toInt32() ) );
673}
674
675/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool Reschedule(bool bHandleAllCurrentEvents=false)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
std::vector< OptimizerSettings > & GetOptimizerSettings()
OUString getString(const PPPOptimizerTokenEnum) const
css::uno::Sequence< css::beans::PropertyValue > GetConfigurationSequence()
void SetConfigProperty(const PPPOptimizerTokenEnum, const css::uno::Any &aValue)
css::uno::Any GetConfigProperty(const PPPOptimizerTokenEnum) const
std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName(const OUString &rName)
css::uno::Reference< css::uno::XComponentContext > mxContext
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
void setDefaultName(const OUString &)
OUString getFilterName() const
sal_Int16 execute()
OUString getURL() const
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeExtension(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
bool hasFinalSlash() const
std::unique_ptr< weld::RadioButton > m_xLossLessCompression
std::unique_ptr< weld::CheckButton > m_xEmbedLinkedGraphics
void UpdateControlStates(bool bJPEGCompression, int nJPEGQuality, bool bRemoveCropArea, int nResolution, bool bEmbedLinkedGraphics)
ImagesPage(weld::Container *pPage, OptimizerDialog &rOptimizerDialog)
std::unique_ptr< weld::CheckButton > m_xRemoveCropArea
std::unique_ptr< weld::ComboBox > m_xResolution
std::unique_ptr< weld::Label > m_xQualityLabel
std::unique_ptr< weld::RadioButton > m_xJpegCompression
std::unique_ptr< weld::SpinButton > m_xQuality
OUString Get_TK_Name() const
void UpdateControlStates(const std::vector< OUString > &rItemList, int nSelectedItem, bool bRemoveButtonEnabled)
IntroPage(weld::Container *pPage, OptimizerDialog &rOptimizerDialog)
std::unique_ptr< weld::ComboBox > mxComboBox
std::unique_ptr< weld::Button > mxButton
void Init(const OUString &rDesc)
std::unique_ptr< weld::RadioButton > m_xForeignOLEObjects
std::unique_ptr< weld::Label > m_xLabel
std::unique_ptr< weld::RadioButton > m_xAllOLEObjects
ObjectsPage(weld::Container *pPage, OptimizerDialog &rOptimizerDialog)
void UpdateControlStates(bool bConvertOLEObjects, int nOLEOptimizationType)
std::unique_ptr< weld::CheckButton > m_xCreateStaticImage
css::beans::PropertyValues GetStatusSequence()
void SetStatusValue(const PPPOptimizerTokenEnum eStat, const css::uno::Any &rStatValue)
const css::uno::Any * GetStatusValue(const PPPOptimizerTokenEnum eStat) const
void InitializeStatusValues(const css::uno::Sequence< css::beans::PropertyValue > &rOptimizationStats)
void InitializeStatusValuesFromDocument(const css::uno::Reference< css::frame::XModel > &rxModel)
SummaryPage * mpPage4
std::unique_ptr< BuilderPage > createPage(vcl::WizardTypes::WizardState nState) override
css::uno::Reference< css::frame::XController > mxController
void UpdateControlStates(sal_Int16 nStep=-1)
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)
css::uno::Reference< css::frame::XFrame > & GetFrame()
SlidesPage * mpPage1
OptimizationStats maStats
css::uno::Reference< css::frame::XDispatch > & GetStatusDispatcher()
void UpdateStatus(const css::uno::Sequence< css::beans::PropertyValue > &rStatus)
virtual OUString getStateDisplayName(vcl::WizardTypes::WizardState nState) const override
ObjectsPage * mpPage3
virtual bool onFinish() override
ImagesPage * mpPage2
void Init(const css::uno::Sequence< OUString > &rCustomShowList)
std::unique_ptr< weld::CheckButton > mxClearNodes
OUString Get_TK_CustomShowName() const
std::unique_ptr< weld::CheckButton > mxUnusedSlides
std::unique_ptr< weld::CheckButton > mxHiddenSlides
void UpdateControlStates(bool bDeleteUnusedMasterPages, bool bDeleteHiddenSlides, bool bDeleteNotesPages)
SlidesPage(weld::Container *pPage, OptimizerDialog &rOptimizerDialog)
std::unique_ptr< weld::ComboBox > mxComboBox
std::unique_ptr< weld::CheckButton > mxMasterSlides
void Init(const OUString &rSettingsName, bool bIsReadonly)
SummaryPage(weld::Container *pPage, OptimizerDialog &rOptimizerDialog)
void UpdateControlStates(bool bSaveAs, bool bSaveSettingsEnabled, const std::vector< OUString > &rItemList, const std::vector< OUString > &rSummaryStrings, const OUString &rCurrentFileSize, const OUString &rEstimatedFileSize)
bool GetSaveAsNew() const
std::unique_ptr< weld::Label > m_xLabel3
std::unique_ptr< weld::Label > m_xLabel2
std::unique_ptr< weld::Label > m_xEstimatedSize
bool GetSaveSettings() const
std::unique_ptr< weld::CheckButton > m_xSaveSettings
std::unique_ptr< weld::Label > m_xLabel1
std::unique_ptr< weld::ProgressBar > m_xProgress
OUString GetSettingsName() const
void UpdateProgressValue(int nProgress)
std::unique_ptr< weld::Label > m_xCurrentSize
std::unique_ptr< weld::Label > m_xStatus
void UpdateStatusLabel(const OUString &rStatus)
std::unique_ptr< weld::ComboBox > m_xComboBox
std::unique_ptr< weld::RadioButton > m_xSaveToNew
std::unique_ptr< weld::RadioButton > m_xApplyToCurrent
std::unique_ptr< weld::Label > m_xLabel
void declarePath(RoadmapWizardTypes::PathId _nPathId, const RoadmapWizardTypes::WizardPath &_lWizardStates)
std::unique_ptr< weld::Button > m_xNextPage
std::unique_ptr< weld::Button > m_xCancel
virtual bool onFinish()
std::unique_ptr< weld::Button > m_xPrevPage
virtual void ActivatePage()
bool ShowPage(WizardTypes::WizardState nState)
std::unique_ptr< weld::Button > m_xFinish
std::unique_ptr< weld::Assistant > m_xAssistant
virtual short run()
void set_title(const OUString &rTitle)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
URL aURL
sal_Int32 nState
#define ERRCODE_IO_GENERAL
#define ERRCODE_IO_CANTWRITE
#define ERRCODE_NONE
OUString aName
uno_Any a
ScModelObj * getModel(const ScDocShell &rDocShell)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
int i
sal_Int16 WizardState
IMPL_LINK_NOARG(IntroPage, ButtonActionPerformed, weld::Button &, void)
IMPL_LINK(SummaryPage, SaveAsNewActionPerformed, weld::Toggleable &, rBox, void)
#define ITEM_ID_OLE_OPTIMIZATION
#define ITEM_ID_SUMMARY
#define ITEM_ID_INTRODUCTION
#define ITEM_ID_SLIDES
#define ITEM_ID_GRAPHIC_OPTIMIZATION
PPPOptimizerTokenEnum TKGet(std::u16string_view rToken)
@ STR_WARN_UNSAVED_PRESENTATION
@ STR_SUMMARY
@ TK_ImageResolution
@ STR_SUN_OPTIMIZATION_WIZARD2
@ STR_SLIDES
@ TK_JPEGCompression
@ STR_OLE_OBJECTS
@ STR_IMAGE_OPTIMIZATION
@ TK_FilterName
@ STR_INTRODUCTION
@ TK_Status
@ TK_DeleteUnusedMasterPages
@ TK_DeleteHiddenSlides
@ TK_RemoveCropArea
@ TK_JPEGQuality
@ TK_DeleteNotesPages
@ TK_OLEOptimization
@ TK_OpenNewDocument
@ TK_Name
@ STR_FILENAME_SUFFIX
@ TK_EmbedLinkedGraphics
@ TK_SaveAsURL
@ TK_Progress
@ TK_OLEOptimizationType
@ TK_SaveAs
@ TK_CustomShowName
#define ERRCTX_SFX_SAVEASDOC
RET_OK
RET_CANCEL
RET_YES