diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-05 11:44:48 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-06 19:29:38 +0000 |
commit | a70ad1568ea0fb5b4d7f888fb56fcee130afc433 (patch) | |
tree | a2235ebca8779a32fd4695d1320d7ed6bcc5ecd2 /sdext | |
parent | 8254bd826d6d415e80ef8dcfb39e8b5c67cf2aab (diff) |
Resolves: tdf#121297 weld Presentation Minimizer
Change-Id: Ifdf1746bc9f6567a1aded233a4350f6828604c9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143678
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/minimizer/configurationaccess.cxx | 2 | ||||
-rw-r--r-- | sdext/source/minimizer/configurationaccess.hxx | 6 | ||||
-rw-r--r-- | sdext/source/minimizer/optimizerdialog.cxx | 1044 | ||||
-rw-r--r-- | sdext/source/minimizer/optimizerdialog.hxx | 258 | ||||
-rw-r--r-- | sdext/source/minimizer/optimizerdialogcontrols.cxx | 604 | ||||
-rw-r--r-- | sdext/source/minimizer/pppoptimizerdialog.cxx | 1 | ||||
-rw-r--r-- | sdext/source/minimizer/pppoptimizertoken.cxx | 56 | ||||
-rw-r--r-- | sdext/source/minimizer/pppoptimizertoken.hxx | 54 |
8 files changed, 652 insertions, 1373 deletions
diff --git a/sdext/source/minimizer/configurationaccess.cxx b/sdext/source/minimizer/configurationaccess.cxx index 8373e1f425f1..55e60c52ca96 100644 --- a/sdext/source/minimizer/configurationaccess.cxx +++ b/sdext/source/minimizer/configurationaccess.cxx @@ -140,10 +140,8 @@ bool OptimizerSettings::operator==( const OptimizerSettings& rOptimizerSettings && ( rOptimizerSettings.mbDeleteUnusedMasterPages == mbDeleteUnusedMasterPages ) && ( rOptimizerSettings.mbDeleteHiddenSlides == mbDeleteHiddenSlides ) && ( rOptimizerSettings.mbDeleteNotesPages == mbDeleteNotesPages ); -// && ( rOptimizerSettings.mbOpenNewDocument == mbOpenNewDocument ); } - ConfigurationAccess::ConfigurationAccess( const Reference< uno::XComponentContext >& rxContext ) : mxContext( rxContext ) { diff --git a/sdext/source/minimizer/configurationaccess.hxx b/sdext/source/minimizer/configurationaccess.hxx index d4d4c4d3f898..5cf884fc13fe 100644 --- a/sdext/source/minimizer/configurationaccess.hxx +++ b/sdext/source/minimizer/configurationaccess.hxx @@ -96,14 +96,14 @@ class ConfigurationAccess std::vector< OptimizerSettings >& GetOptimizerSettings() { return maSettings; }; std::vector< OptimizerSettings >::iterator GetOptimizerSettingsByName( const OUString& rName ); - private: + protected: + css::uno::Reference< css::uno::XComponentContext > mxContext; + private: std::map < PPPOptimizerTokenEnum, OUString > maStrings; std::vector< OptimizerSettings > maSettings; - css::uno::Reference< css::uno::XComponentContext > mxContext; - void LoadStrings(); void LoadConfiguration(); css::uno::Reference< css::uno::XInterface > OpenConfiguration( bool bReadOnly ); diff --git a/sdext/source/minimizer/optimizerdialog.cxx b/sdext/source/minimizer/optimizerdialog.cxx index 3112c6f22959..15ce1c3d1187 100644 --- a/sdext/source/minimizer/optimizerdialog.cxx +++ b/sdext/source/minimizer/optimizerdialog.cxx @@ -55,164 +55,220 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; +IntroPage::IntroPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) + : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmintropage.ui", "PMIntroPage") + , mrOptimizerDialog(rOptimizerDialog) + , mxComboBox(m_xBuilder->weld_combo_box("LB_SETTINGS")) + , mxButton(m_xBuilder->weld_button("STR_REMOVE")) +{ + mxComboBox->connect_changed(LINK(this, IntroPage, ComboBoxActionPerformed)); + mxButton->connect_clicked(LINK(this, IntroPage, ButtonActionPerformed)); +} -void OptimizerDialog::InitDialog() +void IntroPage::UpdateControlStates(const std::vector<OUString>& rItemList, int nSelectedItem, bool bRemoveButtonEnabled) { - // setting the dialog properties - OUString pNames[] = { - OUString("Closeable"), - OUString("Height"), - OUString("Moveable"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Title"), - OUString("Width") }; + mxComboBox->clear(); + for (const auto& a : rItemList) + mxComboBox->append_text(a); + mxComboBox->set_active(nSelectedItem); + mxButton->set_sensitive(bRemoveButtonEnabled); +} - Any pValues[] = { - Any( true ), - Any( sal_Int32( DIALOG_HEIGHT ) ), - Any( true ), - Any( sal_Int32( 200 ) ), - Any( sal_Int32( 52 ) ), - Any( getString( STR_SUN_OPTIMIZATION_WIZARD2 ) ), - Any( sal_Int32( OD_DIALOG_WIDTH ) ) }; +SlidesPage::SlidesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) + : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmslidespage.ui", "PMSlidesPage") + , mrOptimizerDialog(rOptimizerDialog) + , mxMasterSlides(m_xBuilder->weld_check_button("STR_DELETE_MASTER_PAGES")) + , mxHiddenSlides(m_xBuilder->weld_check_button("STR_DELETE_HIDDEN_SLIDES")) + , mxUnusedSlides(m_xBuilder->weld_check_button("STR_CUSTOM_SHOW")) + , mxComboBox(m_xBuilder->weld_combo_box("LB_SLIDES")) + , mxClearNodes(m_xBuilder->weld_check_button("STR_DELETE_NOTES_PAGES")) +{ + mxMasterSlides->connect_toggled(LINK(this, SlidesPage, UnusedMasterPagesActionPerformed)); + mxHiddenSlides->connect_toggled(LINK(this, SlidesPage, UnusedHiddenSlidesActionPerformed)); + mxUnusedSlides->connect_toggled(LINK(this, SlidesPage, UnusedSlidesActionPerformed)); + mxClearNodes->connect_toggled(LINK(this, SlidesPage, DeleteNotesActionPerformed)); +} - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); +void SlidesPage::Init(const css::uno::Sequence<OUString>& rCustomShowList) +{ + mxComboBox->clear(); + for (const auto& a : rCustomShowList) + mxComboBox->append_text(a); + mxUnusedSlides->set_sensitive(rCustomShowList.hasElements()); +} + +void SlidesPage::UpdateControlStates(bool bDeleteUnusedMasterPages, bool bDeleteHiddenSlides, bool bDeleteNotesPages) +{ + mxMasterSlides->set_active(bDeleteUnusedMasterPages); + mxHiddenSlides->set_active(bDeleteHiddenSlides); + mxClearNodes->set_active(bDeleteNotesPages); + mxComboBox->set_sensitive(mxUnusedSlides->get_sensitive()); +} - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); +ImagesPage::ImagesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) + : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmimagespage.ui", "PMImagesPage") + , mrOptimizerDialog(rOptimizerDialog) + , m_xLossLessCompression(m_xBuilder->weld_radio_button("STR_LOSSLESS_COMPRESSION")) + , m_xQualityLabel(m_xBuilder->weld_label("STR_QUALITY")) + , m_xQuality(m_xBuilder->weld_spin_button("SB_QUALITY")) + , m_xJpegCompression(m_xBuilder->weld_radio_button("STR_JPEG_COMPRESSION")) + , m_xResolution(m_xBuilder->weld_combo_box("LB_RESOLUTION")) + , m_xRemoveCropArea(m_xBuilder->weld_check_button("STR_REMOVE_CROP_AREA")) + , m_xEmbedLinkedGraphics(m_xBuilder->weld_check_button("STR_EMBED_LINKED_GRAPHICS")) +{ + m_xRemoveCropArea->connect_toggled(LINK(this, ImagesPage, RemoveCropAreaActionPerformed)); + m_xEmbedLinkedGraphics->connect_toggled(LINK(this, ImagesPage, EmbedLinkedGraphicsActionPerformed)); + m_xResolution->connect_changed(LINK(this, ImagesPage, ComboBoxActionPerformed)); + m_xQuality->connect_value_changed(LINK(this, ImagesPage, SpinButtonActionPerformed)); - setPropertyValues(aNames, aValues); + m_xJpegCompression->connect_toggled(LINK(this, ImagesPage, CompressionActionPerformed)); + m_xLossLessCompression->connect_toggled(LINK(this, ImagesPage, CompressionActionPerformed)); } +void ImagesPage::UpdateControlStates(bool bJPEGCompression, int nJPEGQuality, bool bRemoveCropArea, + int nResolution, bool bEmbedLinkedGraphics) +{ + m_xLossLessCompression->set_active(!bJPEGCompression); + m_xJpegCompression->set_active(bJPEGCompression); + m_xQualityLabel->set_sensitive(bJPEGCompression); + m_xQuality->set_sensitive(bJPEGCompression); + m_xQuality->set_value(nJPEGQuality); + m_xResolution->set_active_id(OUString::number(nResolution)); + m_xRemoveCropArea->set_active(bRemoveCropArea); + m_xEmbedLinkedGraphics->set_active(bEmbedLinkedGraphics); +} -void OptimizerDialog::InitRoadmap() +ObjectsPage::ObjectsPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) + : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmobjectspage.ui", "PMObjectsPage") + , mrOptimizerDialog(rOptimizerDialog) + , m_xCreateStaticImage(m_xBuilder->weld_check_button("STR_OLE_REPLACE")) + , m_xAllOLEObjects(m_xBuilder->weld_radio_button("STR_ALL_OLE_OBJECTS")) + , m_xForeignOLEObjects(m_xBuilder->weld_radio_button("STR_ALIEN_OLE_OBJECTS_ONLY")) + , m_xLabel(m_xBuilder->weld_label("STR_OLE_OBJECTS_DESC")) { - try - { - OUString pNames[] = { - OUString("Height"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( sal_Int32( DIALOG_HEIGHT - 26 ) ), - Any( sal_Int32( 0 ) ), - Any( sal_Int32( 0 ) ), - Any( sal_Int32( 0 ) ), - Any( mnTabIndex++ ), - Any( sal_Int32( 85 ) ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - mxRoadmapControlModel = insertControlModel( "com.sun.star.awt.UnoControlRoadmapModel", - "rdmNavi", aNames, aValues ); - - Reference< XPropertySet > xPropertySet( mxRoadmapControlModel, UNO_QUERY_THROW ); - xPropertySet->setPropertyValue( "Name", Any( OUString("rdmNavi") ) ); - mxRoadmapControl = getControl( "rdmNavi" ); - InsertRoadmapItem( 0, getString( STR_INTRODUCTION ), ITEM_ID_INTRODUCTION ); - InsertRoadmapItem( 1, getString( STR_SLIDES ), ITEM_ID_SLIDES ); - InsertRoadmapItem( 2, getString( STR_IMAGE_OPTIMIZATION ), ITEM_ID_GRAPHIC_OPTIMIZATION ); - InsertRoadmapItem( 3, getString( STR_OLE_OBJECTS ), ITEM_ID_OLE_OPTIMIZATION ); - InsertRoadmapItem( 4, getString( STR_SUMMARY ), ITEM_ID_SUMMARY ); - - xPropertySet->setPropertyValue( "ImageURL", Any( OUString("private:graphicrepository/" BMP_PRESENTATION_MINIMIZER) ) ); - xPropertySet->setPropertyValue( "Activated", Any( true ) ); - xPropertySet->setPropertyValue( "Complete", Any( true ) ); - xPropertySet->setPropertyValue( "CurrentItemID", Any( sal_Int16(ITEM_ID_INTRODUCTION) ) ); - xPropertySet->setPropertyValue( "Text", Any( getString( STR_STEPS ) ) ); - } - catch( Exception& ) - { - } + m_xCreateStaticImage->connect_toggled(LINK(this, ObjectsPage, OLEOptimizationActionPerformed)); + m_xAllOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed)); + m_xForeignOLEObjects->connect_toggled(LINK(this, ObjectsPage, OLEActionPerformed)); } +void ObjectsPage::Init(const OUString& rDesc) +{ + m_xLabel->set_label(rDesc); +} -void OptimizerDialog::InsertRoadmapItem( const sal_Int32 nIndex, const OUString& rLabel, const sal_Int32 nItemID ) +void ObjectsPage::UpdateControlStates(bool bConvertOLEObjects, int nOLEOptimizationType) { - try - { - Reference< XSingleServiceFactory > xSFRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); - Reference< XIndexContainer > aIndexContainerRoadmap( mxRoadmapControlModel, UNO_QUERY_THROW ); - Reference< XInterface > xRoadmapItem( xSFRoadmap->createInstance(), UNO_SET_THROW ); - Reference< XPropertySet > xPropertySet( xRoadmapItem, UNO_QUERY_THROW ); - xPropertySet->setPropertyValue( "Label", Any( rLabel ) ); - xPropertySet->setPropertyValue( "Enabled", Any( true ) ); - xPropertySet->setPropertyValue( "ID", Any( nItemID ) ); - aIndexContainerRoadmap->insertByIndex( nIndex, Any( xRoadmapItem ) ); - } - catch( Exception& ) - { + m_xCreateStaticImage->set_active(bConvertOLEObjects); + m_xAllOLEObjects->set_sensitive(bConvertOLEObjects); + m_xForeignOLEObjects->set_sensitive(bConvertOLEObjects); + m_xAllOLEObjects->set_active(nOLEOptimizationType == 0); + m_xForeignOLEObjects->set_active(nOLEOptimizationType == 1); +} - } +SummaryPage::SummaryPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog) + : vcl::OWizardPage(pPage, &rOptimizerDialog, "modules/simpress/ui/pmsummarypage.ui", "PMSummaryPage") + , mrOptimizerDialog(rOptimizerDialog) + , m_xLabel1(m_xBuilder->weld_label("LABEL1")) + , m_xLabel2(m_xBuilder->weld_label("LABEL2")) + , m_xLabel3(m_xBuilder->weld_label("LABEL3")) + , m_xCurrentSize(m_xBuilder->weld_label("CURRENT_FILESIZE")) + , m_xEstimatedSize(m_xBuilder->weld_label("ESTIMATED_FILESIZE")) + , m_xStatus(m_xBuilder->weld_label("STR_STATUS")) + , m_xProgress(m_xBuilder->weld_progress_bar("PROGRESS")) + , m_xApplyToCurrent(m_xBuilder->weld_radio_button("STR_APPLY_TO_CURRENT")) + , m_xSaveToNew(m_xBuilder->weld_radio_button("STR_SAVE_AS")) + , m_xComboBox(m_xBuilder->weld_combo_box("MY_SETTINGS")) + , m_xSaveSettings(m_xBuilder->weld_check_button("STR_SAVE_SETTINGS")) +{ + m_xApplyToCurrent->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed)); + m_xSaveToNew->connect_toggled(LINK(this, SummaryPage, SaveAsNewActionPerformed)); + m_xSaveSettings->connect_toggled(LINK(this, SummaryPage, SaveSettingsActionPerformed)); } +void SummaryPage::Init(const OUString& rSettingsName, bool bIsReadonly) +{ + m_xComboBox->set_entry_text(rSettingsName); + m_xApplyToCurrent->set_sensitive(!bIsReadonly); + m_xSaveToNew->set_sensitive(!bIsReadonly); +} -void OptimizerDialog::UpdateConfiguration() +void SummaryPage::UpdateControlStates(bool bSaveAs, bool bSaveSettingsEnabled, + const std::vector<OUString>& rItemList, + const std::vector<OUString>& rSummaryStrings, + const OUString& rCurrentFileSize, + const OUString& rEstimatedFileSize) { - sal_Int16 nInt16 = 0; - Any aAny; + m_xApplyToCurrent->set_active(!bSaveAs); + m_xSaveToNew->set_active(bSaveAs); - Sequence< sal_Int16 > aSelectedItems; - Sequence< OUString > aStringItemList; + for (const auto& a : rItemList) + m_xComboBox->append_text(a); - // page0 - aAny = getControlProperty( "ListBox0Pg0", "SelectedItems" ); - if ( aAny >>= aSelectedItems ) - { - if ( aSelectedItems.hasElements() ) - { - sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; - aAny = getControlProperty( "ListBox0Pg0", "StringItemList" ); - if ( aAny >>= aStringItemList ) - { - if ( aStringItemList.getLength() > nSelectedItem ) - SetConfigProperty( TK_Name, Any( aStringItemList[ nSelectedItem ] ) ); - } - } - } + m_xSaveSettings->set_sensitive(bSaveSettingsEnabled); + m_xComboBox->set_sensitive(bSaveSettingsEnabled && m_xSaveSettings->get_active()); - aAny = getControlProperty( "CheckBox3Pg3", "State" ); - if ( !((aAny >>= nInt16) && nInt16) ) - return; + assert(rSummaryStrings.size() == 3); + m_xLabel1->set_label(rSummaryStrings[0]); + m_xLabel2->set_label(rSummaryStrings[1]); + m_xLabel3->set_label(rSummaryStrings[2]); - aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" ); - if ( !(aAny >>= aSelectedItems) ) - return; + m_xCurrentSize->set_label(rCurrentFileSize); + m_xEstimatedSize->set_label(rEstimatedFileSize); +} - if ( aSelectedItems.hasElements() ) - { - sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; - aAny = getControlProperty( "ListBox0Pg3", "StringItemList" ); - if ( aAny >>= aStringItemList ) - { - if ( aStringItemList.getLength() > nSelectedItem ) - SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); - } - } +void SummaryPage::UpdateStatusLabel(const OUString& rStatus) +{ + m_xStatus->set_label(rStatus); +} + +void SummaryPage::UpdateProgressValue(int nProgress) +{ + m_xProgress->set_percentage(nProgress); +} + +void OptimizerDialog::InitDialog() +{ + set_title(getString(STR_SUN_OPTIMIZATION_WIZARD2)); } +void OptimizerDialog::InitRoadmap() +{ + declarePath( + 0, + {ITEM_ID_INTRODUCTION, + ITEM_ID_SLIDES, + ITEM_ID_GRAPHIC_OPTIMIZATION, + ITEM_ID_OLE_OPTIMIZATION, + ITEM_ID_SUMMARY} + ); + +#if 0 + xPropertySet->setPropertyValue( "ImageURL", Any( OUString("private:graphicrepository/" BMP_PRESENTATION_MINIMIZER) ) ); +#endif +} -OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame > const & rxFrame, Reference< XDispatch > const & rxStatusDispatcher ) : - UnoDialog( rxContext, rxFrame ), - ConfigurationAccess( rxContext ), - mnCurrentStep( 0 ), - mnTabIndex( 0 ), - mxFrame( rxFrame ), - mxItemListener( new ItemListener( *this ) ), - mxActionListener( new ActionListener( *this ) ), - mxActionListenerListBox0Pg0( new ActionListenerListBox0Pg0( *this ) ), - mxTextListenerFormattedField0Pg1( new TextListenerFormattedField0Pg1( *this ) ), - mxTextListenerComboBox0Pg1( new TextListenerComboBox0Pg1( *this ) ), - mxSpinListenerFormattedField0Pg1( new SpinListenerFormattedField0Pg1( *this ) ), - mxStatusDispatcher( rxStatusDispatcher ) +void OptimizerDialog::UpdateConfiguration() +{ + // page0 + OUString sTKName(mpPage0->Get_TK_Name()); + if (!sTKName.isEmpty()) + SetConfigProperty(TK_Name, Any(sTKName)); + + // page1 + OUString sTKCustomShowName(mpPage1->Get_TK_CustomShowName()); + if (!sTKCustomShowName.isEmpty()) + SetConfigProperty(TK_CustomShowName, Any(sTKCustomShowName)); +} + +OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContext, Reference< XFrame > const & rxFrame, Reference< XDispatch > const & rxStatusDispatcher ) + : vcl::RoadmapWizardMachine(Application::GetFrameWeld(rxFrame->getComponentWindow())) + , ConfigurationAccess(rxContext) + , mnCurrentStep(0) + , mnTabIndex(0) + , mnEndStatus(RET_CANCEL) + , mxFrame(rxFrame) + , mxController(rxFrame->getController()) + , mxStatusDispatcher(rxStatusDispatcher) { Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY_THROW ); mbIsReadonly = xStorable->isReadonly(); @@ -225,7 +281,9 @@ OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContex InitPage2(); InitPage3(); InitPage4(); - ActivatePage( 0 ); + + ActivatePage(); + m_xAssistant->set_current_page(0); OptimizationStats aStats; aStats.InitializeStatusValuesFromDocument( mxController->getModel() ); @@ -233,48 +291,71 @@ OptimizerDialog::OptimizerDialog( const Reference< XComponentContext > &rxContex UpdateStatus( aStatusSequence ); } - -OptimizerDialog::~OptimizerDialog() +OUString OptimizerDialog::getStateDisplayName(vcl::WizardTypes::WizardState nState) const { - // not saving configuration if the dialog has been finished via cancel or close window - if ( endStatus() ) - SaveConfiguration(); + switch (nState) + { + case ITEM_ID_INTRODUCTION: + return getString(STR_INTRODUCTION); + case ITEM_ID_SLIDES: + return getString(STR_SLIDES); + case ITEM_ID_GRAPHIC_OPTIMIZATION: + return getString(STR_IMAGE_OPTIMIZATION); + case ITEM_ID_OLE_OPTIMIZATION: + return getString(STR_OLE_OBJECTS); + case ITEM_ID_SUMMARY: + return getString(STR_SUMMARY); + } + return OUString(); } - -void OptimizerDialog::execute() +std::unique_ptr<BuilderPage> OptimizerDialog::createPage(vcl::WizardTypes::WizardState nState) { - Reference< XItemEventBroadcaster > xRoadmapBroadcaster( mxRoadmapControl, UNO_QUERY_THROW ); - xRoadmapBroadcaster->addItemListener( mxItemListener ); - UnoDialog::execute(); - UpdateConfiguration(); // taking actual control settings for the configuration - xRoadmapBroadcaster->removeItemListener( mxItemListener ); -} + OString sIdent(OString::number(nState)); + weld::Container* pPageContainer = m_xAssistant->append_page(sIdent); + std::unique_ptr<vcl::OWizardPage> xRet; -void OptimizerDialog::SwitchPage( sal_Int16 nNewStep ) -{ - if ( !(( nNewStep != mnCurrentStep ) && ( nNewStep <= MAX_STEP ) && ( nNewStep >= 0 )) ) - return; - - sal_Int16 nOldStep = mnCurrentStep; - if ( nNewStep == 0 ) - disableControl( "btnNavBack" ); - else if ( nOldStep == 0 ) - enableControl( "btnNavBack" ); + switch (nState) + { + case ITEM_ID_INTRODUCTION: + xRet.reset(new IntroPage(pPageContainer, *this)); + mpPage0 = static_cast<IntroPage*>(xRet.get()); + break; + case ITEM_ID_SLIDES: + xRet.reset(new SlidesPage(pPageContainer, *this)); + mpPage1 = static_cast<SlidesPage*>(xRet.get()); + break; + case ITEM_ID_GRAPHIC_OPTIMIZATION: + xRet.reset(new ImagesPage(pPageContainer, *this)); + mpPage2 = static_cast<ImagesPage*>(xRet.get()); + break; + case ITEM_ID_OLE_OPTIMIZATION: + xRet.reset(new ObjectsPage(pPageContainer, *this)); + mpPage3 = static_cast<ObjectsPage*>(xRet.get()); + break; + case ITEM_ID_SUMMARY: + xRet.reset(new SummaryPage(pPageContainer, *this)); + mpPage4 = static_cast<SummaryPage*>(xRet.get()); + break; + }; - if ( nNewStep == MAX_STEP ) - disableControl( "btnNavNext" ); - else if ( nOldStep == MAX_STEP ) - enableControl( "btnNavNext" ); + m_xAssistant->set_page_title(sIdent, getStateDisplayName(nState)); - setControlProperty( "rdmNavi", "CurrentItemID", Any( nNewStep ) ); + return xRet; +} - DeactivatePage( nOldStep ); - UpdateControlStates( nNewStep ); +OptimizerDialog::~OptimizerDialog() +{ + // not saving configuration if the dialog has been finished via cancel or close window + if (mnEndStatus == RET_OK) + SaveConfiguration(); +} - ActivatePage( nNewStep ); - mnCurrentStep = nNewStep; +void OptimizerDialog::execute() +{ + mnEndStatus = run(); + UpdateConfiguration(); // taking actual control settings for the configuration } void OptimizerDialog::UpdateControlStates( sal_Int16 nPage ) @@ -297,27 +378,6 @@ void OptimizerDialog::UpdateControlStates( sal_Int16 nPage ) } } - -OUString OptimizerDialog::GetSelectedString( OUString const & token ) -{ - OUString aSelectedItem; - Sequence< sal_Int16 > sSelectedItems; - Sequence< OUString > sItemList; - - if ( ( getControlProperty( token, "SelectedItems" ) >>= sSelectedItems ) && - ( getControlProperty( token, "StringItemList" ) >>= sItemList ) ) - { - if ( sSelectedItems.getLength() == 1 ) - { - sal_Int16 nSelectedItem = sSelectedItems[ 0 ]; - if ( nSelectedItem < sItemList.getLength() ) - aSelectedItem = sItemList[ nSelectedItem ]; - } - } - return aSelectedItem; -} - - void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus ) { maStats.InitializeStatusValues( rStatus ); @@ -327,8 +387,7 @@ void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::Proper OUString sStatus; if ( *pVal >>= sStatus ) { - setControlProperty( "FixedText1Pg4", "Enabled", Any( true ) ); - setControlProperty( "FixedText1Pg4", "Label", Any( getString( TKGet( sStatus ) ) ) ); + mpPage4->UpdateStatusLabel(getString(TKGet(sStatus))); } } pVal = maStats.GetStatusValue( TK_Progress ); @@ -336,445 +395,284 @@ void OptimizerDialog::UpdateStatus( const css::uno::Sequence< css::beans::Proper { sal_Int32 nProgress = 0; if ( *pVal >>= nProgress ) - setControlProperty( "Progress", "ProgressValue", Any( nProgress ) ); + mpPage4->UpdateProgressValue(nProgress); } pVal = maStats.GetStatusValue( TK_OpenNewDocument ); if ( pVal ) SetConfigProperty( TK_OpenNewDocument, *pVal ); - reschedule(); + Application::Reschedule(true); } - -void ItemListener::itemStateChanged( const ItemEvent& Event ) +IMPL_LINK(SummaryPage, SaveAsNewActionPerformed, weld::Toggleable&, rBox, void) { - try - { - sal_Int16 nState; - Reference< XControl > xControl; - Any aSource( Event.Source ); - if ( aSource >>= xControl ) - { - Reference< XPropertySet > xPropertySet( xControl->getModel(), UNO_QUERY_THROW ); - OUString aControlName; - xPropertySet->getPropertyValue( "Name" ) >>= aControlName; - PPPOptimizerTokenEnum eControl( TKGet( aControlName ) ); - switch( eControl ) - { - case TK_rdmNavi : - { - mrOptimizerDialog.SwitchPage( static_cast< sal_Int16 >( Event.ItemId ) ); - } - break; - case TK_CheckBox1Pg1 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_RemoveCropArea, Any( nState != 0 ) ); - } - break; - case TK_CheckBox2Pg1 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_EmbedLinkedGraphics, Any( nState != 0 ) ); - } - break; - case TK_CheckBox0Pg2 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - { - mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any( nState != 0 ) ); - mrOptimizerDialog.setControlProperty( "RadioButton0Pg2", "Enabled", Any( nState != 0 ) ); - mrOptimizerDialog.setControlProperty( "RadioButton1Pg2", "Enabled", Any( nState != 0 ) ); - } - } - break; - case TK_RadioButton0Pg1 : - { - sal_Int16 nInt16 = 0; - if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 ) - { - nInt16 ^= 1; - mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nInt16 != 0 ) ); - mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nInt16 != 0 ) ); - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nInt16 != 0 ) ); - } - } - break; - case TK_RadioButton1Pg1 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - { - mrOptimizerDialog.SetConfigProperty( TK_JPEGCompression, Any( nState != 0 ) ); - mrOptimizerDialog.setControlProperty( "FixedText1Pg1", "Enabled", Any( nState != 0 ) ); - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "Enabled", Any( nState != 0 ) ); - } - } - break; - case TK_RadioButton0Pg2 : - { - sal_Int16 nInt16; - if ( xPropertySet->getPropertyValue( "State" ) >>= nInt16 ) - { - nInt16 ^= 1; - mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) ); - } - } - break; - case TK_RadioButton1Pg2 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nState ) ); - } - break; - case TK_CheckBox0Pg3 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_DeleteUnusedMasterPages, Any( nState != 0 ) ); - } - break; - case TK_CheckBox1Pg3 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_DeleteNotesPages, Any( nState != 0 ) ); - } - break; - case TK_CheckBox2Pg3 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_DeleteHiddenSlides, Any( nState != 0 ) ); - } - break; - case TK_CheckBox3Pg3 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.setControlProperty( "ListBox0Pg3", "Enabled", Any( nState != 0 ) ); - } - break; - case TK_CheckBox1Pg4 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.setControlProperty( "ComboBox0Pg4", "Enabled", Any( nState != 0 ) ); - } - break; - case TK_RadioButton0Pg4 : - case TK_RadioButton1Pg4 : - { - if ( xPropertySet->getPropertyValue( "State" ) >>= nState ) - mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any( eControl == TK_RadioButton1Pg4 ? nState != 0 : nState == 0 ) ); - } - break; - default: - break; - } - } - } - catch ( Exception& ) - { + if (!rBox.get_active()) + return; - } + const bool bSaveToNew = &rBox == m_xSaveToNew.get(); + mrOptimizerDialog.SetConfigProperty( TK_SaveAs, Any(bSaveToNew) ); } -void ItemListener::disposing( const css::lang::EventObject& /* Source */ ) + +IMPL_LINK(SummaryPage, SaveSettingsActionPerformed, weld::Toggleable&, rBox, void) { + m_xComboBox->set_sensitive(rBox.get_active()); } -void ActionListener::actionPerformed( const ActionEvent& rEvent ) +IMPL_LINK(ObjectsPage, OLEActionPerformed, weld::Toggleable&, rBox, void) { - switch( TKGet( rEvent.ActionCommand ) ) - { - case TK_btnNavBack : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep - 1 ); break; - case TK_btnNavNext : mrOptimizerDialog.SwitchPage( mrOptimizerDialog.mnCurrentStep + 1 ); break; - case TK_btnNavFinish : - { - mrOptimizerDialog.UpdateConfiguration(); - - mrOptimizerDialog.SwitchPage( ITEM_ID_SUMMARY ); - mrOptimizerDialog.DisablePage( ITEM_ID_SUMMARY ); - mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( false ) ); - mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( false ) ); - mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( false ) ); - mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( false ) ); - mrOptimizerDialog.setControlProperty( "FixedText0Pg4", "Enabled", Any( true ) ); - - // check if we have to open the FileDialog - bool bSuccessfullyExecuted = true; - sal_Int16 nInt16 = 0; - mrOptimizerDialog.getControlProperty( "RadioButton1Pg4", "State" ) >>= nInt16; - if ( nInt16 ) - { - // Duplicate presentation before applying changes - OUString aSaveAsURL; - FileOpenDialog aFileOpenDialog( mrOptimizerDialog.GetComponentContext() ); - - // generating default file name - OUString aName; - Reference< XStorable > xStorable( mrOptimizerDialog.controller()->getModel(), UNO_QUERY ); - if ( xStorable.is() && xStorable->hasLocation() ) - { - INetURLObject aURLObj( xStorable->getLocation() ); - if ( !aURLObj.hasFinalSlash() ) - { - // tdf#105382 uri-decode file name - aURLObj.removeExtension(INetURLObject::LAST_SEGMENT, false); - aName = aURLObj.getName(INetURLObject::LAST_SEGMENT, false, - INetURLObject::DecodeMechanism::WithCharset); - } - } - else - { - // If no filename, try to use model title ("Untitled 1" or something like this) - Reference<XTitle> xTitle( - mrOptimizerDialog.GetFrame()->getController()->getModel(), UNO_QUERY); - aName = xTitle->getTitle(); - } - - if (!aName.isEmpty()) - { - aName += " " + mrOptimizerDialog.getString(STR_FILENAME_SUFFIX); - aFileOpenDialog.setDefaultName(aName); - } - - if (aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK) - { - aSaveAsURL = aFileOpenDialog.getURL(); - mrOptimizerDialog.SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) ); - mrOptimizerDialog.SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) ); - } - if ( aSaveAsURL.isEmpty() ) - { - // something goes wrong... - bSuccessfullyExecuted = false; - } - - // waiting for 500ms - mrOptimizerDialog.reschedule(); - for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); ) - mrOptimizerDialog.reschedule(); - } - else - { - // Apply changes to current presentation - Reference<XModifiable> xModifiable(mrOptimizerDialog.controller()->getModel(), - UNO_QUERY_THROW ); - if ( xModifiable->isModified() ) - { - SolarMutexGuard aSolarGuard; - std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog( - nullptr, VclMessageType::Question, VclButtonsType::YesNo, - mrOptimizerDialog.getString(STR_WARN_UNSAVED_PRESENTATION))); - if (popupDlg->run() != RET_YES) - { - // Selected not "yes" ("no" or dialog was cancelled) so return to previous step - mrOptimizerDialog.setControlProperty("btnNavBack", "Enabled", - Any(true)); - mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false)); - mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true)); - mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true)); - mrOptimizerDialog.EnablePage(ITEM_ID_SUMMARY); - return; - } - } - } - if ( bSuccessfullyExecuted ) - { // now check if we have to store a session template - nInt16 = 0; - OUString aSettingsName; - mrOptimizerDialog.getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16; - mrOptimizerDialog.getControlProperty( "ComboBox0Pg4", "Text" ) >>= aSettingsName; - if ( nInt16 && !aSettingsName.isEmpty() ) - { - std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSettingsName ) ); - std::vector< OptimizerSettings >& rSettings( mrOptimizerDialog.GetOptimizerSettings() ); - OptimizerSettings aNewSettings( rSettings[ 0 ] ); - aNewSettings.maName = aSettingsName; - if ( aIter == rSettings.end() ) - rSettings.push_back( aNewSettings ); - else - *aIter = aNewSettings; - } - } - if ( bSuccessfullyExecuted ) - { - URL aURL; - aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:"; - aURL.Path = "optimize"; - - Sequence< PropertyValue > lArguments{ - comphelper::makePropertyValue("Settings", mrOptimizerDialog.GetConfigurationSequence()), - comphelper::makePropertyValue("StatusDispatcher", mrOptimizerDialog.GetStatusDispatcher()), - comphelper::makePropertyValue("InformationDialog", mrOptimizerDialog.GetFrame()) - }; - - ErrCode errorCode; - try - { - ImpOptimizer aOptimizer( - mrOptimizerDialog.GetComponentContext(), - mrOptimizerDialog.GetFrame()->getController()->getModel()); - aOptimizer.Optimize(lArguments); - } - catch (css::io::IOException&) - { - // We always receive just ERRCODE_IO_CANTWRITE in case of problems, so no need to bother - // about extracting error code from exception text - errorCode = ERRCODE_IO_CANTWRITE; - } - catch (css::uno::Exception&) - { - // Other general exception - errorCode = ERRCODE_IO_GENERAL; - } - - if (errorCode != ERRCODE_NONE) - { - // Restore wizard controls - mrOptimizerDialog.maStats.SetStatusValue(TK_Progress, - Any(static_cast<sal_Int32>(0))); - mrOptimizerDialog.setControlProperty("btnNavBack", "Enabled", Any(true)); - mrOptimizerDialog.setControlProperty("btnNavNext", "Enabled", Any(false)); - mrOptimizerDialog.setControlProperty("btnNavFinish", "Enabled", Any(true)); - mrOptimizerDialog.setControlProperty("btnNavCancel", "Enabled", Any(true)); - - OUString aFileName; - mrOptimizerDialog.GetConfigProperty(TK_SaveAsURL) >>= aFileName; - SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, aFileName); - ErrorHandler::HandleError(errorCode); - break; - } - - mrOptimizerDialog.endExecute( bSuccessfullyExecuted ); - } - else - { - mrOptimizerDialog.setControlProperty( "btnNavBack", "Enabled", Any( true ) ); - mrOptimizerDialog.setControlProperty( "btnNavNext", "Enabled", Any( false ) ); - mrOptimizerDialog.setControlProperty( "btnNavFinish", "Enabled", Any( true ) ); - mrOptimizerDialog.setControlProperty( "btnNavCancel", "Enabled", Any( true ) ); - mrOptimizerDialog.EnablePage( ITEM_ID_SUMMARY ); - } - } - break; - case TK_btnNavCancel : mrOptimizerDialog.endExecute( false ); break; - case TK_Button0Pg0 : // delete configuration - { - OUString aSelectedItem( mrOptimizerDialog.GetSelectedString( "ListBox0Pg0" ) ); - if ( !aSelectedItem.isEmpty() ) - { - std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) ); - std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); - if ( aIter != rList.end() ) - { - rList.erase( aIter ); - mrOptimizerDialog.UpdateControlStates(); - } - } - } - break; - default: break; - } + if (!rBox.get_active()) + return; + + const bool bALLOles = &rBox == m_xAllOLEObjects.get(); + sal_Int16 nInt16 = bALLOles ? 0 : 1; + mrOptimizerDialog.SetConfigProperty( TK_OLEOptimizationType, Any( nInt16 ) ); } -void ActionListener::disposing( const css::lang::EventObject& /* Source */ ) + +IMPL_LINK(ObjectsPage, OLEOptimizationActionPerformed, weld::Toggleable&, rBox, void) { + const bool bOLEOptimization = rBox.get_active(); + mrOptimizerDialog.SetConfigProperty( TK_OLEOptimization, Any(bOLEOptimization) ); + m_xAllOLEObjects->set_sensitive(bOLEOptimization); + m_xForeignOLEObjects->set_sensitive(bOLEOptimization); } - -void ActionListenerListBox0Pg0::actionPerformed( const ActionEvent& rEvent ) +IMPL_LINK(ImagesPage, CompressionActionPerformed, weld::Toggleable&, rBox, void) { - if ( !rEvent.ActionCommand.isEmpty() ) - { - std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( rEvent.ActionCommand ) ); - std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); - if ( aIter != rList.end() ) - rList[ 0 ] = *aIter; - } - mrOptimizerDialog.UpdateControlStates(); + if (!rBox.get_active()) + return; + + const bool bJPEGCompression = &rBox == m_xJpegCompression.get(); + mrOptimizerDialog.SetConfigProperty(TK_JPEGCompression, Any(bJPEGCompression)); + m_xQualityLabel->set_sensitive(bJPEGCompression); + m_xQuality->set_sensitive(bJPEGCompression); } -void ActionListenerListBox0Pg0::disposing( const css::lang::EventObject& /* Source */ ) + +IMPL_LINK(ImagesPage, RemoveCropAreaActionPerformed, weld::Toggleable&, rBox, void) { + mrOptimizerDialog.SetConfigProperty(TK_RemoveCropArea, Any(rBox.get_active())); } - -void TextListenerFormattedField0Pg1::textChanged( const TextEvent& /* rEvent */ ) +IMPL_LINK(ImagesPage, EmbedLinkedGraphicsActionPerformed, weld::Toggleable&, rBox, void) { - double fDouble = 0; - Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" ); - if ( aAny >>= fDouble ) - mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) ); + mrOptimizerDialog.SetConfigProperty(TK_EmbedLinkedGraphics, Any(rBox.get_active())); } -void TextListenerFormattedField0Pg1::disposing( const css::lang::EventObject& /* Source */ ) + +IMPL_LINK(SlidesPage, UnusedHiddenSlidesActionPerformed, weld::Toggleable&, rBox, void) { + mrOptimizerDialog.SetConfigProperty(TK_DeleteHiddenSlides, Any(rBox.get_active())); } -namespace +IMPL_LINK(SlidesPage, UnusedMasterPagesActionPerformed, weld::Toggleable&, rBox, void) { + mrOptimizerDialog.SetConfigProperty(TK_DeleteUnusedMasterPages, Any(rBox.get_active())); +} -bool lcl_mapResolution(OUString& rResolution, std::u16string_view rImageResolution) +IMPL_LINK(SlidesPage, DeleteNotesActionPerformed, weld::Toggleable&, rBox, void) { - if (o3tl::getToken(rImageResolution, 1, ';')!=rResolution) - return false; - rResolution = o3tl::getToken(rImageResolution, 0, ';'); - return true; + mrOptimizerDialog.SetConfigProperty(TK_DeleteNotesPages, Any(rBox.get_active())); } +IMPL_LINK(SlidesPage, UnusedSlidesActionPerformed, weld::Toggleable&, rBox, void) +{ + mxComboBox->set_sensitive(rBox.get_active()); } -void TextListenerComboBox0Pg1::textChanged( const TextEvent& /* rEvent */ ) +bool OptimizerDialog::onFinish() { - OUString aString; - Any aAny = mrOptimizerDialog.getControlProperty( "ComboBox0Pg1", "Text" ); - if ( !(aAny >>= aString) ) - return; + UpdateConfiguration(); - for (int nIR{ STR_IMAGE_RESOLUTION_0 }; nIR <= STR_IMAGE_RESOLUTION_3; ++nIR) + ShowPage(ITEM_ID_SUMMARY); + m_xPrevPage->set_sensitive(false); + m_xNextPage->set_sensitive(false); + m_xFinish->set_sensitive(false); + m_xCancel->set_sensitive(false); + + // check if we have to open the FileDialog + bool bSuccessfullyExecuted = true; + if (mpPage4->GetSaveAsNew()) { - if (lcl_mapResolution(aString, mrOptimizerDialog.getString(static_cast<PPPOptimizerTokenEnum>(nIR)))) - break; - } + // Duplicate presentation before applying changes + OUString aSaveAsURL; + FileOpenDialog aFileOpenDialog(mxContext); + + // generating default file name + OUString aName; + Reference< XStorable > xStorable( mxController->getModel(), UNO_QUERY ); + if ( xStorable.is() && xStorable->hasLocation() ) + { + INetURLObject aURLObj( xStorable->getLocation() ); + if ( !aURLObj.hasFinalSlash() ) + { + // tdf#105382 uri-decode file name + aURLObj.removeExtension(INetURLObject::LAST_SEGMENT, false); + aName = aURLObj.getName(INetURLObject::LAST_SEGMENT, false, + INetURLObject::DecodeMechanism::WithCharset); + } + } + else + { + // If no filename, try to use model title ("Untitled 1" or something like this) + Reference<XTitle> xTitle( + GetFrame()->getController()->getModel(), UNO_QUERY); + aName = xTitle->getTitle(); + } - mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( aString.toInt32() ) ); -} -void TextListenerComboBox0Pg1::disposing( const css::lang::EventObject& /* Source */ ) -{ -} + if (!aName.isEmpty()) + { + aName += " " + getString(STR_FILENAME_SUFFIX); + aFileOpenDialog.setDefaultName(aName); + } + if (aFileOpenDialog.execute() == dialogs::ExecutableDialogResults::OK) + { + aSaveAsURL = aFileOpenDialog.getURL(); + SetConfigProperty( TK_SaveAsURL, Any( aSaveAsURL ) ); + SetConfigProperty( TK_FilterName, Any( aFileOpenDialog.getFilterName() ) ); + } + if ( aSaveAsURL.isEmpty() ) + { + // something goes wrong... + bSuccessfullyExecuted = false; + } -void SpinListenerFormattedField0Pg1::up( const SpinEvent& /* rEvent */ ) -{ - double fDouble; - Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" ); - if ( aAny >>= fDouble ) + // waiting for 500ms + Application::Reschedule(true); + for ( sal_uInt32 i = osl_getGlobalTimer(); ( i + 500 ) > ( osl_getGlobalTimer() ); ) + Application::Reschedule(true); + } + else { - fDouble += 9; - if ( fDouble > 100 ) - fDouble = 100; - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) ); - mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) ); + // Apply changes to current presentation + Reference<XModifiable> xModifiable(mxController->getModel(), + UNO_QUERY_THROW ); + if ( xModifiable->isModified() ) + { + SolarMutexGuard aSolarGuard; + std::unique_ptr<weld::MessageDialog> popupDlg(Application::CreateMessageDialog( + m_xAssistant.get(), VclMessageType::Question, VclButtonsType::YesNo, + getString(STR_WARN_UNSAVED_PRESENTATION))); + if (popupDlg->run() != RET_YES) + { + // Selected not "yes" ("no" or dialog was cancelled) so return to previous step + m_xPrevPage->set_sensitive(true); + m_xNextPage->set_sensitive(true); + m_xFinish->set_sensitive(true); + m_xCancel->set_sensitive(true); + return false; + } + } } + if ( bSuccessfullyExecuted ) + { + // now check if we have to store a session template + const bool bSaveSettings = mpPage4->GetSaveSettings(); + OUString aSettingsName = mpPage4->GetSettingsName(); + if (bSaveSettings && !aSettingsName.isEmpty()) + { + std::vector< OptimizerSettings >::iterator aIter( GetOptimizerSettingsByName( aSettingsName ) ); + std::vector< OptimizerSettings >& rSettings( GetOptimizerSettings() ); + OptimizerSettings aNewSettings( rSettings[ 0 ] ); + aNewSettings.maName = aSettingsName; + if ( aIter == rSettings.end() ) + rSettings.push_back( aNewSettings ); + else + *aIter = aNewSettings; + } + } + if ( bSuccessfullyExecuted ) + { + URL aURL; + aURL.Protocol = "vnd.com.sun.star.comp.PPPOptimizer:"; + aURL.Path = "optimize"; + + Sequence< PropertyValue > lArguments{ + comphelper::makePropertyValue("Settings", GetConfigurationSequence()), + comphelper::makePropertyValue("StatusDispatcher", GetStatusDispatcher()), + comphelper::makePropertyValue("InformationDialog", GetFrame()) + }; + + ErrCode errorCode; + try + { + ImpOptimizer aOptimizer(mxContext, GetFrame()->getController()->getModel()); + aOptimizer.Optimize(lArguments); + } + catch (css::io::IOException&) + { + // We always receive just ERRCODE_IO_CANTWRITE in case of problems, so no need to bother + // about extracting error code from exception text + errorCode = ERRCODE_IO_CANTWRITE; + } + catch (css::uno::Exception&) + { + // Other general exception + errorCode = ERRCODE_IO_GENERAL; + } + + if (errorCode != ERRCODE_NONE) + { + // Restore wizard controls + maStats.SetStatusValue(TK_Progress, Any(static_cast<sal_Int32>(0))); + m_xPrevPage->set_sensitive(true); + m_xNextPage->set_sensitive(false); + m_xFinish->set_sensitive(true); + m_xCancel->set_sensitive(true); + + OUString aFileName; + GetConfigProperty(TK_SaveAsURL) >>= aFileName; + SfxErrorContext aEc(ERRCTX_SFX_SAVEASDOC, aFileName); + ErrorHandler::HandleError(errorCode); + return false; + } + } + else + { + m_xPrevPage->set_sensitive(true); + m_xNextPage->set_sensitive(false); + m_xFinish->set_sensitive(true); + m_xCancel->set_sensitive(true); + } + + return vcl::RoadmapWizardMachine::onFinish(); } -void SpinListenerFormattedField0Pg1::down( const SpinEvent& /* rEvent */ ) + +IMPL_LINK_NOARG(IntroPage, ButtonActionPerformed, weld::Button&, void) { - double fDouble; - Any aAny = mrOptimizerDialog.getControlProperty( "FormattedField0Pg1", "EffectiveValue" ); - if ( aAny >>= fDouble ) + // delete configuration + OUString aSelectedItem(mxComboBox->get_active_text()); + if ( !aSelectedItem.isEmpty() ) { - fDouble -= 9; - if ( fDouble < 0 ) - fDouble = 0; - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( fDouble ) ); - mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(fDouble) ) ); + std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName( aSelectedItem ) ); + std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); + if ( aIter != rList.end() ) + { + rList.erase( aIter ); + mrOptimizerDialog.UpdateControlStates(); + } } } -void SpinListenerFormattedField0Pg1::first( const SpinEvent& /* rEvent */ ) + +IMPL_LINK(IntroPage, ComboBoxActionPerformed, weld::ComboBox&, rBox, void) { - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 0 ) ) ); - mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( sal_Int32(0) ) ); + OUString sActionCommand(rBox.get_active_text()); + if (!sActionCommand.isEmpty()) + { + std::vector< OptimizerSettings >::iterator aIter( mrOptimizerDialog.GetOptimizerSettingsByName(sActionCommand) ); + std::vector< OptimizerSettings >& rList( mrOptimizerDialog.GetOptimizerSettings() ); + if ( aIter != rList.end() ) + rList[ 0 ] = *aIter; + } + mrOptimizerDialog.UpdateControlStates(); } -void SpinListenerFormattedField0Pg1::last( const SpinEvent& /* rEvent */ ) + +IMPL_LINK(ImagesPage, SpinButtonActionPerformed, weld::SpinButton&, rBox, void) { - mrOptimizerDialog.setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast< double >( 100 ) ) ); - mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( sal_Int32(100) ) ); + mrOptimizerDialog.SetConfigProperty( TK_JPEGQuality, Any( static_cast<sal_Int32>(rBox.get_value()) ) ); } -void SpinListenerFormattedField0Pg1::disposing( const css::lang::EventObject& /* Source */ ) + +IMPL_LINK_NOARG(ImagesPage, ComboBoxActionPerformed, weld::ComboBox&, void) { + mrOptimizerDialog.SetConfigProperty( TK_ImageResolution, Any( m_xResolution->get_active_id().toInt32() ) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/optimizerdialog.hxx b/sdext/source/minimizer/optimizerdialog.hxx index 4ea28eb7590a..2e9ad3fd5bca 100644 --- a/sdext/source/minimizer/optimizerdialog.hxx +++ b/sdext/source/minimizer/optimizerdialog.hxx @@ -17,19 +17,17 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX -#define INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX +#pragma once + #include <vector> #include "unodialog.hxx" #include "optimizationstats.hxx" #include "configurationaccess.hxx" -#include <com/sun/star/awt/XItemListener.hpp> -#include <com/sun/star/awt/XSpinListener.hpp> -#include <com/sun/star/awt/XTextListener.hpp> #include <com/sun/star/uno/Sequence.h> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <cppuhelper/implbase.hxx> +#include <vcl/roadmapwizard.hxx> #define MAX_STEP 4 #define OD_DIALOG_WIDTH 330 @@ -48,36 +46,167 @@ #define ITEM_ID_OLE_OPTIMIZATION 3 #define ITEM_ID_SUMMARY 4 -class OptimizerDialog : public UnoDialog, public ConfigurationAccess +class OptimizerDialog; + +class IntroPage : public vcl::OWizardPage +{ +private: + OptimizerDialog& mrOptimizerDialog; + std::unique_ptr<weld::ComboBox> mxComboBox; + std::unique_ptr<weld::Button> mxButton; + + DECL_LINK(ComboBoxActionPerformed, weld::ComboBox&, void); + DECL_LINK(ButtonActionPerformed, weld::Button&, void); + +public: + IntroPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog); + void UpdateControlStates(const std::vector<OUString>& rItemList, int nSelectedItem, bool bRemoveButtonEnabled); + OUString Get_TK_Name() const + { + return mxComboBox->get_active_text(); + } +}; + +class SlidesPage : public vcl::OWizardPage +{ +private: + OptimizerDialog& mrOptimizerDialog; + std::unique_ptr<weld::CheckButton> mxMasterSlides; + std::unique_ptr<weld::CheckButton> mxHiddenSlides; + std::unique_ptr<weld::CheckButton> mxUnusedSlides; + std::unique_ptr<weld::ComboBox> mxComboBox; + std::unique_ptr<weld::CheckButton> mxClearNodes; + + DECL_LINK(UnusedMasterPagesActionPerformed, weld::Toggleable&, void); + DECL_LINK(UnusedHiddenSlidesActionPerformed, weld::Toggleable&, void); + DECL_LINK(UnusedSlidesActionPerformed, weld::Toggleable&, void); + DECL_LINK(DeleteNotesActionPerformed, weld::Toggleable&, void); + +public: + SlidesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog); + void Init(const css::uno::Sequence<OUString>& rCustomShowList); + void UpdateControlStates(bool bDeleteUnusedMasterPages, bool bDeleteHiddenSlides, bool bDeleteNotesPages); + OUString Get_TK_CustomShowName() const + { + if (!mxUnusedSlides->get_sensitive()) + return OUString(); + return mxComboBox->get_active_text(); + } +}; + +class ImagesPage : public vcl::OWizardPage +{ +private: + OptimizerDialog& mrOptimizerDialog; + std::unique_ptr<weld::RadioButton> m_xLossLessCompression; + std::unique_ptr<weld::Label> m_xQualityLabel; + std::unique_ptr<weld::SpinButton> m_xQuality; + std::unique_ptr<weld::RadioButton> m_xJpegCompression; + std::unique_ptr<weld::ComboBox> m_xResolution; + std::unique_ptr<weld::CheckButton> m_xRemoveCropArea; + std::unique_ptr<weld::CheckButton> m_xEmbedLinkedGraphics; + + DECL_LINK(EmbedLinkedGraphicsActionPerformed, weld::Toggleable&, void); + DECL_LINK(RemoveCropAreaActionPerformed, weld::Toggleable&, void); + DECL_LINK(ComboBoxActionPerformed, weld::ComboBox&, void); + DECL_LINK(CompressionActionPerformed, weld::Toggleable&, void); + DECL_LINK(SpinButtonActionPerformed, weld::SpinButton&, void); + +public: + ImagesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog); + + void UpdateControlStates(bool bJPEGCompression, int nJPEGQuality, bool bRemoveCropArea, + int nResolution, bool bEmbedLinkedGraphics); +}; + +class ObjectsPage : public vcl::OWizardPage +{ +private: + OptimizerDialog& mrOptimizerDialog; + std::unique_ptr<weld::CheckButton> m_xCreateStaticImage; + std::unique_ptr<weld::RadioButton> m_xAllOLEObjects; + std::unique_ptr<weld::RadioButton> m_xForeignOLEObjects; + std::unique_ptr<weld::Label> m_xLabel; + + DECL_LINK(OLEOptimizationActionPerformed, weld::Toggleable&, void); + DECL_LINK(OLEActionPerformed, weld::Toggleable&, void); + +public: + ObjectsPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog); + + void Init(const OUString& rDesc); + + void UpdateControlStates(bool bConvertOLEObjects, int nOLEOptimizationType); +}; + +class SummaryPage : public vcl::OWizardPage +{ +private: + OptimizerDialog& mrOptimizerDialog; + std::unique_ptr<weld::Label> m_xLabel1; + std::unique_ptr<weld::Label> m_xLabel2; + std::unique_ptr<weld::Label> m_xLabel3; + std::unique_ptr<weld::Label> m_xCurrentSize; + std::unique_ptr<weld::Label> m_xEstimatedSize; + std::unique_ptr<weld::Label> m_xStatus; + std::unique_ptr<weld::ProgressBar> m_xProgress; + std::unique_ptr<weld::RadioButton> m_xApplyToCurrent; + std::unique_ptr<weld::RadioButton> m_xSaveToNew; + std::unique_ptr<weld::ComboBox> m_xComboBox; + std::unique_ptr<weld::CheckButton> m_xSaveSettings; + + DECL_LINK(SaveSettingsActionPerformed, weld::Toggleable&, void); + DECL_LINK(SaveAsNewActionPerformed, weld::Toggleable&, void); + +public: + SummaryPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog); + + void Init(const OUString& rSettingsName, bool bIsReadonly); + + void UpdateControlStates(bool bSaveAs, bool bSaveSettingsEnabled, + const std::vector<OUString>& rItemList, + const std::vector<OUString>& rSummaryStrings, + const OUString& rCurrentFileSize, + const OUString& rEstimatedFileSize); + + void UpdateStatusLabel(const OUString& rStatus); + void UpdateProgressValue(int nProgress); + + bool GetSaveAsNew() const { return m_xSaveToNew->get_active(); } + bool GetSaveSettings() const { return m_xSaveSettings->get_active(); } + OUString GetSettingsName() const { return m_xComboBox->get_active_text(); } +}; + +class OptimizerDialog : public vcl::RoadmapWizardMachine, public ConfigurationAccess { public: 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 ); + std::unique_ptr<BuilderPage> createPage(vcl::WizardTypes::WizardState nState) override; ~OptimizerDialog(); void execute(); - sal_Int16 mnCurrentStep; - sal_Int16 mnTabIndex; + sal_Int16 mnCurrentStep; + sal_Int16 mnTabIndex; + short mnEndStatus; bool mbIsReadonly; private: css::uno::Reference< css::frame::XFrame > mxFrame; + css::uno::Reference< css::frame::XController > mxController; - css::uno::Reference< css::uno::XInterface > mxRoadmapControl; - css::uno::Reference< css::uno::XInterface > mxRoadmapControlModel; - - css::uno::Reference< css::awt::XItemListener > mxItemListener; - css::uno::Reference< css::awt::XActionListener > mxActionListener; - css::uno::Reference< css::awt::XActionListener > mxActionListenerListBox0Pg0; - css::uno::Reference< css::awt::XTextListener > mxTextListenerFormattedField0Pg1; - css::uno::Reference< css::awt::XTextListener > mxTextListenerComboBox0Pg1; - css::uno::Reference< css::awt::XSpinListener > mxSpinListenerFormattedField0Pg1; css::uno::Reference< css::frame::XDispatch > mxStatusDispatcher; std::vector< std::vector< OUString > > maControlPages; + IntroPage* mpPage0; + SlidesPage* mpPage1; + ImagesPage* mpPage2; + ObjectsPage* mpPage3; + SummaryPage* mpPage4; + void InitDialog(); void InitRoadmap(); void InitNavigationBar(); @@ -92,9 +221,9 @@ private: void UpdateControlStatesPage3(); void UpdateControlStatesPage4(); - void ActivatePage( sal_Int16 nStep ); - void DeactivatePage( sal_Int16 nStep ); - void InsertRoadmapItem( const sal_Int32 nIndex, const OUString& rLabel, const sal_Int32 nItemID ); + virtual OUString getStateDisplayName(vcl::WizardTypes::WizardState nState) const override; + + virtual bool onFinish() override; public: @@ -105,99 +234,10 @@ public: // the ConfigurationAccess is updated to actual control settings void UpdateConfiguration(); - void EnablePage( sal_Int16 nStep ); - void DisablePage( sal_Int16 nStep ); - - void SwitchPage( sal_Int16 nNewStep ); void UpdateControlStates( sal_Int16 nStep = -1 ); - OUString GetSelectedString( OUString const & token ); css::uno::Reference< css::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; }; css::uno::Reference< css::frame::XFrame>& GetFrame() { return mxFrame; }; - const css::uno::Reference< css::uno::XComponentContext >& GetComponentContext() const { return UnoDialog::mxContext; }; -}; - - -class ItemListener : public ::cppu::WeakImplHelper< css::awt::XItemListener > -{ -public: - explicit ItemListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; }; - -class ActionListener : public ::cppu::WeakImplHelper< css::awt::XActionListener > -{ -public: - explicit ActionListener( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; -}; - - -class ActionListenerListBox0Pg0 : public ::cppu::WeakImplHelper< css::awt::XActionListener > -{ -public: - explicit ActionListenerListBox0Pg0( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; -}; - - -class TextListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper< css::awt::XTextListener > -{ -public: - explicit TextListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL textChanged( const css::awt::TextEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; -}; - - -class TextListenerComboBox0Pg1 : public ::cppu::WeakImplHelper< css::awt::XTextListener > -{ -public: - explicit TextListenerComboBox0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL textChanged( const css::awt::TextEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; -}; - - -class SpinListenerFormattedField0Pg1 : public ::cppu::WeakImplHelper< css::awt::XSpinListener > -{ -public: - explicit SpinListenerFormattedField0Pg1( OptimizerDialog& rOptimizerDialog ) : mrOptimizerDialog( rOptimizerDialog ){} - - virtual void SAL_CALL up( const css::awt::SpinEvent& Event ) override; - virtual void SAL_CALL down( const css::awt::SpinEvent& Event ) override; - virtual void SAL_CALL first( const css::awt::SpinEvent& Event ) override; - virtual void SAL_CALL last( const css::awt::SpinEvent& Event ) override; - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; -private: - - OptimizerDialog& mrOptimizerDialog; -}; - -#endif // INCLUDED_SDEXT_SOURCE_MINIMIZER_OPTIMIZERDIALOG_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/optimizerdialogcontrols.cxx b/sdext/source/minimizer/optimizerdialogcontrols.cxx index 4ab29d9694e6..5ed2dd942b7e 100644 --- a/sdext/source/minimizer/optimizerdialogcontrols.cxx +++ b/sdext/source/minimizer/optimizerdialogcontrols.cxx @@ -47,357 +47,21 @@ using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::container; using namespace ::com::sun::star::presentation; - -static void SetBold( OptimizerDialog& rOptimizerDialog, const OUString& rControl ) -{ - FontDescriptor aFontDescriptor; - if ( rOptimizerDialog.getControlProperty( rControl, "FontDescriptor" ) >>= aFontDescriptor ) - { - aFontDescriptor.Weight = com::sun::star::awt::FontWeight::BOLD; - rOptimizerDialog.setControlProperty( rControl, "FontDescriptor", Any( aFontDescriptor ) ); - } -} - - -static OUString InsertSeparator( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, sal_Int32 nOrientation, - sal_Int32 nPosX, sal_Int32 nPosY, sal_Int32 nWidth, sal_Int32 nHeight ) -{ - OUString pNames[] = { - OUString("Height"), - OUString("Orientation"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("Width") }; - - Any pValues[] = { - Any( nHeight ), - Any( nOrientation ), - Any( nPosX ), - Any( nPosY ), - Any( sal_Int16( 0 ) ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - rOptimizerDialog.insertControlModel( "com.sun.star.awt.UnoControlFixedLineModel", - rControlName, aNames, aValues ); - return rControlName; -} - - -static OUString InsertButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, Reference< XActionListener > const & xActionListener, - sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex, bool bEnabled, PPPOptimizerTokenEnum nResID, css::awt::PushButtonType nPushButtonType ) -{ - sal_Int32 nHeight = BUTTON_HEIGHT; - OUString pNames[] = { - OUString("Enabled"), - OUString("Height"), - OUString("Label"), - OUString("PositionX"), - OUString("PositionY"), - OUString("PushButtonType"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( bEnabled ), - Any( nHeight ), - Any( rOptimizerDialog.getString( nResID ) ), - Any( nXPos ), - Any( nYPos ), - Any( static_cast< sal_Int16 >(nPushButtonType) ), - Any( sal_Int16(0) ), - Any( nTabIndex ), - Any( nWidth ) }; - - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - rOptimizerDialog.insertButton( rControlName, xActionListener, aNames, aValues ); - return rControlName; -} - - -static OUString InsertFixedText( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const OUString& rLabel, - sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int32 nHeight, bool bMultiLine, bool bBold, sal_Int16 nTabIndex ) -{ - OUString pNames[] = { - OUString("Height"), - OUString("Label"), - OUString("MultiLine"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( nHeight ), - Any( rLabel ), - Any( bMultiLine ), - Any( nXPos ), - Any( nYPos ), - Any( sal_Int16(0) ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - rOptimizerDialog.insertFixedText( rControlName, aNames, aValues ); - if ( bBold ) - SetBold( rOptimizerDialog, rControlName ); - return rControlName; -} - - -static OUString InsertCheckBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, - const Reference< XItemListener >& xItemListener, const OUString& rLabel, - sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex ) -{ - sal_Int32 nHeight = 8; - OUString pNames[] = { - OUString("Enabled"), - OUString("Height"), - OUString("Label"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( true ), - Any( nHeight ), - Any( rLabel ), - Any( nXPos ), - Any( nYPos ), - Any( sal_Int16(0) ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - Reference< XCheckBox > xCheckBox( rOptimizerDialog.insertCheckBox( rControlName, aNames, aValues ) ); - if ( xItemListener.is() ) - xCheckBox->addItemListener( xItemListener ); - return rControlName; -} - - -static OUString InsertFormattedField( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, - const Reference< XTextListener >& xTextListener, const Reference< XSpinListener >& xSpinListener, sal_Int32 nXPos, sal_Int32 nYPos, - double fEffectiveMin, double fEffectiveMax, sal_Int16 nTabIndex ) -{ - sal_Int32 nWidth = 50; - OUString pNames[] = { - OUString("EffectiveMax"), - OUString("EffectiveMin"), - OUString("Enabled"), - OUString("Height"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Repeat"), - OUString("Spin"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( fEffectiveMax ), - Any( fEffectiveMin ), - Any( true ), - Any( sal_Int32(12) ), - Any( nXPos ), - Any( nYPos ), - Any( true ), - Any( true ), - Any( sal_Int16(0) ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertFormattedField( rControlName, aNames, aValues ), UNO_QUERY_THROW ); - if ( xTextListener.is() ) - xTextComponent->addTextListener( xTextListener ); - if ( xSpinListener.is() ) - { - Reference< XSpinField > xSpinField( xTextComponent, UNO_QUERY_THROW ); - xSpinField->addSpinListener( xSpinListener ); - } - return rControlName; -} - - -static OUString InsertComboBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, - const Reference< XTextListener >& rTextListener, const bool bEnabled, const Sequence< OUString >& rItemList, - sal_Int32 nXPos, sal_Int32 nYPos, sal_Int16 nTabIndex ) -{ - sal_Int32 nHeight = 12; - sal_Int32 nWidth = 100; - OUString pNames[] = { - OUString("Dropdown"), - OUString("Enabled"), - OUString("Height"), - OUString("LineCount"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("StringItemList"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( true ), - Any( bEnabled ), - Any( nHeight ), - Any( sal_Int16(8)), - Any( nXPos ), - Any( nYPos ), - Any( sal_Int16(0) ), - Any( rItemList ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - Reference< XTextComponent > xTextComponent( rOptimizerDialog.insertComboBox( rControlName, aNames, aValues ), UNO_QUERY_THROW ); - if ( rTextListener.is() ) - xTextComponent->addTextListener( rTextListener ); - return rControlName; -} - - -static OUString InsertRadioButton( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, const Reference< XItemListener >& rItemListener, - const OUString& rLabel, sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex ) -{ - sal_Int32 nHeight = 8; - OUString pNames[] = { - OUString("Height"), - OUString("Label"), - OUString("MultiLine"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( nHeight ), - Any( rLabel ), - Any( false ), // bMultiLine - Any( nXPos ), - Any( nYPos ), - Any( sal_Int16(0) ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - Reference< XRadioButton > xRadioButton( rOptimizerDialog.insertRadioButton( rControlName, aNames, aValues ) ); - if ( rItemListener.is() ) - xRadioButton->addItemListener( rItemListener ); - return rControlName; -} - - -static OUString InsertListBox( OptimizerDialog& rOptimizerDialog, const OUString& rControlName, - const Reference< XActionListener >& rActionListener, const bool bEnabled, const Sequence< OUString >& rItemList, - sal_Int32 nXPos, sal_Int32 nYPos, sal_Int32 nWidth, sal_Int16 nTabIndex ) -{ - sal_Int32 nHeight = 12; - OUString pNames[] = { - OUString("Dropdown"), - OUString("Enabled"), - OUString("Height"), - OUString("LineCount"), - OUString("MultiSelection"), - OUString("PositionX"), - OUString("PositionY"), - OUString("Step"), - OUString("StringItemList"), - OUString("TabIndex"), - OUString("Width") }; - - Any pValues[] = { - Any( true ), - Any( bEnabled ), - Any( nHeight ), - Any( sal_Int16(8)), - Any( false ), - Any( nXPos ), - Any( nYPos ), - Any( sal_Int16(0) ), - Any( rItemList ), - Any( nTabIndex ), - Any( nWidth ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - Reference< XListBox > xListBox( rOptimizerDialog.insertListBox( rControlName, aNames, aValues ) ); - if ( xListBox.is() ) - xListBox->addActionListener( rActionListener ); - return rControlName; -} - - void OptimizerDialog::InitNavigationBar() { - sal_Int32 nCancelPosX = OD_DIALOG_WIDTH - BUTTON_WIDTH - 6; - sal_Int32 nFinishPosX = nCancelPosX - 6 - BUTTON_WIDTH; - sal_Int32 nNextPosX = nFinishPosX - 6 - BUTTON_WIDTH; - sal_Int32 nBackPosX = nNextPosX - 3 - BUTTON_WIDTH; - - InsertSeparator( *this, "lnNavSep1", 0, 0, DIALOG_HEIGHT - 26, OD_DIALOG_WIDTH, 1 ); - InsertSeparator( *this, "lnNavSep2", 1, 85, 0, 1, BUTTON_POS_Y - 6 ); - - InsertButton( *this, "btnNavBack", mxActionListener, nBackPosX, BUTTON_POS_Y, BUTTON_WIDTH, mnTabIndex++, false, STR_BACK, PushButtonType_STANDARD ); - InsertButton( *this, "btnNavNext", mxActionListener, nNextPosX, BUTTON_POS_Y, BUTTON_WIDTH, mnTabIndex++, true, STR_NEXT, PushButtonType_STANDARD ); - InsertButton( *this, "btnNavFinish", mxActionListener, nFinishPosX, BUTTON_POS_Y, BUTTON_WIDTH, mnTabIndex++, true, STR_FINISH, PushButtonType_STANDARD ); - InsertButton( *this, "btnNavCancel", mxActionListener, nCancelPosX, BUTTON_POS_Y, BUTTON_WIDTH, mnTabIndex++, true, STR_CANCEL, PushButtonType_STANDARD ); - - setControlProperty( "btnNavNext", "DefaultButton", Any( true ) ); + m_xHelp->hide(); } - void OptimizerDialog::UpdateControlStatesPage0() { - short nSelectedItem = -1; - Sequence< OUString > aItemList; + int nSelectedItem = -1; + std::vector<OUString> aItemList; const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() ); if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one { - aItemList.realloc( rList.size() - 1 ); - auto pItemList = aItemList.getArray(); for ( std::vector<OptimizerSettings>::size_type i = 1; i < rList.size(); i++ ) { - pItemList[ i - 1 ] = rList[ i ].maName; + aItemList.push_back(rList[i].maName); if ( nSelectedItem < 0 ) { if ( rList[ i ] == rList[ 0 ] ) @@ -406,45 +70,27 @@ void OptimizerDialog::UpdateControlStatesPage0() } } bool bRemoveButtonEnabled = false; - Sequence< short > aSelectedItems; if ( nSelectedItem >= 0 ) { - aSelectedItems = { nSelectedItem }; if ( nSelectedItem > 2 ) // only allowing to delete custom themes, the first can|t be deleted bRemoveButtonEnabled = true; } - setControlProperty( "ListBox0Pg0", "StringItemList", Any( aItemList ) ); - setControlProperty( "ListBox0Pg0", "SelectedItems", Any( aSelectedItems ) ); - setControlProperty( "Button0Pg0", "Enabled", Any( bRemoveButtonEnabled ) ); + mpPage0->UpdateControlStates(aItemList, nSelectedItem, bRemoveButtonEnabled); } + void OptimizerDialog::InitPage0() { - Sequence< OUString > aItemList; - std::vector< OUString > aControlList - { - InsertFixedText( *this, "FixedText0Pg0", getString( STR_INTRODUCTION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ), - InsertFixedText( *this, "FixedText1Pg0", getString( STR_INTRODUCTION_T ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 100, true, false, mnTabIndex++ ), - InsertSeparator( *this, "Separator1Pg0", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 66, PAGE_WIDTH - 12, 1 ), - InsertFixedText( *this, "FixedText2Pg0", getString( STR_CHOSE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 60, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ), - InsertListBox( *this, "ListBox0Pg0", mxActionListenerListBox0Pg0, true, aItemList, PAGE_POS_X + 6, DIALOG_HEIGHT - 48, ( OD_DIALOG_WIDTH - 50 ) - ( PAGE_POS_X + 6 ), mnTabIndex++ ), - InsertButton( *this, "Button0Pg0", mxActionListener, OD_DIALOG_WIDTH - 46, DIALOG_HEIGHT - 49, 40, mnTabIndex++, true, STR_REMOVE, PushButtonType_STANDARD ) - }; - maControlPages.push_back( aControlList ); - DeactivatePage( 0 ); UpdateControlStatesPage0(); } - void OptimizerDialog::UpdateControlStatesPage1() { bool bDeleteUnusedMasterPages( GetConfigProperty( TK_DeleteUnusedMasterPages, false ) ); bool bDeleteHiddenSlides( GetConfigProperty( TK_DeleteHiddenSlides, false ) ); bool bDeleteNotesPages( GetConfigProperty( TK_DeleteNotesPages, false ) ); - - setControlProperty( "CheckBox0Pg3", "State", Any( static_cast<sal_Int16>(bDeleteUnusedMasterPages) ) ); - setControlProperty( "CheckBox1Pg3", "State", Any( static_cast<sal_Int16>(bDeleteNotesPages) ) ); - setControlProperty( "CheckBox2Pg3", "State", Any( static_cast<sal_Int16>(bDeleteHiddenSlides) ) ); + mpPage1->UpdateControlStates(bDeleteUnusedMasterPages, bDeleteHiddenSlides, bDeleteNotesPages); } + void OptimizerDialog::InitPage1() { Sequence< OUString > aCustomShowList; @@ -456,104 +102,35 @@ void OptimizerDialog::InitPage1() if ( aXCont.is() ) aCustomShowList = aXCont->getElementNames(); } - std::vector< OUString > aControlList - { - InsertFixedText( *this, "FixedText0Pg3", getString( STR_CHOOSE_SLIDES ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox0Pg3", mxItemListener, getString( STR_DELETE_MASTER_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox2Pg3", mxItemListener, getString( STR_DELETE_HIDDEN_SLIDES ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox3Pg3", mxItemListener, getString( STR_CUSTOM_SHOW ), PAGE_POS_X + 6, PAGE_POS_Y + 42, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertListBox( *this, "ListBox0Pg3", mxActionListener, true, aCustomShowList, PAGE_POS_X + 14, PAGE_POS_Y + 54, 150, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox1Pg3", mxItemListener, getString( STR_DELETE_NOTES_PAGES ), PAGE_POS_X + 6, PAGE_POS_Y + 70, PAGE_WIDTH - 12, mnTabIndex++ ) - }; - maControlPages.push_back( aControlList ); - DeactivatePage( 1 ); - - setControlProperty( "CheckBox3Pg3", "State", Any( false ) ); - setControlProperty( "CheckBox3Pg3", "Enabled", Any( aCustomShowList.hasElements() ) ); - setControlProperty( "ListBox0Pg3", "Enabled", Any( false ) ); + mpPage1->Init(aCustomShowList); UpdateControlStatesPage1(); } -namespace -{ - -bool lcl_getResolutionText(OUString& rResolutionText, std::u16string_view rImageResolution, sal_Int32 nTargetRes) -{ - sal_Int32 nIdx{ 0 }; - if (o3tl::toInt32(o3tl::getToken(rImageResolution, 0, ';', nIdx))!=nTargetRes) - return false; - rResolutionText = o3tl::getToken(rImageResolution, 0, ';', nIdx); - return true; -} - -} - void OptimizerDialog::UpdateControlStatesPage2() { bool bJPEGCompression( GetConfigProperty( TK_JPEGCompression, false ) ); bool bRemoveCropArea( GetConfigProperty( TK_RemoveCropArea, false ) ); bool bEmbedLinkedGraphics( GetConfigProperty( TK_EmbedLinkedGraphics, true ) ); sal_Int32 nJPEGQuality( GetConfigProperty( TK_JPEGQuality, sal_Int32(90) ) ); - sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, sal_Int32(0) ) ); - OUString aResolutionText; - for (int nIR{ STR_IMAGE_RESOLUTION_0 }; nIR<=STR_IMAGE_RESOLUTION_3; ++nIR) - { - if (lcl_getResolutionText(aResolutionText, getString(static_cast<PPPOptimizerTokenEnum>(nIR)), nImageResolution)) - break; - } - if ( aResolutionText.isEmpty() ) - aResolutionText = OUString::number( nImageResolution ); - - setControlProperty( "RadioButton0Pg1", "State", Any( static_cast<sal_Int16>( !bJPEGCompression ) ) ); - setControlProperty( "RadioButton1Pg1", "State", Any( static_cast<sal_Int16>(bJPEGCompression) ) ); - setControlProperty( "FixedText1Pg1", "Enabled", Any( bJPEGCompression ) ); - setControlProperty( "FormattedField0Pg1", "Enabled", Any( bJPEGCompression ) ); - setControlProperty( "FormattedField0Pg1", "EffectiveValue", Any( static_cast<double>(nJPEGQuality) ) ); - setControlProperty( "CheckBox1Pg1", "State", Any( static_cast<sal_Int16>(bRemoveCropArea) ) ); - setControlProperty( "ComboBox0Pg1", "Text", Any( aResolutionText ) ); - setControlProperty( "CheckBox2Pg1", "State", Any( static_cast<sal_Int16>(bEmbedLinkedGraphics) ) ); + mpPage2->UpdateControlStates(bJPEGCompression, nJPEGQuality, bRemoveCropArea, nImageResolution, bEmbedLinkedGraphics); } + void OptimizerDialog::InitPage2() { - Sequence< OUString > aResolutionItemList{ - getString( STR_IMAGE_RESOLUTION_0 ).getToken( 1, ';' ), - getString( STR_IMAGE_RESOLUTION_1 ).getToken( 1, ';' ), - getString( STR_IMAGE_RESOLUTION_2 ).getToken( 1, ';' ), - getString( STR_IMAGE_RESOLUTION_3 ).getToken( 1, ';' ) - }; - - std::vector< OUString > aControlList - { - InsertFixedText( *this, "FixedText0Pg1", getString( STR_GRAPHIC_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ), - InsertRadioButton( *this, "RadioButton0Pg1", mxItemListener, getString( STR_LOSSLESS_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertRadioButton( *this, "RadioButton1Pg1", mxItemListener, getString( STR_JPEG_COMPRESSION ), PAGE_POS_X + 6, PAGE_POS_Y + 28, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertFixedText( *this, "FixedText1Pg1", getString( STR_QUALITY ), PAGE_POS_X + 20, PAGE_POS_Y + 40, 72, 8, false, false, mnTabIndex++ ), - InsertFormattedField( *this, "FormattedField0Pg1", mxTextListenerFormattedField0Pg1, mxSpinListenerFormattedField0Pg1, PAGE_POS_X + 106, PAGE_POS_Y + 38, 0, 100, mnTabIndex++ ), - InsertFixedText( *this, "FixedText2Pg1", getString( STR_IMAGE_RESOLUTION ), PAGE_POS_X + 6, PAGE_POS_Y + 54, 94, 8, false, false, mnTabIndex++ ), - InsertComboBox( *this, "ComboBox0Pg1", mxTextListenerComboBox0Pg1, true, aResolutionItemList, PAGE_POS_X + 106, PAGE_POS_Y + 52, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox1Pg1", mxItemListener, getString( STR_REMOVE_CROP_AREA ), PAGE_POS_X + 6, PAGE_POS_Y + 68, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox2Pg1", mxItemListener, getString( STR_EMBED_LINKED_GRAPHICS ), PAGE_POS_X + 6, PAGE_POS_Y + 82, PAGE_WIDTH - 12, mnTabIndex++ ) - }; - maControlPages.push_back( aControlList ); - DeactivatePage( 2 ); UpdateControlStatesPage2(); } - void OptimizerDialog::UpdateControlStatesPage3() { bool bConvertOLEObjects( GetConfigProperty( TK_OLEOptimization, false ) ); sal_Int16 nOLEOptimizationType( GetConfigProperty( TK_OLEOptimizationType, sal_Int16(0) ) ); - setControlProperty( "CheckBox0Pg2", "State", Any( static_cast<sal_Int16>(bConvertOLEObjects) ) ); - setControlProperty( "RadioButton0Pg2", "Enabled", Any( bConvertOLEObjects ) ); - setControlProperty( "RadioButton0Pg2", "State", Any( static_cast<sal_Int16>( nOLEOptimizationType == 0 ) ) ); - setControlProperty( "RadioButton1Pg2", "Enabled", Any( bConvertOLEObjects ) ); - setControlProperty( "RadioButton1Pg2", "State", Any( static_cast<sal_Int16>( nOLEOptimizationType == 1 ) ) ); + mpPage3->UpdateControlStates(bConvertOLEObjects, nOLEOptimizationType); } + void OptimizerDialog::InitPage3() { int nOLECount = 0; @@ -571,20 +148,11 @@ void OptimizerDialog::InitPage3() } } - std::vector< OUString > aControlList - { - InsertFixedText( *this, "FixedText0Pg2", getString( STR_OLE_OPTIMIZATION ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ), - InsertCheckBox( *this, "CheckBox0Pg2", mxItemListener, getString( STR_OLE_REPLACE ), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, mnTabIndex++ ), - InsertRadioButton( *this, "RadioButton0Pg2", mxItemListener, getString( STR_ALL_OLE_OBJECTS ), PAGE_POS_X + 14, PAGE_POS_Y + 28, PAGE_WIDTH - 22, mnTabIndex++ ), - InsertRadioButton( *this, "RadioButton1Pg2", mxItemListener, getString( STR_ALIEN_OLE_OBJECTS_ONLY ), PAGE_POS_X + 14, PAGE_POS_Y + 40, PAGE_WIDTH - 22, mnTabIndex++ ), - InsertFixedText( *this, "FixedText1Pg2", nOLECount ? getString( STR_OLE_OBJECTS_DESC ) : getString( STR_NO_OLE_OBJECTS_DESC ), PAGE_POS_X + 6, PAGE_POS_Y + 64, PAGE_WIDTH - 22, 50, true, false, mnTabIndex++ ) - }; - maControlPages.push_back( aControlList ); - DeactivatePage( 3 ); + mpPage3->Init(nOLECount ? getString(STR_OLE_OBJECTS_DESC) : getString(STR_NO_OLE_OBJECTS_DESC)); + UpdateControlStatesPage3(); } - static OUString ImpValueOfInMB( sal_Int64 rVal, sal_Unicode nSeparator ) { double fVal( static_cast<double>( rVal ) ); @@ -605,27 +173,15 @@ void OptimizerDialog::UpdateControlStatesPage4() { bool bSaveAs( GetConfigProperty( TK_SaveAs, true ) ); if ( mbIsReadonly ) - { - setControlProperty( "RadioButton0Pg4", "State", Any( sal_Int16(false) ) ); - setControlProperty( "RadioButton1Pg4", "State", Any( sal_Int16(true) ) ); - } - else - { - setControlProperty( "RadioButton0Pg4", "State", Any( static_cast<sal_Int16>( !bSaveAs ) ) ); - setControlProperty( "RadioButton1Pg4", "State", Any( static_cast<sal_Int16>(bSaveAs) ) ); - } - setControlProperty( "ComboBox0Pg4", "Enabled", Any( false ) ); + bSaveAs = true; - Sequence< OUString > aItemList; + std::vector<OUString> aItemList; const std::vector< OptimizerSettings >& rList( GetOptimizerSettings() ); if ( rList.size() > 1 ) // the first session in the list is the actual one -> skipping first one { - aItemList.realloc( rList.size() - 1 ); - auto pItemList = aItemList.getArray(); for ( std::vector<OptimizerSettings>::size_type w = 1; w < rList.size(); w++ ) - pItemList[ w - 1 ] = rList[ w ].maName; + aItemList.push_back(rList[ w ].maName); } - setControlProperty( "ComboBox0Pg4", "StringItemList", Any( aItemList ) ); // now check if it is sensible to enable the combo box bool bSaveSettingsEnabled = true; @@ -640,37 +196,14 @@ void OptimizerDialog::UpdateControlStatesPage4() } } } - sal_Int16 nInt16 = 0; - getControlProperty( "CheckBox1Pg4", "State" ) >>= nInt16; - setControlProperty( "CheckBox1Pg4", "Enabled", Any( bSaveSettingsEnabled ) ); - setControlProperty( "ComboBox0Pg4", "Enabled", Any( bSaveSettingsEnabled && nInt16 ) ); std::vector< OUString > aSummaryStrings; // taking care of deleted slides sal_Int32 nDeletedSlides = 0; - if ( getControlProperty( "CheckBox3Pg3", "State" ) >>= nInt16 ) - { - if ( nInt16 ) - { - Sequence< short > aSelectedItems; - Sequence< OUString > aStringItemList; - Any aAny = getControlProperty( "ListBox0Pg3", "SelectedItems" ); - if ( aAny >>= aSelectedItems ) - { - if ( aSelectedItems.hasElements() ) - { - sal_Int16 nSelectedItem = aSelectedItems[ 0 ]; - aAny = getControlProperty( "ListBox0Pg3", "StringItemList" ); - if ( aAny >>= aStringItemList ) - { - if ( aStringItemList.getLength() > nSelectedItem ) - SetConfigProperty( TK_CustomShowName, Any( aStringItemList[ nSelectedItem ] ) ); - } - } - } - } - } + OUString sTKCustomShowName(mpPage1->Get_TK_CustomShowName()); + if (!sTKCustomShowName.isEmpty()) + SetConfigProperty(TK_CustomShowName, Any(sTKCustomShowName)); if ( GetConfigProperty( TK_DeleteHiddenSlides, false ) ) { Reference< XDrawPagesSupplier > xDrawPagesSupplier( mxController->getModel(), UNO_QUERY_THROW ); @@ -714,7 +247,7 @@ void OptimizerDialog::UpdateControlStatesPage4() sal_Int32 nImageResolution( GetConfigProperty( TK_ImageResolution, sal_Int32(0) ) ); GraphicSettings aGraphicSettings( bJPEGCompression, nJPEGQuality, GetConfigProperty( TK_RemoveCropArea, false ), nImageResolution, GetConfigProperty( TK_EmbedLinkedGraphics, true ) ); - GraphicCollector::CountGraphics( UnoDialog::mxContext, mxController->getModel(), aGraphicSettings, nGraphics ); + GraphicCollector::CountGraphics( mxContext, mxController->getModel(), aGraphicSettings, nGraphics ); if ( nGraphics > 1 ) { OUString aStr( getString( STR_OPTIMIZE_IMAGES ) ); @@ -763,9 +296,6 @@ void OptimizerDialog::UpdateControlStatesPage4() } while( aSummaryStrings.size() < 3 ) aSummaryStrings.emplace_back( ); - setControlProperty( "FixedText4Pg4", "Label", Any( aSummaryStrings[ 0 ] ) ); - setControlProperty( "FixedText5Pg4", "Label", Any( aSummaryStrings[ 1 ] ) ); - setControlProperty( "FixedText6Pg4", "Label", Any( aSummaryStrings[ 2 ] ) ); sal_Int64 nCurrentFileSize = 0; sal_Int64 nEstimatedFileSize = 0; @@ -793,71 +323,15 @@ void OptimizerDialog::UpdateControlStatesPage4() OUString aStr( getString( STR_FILESIZESEPARATOR ) ); if ( !aStr.isEmpty() ) nSeparator = aStr[ 0 ]; - setControlProperty( "FixedText7Pg4", "Label", Any( ImpValueOfInMB( nCurrentFileSize, nSeparator ) ) ); - setControlProperty( "FixedText8Pg4", "Label", Any( ImpValueOfInMB( nEstimatedFileSize, nSeparator ) ) ); + mpPage4->UpdateControlStates(bSaveAs, bSaveSettingsEnabled, aItemList, + aSummaryStrings, + ImpValueOfInMB(nCurrentFileSize, nSeparator), + ImpValueOfInMB(nEstimatedFileSize, nSeparator)); SetConfigProperty( TK_EstimatedFileSize, Any( nEstimatedFileSize ) ); } void OptimizerDialog::InitPage4() { - { // creating progress bar: - OUString pNames[] = { - OUString("Height"), - OUString("Name"), - OUString("PositionX"), - OUString("PositionY"), - OUString("ProgressValue"), - OUString("ProgressValueMax"), - OUString("ProgressValueMin"), - OUString("Width") }; - - Any pValues[] = { - Any( sal_Int32(12) ), - Any( OUString("STR_SAVE_AS") ), - Any( sal_Int32( PAGE_POS_X + 6 ) ), - Any( sal_Int32( DIALOG_HEIGHT - 75 ) ), - Any( sal_Int32(0) ), - Any( sal_Int32(100) ), - Any( sal_Int32(0) ), - Any( sal_Int32( PAGE_WIDTH - 12 ) ) }; - - sal_Int32 nCount = SAL_N_ELEMENTS( pNames ); - - Sequence< OUString > aNames( pNames, nCount ); - Sequence< Any > aValues( pValues, nCount ); - - insertControlModel( "com.sun.star.awt.UnoControlProgressBarModel", - "Progress", aNames, aValues ); - } - Reference< XTextListener > xTextListener; - Sequence< OUString > aItemList; - std::vector< OUString > aControlList - { - InsertFixedText( *this, "FixedText0Pg4", getString( STR_SUMMARY_TITLE ), PAGE_POS_X, PAGE_POS_Y, PAGE_WIDTH, 8, false, true, mnTabIndex++ ), - // InsertSeparator( *this, "Separator0Pg4", 0, PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, 1 ), - - InsertFixedText( *this, "FixedText4Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 14, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ), - InsertFixedText( *this, "FixedText5Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 22, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ), - InsertFixedText( *this, "FixedText6Pg4", OUString(), PAGE_POS_X + 6, PAGE_POS_Y + 30, PAGE_WIDTH - 12, 8, false, false, mnTabIndex++ ), - - InsertFixedText( *this, "FixedText2Pg4", getString( STR_CURRENT_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 50, 88, 8, false, false, mnTabIndex++ ), - InsertFixedText( *this, "FixedText7Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 50, 30, 8, false, false, mnTabIndex++ ) - }; - setControlProperty( "FixedText7Pg4", "Align", Any( static_cast< short >( 2 ) ) ); - aControlList.push_back( InsertFixedText( *this, "FixedText3Pg4", getString( STR_ESTIMATED_FILESIZE ), PAGE_POS_X + 6, PAGE_POS_Y + 58, 88, 8, false, false, mnTabIndex++ ) ); - aControlList.push_back( InsertFixedText( *this, "FixedText8Pg4", OUString(), PAGE_POS_X + 100, PAGE_POS_Y + 58, 30, 8, false, false, mnTabIndex++ ) ); - setControlProperty( "FixedText8Pg4", "Align", Any( static_cast< short >( 2 ) ) ); - - aControlList.push_back( InsertRadioButton( *this, "RadioButton0Pg4", mxItemListener, getString( STR_APPLY_TO_CURRENT ), PAGE_POS_X + 6, PAGE_POS_Y + 78, PAGE_WIDTH - 12, mnTabIndex++ ) ); - aControlList.push_back( InsertRadioButton( *this, "RadioButton1Pg4", mxItemListener, getString( STR_SAVE_AS ), PAGE_POS_X + 6, PAGE_POS_Y + 90, PAGE_WIDTH - 12, mnTabIndex++ ) ); - aControlList.push_back( InsertFixedText( *this, "FixedText1Pg4", OUString(), PAGE_POS_X + 6, DIALOG_HEIGHT - 87, PAGE_WIDTH - 12, 8, true, false, mnTabIndex++ ) ); - aControlList.emplace_back("Progress" ); - aControlList.push_back( InsertSeparator( *this, "Separator1Pg4", 0, PAGE_POS_X + 6, DIALOG_HEIGHT - 58, PAGE_WIDTH - 12, 1 ) ); - aControlList.push_back( InsertCheckBox( *this, "CheckBox1Pg4", mxItemListener, getString( STR_SAVE_SETTINGS ), PAGE_POS_X + 6, DIALOG_HEIGHT - 47, 100, mnTabIndex++ ) ); - aControlList.push_back( InsertComboBox( *this, "ComboBox0Pg4", xTextListener, true, aItemList, PAGE_POS_X + 106, DIALOG_HEIGHT - 48, mnTabIndex++ ) ); - maControlPages.push_back( aControlList ); - DeactivatePage( 4 ); - // creating a default session name that hasn't been used yet OUString aSettingsName; OUString aDefault( getString( STR_MY_SETTINGS ) ); @@ -877,33 +351,9 @@ void OptimizerDialog::InitPage4() } while( aSettingsName.isEmpty() ); - setControlProperty( "ComboBox0Pg4", "Text", Any( aSettingsName ) ); - setControlProperty( "RadioButton0Pg4", "Enabled", Any( !mbIsReadonly ) ); - setControlProperty( "RadioButton1Pg4", "Enabled", Any( !mbIsReadonly ) ); + mpPage4->Init(aSettingsName, mbIsReadonly); UpdateControlStatesPage4(); } - -void OptimizerDialog::EnablePage( sal_Int16 nStep ) -{ - for( const auto& rItem : maControlPages[ nStep ] ) - setControlProperty( rItem, "Enabled", Any( true ) ); -} -void OptimizerDialog::DisablePage( sal_Int16 nStep ) -{ - for( const auto& rItem : maControlPages[ nStep ] ) - setControlProperty( rItem, "Enabled", Any( false ) ); -} -void OptimizerDialog::ActivatePage( sal_Int16 nStep ) -{ - for( const auto& rItem : maControlPages[ nStep ] ) - setVisible( rItem, true ); -} -void OptimizerDialog::DeactivatePage( sal_Int16 nStep ) -{ - for( const auto& rItem : maControlPages[ nStep ] ) - setVisible( rItem, false ); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sdext/source/minimizer/pppoptimizerdialog.cxx b/sdext/source/minimizer/pppoptimizerdialog.cxx index 74a89bfbac1a..9ad72b748726 100644 --- a/sdext/source/minimizer/pppoptimizerdialog.cxx +++ b/sdext/source/minimizer/pppoptimizerdialog.cxx @@ -125,6 +125,7 @@ void SAL_CALL PPPOptimizerDialog::dispatch( const URL& rURL, } else if ( rURL.Path == "statusupdate" ) { + fprintf(stderr, "statusupdate\n"); if ( mpOptimizerDialog ) mpOptimizerDialog->UpdateStatus( rArguments ); } diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index c21880edd8f3..6062efa44f14 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -45,27 +45,7 @@ struct TokenTable const TokenTable pTokenTableArray[] = { - { "rdmNavi", TK_rdmNavi }, - { "btnNavBack", TK_btnNavBack }, - { "btnNavNext", TK_btnNavNext }, { "btnNavFinish", TK_btnNavFinish }, - { "btnNavCancel", TK_btnNavCancel }, - - { "Button0Pg0", TK_Button0Pg0 }, - { "RadioButton0Pg1", TK_RadioButton0Pg1 }, - { "RadioButton1Pg1", TK_RadioButton1Pg1 }, - { "CheckBox1Pg1", TK_CheckBox1Pg1 }, - { "CheckBox2Pg1", TK_CheckBox2Pg1 }, - { "CheckBox0Pg2", TK_CheckBox0Pg2 }, - { "RadioButton0Pg2", TK_RadioButton0Pg2 }, - { "RadioButton1Pg2", TK_RadioButton1Pg2 }, - { "CheckBox0Pg3", TK_CheckBox0Pg3 }, - { "CheckBox1Pg3", TK_CheckBox1Pg3 }, - { "CheckBox2Pg3", TK_CheckBox2Pg3 }, - { "CheckBox3Pg3", TK_CheckBox3Pg3 }, - { "RadioButton0Pg4", TK_RadioButton0Pg4 }, - { "RadioButton1Pg4", TK_RadioButton1Pg4 }, - { "CheckBox1Pg4", TK_CheckBox1Pg4 }, { "DocumentService", TK_DocumentService }, { "FileSizeDestination",TK_FileSizeDestination }, @@ -100,51 +80,17 @@ const TokenTable pTokenTableArray[] = { "Pages", TK_Pages }, { "STR_SUN_OPTIMIZATION_WIZARD2",STR_SUN_OPTIMIZATION_WIZARD2 }, - { "STR_STEPS", STR_STEPS }, - { "STR_BACK", STR_BACK }, - { "STR_NEXT", STR_NEXT }, - { "STR_FINISH", STR_FINISH }, - { "STR_CANCEL", STR_CANCEL }, { "STR_INTRODUCTION", STR_INTRODUCTION }, - { "STR_INTRODUCTION_T", STR_INTRODUCTION_T }, - { "STR_CHOSE_SETTINGS", STR_CHOSE_SETTINGS }, - { "STR_REMOVE", STR_REMOVE }, - { "STR_GRAPHIC_OPTIMIZATION", STR_GRAPHIC_OPTIMIZATION }, { "STR_IMAGE_OPTIMIZATION", STR_IMAGE_OPTIMIZATION }, - { "STR_LOSSLESS_COMPRESSION", STR_LOSSLESS_COMPRESSION }, - { "STR_JPEG_COMPRESSION", STR_JPEG_COMPRESSION }, - { "STR_QUALITY", STR_QUALITY }, - { "STR_REMOVE_CROP_AREA", STR_REMOVE_CROP_AREA }, - { "STR_IMAGE_RESOLUTION", STR_IMAGE_RESOLUTION }, - { "STR_IMAGE_RESOLUTION_0", STR_IMAGE_RESOLUTION_0 }, - { "STR_IMAGE_RESOLUTION_1", STR_IMAGE_RESOLUTION_1 }, - { "STR_IMAGE_RESOLUTION_2", STR_IMAGE_RESOLUTION_2 }, - { "STR_IMAGE_RESOLUTION_3", STR_IMAGE_RESOLUTION_3 }, - { "STR_EMBED_LINKED_GRAPHICS", STR_EMBED_LINKED_GRAPHICS }, { "STR_OLE_OBJECTS", STR_OLE_OBJECTS }, - { "STR_OLE_OPTIMIZATION", STR_OLE_OPTIMIZATION }, - { "STR_OLE_REPLACE", STR_OLE_REPLACE }, - { "STR_ALL_OLE_OBJECTS", STR_ALL_OLE_OBJECTS }, - { "STR_ALIEN_OLE_OBJECTS_ONLY", STR_ALIEN_OLE_OBJECTS_ONLY }, - { "STR__OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC }, + { "STR_OLE_OBJECTS_DESC", STR_OLE_OBJECTS_DESC }, { "STR_NO_OLE_OBJECTS_DESC", STR_NO_OLE_OBJECTS_DESC }, { "STR_SLIDES", STR_SLIDES }, - { "STR_CHOOSE_SLIDES", STR_CHOOSE_SLIDES }, - { "STR_DELETE_MASTER_PAGES", STR_DELETE_MASTER_PAGES }, - { "STR_DELETE_NOTES_PAGES", STR_DELETE_NOTES_PAGES }, - { "STR_DELETE_HIDDEN_SLIDES", STR_DELETE_HIDDEN_SLIDES }, - { "STR_CUSTOM_SHOW", STR_CUSTOM_SHOW }, { "STR_SUMMARY", STR_SUMMARY }, - { "STR_SUMMARY_TITLE", STR_SUMMARY_TITLE }, - { "STR_APPLY_TO_CURRENT", STR_APPLY_TO_CURRENT }, { "STR_AUTOMATICALLY_OPEN", STR_AUTOMATICALLY_OPEN }, - { "STR_SAVE_SETTINGS", STR_SAVE_SETTINGS }, - { "STR_SAVE_AS", STR_SAVE_AS }, { "STR_DELETE_SLIDES", STR_DELETE_SLIDES }, { "STR_OPTIMIZE_IMAGES", STR_OPTIMIZE_IMAGES }, { "STR_CREATE_REPLACEMENT", STR_CREATE_REPLACEMENT }, - { "STR_CURRENT_FILESIZE", STR_CURRENT_FILESIZE }, - { "STR_ESTIMATED_FILESIZE", STR_ESTIMATED_FILESIZE }, { "MY_SETTINGS", STR_MY_SETTINGS }, { "STR_OK", STR_OK }, { "STR_INFO_1", STR_INFO_1 }, diff --git a/sdext/source/minimizer/pppoptimizertoken.hxx b/sdext/source/minimizer/pppoptimizertoken.hxx index 3f946fcc0b08..4f74e73319d6 100644 --- a/sdext/source/minimizer/pppoptimizertoken.hxx +++ b/sdext/source/minimizer/pppoptimizertoken.hxx @@ -24,27 +24,7 @@ enum PPPOptimizerTokenEnum { - TK_rdmNavi, - TK_btnNavBack, - TK_btnNavNext, TK_btnNavFinish, - TK_btnNavCancel, - - TK_Button0Pg0, - TK_RadioButton0Pg1, - TK_RadioButton1Pg1, - TK_CheckBox1Pg1, - TK_CheckBox2Pg1, - TK_CheckBox0Pg2, - TK_RadioButton0Pg2, - TK_RadioButton1Pg2, - TK_CheckBox0Pg3, - TK_CheckBox1Pg3, - TK_CheckBox2Pg3, - TK_CheckBox3Pg3, - TK_RadioButton0Pg4, - TK_RadioButton1Pg4, - TK_CheckBox1Pg4, TK_DocumentService, TK_FileSizeDestination, @@ -79,51 +59,17 @@ enum PPPOptimizerTokenEnum TK_Pages, STR_SUN_OPTIMIZATION_WIZARD2, - STR_STEPS, - STR_BACK, - STR_NEXT, - STR_FINISH, - STR_CANCEL, STR_INTRODUCTION, - STR_INTRODUCTION_T, - STR_CHOSE_SETTINGS, - STR_REMOVE, - STR_GRAPHIC_OPTIMIZATION, STR_IMAGE_OPTIMIZATION, - STR_LOSSLESS_COMPRESSION, - STR_JPEG_COMPRESSION, - STR_QUALITY, - STR_REMOVE_CROP_AREA, - STR_IMAGE_RESOLUTION, - STR_IMAGE_RESOLUTION_0, - STR_IMAGE_RESOLUTION_1, - STR_IMAGE_RESOLUTION_2, - STR_IMAGE_RESOLUTION_3, - STR_EMBED_LINKED_GRAPHICS, STR_OLE_OBJECTS, - STR_OLE_OPTIMIZATION, - STR_OLE_REPLACE, - STR_ALL_OLE_OBJECTS, - STR_ALIEN_OLE_OBJECTS_ONLY, STR_OLE_OBJECTS_DESC, STR_NO_OLE_OBJECTS_DESC, STR_SLIDES, - STR_CHOOSE_SLIDES, - STR_DELETE_MASTER_PAGES, - STR_DELETE_NOTES_PAGES, - STR_DELETE_HIDDEN_SLIDES, - STR_CUSTOM_SHOW, STR_SUMMARY, - STR_SUMMARY_TITLE, - STR_APPLY_TO_CURRENT, STR_AUTOMATICALLY_OPEN, - STR_SAVE_SETTINGS, - STR_SAVE_AS, STR_DELETE_SLIDES, STR_OPTIMIZE_IMAGES, STR_CREATE_REPLACEMENT, - STR_CURRENT_FILESIZE, - STR_ESTIMATED_FILESIZE, STR_MY_SETTINGS, STR_OK, STR_INFO_1, |