Update git submodules
[LibreOffice.git] / sdext / source / minimizer / optimizerdialog.hxx
blobf095ccf0556f776746cceb4f8bd3aa9c40721b57
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #include <vector>
23 #include "optimizationstats.hxx"
24 #include "configurationaccess.hxx"
25 #include <com/sun/star/uno/Sequence.h>
26 #include <com/sun/star/uno/XComponentContext.hpp>
27 #include <com/sun/star/frame/XDispatch.hpp>
28 #include <cppuhelper/implbase.hxx>
29 #include <vcl/roadmapwizard.hxx>
31 #define MAX_STEP 4
32 #define OD_DIALOG_WIDTH 330
33 #define DIALOG_HEIGHT 210
34 #define BUTTON_WIDTH 50
35 #define BUTTON_HEIGHT 14
36 #define BUTTON_POS_Y DIALOG_HEIGHT - BUTTON_HEIGHT - 6
38 #define PAGE_POS_X 91
39 #define PAGE_POS_Y 8
40 #define PAGE_WIDTH OD_DIALOG_WIDTH - PAGE_POS_X
42 #define ITEM_ID_INTRODUCTION 0
43 #define ITEM_ID_SLIDES 1
44 #define ITEM_ID_GRAPHIC_OPTIMIZATION 2
45 #define ITEM_ID_OLE_OPTIMIZATION 3
46 #define ITEM_ID_SUMMARY 4
48 class OptimizerDialog;
50 class OptimizedDialogPage : public vcl::OWizardPage
52 protected:
53 OptimizerDialog& mrOptimizerDialog;
54 private:
55 int m_nPageNum;
56 public:
57 OptimizedDialogPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog,
58 const OUString& rUIXMLDescription, const OUString& rID,
59 int nPageNum);
60 virtual void Activate() override;
63 class IntroPage : public OptimizedDialogPage
65 private:
66 std::unique_ptr<weld::ComboBox> mxComboBox;
67 std::unique_ptr<weld::Button> mxButton;
69 DECL_LINK(ComboBoxActionPerformed, weld::ComboBox&, void);
70 DECL_LINK(ButtonActionPerformed, weld::Button&, void);
72 public:
73 IntroPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog);
74 void UpdateControlStates(const std::vector<OUString>& rItemList, int nSelectedItem, bool bRemoveButtonEnabled);
75 OUString Get_TK_Name() const
77 return mxComboBox->get_active_text();
81 class SlidesPage : public OptimizedDialogPage
83 private:
84 std::unique_ptr<weld::CheckButton> mxMasterSlides;
85 std::unique_ptr<weld::CheckButton> mxHiddenSlides;
86 std::unique_ptr<weld::CheckButton> mxUnusedSlides;
87 std::unique_ptr<weld::ComboBox> mxComboBox;
88 std::unique_ptr<weld::CheckButton> mxClearNodes;
90 DECL_LINK(UnusedMasterPagesActionPerformed, weld::Toggleable&, void);
91 DECL_LINK(UnusedHiddenSlidesActionPerformed, weld::Toggleable&, void);
92 DECL_LINK(UnusedSlidesActionPerformed, weld::Toggleable&, void);
93 DECL_LINK(DeleteNotesActionPerformed, weld::Toggleable&, void);
95 public:
96 SlidesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog);
97 void Init(const css::uno::Sequence<OUString>& rCustomShowList);
98 void UpdateControlStates(bool bDeleteUnusedMasterPages, bool bDeleteHiddenSlides, bool bDeleteNotesPages);
99 OUString Get_TK_CustomShowName() const
101 if (!mxUnusedSlides->get_sensitive())
102 return OUString();
103 return mxComboBox->get_active_text();
107 class ImagesPage : public OptimizedDialogPage
109 private:
110 std::unique_ptr<weld::RadioButton> m_xLossLessCompression;
111 std::unique_ptr<weld::Label> m_xQualityLabel;
112 std::unique_ptr<weld::SpinButton> m_xQuality;
113 std::unique_ptr<weld::RadioButton> m_xJpegCompression;
114 std::unique_ptr<weld::ComboBox> m_xResolution;
115 std::unique_ptr<weld::CheckButton> m_xRemoveCropArea;
116 std::unique_ptr<weld::CheckButton> m_xEmbedLinkedGraphics;
118 DECL_LINK(EmbedLinkedGraphicsActionPerformed, weld::Toggleable&, void);
119 DECL_LINK(RemoveCropAreaActionPerformed, weld::Toggleable&, void);
120 DECL_LINK(ComboBoxActionPerformed, weld::ComboBox&, void);
121 DECL_LINK(CompressionActionPerformed, weld::Toggleable&, void);
122 DECL_LINK(SpinButtonActionPerformed, weld::SpinButton&, void);
124 public:
125 ImagesPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog);
127 void UpdateControlStates(bool bJPEGCompression, int nJPEGQuality, bool bRemoveCropArea,
128 int nResolution, bool bEmbedLinkedGraphics);
131 class ObjectsPage : public OptimizedDialogPage
133 private:
134 std::unique_ptr<weld::CheckButton> m_xCreateStaticImage;
135 std::unique_ptr<weld::RadioButton> m_xAllOLEObjects;
136 std::unique_ptr<weld::RadioButton> m_xForeignOLEObjects;
137 std::unique_ptr<weld::Label> m_xLabel;
139 DECL_LINK(OLEOptimizationActionPerformed, weld::Toggleable&, void);
140 DECL_LINK(OLEActionPerformed, weld::Toggleable&, void);
142 public:
143 ObjectsPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog);
145 void Init(const OUString& rDesc);
147 void UpdateControlStates(bool bConvertOLEObjects, int nOLEOptimizationType);
150 class SummaryPage : public OptimizedDialogPage
152 private:
153 std::unique_ptr<weld::Label> m_xLabel1;
154 std::unique_ptr<weld::Label> m_xLabel2;
155 std::unique_ptr<weld::Label> m_xLabel3;
156 std::unique_ptr<weld::Label> m_xCurrentSize;
157 std::unique_ptr<weld::Label> m_xEstimatedSize;
158 std::unique_ptr<weld::Label> m_xStatus;
159 std::unique_ptr<weld::ProgressBar> m_xProgress;
160 std::unique_ptr<weld::RadioButton> m_xApplyToCurrent;
161 std::unique_ptr<weld::RadioButton> m_xSaveToNew;
162 std::unique_ptr<weld::ComboBox> m_xComboBox;
163 std::unique_ptr<weld::CheckButton> m_xSaveSettings;
165 DECL_LINK(SaveSettingsActionPerformed, weld::Toggleable&, void);
166 DECL_LINK(SaveAsNewActionPerformed, weld::Toggleable&, void);
168 public:
169 SummaryPage(weld::Container* pPage, OptimizerDialog& rOptimizerDialog);
171 void Init(const OUString& rSettingsName, bool bIsReadonly);
173 void UpdateControlStates(bool bSaveAs, bool bSaveSettingsEnabled,
174 const std::vector<OUString>& rItemList,
175 const std::vector<OUString>& rSummaryStrings,
176 const OUString& rCurrentFileSize,
177 const OUString& rEstimatedFileSize);
179 void UpdateStatusLabel(const OUString& rStatus);
180 void UpdateProgressValue(int nProgress);
182 bool GetSaveAsNew() const { return m_xSaveToNew->get_active(); }
183 bool GetSaveSettings() const { return m_xSaveSettings->get_active(); }
184 OUString GetSettingsName() const { return m_xComboBox->get_active_text(); }
187 class OptimizerDialog : public vcl::RoadmapWizardMachine, public ConfigurationAccess
189 public:
191 OptimizerDialog( const css::uno::Reference< css::uno::XComponentContext >& rxContext, css::uno::Reference< css::frame::XFrame > const & rxFrame,
192 css::uno::Reference< css::frame::XDispatch > const & rxStatusDispatcher );
193 std::unique_ptr<BuilderPage> createPage(vcl::WizardTypes::WizardState nState) override;
194 ~OptimizerDialog();
196 void execute();
198 short mnEndStatus;
199 bool mbIsReadonly;
201 private:
202 css::uno::Reference< css::frame::XFrame > mxFrame;
203 css::uno::Reference< css::frame::XController > mxController;
205 css::uno::Reference< css::frame::XDispatch > mxStatusDispatcher;
207 IntroPage* mpPage0;
208 SlidesPage* mpPage1;
209 ImagesPage* mpPage2;
210 ObjectsPage* mpPage3;
211 SummaryPage* mpPage4;
213 void InitDialog();
214 void InitRoadmap();
215 void InitNavigationBar();
216 void InitPage0();
217 void InitPage1();
218 void InitPage2();
219 void InitPage3();
220 void InitPage4();
221 void UpdateControlStatesPage0();
222 void UpdateControlStatesPage1();
223 void UpdateControlStatesPage2();
224 void UpdateControlStatesPage3();
225 void UpdateControlStatesPage4();
227 virtual OUString getStateDisplayName(vcl::WizardTypes::WizardState nState) const override;
229 virtual bool onFinish() override;
231 public:
233 OptimizationStats maStats;
235 void UpdateStatus( const css::uno::Sequence< css::beans::PropertyValue >& rStatus );
237 // the ConfigurationAccess is updated to actual control settings
238 void UpdateConfiguration();
240 void UpdateControlStates( sal_Int16 nStep = -1 );
242 void SetIntroPage(IntroPage* pPage0) { mpPage0 = pPage0; }
243 void SetSlidesPage(SlidesPage* pPage1) { mpPage1 = pPage1; }
244 void SetImagesPage(ImagesPage* pPage2) { mpPage2 = pPage2; }
245 void SetObjectsPage(ObjectsPage* pPage3) { mpPage3 = pPage3; }
246 void SetSummaryPage(SummaryPage* pPage4) { mpPage4 = pPage4; }
248 css::uno::Reference< css::frame::XDispatch >& GetStatusDispatcher() { return mxStatusDispatcher; };
249 css::uno::Reference< css::frame::XFrame>& GetFrame() { return mxFrame; };
252 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */