1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
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>
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
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 IntroPage
: public vcl::OWizardPage
53 OptimizerDialog
& mrOptimizerDialog
;
54 std::unique_ptr
<weld::ComboBox
> mxComboBox
;
55 std::unique_ptr
<weld::Button
> mxButton
;
57 DECL_LINK(ComboBoxActionPerformed
, weld::ComboBox
&, void);
58 DECL_LINK(ButtonActionPerformed
, weld::Button
&, void);
61 IntroPage(weld::Container
* pPage
, OptimizerDialog
& rOptimizerDialog
);
62 void UpdateControlStates(const std::vector
<OUString
>& rItemList
, int nSelectedItem
, bool bRemoveButtonEnabled
);
63 OUString
Get_TK_Name() const
65 return mxComboBox
->get_active_text();
69 class SlidesPage
: public vcl::OWizardPage
72 OptimizerDialog
& mrOptimizerDialog
;
73 std::unique_ptr
<weld::CheckButton
> mxMasterSlides
;
74 std::unique_ptr
<weld::CheckButton
> mxHiddenSlides
;
75 std::unique_ptr
<weld::CheckButton
> mxUnusedSlides
;
76 std::unique_ptr
<weld::ComboBox
> mxComboBox
;
77 std::unique_ptr
<weld::CheckButton
> mxClearNodes
;
79 DECL_LINK(UnusedMasterPagesActionPerformed
, weld::Toggleable
&, void);
80 DECL_LINK(UnusedHiddenSlidesActionPerformed
, weld::Toggleable
&, void);
81 DECL_LINK(UnusedSlidesActionPerformed
, weld::Toggleable
&, void);
82 DECL_LINK(DeleteNotesActionPerformed
, weld::Toggleable
&, void);
85 SlidesPage(weld::Container
* pPage
, OptimizerDialog
& rOptimizerDialog
);
86 void Init(const css::uno::Sequence
<OUString
>& rCustomShowList
);
87 void UpdateControlStates(bool bDeleteUnusedMasterPages
, bool bDeleteHiddenSlides
, bool bDeleteNotesPages
);
88 OUString
Get_TK_CustomShowName() const
90 if (!mxUnusedSlides
->get_sensitive())
92 return mxComboBox
->get_active_text();
96 class ImagesPage
: public vcl::OWizardPage
99 OptimizerDialog
& mrOptimizerDialog
;
100 std::unique_ptr
<weld::RadioButton
> m_xLossLessCompression
;
101 std::unique_ptr
<weld::Label
> m_xQualityLabel
;
102 std::unique_ptr
<weld::SpinButton
> m_xQuality
;
103 std::unique_ptr
<weld::RadioButton
> m_xJpegCompression
;
104 std::unique_ptr
<weld::ComboBox
> m_xResolution
;
105 std::unique_ptr
<weld::CheckButton
> m_xRemoveCropArea
;
106 std::unique_ptr
<weld::CheckButton
> m_xEmbedLinkedGraphics
;
108 DECL_LINK(EmbedLinkedGraphicsActionPerformed
, weld::Toggleable
&, void);
109 DECL_LINK(RemoveCropAreaActionPerformed
, weld::Toggleable
&, void);
110 DECL_LINK(ComboBoxActionPerformed
, weld::ComboBox
&, void);
111 DECL_LINK(CompressionActionPerformed
, weld::Toggleable
&, void);
112 DECL_LINK(SpinButtonActionPerformed
, weld::SpinButton
&, void);
115 ImagesPage(weld::Container
* pPage
, OptimizerDialog
& rOptimizerDialog
);
117 void UpdateControlStates(bool bJPEGCompression
, int nJPEGQuality
, bool bRemoveCropArea
,
118 int nResolution
, bool bEmbedLinkedGraphics
);
121 class ObjectsPage
: public vcl::OWizardPage
124 OptimizerDialog
& mrOptimizerDialog
;
125 std::unique_ptr
<weld::CheckButton
> m_xCreateStaticImage
;
126 std::unique_ptr
<weld::RadioButton
> m_xAllOLEObjects
;
127 std::unique_ptr
<weld::RadioButton
> m_xForeignOLEObjects
;
128 std::unique_ptr
<weld::Label
> m_xLabel
;
130 DECL_LINK(OLEOptimizationActionPerformed
, weld::Toggleable
&, void);
131 DECL_LINK(OLEActionPerformed
, weld::Toggleable
&, void);
134 ObjectsPage(weld::Container
* pPage
, OptimizerDialog
& rOptimizerDialog
);
136 void Init(const OUString
& rDesc
);
138 void UpdateControlStates(bool bConvertOLEObjects
, int nOLEOptimizationType
);
141 class SummaryPage
: public vcl::OWizardPage
144 OptimizerDialog
& mrOptimizerDialog
;
145 std::unique_ptr
<weld::Label
> m_xLabel1
;
146 std::unique_ptr
<weld::Label
> m_xLabel2
;
147 std::unique_ptr
<weld::Label
> m_xLabel3
;
148 std::unique_ptr
<weld::Label
> m_xCurrentSize
;
149 std::unique_ptr
<weld::Label
> m_xEstimatedSize
;
150 std::unique_ptr
<weld::Label
> m_xStatus
;
151 std::unique_ptr
<weld::ProgressBar
> m_xProgress
;
152 std::unique_ptr
<weld::RadioButton
> m_xApplyToCurrent
;
153 std::unique_ptr
<weld::RadioButton
> m_xSaveToNew
;
154 std::unique_ptr
<weld::ComboBox
> m_xComboBox
;
155 std::unique_ptr
<weld::CheckButton
> m_xSaveSettings
;
157 DECL_LINK(SaveSettingsActionPerformed
, weld::Toggleable
&, void);
158 DECL_LINK(SaveAsNewActionPerformed
, weld::Toggleable
&, void);
161 SummaryPage(weld::Container
* pPage
, OptimizerDialog
& rOptimizerDialog
);
163 void Init(const OUString
& rSettingsName
, bool bIsReadonly
);
165 void UpdateControlStates(bool bSaveAs
, bool bSaveSettingsEnabled
,
166 const std::vector
<OUString
>& rItemList
,
167 const std::vector
<OUString
>& rSummaryStrings
,
168 const OUString
& rCurrentFileSize
,
169 const OUString
& rEstimatedFileSize
);
171 void UpdateStatusLabel(const OUString
& rStatus
);
172 void UpdateProgressValue(int nProgress
);
174 bool GetSaveAsNew() const { return m_xSaveToNew
->get_active(); }
175 bool GetSaveSettings() const { return m_xSaveSettings
->get_active(); }
176 OUString
GetSettingsName() const { return m_xComboBox
->get_active_text(); }
179 class OptimizerDialog
: public vcl::RoadmapWizardMachine
, public ConfigurationAccess
183 OptimizerDialog( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
, css::uno::Reference
< css::frame::XFrame
> const & rxFrame
,
184 css::uno::Reference
< css::frame::XDispatch
> const & rxStatusDispatcher
);
185 std::unique_ptr
<BuilderPage
> createPage(vcl::WizardTypes::WizardState nState
) override
;
194 css::uno::Reference
< css::frame::XFrame
> mxFrame
;
195 css::uno::Reference
< css::frame::XController
> mxController
;
197 css::uno::Reference
< css::frame::XDispatch
> mxStatusDispatcher
;
202 ObjectsPage
* mpPage3
;
203 SummaryPage
* mpPage4
;
207 void InitNavigationBar();
213 void UpdateControlStatesPage0();
214 void UpdateControlStatesPage1();
215 void UpdateControlStatesPage2();
216 void UpdateControlStatesPage3();
217 void UpdateControlStatesPage4();
219 virtual OUString
getStateDisplayName(vcl::WizardTypes::WizardState nState
) const override
;
221 virtual bool onFinish() override
;
225 OptimizationStats maStats
;
227 void UpdateStatus( const css::uno::Sequence
< css::beans::PropertyValue
>& rStatus
);
229 // the ConfigurationAccess is updated to actual control settings
230 void UpdateConfiguration();
232 void UpdateControlStates( sal_Int16 nStep
= -1 );
234 void SetIntroPage(IntroPage
* pPage0
) { mpPage0
= pPage0
; }
235 void SetSlidesPage(SlidesPage
* pPage1
) { mpPage1
= pPage1
; }
236 void SetImagesPage(ImagesPage
* pPage2
) { mpPage2
= pPage2
; }
237 void SetObjectsPage(ObjectsPage
* pPage3
) { mpPage3
= pPage3
; }
238 void SetSummaryPage(SummaryPage
* pPage4
) { mpPage4
= pPage4
; }
240 css::uno::Reference
< css::frame::XDispatch
>& GetStatusDispatcher() { return mxStatusDispatcher
; };
241 css::uno::Reference
< css::frame::XFrame
>& GetFrame() { return mxFrame
; };
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */